stack_wallet/lib/themes/coin_icon_provider.dart
2024-01-19 17:44:01 -06:00

63 lines
1.8 KiB
Dart

/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/themes/theme_providers.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
final coinIconProvider = Provider.family<String, Coin>((ref, coin) {
final assets = ref.watch(themeAssetsProvider);
// TODO: handle this differently by adding proper frost assets to themes
if (coin == Coin.bitcoinFrost) {
coin = Coin.bitcoin;
} else if (coin == Coin.bitcoinFrostTestNet) {
coin = Coin.bitcoinTestNet;
}
if (assets is ThemeAssets) {
switch (coin) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
return assets.bitcoin;
case Coin.litecoin:
case Coin.litecoinTestNet:
return assets.litecoin;
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
return assets.bitcoincash;
case Coin.dogecoin:
case Coin.dogecoinTestNet:
return assets.dogecoin;
case Coin.epicCash:
return assets.epicCash;
case Coin.firo:
case Coin.firoTestNet:
return assets.firo;
case Coin.monero:
return assets.monero;
case Coin.wownero:
return assets.wownero;
case Coin.namecoin:
return assets.namecoin;
case Coin.particl:
return assets.particl;
case Coin.ethereum:
return assets.ethereum;
default:
return assets.stackIcon;
}
} else if (assets is ThemeAssetsV2) {
return (assets).coinIcons[coin.mainNetVersion]!;
} else {
return (assets as ThemeAssetsV3).coinIcons[coin.mainNetVersion]!;
}
});