From 500fd9b94de711f84b1269916ec2915346b72992 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 15 Jan 2024 15:44:55 -0600 Subject: [PATCH] use isTestnet flag on coin enum --- .../add_wallet_views/add_wallet_view/add_wallet_view.dart | 6 ++---- lib/pages/address_book_views/address_book_view.dart | 2 +- .../subviews/address_book_filter_view.dart | 5 +---- .../address_book_views/subviews/coin_select_sheet.dart | 2 +- .../subviews/new_contact_address_entry_form.dart | 2 +- .../manage_coin_units/manage_coin_units_view.dart | 5 ++--- .../manage_nodes_views/manage_nodes_view.dart | 5 ++--- .../address_book_view/desktop_address_book.dart | 2 +- .../desktop_manage_block_explorers_dialog.dart | 2 +- .../settings/settings_menu/nodes_settings.dart | 5 ++--- lib/utilities/enums/coin_enum.dart | 3 --- lib/widgets/choose_coin_view.dart | 5 ++--- 12 files changed, 16 insertions(+), 28 deletions(-) diff --git a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart index ff769f691..c817b5899 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart @@ -60,11 +60,9 @@ class _AddWalletViewState extends ConsumerState { String _searchTerm = ""; final List _coinsTestnet = [ - ...Coin.values.sublist(Coin.values.length - kTestNetCoinCount - 1), - ]; - final List _coins = [ - ...Coin.values.sublist(0, Coin.values.length - kTestNetCoinCount - 1) + ...Coin.values.where((e) => e.isTestNet), ]; + final List _coins = [...Coin.values.where((e) => !e.isTestNet)]; final List coinEntities = []; final List tokenEntities = []; diff --git a/lib/pages/address_book_views/address_book_view.dart b/lib/pages/address_book_views/address_book_view.dart index 009077f71..f302c287c 100644 --- a/lib/pages/address_book_views/address_book_view.dart +++ b/lib/pages/address_book_views/address_book_view.dart @@ -71,7 +71,7 @@ class _AddressBookViewState extends ConsumerState { } else { ref .read(addressBookFilterProvider) - .addAll(coins.getRange(0, coins.length - kTestNetCoinCount), false); + .addAll(coins.where((e) => !e.isTestNet), false); } } else { ref.read(addressBookFilterProvider).add(widget.coin!, false); diff --git a/lib/pages/address_book_views/subviews/address_book_filter_view.dart b/lib/pages/address_book_views/subviews/address_book_filter_view.dart index 83ed65ca4..64eb97552 100644 --- a/lib/pages/address_book_views/subviews/address_book_filter_view.dart +++ b/lib/pages/address_book_views/subviews/address_book_filter_view.dart @@ -47,10 +47,7 @@ class _AddressBookFilterViewState extends ConsumerState { if (showTestNet) { _coins = coins.toList(growable: false); } else { - _coins = coins - .toList(growable: false) - .getRange(0, coins.length - kTestNetCoinCount) - .toList(growable: false); + _coins = coins.where((e) => !e.isTestNet).toList(growable: false); } super.initState(); } diff --git a/lib/pages/address_book_views/subviews/coin_select_sheet.dart b/lib/pages/address_book_views/subviews/coin_select_sheet.dart index ca4405b64..922502abd 100644 --- a/lib/pages/address_book_views/subviews/coin_select_sheet.dart +++ b/lib/pages/address_book_views/subviews/coin_select_sheet.dart @@ -85,7 +85,7 @@ class CoinSelectSheet extends StatelessWidget { shrinkWrap: true, itemCount: showTestNet ? coins_.length - : coins_.length - kTestNetCoinCount, + : coins_.where((e) => !e.isTestNet).length, itemBuilder: (builderContext, index) { final coin = coins_[index]; return Padding( diff --git a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart index 9ca3f35e4..7381de7cc 100644 --- a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart +++ b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart @@ -96,7 +96,7 @@ class _NewContactAddressEntryFormState coins.remove(Coin.firoTestNet); if (showTestNet) { - coins = coins.sublist(0, coins.length - kTestNetCoinCount); + coins = coins.where((e) => !e.isTestNet).toList(); } } diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart index 6f16cda4e..f562b911e 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart @@ -45,9 +45,8 @@ class ManageCoinUnitsView extends ConsumerWidget { final _coins = Coin.values.where((e) => e != Coin.firoTestNet).toList(); - List coins = showTestNet - ? _coins - : _coins.sublist(0, _coins.length - kTestNetCoinCount); + List coins = + showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); return ConditionalParent( condition: Util.isDesktop, diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart index b6d9a9df2..c6e59c96c 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart @@ -56,9 +56,8 @@ class _ManageNodesViewState extends ConsumerState { prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - List coins = showTestNet - ? _coins - : _coins.sublist(0, _coins.length - kTestNetCoinCount); + List coins = + showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); return Background( child: Scaffold( diff --git a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart index 3da119839..d5390e3fd 100644 --- a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart +++ b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart @@ -103,7 +103,7 @@ class _DesktopAddressBook extends ConsumerState { } else { ref .read(addressBookFilterProvider) - .addAll(coins.getRange(0, coins.length - kTestNetCoinCount), false); + .addAll(coins.where((e) => !e.isTestNet), false); } // } else { // ref.read(addressBookFilterProvider).add(widget.coin!, false); diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart index 18fffedfd..2fd6431c1 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart @@ -40,7 +40,7 @@ class DesktopManageBlockExplorersDialog extends ConsumerWidget { final List coins = showTestNet ? Coin.values - : Coin.values.sublist(0, Coin.values.length - kTestNetCoinCount); + : Coin.values.where((e) => !e.isTestNet).toList(); return DesktopDialog( maxHeight: 850, diff --git a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart index da8ca07c9..eec6e1a5f 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart @@ -97,9 +97,8 @@ class _NodesSettings extends ConsumerState { prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - List coins = showTestNet - ? _coins - : _coins.sublist(0, _coins.length - kTestNetCoinCount); + List coins = + showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); coins = _search(filter, coins); diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index 3ffb738cf..c71d39ba4 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -42,9 +42,6 @@ enum Coin { stellarTestnet, } -final int kTestNetCoinCount = 6; // Util.isDesktop ? 5 : 4; -// remove firotestnet for now - extension CoinExt on Coin { String get prettyName { switch (this) { diff --git a/lib/widgets/choose_coin_view.dart b/lib/widgets/choose_coin_view.dart index 5bf6f6996..52ff990f2 100644 --- a/lib/widgets/choose_coin_view.dart +++ b/lib/widgets/choose_coin_view.dart @@ -70,9 +70,8 @@ class _ChooseCoinViewState extends ConsumerState { prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - List coins = showTestNet - ? _coins - : _coins.sublist(0, _coins.length - kTestNetCoinCount); + List coins = + showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); return Background( child: Scaffold(