From 18ccd5de35d7a5b559122246df4b9b52442909ec Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 14 Sep 2020 22:07:44 +0300 Subject: [PATCH] redesign | merged with dev branch --- lib/di.dart | 4 +- lib/reactions/bootstrap.dart | 4 +- lib/src/screens/dashboard/dashboard_page.dart | 18 +- lib/src/screens/dashboard/wallet_menu.dart | 8 +- .../send/widgets/base_send_widget.dart | 530 +++++++++--------- pubspec.lock | 31 +- 6 files changed, 301 insertions(+), 294 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index 88aba04c8..dbd8ca63a 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -257,8 +257,8 @@ Future setup( getIt.registerFactory( () => SendPage(sendViewModel: getIt.get())); - // getIt.registerFactory( - // () => SendTemplatePage(sendViewModel: getIt.get())); + getIt.registerFactory( + () => SendTemplatePage(sendViewModel: getIt.get())); getIt.registerFactory(() => WalletListViewModel( walletInfoSource, getIt.get(), getIt.get())); diff --git a/lib/reactions/bootstrap.dart b/lib/reactions/bootstrap.dart index b371ed74e..c727a0868 100644 --- a/lib/reactions/bootstrap.dart +++ b/lib/reactions/bootstrap.dart @@ -24,8 +24,8 @@ import 'package:cake_wallet/store/dashboard/fiat_convertation_store.dart'; // FIXME: move me Future loadCurrentWallet() async { final appStore = getIt.get(); - final name = 'test'; - getIt.get().getString('current_wallet_name'); + //final name = 'test'; + final name = getIt.get().getString('current_wallet_name'); final typeRaw = getIt.get().getInt('current_wallet_type') ?? 0; final type = deserializeFromInt(typeRaw); diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index d3ae08cbe..4c0ee613c 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -104,9 +104,12 @@ class DashboardPage extends BasePage { )), Container( width: double.infinity, - padding: EdgeInsets.only(left: 44, right: 0, bottom: 24), + padding: EdgeInsets.only( + left: 45, + right: 45, + bottom: 24 + ), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( child: ActionButton( @@ -120,7 +123,16 @@ class DashboardPage extends BasePage { child: ActionButton( image: exchangeImage, title: S.of(context).exchange, - route: Routes.exchange), + route: Routes.exchange + ), + ), + Flexible( + child: ActionButton( + image: receiveImage, + title: S.of(context).receive, + route: Routes.receive, + alignment: Alignment.centerRight, + ), ) ], ), diff --git a/lib/src/screens/dashboard/wallet_menu.dart b/lib/src/screens/dashboard/wallet_menu.dart index 07fe0810d..0b13ec9fa 100644 --- a/lib/src/screens/dashboard/wallet_menu.dart +++ b/lib/src/screens/dashboard/wallet_menu.dart @@ -79,13 +79,13 @@ class WalletMenu { return AlertWithTwoActions( alertTitle: S.of(context).reconnection, alertContent: S.of(context).reconnect_alert_text, - leftButtonText: S.of(context).ok, - rightButtonText: S.of(context).cancel, - actionLeftButton: () async { + rightButtonText: S.of(context).ok, + leftButtonText: S.of(context).cancel, + actionRightButton: () async { await reconnect?.call(); Navigator.of(context).pop(); }, - actionRightButton: () => Navigator.of(context).pop()); + actionLeftButton: () => Navigator.of(context).pop()); }); } } diff --git a/lib/src/screens/send/widgets/base_send_widget.dart b/lib/src/screens/send/widgets/base_send_widget.dart index 260923124..871482a4c 100644 --- a/lib/src/screens/send/widgets/base_send_widget.dart +++ b/lib/src/screens/send/widgets/base_send_widget.dart @@ -10,6 +10,7 @@ import 'package:cake_wallet/view_model/send/send_view_model.dart'; import 'package:flutter/services.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/src/widgets/address_text_field.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/top_panel.dart'; @@ -25,9 +26,9 @@ import 'package:cake_wallet/routes.dart'; class BaseSendWidget extends StatelessWidget { BaseSendWidget( {@required this.sendViewModel, - @required this.leading, - @required this.middle, - this.isTemplate = false}); + @required this.leading, + @required this.middle, + this.isTemplate = false}); final SendViewModel sendViewModel; final bool isTemplate; @@ -72,32 +73,33 @@ class BaseSendWidget extends StatelessWidget { children: [ isTemplate ? BaseTextFormField( - controller: _nameController, - hintText: S.of(context).send_name, - borderColor: Theme.of(context) - .primaryTextTheme - .headline - .color, - textStyle: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w500, - color: Colors.white), - placeholderTextStyle: TextStyle( - color: Theme.of(context) - .primaryTextTheme - .headline - .decorationColor, - fontWeight: FontWeight.w500, - fontSize: 14), - validator: sendViewModel.templateValidator, - ) + controller: _nameController, + hintText: S.of(context).send_name, + borderColor: Theme.of(context) + .primaryTextTheme + .headline + .color, + textStyle: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w500, + color: Colors.white), + placeholderTextStyle: TextStyle( + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor, + fontWeight: FontWeight.w500, + fontSize: 14), + validator: sendViewModel.templateValidator, + ) : Offstage(), Padding( padding: EdgeInsets.only(top: isTemplate ? 20 : 0), child: AddressTextField( controller: _addressController, - placeholder: S.of(context).send_address( - sendViewModel.cryptoCurrencyTitle), + // placeholder: S + // .of(context) + // .send_address(sendViewModel.cryptoCurrencyTitle), focusNode: _focusNode, onURIScanned: (uri) { var address = ''; @@ -119,9 +121,9 @@ class BaseSendWidget extends StatelessWidget { AddressTextFieldOption.addressBook ], buttonColor: - Theme.of(context).primaryTextTheme.display1.color, + Theme.of(context).primaryTextTheme.display1.color, borderColor: - Theme.of(context).primaryTextTheme.headline.color, + Theme.of(context).primaryTextTheme.headline.color, textStyle: TextStyle( fontSize: 14, fontWeight: FontWeight.w500, @@ -150,43 +152,43 @@ class BaseSendWidget extends StatelessWidget { prefixIcon: Padding( padding: EdgeInsets.only(top: 9), child: - Text(sendViewModel.currency.title + ':', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Colors.white, - )), + Text(sendViewModel.currency.title + ':', + style: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.white, + )), ), suffixIcon: isTemplate ? Offstage() : Container( - height: 32, - width: 32, - margin: EdgeInsets.only( - left: 14, top: 4, bottom: 10), - decoration: BoxDecoration( - color: Theme.of(context) - .primaryTextTheme - .display1 - .color, - borderRadius: BorderRadius.all( - Radius.circular(6))), - child: InkWell( - onTap: () => - sendViewModel.setSendAll(), - child: Center( - child: Text(S.of(context).all, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.bold, - color: Theme.of(context) - .primaryTextTheme - .display1 - .decorationColor)), - ), - ), - ), + height: 32, + width: 32, + margin: EdgeInsets.only( + left: 14, top: 4, bottom: 10), + decoration: BoxDecoration( + color: Theme.of(context) + .primaryTextTheme + .display1 + .color, + borderRadius: BorderRadius.all( + Radius.circular(6))), + child: InkWell( + onTap: () => + sendViewModel.setSendAll(), + child: Center( + child: Text(S.of(context).all, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .display1 + .decorationColor)), + ), + ), + ), hintText: '0.0000', borderColor: Theme.of(context) .primaryTextTheme @@ -208,37 +210,37 @@ class BaseSendWidget extends StatelessWidget { isTemplate ? Offstage() : Observer( - builder: (_) => Padding( - padding: EdgeInsets.only(top: 10), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - S.of(context).available_balance + ':', - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .headline - .decorationColor), - )), - Text( - sendViewModel.balance, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .headline - .decorationColor), - ) - ], - ), - )), + builder: (_) => Padding( + padding: EdgeInsets.only(top: 10), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Text( + S.of(context).available_balance + ':', + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor), + )), + Text( + sendViewModel.balance, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Theme.of(context) + .primaryTextTheme + .headline + .decorationColor), + ) + ], + ), + )), Padding( padding: const EdgeInsets.only(top: 20), child: BaseTextFormField( @@ -278,52 +280,52 @@ class BaseSendWidget extends StatelessWidget { isTemplate ? Offstage() : Observer( - builder: (_) => GestureDetector( - onTap: () => - _setTransactionPriority(context), - child: Container( - padding: EdgeInsets.only(top: 24), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text(S.of(context).send_estimated_fee, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w500, - //color: Theme.of(context).primaryTextTheme.display2.color, - color: Colors.white)), - Container( - child: Row( - children: [ - Text( - sendViewModel.estimatedFee - .toString() + - ' ' + - sendViewModel - .currency.title, - style: TextStyle( - fontSize: 12, - fontWeight: - FontWeight.w600, - //color: Theme.of(context).primaryTextTheme.display2.color, - color: Colors.white)), - Padding( - padding: - EdgeInsets.only(left: 5), - child: Icon( - Icons.arrow_forward_ios, - size: 12, - color: Colors.white, - ), - ) - ], - ), - ) - ], - ), + builder: (_) => GestureDetector( + onTap: () => + _setTransactionPriority(context), + child: Container( + padding: EdgeInsets.only(top: 24), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text(S.of(context).send_estimated_fee, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w500, + //color: Theme.of(context).primaryTextTheme.display2.color, + color: Colors.white)), + Container( + child: Row( + children: [ + Text( + sendViewModel.estimatedFee + .toString() + + ' ' + + sendViewModel + .currency.title, + style: TextStyle( + fontSize: 12, + fontWeight: + FontWeight.w600, + //color: Theme.of(context).primaryTextTheme.display2.color, + color: Colors.white)), + Padding( + padding: + EdgeInsets.only(left: 5), + child: Icon( + Icons.arrow_forward_ios, + size: 12, + color: Colors.white, + ), + ) + ], ), - )) + ) + ], + ), + ), + )) ], ), ) @@ -333,117 +335,117 @@ class BaseSendWidget extends StatelessWidget { isTemplate ? Offstage() : Padding( - padding: EdgeInsets.only(top: 30, left: 24, bottom: 24), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - S.of(context).send_templates, - style: TextStyle( - fontSize: 18, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .display4 - .color), - ) - ], - ), - ), + padding: EdgeInsets.only(top: 30, left: 24, bottom: 24), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + S.of(context).send_templates, + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.w600, + color: Theme.of(context) + .primaryTextTheme + .display4 + .color), + ) + ], + ), + ), isTemplate ? Offstage() : Container( - height: 40, - width: double.infinity, - padding: EdgeInsets.only(left: 24), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: [ - GestureDetector( - onTap: () => Navigator.of(context) - .pushNamed(Routes.sendTemplate), + height: 40, + width: double.infinity, + padding: EdgeInsets.only(left: 24), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: [ + GestureDetector( + onTap: () => Navigator.of(context) + .pushNamed(Routes.sendTemplate), + child: Container( + padding: EdgeInsets.only(left: 1, right: 10), + child: DottedBorder( + borderType: BorderType.RRect, + dashPattern: [6, 4], + color: Theme.of(context) + .primaryTextTheme + .display2 + .decorationColor, + strokeWidth: 2, + radius: Radius.circular(20), child: Container( - padding: EdgeInsets.only(left: 1, right: 10), - child: DottedBorder( - borderType: BorderType.RRect, - dashPattern: [6, 4], - color: Theme.of(context) - .primaryTextTheme - .display2 - .decorationColor, - strokeWidth: 2, - radius: Radius.circular(20), - child: Container( - height: 34, - width: 75, - padding: EdgeInsets.only(left: 10, right: 10), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(20)), - color: Colors.transparent, - ), - child: Text( - S.of(context).send_new, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme - .display3 - .color), - ), - )), - ), - ), - // Observer( - // builder: (_) { - // final templates = sendViewModel.templates; - // final itemCount = templates.length; + height: 34, + width: 75, + padding: EdgeInsets.only(left: 10, right: 10), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(20)), + color: Colors.transparent, + ), + child: Text( + S.of(context).send_new, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Theme.of(context) + .primaryTextTheme + .display3 + .color), + ), + )), + ), + ), + // Observer( + // builder: (_) { + // final templates = sendViewModel.templates; + // final itemCount = templates.length; - // return ListView.builder( - // scrollDirection: Axis.horizontal, - // shrinkWrap: true, - // physics: NeverScrollableScrollPhysics(), - // itemCount: itemCount, - // itemBuilder: (context, index) { - // final template = templates[index]; + // return ListView.builder( + // scrollDirection: Axis.horizontal, + // shrinkWrap: true, + // physics: NeverScrollableScrollPhysics(), + // itemCount: itemCount, + // itemBuilder: (context, index) { + // final template = templates[index]; - return TemplateTile( - key: UniqueKey(), - to: template.name, - amount: template.amount, - from: template.cryptoCurrency, - onTap: () { - _addressController.text = template.address; - _cryptoAmountController.text = template.amount; - getOpenaliasRecord(context); - }, - onRemove: () { - showDialog( - context: context, - builder: (dialogContext) { - return AlertWithTwoActions( - alertTitle: S.of(context).template, - alertContent: S.of(context).confirm_delete_template, - rightButtonText: S.of(context).delete, - leftButtonText: S.of(context).cancel, - actionRightButton: () { - Navigator.of(dialogContext).pop(); - sendViewModel.sendTemplateStore.remove(template: template); - sendViewModel.sendTemplateStore.update(); - }, - actionLeftButton: () => Navigator.of(dialogContext).pop() - ); - } - ); - }, - ); - } - ); - } - ) + // return TemplateTile( + // key: UniqueKey(), + // to: template.name, + // amount: template.amount, + // from: template.cryptoCurrency, + // onTap: () { + // _addressController.text = template.address; + // _cryptoAmountController.text = template.amount; + // getOpenaliasRecord(context); + // }, + // onRemove: () { + // showDialog( + // context: context, + // builder: (dialogContext) { + // return AlertWithTwoActions( + // alertTitle: S.of(context).template, + // alertContent: S.of(context).confirm_delete_template, + // leftButtonText: S.of(context).delete, + // rightButtonText: S.of(context).cancel, + // actionLeftButton: () { + // Navigator.of(dialogContext).pop(); + // sendViewModel.sendTemplateStore.remove(template: template); + // sendViewModel.sendTemplateStore.update(); + // }, + // actionRightButton: () => Navigator.of(dialogContext).pop() + // ); + // } + // ); + // }, + // ); + // } + // ); + // } + // ) ], ), ), @@ -453,20 +455,20 @@ class BaseSendWidget extends StatelessWidget { bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSection: isTemplate ? PrimaryButton( - onPressed: () { - if (_formKey.currentState.validate()) { - // sendViewModel.sendTemplateStore.addTemplate( - // name: _nameController.text, - // address: _addressController.text, - // cryptoCurrency: sendViewModel.currency.title, - // amount: _cryptoAmountController.text); - // sendViewModel.sendTemplateStore.update(); - Navigator.of(context).pop(); - } - }, - text: S.of(context).save, - color: Colors.green, - textColor: Colors.white) + onPressed: () { + if (_formKey.currentState.validate()) { + // sendViewModel.sendTemplateStore.addTemplate( + // name: _nameController.text, + // address: _addressController.text, + // cryptoCurrency: sendViewModel.currency.title, + // amount: _cryptoAmountController.text); + // sendViewModel.sendTemplateStore.update(); + Navigator.of(context).pop(); + } + }, + text: S.of(context).save, + color: Colors.green, + textColor: Colors.white) : Observer(builder: (_) { return LoadingPrimaryButton( onPressed: () { @@ -552,7 +554,7 @@ class BaseSendWidget extends StatelessWidget { alertTitle: S.of(context).confirm_sending, amount: S.of(context).send_amount, amountValue: - sendViewModel.pendingTransaction.amountFormatted, + sendViewModel.pendingTransaction.amountFormatted, fee: S.of(context).send_fee, feeValue: sendViewModel.pendingTransaction.feeFormatted, leftButtonText: S.of(context).ok, @@ -694,14 +696,14 @@ class BaseSendWidget extends StatelessWidget { await showDialog( builder: (_) => Picker( - items: items, - selectedAtIndex: selectedItem, - title: S.of(context).please_select, - mainAxisAlignment: MainAxisAlignment.center, - onItemSelected: (TransactionPriority priority) => null, - // sendViewModel.setTransactionPriority(priority), - isAlwaysShowScrollThumb: true, - ), + items: items, + selectedAtIndex: selectedItem, + title: S.of(context).please_select, + mainAxisAlignment: MainAxisAlignment.center, + onItemSelected: (TransactionPriority priority) => null, + // sendViewModel.setTransactionPriority(priority), + isAlwaysShowScrollThumb: true, + ), context: context); } -} +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index ab4e1d14e..158fdec7c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,7 +42,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.4.1" auto_size_text: dependency: "direct main" description: @@ -210,7 +210,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.14.12" convert: dependency: transitive description: @@ -224,7 +224,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "2.1.4" csslib: dependency: transitive description: @@ -302,13 +302,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" ffi: dependency: transitive description: @@ -475,7 +468,7 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.14" + version: "2.1.12" intl: dependency: "direct main" description: @@ -524,7 +517,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.6" meta: dependency: transitive description: @@ -594,7 +587,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.6.4" path_drawing: dependency: transitive description: @@ -650,7 +643,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "2.4.0" platform: dependency: transitive description: @@ -830,7 +823,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.9.3" stream_channel: dependency: transitive description: @@ -865,7 +858,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.15" time: dependency: transitive description: @@ -886,7 +879,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.6" url_launcher: dependency: "direct main" description: @@ -963,7 +956,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "4.2.0" + version: "3.6.1" yaml: dependency: "direct main" description: @@ -972,5 +965,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"