coin select item token icon

This commit is contained in:
julian-CStack 2023-03-05 13:01:12 -06:00
parent 55bac49481
commit e3bd3d3bf3

View file

@ -1,8 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.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/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/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/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
@ -24,6 +29,22 @@ class CoinSelectItem extends ConsumerWidget {
final isDesktop = Util.isDesktop; 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( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: selectedEntity == entity color: selectedEntity == entity
@ -48,11 +69,17 @@ class CoinSelectItem extends ConsumerWidget {
), ),
child: Row( child: Row(
children: [ children: [
SvgPicture.asset( tokenImageUri != null
Assets.svg.iconFor(coin: entity.coin), ? SvgPicture.network(
width: 26, tokenImageUri,
height: 26, width: 26,
), height: 26,
)
: SvgPicture.asset(
Assets.svg.iconFor(coin: entity.coin),
width: 26,
height: 26,
),
SizedBox( SizedBox(
width: isDesktop ? 12 : 10, width: isDesktop ? 12 : 10,
), ),