From e3bd3d3bf34d67f5fea352b441d2f66054192072 Mon Sep 17 00:00:00 2001 From: julian-CStack Date: Sun, 5 Mar 2023 13:01:12 -0600 Subject: [PATCH] coin select item token icon --- .../sub_widgets/coin_select_item.dart | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart index 1a7ca829f..4f2a84a9a 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart @@ -1,8 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:isar/isar.dart'; import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; +import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; +import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -24,6 +29,22 @@ class CoinSelectItem extends ConsumerWidget { final isDesktop = Util.isDesktop; + String? tokenImageUri; + if (entity is EthTokenEntity) { + final currency = ExchangeDataLoadingService.instance.isar.currencies + .where() + .exchangeNameEqualTo(ChangeNowExchange.exchangeName) + .filter() + .tokenContractEqualTo( + (entity as EthTokenEntity).token.address, + caseSensitive: false, + ) + .and() + .imageIsNotEmpty() + .findFirstSync(); + tokenImageUri = currency?.image; + } + return Container( decoration: BoxDecoration( color: selectedEntity == entity @@ -48,11 +69,17 @@ class CoinSelectItem extends ConsumerWidget { ), child: Row( children: [ - SvgPicture.asset( - Assets.svg.iconFor(coin: entity.coin), - width: 26, - height: 26, - ), + tokenImageUri != null + ? SvgPicture.network( + tokenImageUri, + width: 26, + height: 26, + ) + : SvgPicture.asset( + Assets.svg.iconFor(coin: entity.coin), + width: 26, + height: 26, + ), SizedBox( width: isDesktop ? 12 : 10, ),