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 = "";
final List<Coin> _coinsTestnet = [
...Coin.values.sublist(Coin.values.length - kTestNetCoinCount - 1),
];
final List<Coin> _coins = [
...Coin.values.sublist(0, Coin.values.length - kTestNetCoinCount - 1)
...Coin.values.where((e) => e.isTestNet),
];
final List<Coin> _coins = [...Coin.values.where((e) => !e.isTestNet)];
final List<AddWalletListEntity> coinEntities = [];
final List<EthTokenEntity> tokenEntities = [];

View file

@ -71,7 +71,7 @@ class _AddressBookViewState extends ConsumerState<AddressBookView> {
} 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);

View file

@ -47,10 +47,7 @@ class _AddressBookFilterViewState extends ConsumerState<AddressBookFilterView> {
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();
}

View file

@ -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(

View file

@ -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();
}
}

View file

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

View file

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

View file

@ -103,7 +103,7 @@ class _DesktopAddressBook extends ConsumerState<DesktopAddressBook> {
} 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);

View file

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

View file

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

View file

@ -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) {

View file

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