Flutter upgrade

This commit is contained in:
M
2022-10-12 13:09:57 -04:00
parent c921ad890a
commit 1beb18b045
505 changed files with 6657 additions and 5875 deletions
@@ -5,7 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
class FullscreenQRPage extends BasePage {
FullscreenQRPage({@required this.qrData, @required this.isLight});
FullscreenQRPage({required this.qrData, required this.isLight});
final bool isLight;
final String qrData;
@@ -23,7 +23,7 @@ class FullscreenQRPage extends BasePage {
Widget leading(BuildContext context) {
final _backButton = Icon(
Icons.arrow_back_ios,
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
size: 16,
);
@@ -32,10 +32,11 @@ class FullscreenQRPage extends BasePage {
width: 37,
child: ButtonTheme(
minWidth: double.minPositive,
child: FlatButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.all(0),
child: TextButton(
// FIX-ME: Style
//highlightColor: Colors.transparent,
//splashColor: Colors.transparent,
//padding: EdgeInsets.all(0),
onPressed: () => onClose(context),
child: _backButton,
),
@@ -70,11 +71,11 @@ class FullscreenQRPage extends BasePage {
child: Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
border: Border.all(width: 3, color: Theme.of(context).accentTextTheme.display3.backgroundColor)),
border: Border.all(width: 3, color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!)),
child: QrImage(
data: qrData,
backgroundColor: isLight ? Colors.transparent : Colors.black,
foregroundColor: Theme.of(context).accentTextTheme.display3.backgroundColor,
foregroundColor: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
),
),
),
+35 -30
View File
@@ -6,7 +6,7 @@ import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:esys_flutter_share/esys_flutter_share.dart';
// import 'package:esys_flutter_share/esys_flutter_share.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/di.dart';
@@ -22,7 +22,7 @@ import 'package:cake_wallet/src/screens/receive/widgets/qr_widget.dart';
import 'package:keyboard_actions/keyboard_actions.dart';
class ReceivePage extends BasePage {
ReceivePage({this.addressListViewModel}) : _cryptoAmountFocus = FocusNode();
ReceivePage({required this.addressListViewModel}) : _cryptoAmountFocus = FocusNode();
final WalletAddressListViewModel addressListViewModel;
@@ -44,7 +44,7 @@ class ReceivePage extends BasePage {
@override
Widget leading(BuildContext context) {
final _backButton = Icon(Icons.arrow_back_ios,
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
size: 16,);
return SizedBox(
@@ -52,10 +52,11 @@ class ReceivePage extends BasePage {
width: 37,
child: ButtonTheme(
minWidth: double.minPositive,
child: FlatButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.all(0),
child: TextButton(
// FIX-ME: Style
//highlightColor: Colors.transparent,
//splashColor: Colors.transparent,
//padding: EdgeInsets.all(0),
onPressed: () => onClose(context),
child: _backButton),
),
@@ -70,7 +71,7 @@ class ReceivePage extends BasePage {
fontSize: 18.0,
fontWeight: FontWeight.bold,
fontFamily: 'Lato',
color: Theme.of(context).accentTextTheme.display3.backgroundColor),
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!),
);
}
@@ -89,19 +90,23 @@ class ReceivePage extends BasePage {
Widget trailing(BuildContext context) {
final shareImage =
Image.asset('assets/images/share.png',
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!);
return SizedBox(
height: 20.0,
width: 20.0,
child: ButtonTheme(
minWidth: double.minPositive,
child: FlatButton(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
padding: EdgeInsets.all(0),
onPressed: () => Share.text(S.current.share_address,
addressListViewModel.address.address, 'text/plain'),
child: TextButton(
// FIX-ME: Style
//highlightColor: Colors.transparent,
//splashColor: Colors.transparent,
//padding: EdgeInsets.all(0),
onPressed: () {
// FIX-ME: Share esys_flutter_share.dart
// Share.text(S.current.share_address,
// addressListViewModel.address.address, 'text/plain')
},
child: shareImage),
),
);
@@ -113,8 +118,8 @@ class ReceivePage extends BasePage {
? KeyboardActions(
config: KeyboardActionsConfig(
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
keyboardBarColor: Theme.of(context).accentTextTheme.body2
.backgroundColor,
keyboardBarColor: Theme.of(context).accentTextTheme!.bodyText1!
.backgroundColor!,
nextFocus: false,
actions: [
KeyboardActionsItem(
@@ -156,7 +161,7 @@ class ReceivePage extends BasePage {
Icons.arrow_forward_ios,
size: 14,
color:
Theme.of(context).textTheme.display1.color,
Theme.of(context).textTheme!.headline4!.color!,
));
}
@@ -169,7 +174,7 @@ class ReceivePage extends BasePage {
Icons.add,
size: 20,
color:
Theme.of(context).textTheme.display1.color,
Theme.of(context).textTheme!.headline4!.color!,
));
}
@@ -179,16 +184,16 @@ class ReceivePage extends BasePage {
addressListViewModel.address.address;
final backgroundColor = isCurrent
? Theme.of(context)
.textTheme
.display3
.decorationColor
.textTheme!
.headline2!
.decorationColor!
: Theme.of(context)
.textTheme
.display2
.decorationColor;
.textTheme!
.headline3!
.decorationColor!;
final textColor = isCurrent
? Theme.of(context).textTheme.display3.color
: Theme.of(context).textTheme.display2.color;
? Theme.of(context).textTheme!.headline2!.color!
: Theme.of(context).textTheme!.headline3!.color!;
return AddressCell.fromItem(item,
isCurrent: isCurrent,
@@ -233,9 +238,9 @@ class ReceivePage extends BasePage {
style: TextStyle(
fontSize: 15,
color: Theme.of(context)
.accentTextTheme
.display2
.backgroundColor)),
.accentTextTheme!
.headline3!
.backgroundColor!)),
],
),
);
@@ -4,15 +4,25 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
class AddressCell extends StatelessWidget {
AddressCell(
{required this.address,
required this.name,
required this.isCurrent,
required this.isPrimary,
required this.backgroundColor,
required this.textColor,
this.onTap,
this.onEdit});
factory AddressCell.fromItem(WalletAddressListItem item,
{@required bool isCurrent,
@required Color backgroundColor,
@required Color textColor,
Function(String) onTap,
Function() onEdit}) =>
{required bool isCurrent,
required Color backgroundColor,
required Color textColor,
Function(String)? onTap,
Function()? onEdit}) =>
AddressCell(
address: item.address,
name: item.name,
name: item.name ?? '',
isCurrent: isCurrent,
isPrimary: item.isPrimary,
backgroundColor: backgroundColor,
@@ -20,24 +30,14 @@ class AddressCell extends StatelessWidget {
onTap: onTap,
onEdit: onEdit);
AddressCell(
{@required this.address,
@required this.name,
@required this.isCurrent,
@required this.isPrimary,
@required this.backgroundColor,
@required this.textColor,
this.onTap,
this.onEdit});
final String address;
final String name;
final bool isCurrent;
final bool isPrimary;
final Color backgroundColor;
final Color textColor;
final Function(String) onTap;
final Function() onEdit;
final Function(String)? onTap;
final Function()? onEdit;
String get label {
if (name.isEmpty){
@@ -55,7 +55,7 @@ class AddressCell extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Widget cell = InkWell(
onTap: () => onTap(address),
onTap: () => onTap?.call(address),
child: Container(
color: backgroundColor,
padding: EdgeInsets.only(left: 24, right: 24, top: 28, bottom: 28),
@@ -69,19 +69,20 @@ class AddressCell extends StatelessWidget {
),
),
));
return Container(
color: backgroundColor,
child: Slidable(
key: Key(address),
actionPane: SlidableDrawerActionPane(),
child: cell,
secondaryActions: <Widget>[
IconSlideAction(
caption: S.of(context).edit,
color: Colors.blue,
icon: Icons.edit,
onTap: () => onEdit?.call())
]));
// FIX-ME: Slidable
return cell;
// return Container(
// color: backgroundColor,
// child: Slidable(
// key: Key(address),
// actionPane: SlidableDrawerActionPane(),
// child: cell,
// secondaryActions: <Widget>[
// IconSlideAction(
// caption: S.of(context).edit,
// color: Colors.blue,
// icon: Icons.edit,
// onTap: () => onEdit?.call())
// ]));
}
}
@@ -2,9 +2,9 @@ import 'package:flutter/material.dart';
class HeaderTile extends StatelessWidget {
HeaderTile({
@required this.onTap,
@required this.title,
@required this.icon
required this.onTap,
required this.title,
required this.icon
});
final VoidCallback onTap;
@@ -22,7 +22,7 @@ class HeaderTile extends StatelessWidget {
top: 24,
bottom: 24
),
color: Theme.of(context).textTheme.display2.decorationColor,
color: Theme.of(context).textTheme!.headline3!.decorationColor!,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -32,7 +32,7 @@ class HeaderTile extends StatelessWidget {
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Theme.of(context).textTheme.display2.color
color: Theme.of(context).textTheme!.headline3!.color!
),
),
Container(
@@ -40,7 +40,7 @@ class HeaderTile extends StatelessWidget {
width: 32,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).textTheme.display1.decorationColor
color: Theme.of(context).textTheme!.headline4!.decorationColor!
),
child: icon,
)
@@ -4,16 +4,16 @@ import 'package:cake_wallet/src/screens/receive/widgets/qr_painter.dart';
class QrImage extends StatelessWidget {
QrImage({
@required String data,
required String data,
this.size = 100.0,
this.backgroundColor,
Color foregroundColor = Colors.black,
int version = 7,
int version = 9, // Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
int errorCorrectionLevel = QrErrorCorrectLevel.L,
}) : _painter = QrPainter(data, foregroundColor, version, errorCorrectionLevel);
final QrPainter _painter;
final Color backgroundColor;
final Color? backgroundColor;
final double size;
@override
@@ -7,11 +7,10 @@ class QrPainter extends CustomPainter {
this.color,
this.version,
this.errorCorrectionLevel,
) : this._qr = QrCode(version, errorCorrectionLevel) {
) : this._qr = QrCode(version, errorCorrectionLevel)..addData(data) {
_p.color = this.color;
_qr.addData(data);
_qr.make();
_qrImage = QrImage(_qr);
}
final int version;
@@ -20,13 +19,14 @@ class QrPainter extends CustomPainter {
final QrCode _qr;
final _p = Paint()..style = PaintingStyle.fill;
late QrImage _qrImage;
@override
void paint(Canvas canvas, Size size) {
final squareSize = size.shortestSide / _qr.moduleCount;
for (int x = 0; x < _qr.moduleCount; x++) {
for (int y = 0; y < _qr.moduleCount; y++) {
if (_qr.isDark(y, x)) {
if (_qrImage.isDark(y, x)) {
final squareRect = Rect.fromLTWH(
x * squareSize, y * squareSize, squareSize, squareSize);
canvas.drawRect(squareRect, _p);
+15 -14
View File
@@ -13,27 +13,27 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_v
class QRWidget extends StatelessWidget {
QRWidget(
{@required this.addressListViewModel,
{required this.addressListViewModel,
required this.isLight,
this.isAmountFieldShow = false,
this.amountTextFieldFocusNode,
this.isLight})
this.amountTextFieldFocusNode})
: amountController = TextEditingController(),
_formKey = GlobalKey<FormState>() {
amountController.addListener(() => addressListViewModel.amount =
_formKey.currentState.validate() ? amountController.text : '');
_formKey.currentState!.validate() ? amountController.text : '');
}
final WalletAddressListViewModel addressListViewModel;
final bool isAmountFieldShow;
final TextEditingController amountController;
final FocusNode amountTextFieldFocusNode;
final FocusNode? amountTextFieldFocusNode;
final GlobalKey<FormState> _formKey;
final bool isLight;
@override
Widget build(BuildContext context) {
final copyImage = Image.asset('assets/images/copy_address.png',
color: Theme.of(context).textTheme.subhead.decorationColor);
color: Theme.of(context).textTheme!.subtitle1!.decorationColor!);
return Column(
mainAxisSize: MainAxisSize.min,
@@ -49,7 +49,7 @@ class QRWidget extends StatelessWidget {
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.display3.backgroundColor),
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!),
),
),
Row(
@@ -86,13 +86,13 @@ class QRWidget extends StatelessWidget {
decoration: BoxDecoration(
border: Border.all(
width: 3,
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
),
),
child: QrImage(
data: addressListViewModel.uri.toString(),
backgroundColor: isLight ? Colors.transparent : Colors.black,
foregroundColor: Theme.of(context).accentTextTheme.display3.backgroundColor,
foregroundColor: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
),
),
),
@@ -118,13 +118,14 @@ class QRWidget extends StatelessWidget {
focusNode: amountTextFieldFocusNode,
controller: amountController,
keyboardType: TextInputType.numberWithOptions(decimal: true),
inputFormatters: [BlacklistingTextInputFormatter(RegExp('[\\-|\\ ]'))],
inputFormatters: [FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))],
textAlign: TextAlign.center,
hintText: S.of(context).receive_amount,
textColor: Theme.of(context).accentTextTheme.display3.backgroundColor,
borderColor: Theme.of(context).textTheme.headline.decorationColor,
textColor: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!,
borderColor: Theme.of(context).textTheme!.headline5!.decorationColor!,
validator: AmountValidator(type: addressListViewModel.type, isAutovalidate: true),
autovalidate: true,
// FIX-ME: Check does it equal to autovalidate: true,
autovalidateMode: AutovalidateMode.always,
placeholderTextStyle: TextStyle(
color: Theme.of(context).hoverColor,
fontSize: 18,
@@ -156,7 +157,7 @@ class QRWidget extends StatelessWidget {
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Theme.of(context).accentTextTheme.display3.backgroundColor),
color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!),
),
),
Padding(