Merge branch 'CAKE-28-update-exchange-screen' of github.com:cake-tech/cake_wallet_private into btc

This commit is contained in:
M 2020-09-01 14:18:14 +03:00
commit c16fac1b1d
2 changed files with 115 additions and 80 deletions

View file

@ -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/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -152,48 +154,26 @@ class BaseSendWidget extends StatelessWidget {
), ),
suffixIcon: isTemplate suffixIcon: isTemplate
? Offstage() ? Offstage()
: Padding( : Container(
padding: EdgeInsets.only(bottom: 2), height: 32,
child: Row( width: 32,
mainAxisSize: MainAxisSize.min, margin: EdgeInsets.only(left: 14, top: 4, bottom: 10),
mainAxisAlignment: MainAxisAlignment.spaceBetween, decoration: BoxDecoration(
children: <Widget>[ color: Theme.of(context).primaryTextTheme.display1.color,
Container( borderRadius: BorderRadius.all(Radius.circular(6))
width: MediaQuery.of(context).size.width/2, ),
alignment: Alignment.centerLeft, child: InkWell(
child: Text( onTap: () => sendViewModel.setSendAll(),
' / ' + sendViewModel.balance, child: Center(
maxLines: 1, child: Text(S.of(context).all,
overflow: TextOverflow.ellipsis, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 12,
color: Theme.of(context).primaryTextTheme.headline.decorationColor 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', 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: <Widget>[
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(
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: BaseTextFormField( child: BaseTextFormField(
@ -247,45 +258,47 @@ class BaseSendWidget extends StatelessWidget {
), ),
isTemplate isTemplate
? Offstage() ? Offstage()
: GestureDetector( : Observer(
onTap: () {}, builder: (_) => GestureDetector(
child: Container( onTap: () => _setTransactionPriority(context),
padding: EdgeInsets.only(top: 24), child: Container(
child: Row( padding: EdgeInsets.only(top: 24),
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: Row(
children: <Widget>[ mainAxisAlignment: MainAxisAlignment.spaceBetween,
Text(S.of(context).send_estimated_fee, children: <Widget>[
style: TextStyle( Text(S.of(context).send_estimated_fee,
fontSize: 12, style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 12,
//color: Theme.of(context).primaryTextTheme.display2.color, fontWeight: FontWeight.w500,
color: Colors.white //color: Theme.of(context).primaryTextTheme.display2.color,
)), color: Colors.white
Container( )),
child: Row( Container(
children: <Widget>[ child: Row(
Text( children: <Widget>[
sendViewModel.estimatedFee.toString() + ' ' Text(
+ sendViewModel.currency.title, sendViewModel.estimatedFee.toString() + ' '
style: TextStyle( + sendViewModel.currency.title,
fontSize: 12, style: TextStyle(
fontWeight: FontWeight.w600, fontSize: 12,
//color: Theme.of(context).primaryTextTheme.display2.color, fontWeight: FontWeight.w600,
color: Colors.white //color: Theme.of(context).primaryTextTheme.display2.color,
)), color: Colors.white
Padding( )),
padding: EdgeInsets.only(left: 5), Padding(
child: Icon( padding: EdgeInsets.only(left: 5),
Icons.arrow_forward_ios, child: Icon(
size: 12, Icons.arrow_forward_ios,
color: Colors.white,), size: 12,
) color: Colors.white,),
], )
), ],
) ),
], )
), ],
), ),
),
)
) )
], ],
), ),
@ -575,4 +588,21 @@ class BaseSendWidget extends StatelessWidget {
}); });
} }
} }
Future<void> _setTransactionPriority(BuildContext context) async {
final items = TransactionPriority.all;
final selectedItem = items.indexOf(sendViewModel.transactionPriority);
await showDialog<void>(
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);
}
} }

View file

@ -193,6 +193,11 @@ abstract class SendViewModelBase with Store {
fiatAmount = ''; fiatAmount = '';
} }
@action
void setTransactionPriority(TransactionPriority transactionPriority) {
_settingsStore.transactionPriority = transactionPriority;
}
final WalletBase _wallet; final WalletBase _wallet;
final SettingsStore _settingsStore; final SettingsStore _settingsStore;