use isTestnet flag on coin enum

This commit is contained in:
julian 2024-01-15 15:44:55 -06:00
parent 3bdb0a1984
commit 500fd9b94d
12 changed files with 16 additions and 28 deletions

View file

@ -60,11 +60,9 @@ class _AddWalletViewState extends ConsumerState<AddWalletView> {
String _searchTerm = ""; String _searchTerm = "";
final List<Coin> _coinsTestnet = [ final List<Coin> _coinsTestnet = [
...Coin.values.sublist(Coin.values.length - kTestNetCoinCount - 1), ...Coin.values.where((e) => e.isTestNet),
];
final List<Coin> _coins = [
...Coin.values.sublist(0, Coin.values.length - kTestNetCoinCount - 1)
]; ];
final List<Coin> _coins = [...Coin.values.where((e) => !e.isTestNet)];
final List<AddWalletListEntity> coinEntities = []; final List<AddWalletListEntity> coinEntities = [];
final List<EthTokenEntity> tokenEntities = []; final List<EthTokenEntity> tokenEntities = [];

View file

@ -71,7 +71,7 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
} else { } else {
ref ref
.read(addressBookFilterProvider) .read(addressBookFilterProvider)
.addAll(coins.getRange(0, coins.length - kTestNetCoinCount), false); .addAll(coins.where((e) => !e.isTestNet), false);
} }
} else { } else {
ref.read(addressBookFilterProvider).add(widget.coin!, false); ref.read(addressBookFilterProvider).add(widget.coin!, false);

View file

@ -47,10 +47,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
if (showTestNet) { if (showTestNet) {
_coins = coins.toList(growable: false); _coins = coins.toList(growable: false);
} else { } else {
_coins = coins _coins = coins.where((e) => !e.isTestNet).toList(growable: false);
.toList(growable: false)
.getRange(0, coins.length - kTestNetCoinCount)
.toList(growable: false);
} }
super.initState(); super.initState();
} }

View file

@ -85,7 +85,7 @@ class CoinSelectSheet extends StatelessWidget {
shrinkWrap: true, shrinkWrap: true,
itemCount: showTestNet itemCount: showTestNet
? coins_.length ? coins_.length
: coins_.length - kTestNetCoinCount, : coins_.where((e) => !e.isTestNet).length,
itemBuilder: (builderContext, index) { itemBuilder: (builderContext, index) {
final coin = coins_[index]; final coin = coins_[index];
return Padding( return Padding(

View file

@ -96,7 +96,7 @@ class _NewContactAddressEntryFormState
coins.remove(Coin.firoTestNet); coins.remove(Coin.firoTestNet);
if (showTestNet) { if (showTestNet) {
coins = coins.sublist(0, coins.length - kTestNetCoinCount); coins = coins.where((e) => !e.isTestNet).toList();
} }
} }

View file

@ -45,9 +45,8 @@ class ManageCoinUnitsView extends ConsumerWidget {
final _coins = Coin.values.where((e) => e != Coin.firoTestNet).toList(); final _coins = Coin.values.where((e) => e != Coin.firoTestNet).toList();
List<Coin> coins = showTestNet List<Coin> coins =
? _coins showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList();
: _coins.sublist(0, _coins.length - kTestNetCoinCount);
return ConditionalParent( return ConditionalParent(
condition: Util.isDesktop, condition: Util.isDesktop,

View file

@ -56,9 +56,8 @@ class _ManageNodesViewState extends ConsumerState<ManageNodesView> {
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
); );
List<Coin> coins = showTestNet List<Coin> coins =
? _coins showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList();
: _coins.sublist(0, _coins.length - kTestNetCoinCount);
return Background( return Background(
child: Scaffold( child: Scaffold(

View file

@ -103,7 +103,7 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
} else { } else {
ref ref
.read(addressBookFilterProvider) .read(addressBookFilterProvider)
.addAll(coins.getRange(0, coins.length - kTestNetCoinCount), false); .addAll(coins.where((e) => !e.isTestNet), false);
} }
// } else { // } else {
// ref.read(addressBookFilterProvider).add(widget.coin!, false); // ref.read(addressBookFilterProvider).add(widget.coin!, false);

View file

@ -40,7 +40,7 @@ class DesktopManageBlockExplorersDialog extends ConsumerWidget {
final List<Coin> coins = showTestNet final List<Coin> coins = showTestNet
? Coin.values ? Coin.values
: Coin.values.sublist(0, Coin.values.length - kTestNetCoinCount); : Coin.values.where((e) => !e.isTestNet).toList();
return DesktopDialog( return DesktopDialog(
maxHeight: 850, maxHeight: 850,

View file

@ -97,9 +97,8 @@ class _NodesSettings extends ConsumerState<NodesSettings> {
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
); );
List<Coin> coins = showTestNet List<Coin> coins =
? _coins showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList();
: _coins.sublist(0, _coins.length - kTestNetCoinCount);
coins = _search(filter, coins); coins = _search(filter, coins);

View file

@ -42,9 +42,6 @@ enum Coin {
stellarTestnet, stellarTestnet,
} }
final int kTestNetCoinCount = 6; // Util.isDesktop ? 5 : 4;
// remove firotestnet for now
extension CoinExt on Coin { extension CoinExt on Coin {
String get prettyName { String get prettyName {
switch (this) { switch (this) {

View file

@ -70,9 +70,8 @@ class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), prefsChangeNotifierProvider.select((value) => value.showTestNetCoins),
); );
List<Coin> coins = showTestNet List<Coin> coins =
? _coins showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList();
: _coins.sublist(0, _coins.length - kTestNetCoinCount);
return Background( return Background(
child: Scaffold( child: Scaffold(