use coin image if buying crypto amount

and remove print in prod
TODO refactor duplicated isStackCoin and getIconForTicker into coin_enum?
This commit is contained in:
sneurlax 2023-01-20 20:05:32 -06:00
parent 8a0c846a1b
commit 1bf55318cc
2 changed files with 13 additions and 15 deletions

View file

@ -350,6 +350,15 @@ class _BuyFormState extends ConsumerState<BuyForm> {
} }
} }
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<void> previewQuote(SimplexQuote quote) async { Future<void> previewQuote(SimplexQuote quote) async {
// if (ref.read(simplexProvider).quote.id == "someID") { // if (ref.read(simplexProvider).quote.id == "someID") {
// // TODO make a better way of detecting a default SimplexQuote // // TODO make a better way of detecting a default SimplexQuote
@ -587,13 +596,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
SvgPicture.asset( getIconForTicker(selectedCrypto?.ticker ?? "BTC")
Assets.svg.iconFor( as Widget,
coin: coinFromTickerCaseInsensitive("BTC"),
),
height: 18,
width: 18,
),
const SizedBox( const SizedBox(
width: 10, width: 10,
), ),
@ -800,13 +804,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
.length)), .length)),
textAlign: TextAlign.center, textAlign: TextAlign.center,
) )
: SvgPicture.asset( : getIconForTicker(selectedCrypto?.ticker ?? "BTC")
Assets.svg.iconFor( as Widget,
coin: coinFromTickerCaseInsensitive("BTC"),
),
height: 18,
width: 18,
),
const SizedBox(width: 10), // maybe make isDesktop-aware? const SizedBox(width: 10), // maybe make isDesktop-aware?
Text( Text(
buyWithFiat buyWithFiat

View file

@ -262,7 +262,6 @@ bool isStackCoin(String? ticker) {
} }
Widget? getIconForTicker(String ticker) { Widget? getIconForTicker(String ticker) {
print(ticker);
String? iconAsset = isStackCoin(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);