use EthTokenIcon class

This commit is contained in:
julian 2023-04-03 16:38:48 -06:00
parent 6e5cffa4d4
commit a9306e5267
3 changed files with 14 additions and 18 deletions

View file

@ -15,6 +15,7 @@ import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
import 'package:stackwallet/widgets/icon_widgets/eth_token_icon.dart';
import 'package:tuple/tuple.dart';
final tokenServiceStateProvider = StateProvider<EthTokenWallet?>((ref) => null);
@ -76,13 +77,13 @@ class _TokenViewState extends ConsumerState<TokenView> {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.svg.iconForToken(
contractAddress: ref.watch(
tokenServiceProvider.select(
(value) => value!.tokenContract.address))),
width: 24,
height: 24,
EthTokenIcon(
contractAddress: ref.watch(
tokenServiceProvider.select(
(value) => value!.tokenContract.address,
),
),
size: 24,
),
const SizedBox(
width: 10,

View file

@ -344,13 +344,6 @@ class _SVG {
}
}
String iconForToken({required String contractAddress}) {
switch (contractAddress) {
default:
return ethereum;
}
}
// big icons
String bitcoinImage(BuildContext context) => "${_path(context)}/bitcoin.svg";
String bitcoincashImage(BuildContext context) =>

View file

@ -10,9 +10,11 @@ class EthTokenIcon extends StatefulWidget {
const EthTokenIcon({
Key? key,
required this.contractAddress,
this.size = 22,
}) : super(key: key);
final String contractAddress;
final double size;
@override
State<EthTokenIcon> createState() => _EthTokenIconState();
@ -37,14 +39,14 @@ class _EthTokenIconState extends State<EthTokenIcon> {
if (imageUrl == null || imageUrl!.isEmpty) {
return SvgPicture.asset(
Assets.svg.iconFor(coin: Coin.ethereum),
width: 22,
height: 22,
width: widget.size,
height: widget.size,
);
} else {
return SvgPicture.network(
imageUrl!,
width: 22,
height: 22,
width: widget.size,
height: widget.size,
);
}
}