mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
get coin images for coins we support
This commit is contained in:
parent
39f5df3158
commit
50a3815946
2 changed files with 50 additions and 12 deletions
|
@ -208,8 +208,7 @@ class _CryptoSelectionViewState extends State<CryptoSelectionView> {
|
|||
placeholderBuilder: (_) =>
|
||||
const LoadingIndicator(),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
: getIconForTicker(_coins[index].ticker)),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
|
@ -250,3 +249,16 @@ class _CryptoSelectionViewState extends State<CryptoSelectionView> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget? getIconForTicker(String ticker) {
|
||||
print(ticker);
|
||||
if (!isCoinSupportedByTicker(ticker)) {
|
||||
return null;
|
||||
}
|
||||
Coin? coin = coinFromTickerCaseInsensitive(ticker);
|
||||
String iconAsset = Assets.svg.iconFor(coin: coin);
|
||||
if (iconAsset != null) {
|
||||
return SvgPicture.asset(iconAsset, height: 20, width: 20);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -330,3 +330,29 @@ Coin coinFromTickerCaseInsensitive(String ticker) {
|
|||
ticker, "name", "No Coin enum value with that ticker");
|
||||
}
|
||||
}
|
||||
|
||||
// This was added for the Buy view.I would use coinFromTickerCaseInsensitive
|
||||
// however I need it to return null or something else to indicate failure
|
||||
// instead of throwing an exception
|
||||
bool isCoinSupportedByTicker(String ticker) {
|
||||
switch (ticker.toLowerCase()) {
|
||||
case "btc":
|
||||
case "ltc":
|
||||
case "bch":
|
||||
case "doge":
|
||||
case "epic":
|
||||
case "firo":
|
||||
case "xmr":
|
||||
case "nmc":
|
||||
case "part":
|
||||
case "tltc":
|
||||
case "tbtc":
|
||||
case "tbch":
|
||||
case "tfiro":
|
||||
case "tdoge":
|
||||
case "wow":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue