mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
token icon based on changenow currency image url
This commit is contained in:
parent
b7eaf9a8c2
commit
af460b54a6
1 changed files with 51 additions and 0 deletions
51
lib/widgets/icon_widgets/eth_token_icon.dart
Normal file
51
lib/widgets/icon_widgets/eth_token_icon.dart
Normal file
|
@ -0,0 +1,51 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/exchange_cache/currency.dart';
|
||||
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
||||
class EthTokenIcon extends StatefulWidget {
|
||||
const EthTokenIcon({
|
||||
Key? key,
|
||||
required this.contractAddress,
|
||||
}) : super(key: key);
|
||||
|
||||
final String contractAddress;
|
||||
|
||||
@override
|
||||
State<EthTokenIcon> createState() => _EthTokenIconState();
|
||||
}
|
||||
|
||||
class _EthTokenIconState extends State<EthTokenIcon> {
|
||||
late final String? imageUrl;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
imageUrl = ExchangeDataLoadingService.instance.isar.currencies
|
||||
.where()
|
||||
.filter()
|
||||
.tokenContractEqualTo(widget.contractAddress, caseSensitive: false)
|
||||
.findFirstSync()
|
||||
?.image;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (imageUrl == null || imageUrl!.isEmpty) {
|
||||
return SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: Coin.ethereum),
|
||||
width: 22,
|
||||
height: 22,
|
||||
);
|
||||
} else {
|
||||
return SvgPicture.network(
|
||||
imageUrl!,
|
||||
width: 22,
|
||||
height: 22,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue