From d6a7f1fb616d2837189f7a9c8467e0600e2a3a79 Mon Sep 17 00:00:00 2001 From: Oleksandr Sobol Date: Mon, 31 Aug 2020 20:53:53 +0300 Subject: [PATCH] CAKE-28 | added available balance row and applied transactions priority picker to base send widget --- .../send/widgets/base_send_widget.dart | 190 ++++++++++-------- lib/view_model/send_view_model.dart | 5 + 2 files changed, 115 insertions(+), 80 deletions(-) diff --git a/lib/src/screens/send/widgets/base_send_widget.dart b/lib/src/screens/send/widgets/base_send_widget.dart index c8d03f389..94f970b95 100644 --- a/lib/src/screens/send/widgets/base_send_widget.dart +++ b/lib/src/screens/send/widgets/base_send_widget.dart @@ -1,3 +1,5 @@ +import 'package:cake_wallet/src/domain/common/transaction_priority.dart'; +import 'package:cake_wallet/src/widgets/picker.dart'; import 'package:cake_wallet/src/widgets/primary_button.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:flutter/cupertino.dart'; @@ -152,48 +154,26 @@ class BaseSendWidget extends StatelessWidget { ), suffixIcon: isTemplate ? Offstage() - : Padding( - padding: EdgeInsets.only(bottom: 2), - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Container( - width: MediaQuery.of(context).size.width/2, - alignment: Alignment.centerLeft, - child: Text( - ' / ' + sendViewModel.balance, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 14, - color: Theme.of(context).primaryTextTheme.headline.decorationColor - ) - ), + : 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 + ) ), - Container( - height: 34, - width: 34, - margin: EdgeInsets.only(left: 12, bottom: 8), - 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', @@ -212,6 +192,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 + ), + ) + ], + ), + ) + ), Padding( padding: const EdgeInsets.only(top: 20), child: BaseTextFormField( @@ -247,45 +258,47 @@ class BaseSendWidget extends StatelessWidget { ), isTemplate ? Offstage() - : GestureDetector( - onTap: () {}, - 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,), - ) - ], - ), - ) - ], - ), - ), + : 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,), + ) + ], + ), + ) + ], + ), + ), + ) ) ], ), @@ -575,4 +588,21 @@ class BaseSendWidget extends StatelessWidget { }); } } + + Future _setTransactionPriority(BuildContext context) async { + final items = TransactionPriority.all; + final selectedItem = items.indexOf(sendViewModel.transactionPriority); + + await showDialog( + builder: (_) => Picker( + items: items, + selectedAtIndex: selectedItem, + title: S.of(context).please_select, + mainAxisAlignment: MainAxisAlignment.center, + onItemSelected: (TransactionPriority priority) => + sendViewModel.setTransactionPriority(priority), + isAlwaysShowScrollThumb: true, + ), + context: context); + } } \ No newline at end of file diff --git a/lib/view_model/send_view_model.dart b/lib/view_model/send_view_model.dart index f5018a2b0..0942c7841 100644 --- a/lib/view_model/send_view_model.dart +++ b/lib/view_model/send_view_model.dart @@ -193,6 +193,11 @@ abstract class SendViewModelBase with Store { fiatAmount = ''; } + @action + void setTransactionPriority(TransactionPriority transactionPriority) { + _settingsStore.transactionPriority = transactionPriority; + } + final WalletBase _wallet; final SettingsStore _settingsStore;