From 1bf55318cc16d81c6d96c52f2d7832339a4566b3 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Fri, 20 Jan 2023 20:05:32 -0600 Subject: [PATCH] use coin image if buying crypto amount and remove print in prod TODO refactor duplicated isStackCoin and getIconForTicker into coin_enum? --- lib/pages/buy_view/buy_form.dart | 27 +++++++++---------- .../sub_widgets/crypto_selection_view.dart | 1 - 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/pages/buy_view/buy_form.dart b/lib/pages/buy_view/buy_form.dart index fe3c214fd..d171bfaef 100644 --- a/lib/pages/buy_view/buy_form.dart +++ b/lib/pages/buy_view/buy_form.dart @@ -350,6 +350,15 @@ class _BuyFormState extends ConsumerState { } } + Widget? getIconForTicker(String ticker) { + String? iconAsset = isStackCoin(ticker) + ? Assets.svg.iconFor(coin: coinFromTickerCaseInsensitive(ticker)) + : Assets.svg.buyIconFor(ticker); + return (iconAsset != null) + ? SvgPicture.asset(iconAsset, height: 20, width: 20) + : null; + } + Future previewQuote(SimplexQuote quote) async { // if (ref.read(simplexProvider).quote.id == "someID") { // // TODO make a better way of detecting a default SimplexQuote @@ -587,13 +596,8 @@ class _BuyFormState extends ConsumerState { padding: const EdgeInsets.all(12), child: Row( children: [ - SvgPicture.asset( - Assets.svg.iconFor( - coin: coinFromTickerCaseInsensitive("BTC"), - ), - height: 18, - width: 18, - ), + getIconForTicker(selectedCrypto?.ticker ?? "BTC") + as Widget, const SizedBox( width: 10, ), @@ -800,13 +804,8 @@ class _BuyFormState extends ConsumerState { .length)), textAlign: TextAlign.center, ) - : SvgPicture.asset( - Assets.svg.iconFor( - coin: coinFromTickerCaseInsensitive("BTC"), - ), - height: 18, - width: 18, - ), + : getIconForTicker(selectedCrypto?.ticker ?? "BTC") + as Widget, const SizedBox(width: 10), // maybe make isDesktop-aware? Text( buyWithFiat diff --git a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart index 2ba50dda8..70b63964e 100644 --- a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart @@ -262,7 +262,6 @@ bool isStackCoin(String? ticker) { } Widget? getIconForTicker(String ticker) { - print(ticker); String? iconAsset = isStackCoin(ticker) ? Assets.svg.iconFor(coin: coinFromTickerCaseInsensitive(ticker)) : Assets.svg.buyIconFor(ticker);