mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
Merge pull request #167 from cake-tech/CAKE-222-fix-fee-picker-on-the-settings-screen
Cake 222 fix fee picker on the settings screen
This commit is contained in:
commit
ae10c9cff7
7 changed files with 23 additions and 16 deletions
|
@ -741,6 +741,7 @@ class SendPage extends BasePage {
|
||||||
Future<void> _setTransactionPriority(BuildContext context) async {
|
Future<void> _setTransactionPriority(BuildContext context) async {
|
||||||
final items = TransactionPriority.forWalletType(sendViewModel.walletType);
|
final items = TransactionPriority.forWalletType(sendViewModel.walletType);
|
||||||
final selectedItem = items.indexOf(sendViewModel.transactionPriority);
|
final selectedItem = items.indexOf(sendViewModel.transactionPriority);
|
||||||
|
final isShowScrollThumb = items.length > 3;
|
||||||
|
|
||||||
await showPopUp<void>(
|
await showPopUp<void>(
|
||||||
builder: (_) => Picker(
|
builder: (_) => Picker(
|
||||||
|
@ -750,7 +751,6 @@ class SendPage extends BasePage {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
onItemSelected: (TransactionPriority priority) =>
|
onItemSelected: (TransactionPriority priority) =>
|
||||||
sendViewModel.setTransactionPriority(priority),
|
sendViewModel.setTransactionPriority(priority),
|
||||||
isAlwaysShowScrollThumb: true,
|
|
||||||
),
|
),
|
||||||
context: context);
|
context: context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ class SettingsPage extends BasePage {
|
||||||
return SettingsPickerCell<dynamic>(
|
return SettingsPickerCell<dynamic>(
|
||||||
title: item.title,
|
title: item.title,
|
||||||
selectedItem: item.selectedItem(),
|
selectedItem: item.selectedItem(),
|
||||||
isAlwaysShowScrollThumb: item.isAlwaysShowScrollThumb,
|
|
||||||
items: item.items,
|
items: item.items,
|
||||||
onItemSelected: (dynamic value) => item.onItemSelected(value),
|
onItemSelected: (dynamic value) => item.onItemSelected(value),
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,8 +9,7 @@ class SettingsPickerCell<ItemType> extends StandardListRow {
|
||||||
{@required String title,
|
{@required String title,
|
||||||
this.selectedItem,
|
this.selectedItem,
|
||||||
this.items,
|
this.items,
|
||||||
this.onItemSelected,
|
this.onItemSelected})
|
||||||
this.isAlwaysShowScrollThumb})
|
|
||||||
: super(
|
: super(
|
||||||
title: title,
|
title: title,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
|
@ -24,7 +23,6 @@ class SettingsPickerCell<ItemType> extends StandardListRow {
|
||||||
selectedAtIndex: selectedAtIndex,
|
selectedAtIndex: selectedAtIndex,
|
||||||
title: S.current.please_select,
|
title: S.current.please_select,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
isAlwaysShowScrollThumb: isAlwaysShowScrollThumb,
|
|
||||||
onItemSelected: (ItemType item) =>
|
onItemSelected: (ItemType item) =>
|
||||||
onItemSelected?.call(item)));
|
onItemSelected?.call(item)));
|
||||||
});
|
});
|
||||||
|
@ -32,7 +30,6 @@ class SettingsPickerCell<ItemType> extends StandardListRow {
|
||||||
final ItemType selectedItem;
|
final ItemType selectedItem;
|
||||||
final List<ItemType> items;
|
final List<ItemType> items;
|
||||||
final void Function(ItemType item) onItemSelected;
|
final void Function(ItemType item) onItemSelected;
|
||||||
final bool isAlwaysShowScrollThumb;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildTrailing(BuildContext context) {
|
Widget buildTrailing(BuildContext context) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ class Picker<Item extends Object> extends StatefulWidget {
|
||||||
this.description,
|
this.description,
|
||||||
@required this.onItemSelected,
|
@required this.onItemSelected,
|
||||||
this.mainAxisAlignment = MainAxisAlignment.start,
|
this.mainAxisAlignment = MainAxisAlignment.start,
|
||||||
this.isAlwaysShowScrollThumb = false
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final int selectedAtIndex;
|
final int selectedAtIndex;
|
||||||
|
@ -25,7 +24,6 @@ class Picker<Item extends Object> extends StatefulWidget {
|
||||||
final String description;
|
final String description;
|
||||||
final Function(Item) onItemSelected;
|
final Function(Item) onItemSelected;
|
||||||
final MainAxisAlignment mainAxisAlignment;
|
final MainAxisAlignment mainAxisAlignment;
|
||||||
final bool isAlwaysShowScrollThumb;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PickerState createState() => PickerState<Item>(items, images, onItemSelected);
|
PickerState createState() => PickerState<Item>(items, images, onItemSelected);
|
||||||
|
@ -56,6 +54,8 @@ class PickerState<Item> extends State<Picker> {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final isShowScrollThumb = items != null ? items.length > 3 : false;
|
||||||
|
|
||||||
return AlertBackground(
|
return AlertBackground(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
@ -168,13 +168,13 @@ class PickerState<Item> extends State<Picker> {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
: Offstage(),
|
: Offstage(),
|
||||||
widget.isAlwaysShowScrollThumb
|
isShowScrollThumb
|
||||||
? CakeScrollbar(
|
? CakeScrollbar(
|
||||||
backgroundHeight: backgroundHeight,
|
backgroundHeight: backgroundHeight,
|
||||||
thumbHeight: thumbHeight,
|
thumbHeight: thumbHeight,
|
||||||
fromTop: fromTop
|
fromTop: fromTop
|
||||||
)
|
)
|
||||||
: Offstage(),
|
: Offstage(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
|
@ -40,6 +40,13 @@ abstract class SendViewModelBase with Store {
|
||||||
_cryptoNumberFormat = NumberFormat(),
|
_cryptoNumberFormat = NumberFormat(),
|
||||||
note = '',
|
note = '',
|
||||||
sendAll = false {
|
sendAll = false {
|
||||||
|
final _priority = _settingsStore.transactionPriority;
|
||||||
|
|
||||||
|
if (!TransactionPriority.forWalletType(walletType).contains(_priority)) {
|
||||||
|
_settingsStore.transactionPriority =
|
||||||
|
TransactionPriority.forWalletType(walletType).first;
|
||||||
|
}
|
||||||
|
|
||||||
_setCryptoNumMaximumFractionDigits();
|
_setCryptoNumMaximumFractionDigits();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,13 @@ class PickerListItem<ItemType> extends SettingsListItem {
|
||||||
{@required String title,
|
{@required String title,
|
||||||
@required this.selectedItem,
|
@required this.selectedItem,
|
||||||
@required this.items,
|
@required this.items,
|
||||||
void Function(ItemType item) onItemSelected,
|
void Function(ItemType item) onItemSelected})
|
||||||
this.isAlwaysShowScrollThumb = false})
|
|
||||||
: _onItemSelected = onItemSelected,
|
: _onItemSelected = onItemSelected,
|
||||||
super(title);
|
super(title);
|
||||||
|
|
||||||
final ItemType Function() selectedItem;
|
final ItemType Function() selectedItem;
|
||||||
final List<ItemType> items;
|
final List<ItemType> items;
|
||||||
final void Function(ItemType item) _onItemSelected;
|
final void Function(ItemType item) _onItemSelected;
|
||||||
final bool isAlwaysShowScrollThumb;
|
|
||||||
|
|
||||||
void onItemSelected(dynamic item) {
|
void onItemSelected(dynamic item) {
|
||||||
if (item is ItemType) {
|
if (item is ItemType) {
|
||||||
|
|
|
@ -35,6 +35,14 @@ abstract class SettingsViewModelBase with Store {
|
||||||
currentVersion = '';
|
currentVersion = '';
|
||||||
PackageInfo.fromPlatform().then(
|
PackageInfo.fromPlatform().then(
|
||||||
(PackageInfo packageInfo) => currentVersion = packageInfo.version);
|
(PackageInfo packageInfo) => currentVersion = packageInfo.version);
|
||||||
|
|
||||||
|
final _priority = _settingsStore.transactionPriority;
|
||||||
|
|
||||||
|
if (!TransactionPriority.forWalletType(_walletType).contains(_priority)) {
|
||||||
|
_settingsStore.transactionPriority =
|
||||||
|
TransactionPriority.forWalletType(_walletType).first;
|
||||||
|
}
|
||||||
|
|
||||||
sections = [
|
sections = [
|
||||||
[
|
[
|
||||||
if ((wallet.balance.availableModes as List).length > 1)
|
if ((wallet.balance.availableModes as List).length > 1)
|
||||||
|
@ -47,7 +55,6 @@ abstract class SettingsViewModelBase with Store {
|
||||||
PickerListItem(
|
PickerListItem(
|
||||||
title: S.current.settings_currency,
|
title: S.current.settings_currency,
|
||||||
items: FiatCurrency.all,
|
items: FiatCurrency.all,
|
||||||
isAlwaysShowScrollThumb: true,
|
|
||||||
selectedItem: () => fiatCurrency,
|
selectedItem: () => fiatCurrency,
|
||||||
onItemSelected: (FiatCurrency currency) =>
|
onItemSelected: (FiatCurrency currency) =>
|
||||||
setFiatCurrency(currency)),
|
setFiatCurrency(currency)),
|
||||||
|
@ -55,7 +62,6 @@ abstract class SettingsViewModelBase with Store {
|
||||||
title: S.current.settings_fee_priority,
|
title: S.current.settings_fee_priority,
|
||||||
items: TransactionPriority.forWalletType(wallet.type),
|
items: TransactionPriority.forWalletType(wallet.type),
|
||||||
selectedItem: () => transactionPriority,
|
selectedItem: () => transactionPriority,
|
||||||
isAlwaysShowScrollThumb: true,
|
|
||||||
onItemSelected: (TransactionPriority priority) =>
|
onItemSelected: (TransactionPriority priority) =>
|
||||||
_settingsStore.transactionPriority = priority),
|
_settingsStore.transactionPriority = priority),
|
||||||
SwitcherListItem(
|
SwitcherListItem(
|
||||||
|
|
Loading…
Reference in a new issue