CAKE-28 | added available balance row and applied transactions priority picker to base send widget

This commit is contained in:
Oleksandr Sobol 2020-08-31 20:53:53 +03:00
parent 81cdf0d878
commit d6a7f1fb61
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/scollable_with_bottom_section.dart';
import 'package:flutter/cupertino.dart';
@ -152,29 +154,10 @@ class BaseSendWidget extends StatelessWidget {
),
suffixIcon: isTemplate
? Offstage()
: Padding(
padding: EdgeInsets.only(bottom: 2),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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: 34,
width: 34,
margin: EdgeInsets.only(left: 12, bottom: 8),
: 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))
@ -192,9 +175,6 @@ class BaseSendWidget extends StatelessWidget {
),
),
),
)
],
),
),
hintText: '0.0000',
borderColor: Theme.of(context).primaryTextTheme.headline.color,
@ -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: const EdgeInsets.only(top: 20),
child: BaseTextFormField(
@ -247,8 +258,9 @@ class BaseSendWidget extends StatelessWidget {
),
isTemplate
? Offstage()
: GestureDetector(
onTap: () {},
: Observer(
builder: (_) => GestureDetector(
onTap: () => _setTransactionPriority(context),
child: Container(
padding: EdgeInsets.only(top: 24),
child: Row(
@ -287,6 +299,7 @@ class BaseSendWidget extends StatelessWidget {
),
),
)
)
],
),
)
@ -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 = '';
}
@action
void setTransactionPriority(TransactionPriority transactionPriority) {
_settingsStore.transactionPriority = transactionPriority;
}
final WalletBase _wallet;
final SettingsStore _settingsStore;