mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
use Julian's isStackCoin helper func
very nice. didn't realize I could catch an error. learning every day round here
This commit is contained in:
parent
b376b00d7c
commit
49f024b656
2 changed files with 15 additions and 31 deletions
|
@ -250,13 +250,23 @@ class _CryptoSelectionViewState extends State<CryptoSelectionView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isStackCoin(String? ticker) {
|
||||||
|
if (ticker == null) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
coinFromTickerCaseInsensitive(ticker);
|
||||||
|
return true;
|
||||||
|
} on ArgumentError catch (_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget? getIconForTicker(String ticker) {
|
Widget? getIconForTicker(String ticker) {
|
||||||
print(ticker);
|
print(ticker);
|
||||||
String? iconAsset = isCoinSupportedByTicker(ticker)
|
String? iconAsset = isStackCoin(ticker)
|
||||||
? Assets.svg.iconFor(coin: coinFromTickerCaseInsensitive(ticker))
|
? Assets.svg.iconFor(coin: coinFromTickerCaseInsensitive(ticker))
|
||||||
: Assets.svg.buyIconFor(ticker);
|
: Assets.svg.buyIconFor(ticker);
|
||||||
if (iconAsset != null) {
|
return (iconAsset != null)
|
||||||
return SvgPicture.asset(iconAsset, height: 20, width: 20);
|
? SvgPicture.asset(iconAsset, height: 20, width: 20)
|
||||||
}
|
: null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,29 +328,3 @@ Coin coinFromTickerCaseInsensitive(String ticker) {
|
||||||
ticker, "name", "No Coin enum value with that 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