diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 5f69a681a..e8d9f3e2a 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -741,6 +741,7 @@ class SendPage extends BasePage { Future _setTransactionPriority(BuildContext context) async { final items = TransactionPriority.forWalletType(sendViewModel.walletType); final selectedItem = items.indexOf(sendViewModel.transactionPriority); + final isShowScrollThumb = items.length > 3; await showPopUp( builder: (_) => Picker( @@ -750,7 +751,6 @@ class SendPage extends BasePage { mainAxisAlignment: MainAxisAlignment.center, onItemSelected: (TransactionPriority priority) => sendViewModel.setTransactionPriority(priority), - isAlwaysShowScrollThumb: true, ), context: context); } diff --git a/lib/src/screens/settings/settings.dart b/lib/src/screens/settings/settings.dart index 2ee3b94ff..d4e70aecb 100644 --- a/lib/src/screens/settings/settings.dart +++ b/lib/src/screens/settings/settings.dart @@ -43,7 +43,6 @@ class SettingsPage extends BasePage { return SettingsPickerCell( title: item.title, selectedItem: item.selectedItem(), - isAlwaysShowScrollThumb: item.isAlwaysShowScrollThumb, items: item.items, onItemSelected: (dynamic value) => item.onItemSelected(value), ); diff --git a/lib/src/screens/settings/widgets/settings_picker_cell.dart b/lib/src/screens/settings/widgets/settings_picker_cell.dart index e2c949683..c27ea753d 100644 --- a/lib/src/screens/settings/widgets/settings_picker_cell.dart +++ b/lib/src/screens/settings/widgets/settings_picker_cell.dart @@ -9,8 +9,7 @@ class SettingsPickerCell extends StandardListRow { {@required String title, this.selectedItem, this.items, - this.onItemSelected, - this.isAlwaysShowScrollThumb}) + this.onItemSelected}) : super( title: title, isSelected: false, @@ -24,7 +23,6 @@ class SettingsPickerCell extends StandardListRow { selectedAtIndex: selectedAtIndex, title: S.current.please_select, mainAxisAlignment: MainAxisAlignment.center, - isAlwaysShowScrollThumb: isAlwaysShowScrollThumb, onItemSelected: (ItemType item) => onItemSelected?.call(item))); }); @@ -32,7 +30,6 @@ class SettingsPickerCell extends StandardListRow { final ItemType selectedItem; final List items; final void Function(ItemType item) onItemSelected; - final bool isAlwaysShowScrollThumb; @override Widget buildTrailing(BuildContext context) { diff --git a/lib/src/widgets/picker.dart b/lib/src/widgets/picker.dart index 7223fe4fb..c157c3dc1 100644 --- a/lib/src/widgets/picker.dart +++ b/lib/src/widgets/picker.dart @@ -15,7 +15,6 @@ class Picker extends StatefulWidget { this.description, @required this.onItemSelected, this.mainAxisAlignment = MainAxisAlignment.start, - this.isAlwaysShowScrollThumb = false }); final int selectedAtIndex; @@ -25,7 +24,6 @@ class Picker extends StatefulWidget { final String description; final Function(Item) onItemSelected; final MainAxisAlignment mainAxisAlignment; - final bool isAlwaysShowScrollThumb; @override PickerState createState() => PickerState(items, images, onItemSelected); @@ -56,6 +54,8 @@ class PickerState extends State { setState(() {}); }); + final isShowScrollThumb = items != null ? items.length > 3 : false; + return AlertBackground( child: Stack( alignment: Alignment.center, @@ -168,13 +168,13 @@ class PickerState extends State { ) ) : Offstage(), - widget.isAlwaysShowScrollThumb - ? CakeScrollbar( + isShowScrollThumb + ? CakeScrollbar( backgroundHeight: backgroundHeight, thumbHeight: thumbHeight, fromTop: fromTop ) - : Offstage(), + : Offstage(), ], ) ), diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index 6bbcd7059..915040de5 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -40,6 +40,13 @@ abstract class SendViewModelBase with Store { _cryptoNumberFormat = NumberFormat(), note = '', sendAll = false { + final _priority = _settingsStore.transactionPriority; + + if (!TransactionPriority.forWalletType(walletType).contains(_priority)) { + _settingsStore.transactionPriority = + TransactionPriority.forWalletType(walletType).first; + } + _setCryptoNumMaximumFractionDigits(); } diff --git a/lib/view_model/settings/picker_list_item.dart b/lib/view_model/settings/picker_list_item.dart index 13d502d7e..1dfc9c06d 100644 --- a/lib/view_model/settings/picker_list_item.dart +++ b/lib/view_model/settings/picker_list_item.dart @@ -6,15 +6,13 @@ class PickerListItem extends SettingsListItem { {@required String title, @required this.selectedItem, @required this.items, - void Function(ItemType item) onItemSelected, - this.isAlwaysShowScrollThumb = false}) + void Function(ItemType item) onItemSelected}) : _onItemSelected = onItemSelected, super(title); final ItemType Function() selectedItem; final List items; final void Function(ItemType item) _onItemSelected; - final bool isAlwaysShowScrollThumb; void onItemSelected(dynamic item) { if (item is ItemType) { diff --git a/lib/view_model/settings/settings_view_model.dart b/lib/view_model/settings/settings_view_model.dart index 983438b6c..93968e8a7 100644 --- a/lib/view_model/settings/settings_view_model.dart +++ b/lib/view_model/settings/settings_view_model.dart @@ -35,6 +35,14 @@ abstract class SettingsViewModelBase with Store { currentVersion = ''; PackageInfo.fromPlatform().then( (PackageInfo packageInfo) => currentVersion = packageInfo.version); + + final _priority = _settingsStore.transactionPriority; + + if (!TransactionPriority.forWalletType(_walletType).contains(_priority)) { + _settingsStore.transactionPriority = + TransactionPriority.forWalletType(_walletType).first; + } + sections = [ [ if ((wallet.balance.availableModes as List).length > 1) @@ -47,7 +55,6 @@ abstract class SettingsViewModelBase with Store { PickerListItem( title: S.current.settings_currency, items: FiatCurrency.all, - isAlwaysShowScrollThumb: true, selectedItem: () => fiatCurrency, onItemSelected: (FiatCurrency currency) => setFiatCurrency(currency)), @@ -55,7 +62,6 @@ abstract class SettingsViewModelBase with Store { title: S.current.settings_fee_priority, items: TransactionPriority.forWalletType(wallet.type), selectedItem: () => transactionPriority, - isAlwaysShowScrollThumb: true, onItemSelected: (TransactionPriority priority) => _settingsStore.transactionPriority = priority), SwitcherListItem(