From 9788fa9d57480e791b19a35b58746a49280551bc Mon Sep 17 00:00:00 2001 From: Serhii Date: Thu, 5 Oct 2023 12:02:05 +0300 Subject: [PATCH] svg address book icons --- cw_core/lib/crypto_currency.dart | 2 +- .../screens/contact/contact_list_page.dart | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cw_core/lib/crypto_currency.dart b/cw_core/lib/crypto_currency.dart index d00686cce..2922ac18f 100644 --- a/cw_core/lib/crypto_currency.dart +++ b/cw_core/lib/crypto_currency.dart @@ -119,7 +119,7 @@ class CryptoCurrency extends EnumerableItem with Serializable implemen static const eos = CryptoCurrency(title: 'EOS', fullName: 'EOS', raw: 7, name: 'eos', iconPath: 'assets/images/crypto_assets/eos_icon.svg'); static const eth = CryptoCurrency(title: 'ETH', fullName: 'Ethereum', raw: 8, name: 'eth', iconPath: 'assets/images/crypto_assets/eth_icon.svg'); static const ltc = CryptoCurrency(title: 'LTC', fullName: 'Litecoin', raw: 9, name: 'ltc', iconPath: 'assets/images/crypto_assets/ltc_icon.svg'); - static const nano = CryptoCurrency(title: 'NANO', raw: 10, name: 'nano', iconPath: 'assets/images/crypto_assets/nano_icon.svg'); + static const nano = CryptoCurrency(title: 'NANO', raw: 10, name: 'nano', iconPath: 'assets/images/crypto_assets/xno_icon.svg'); static const trx = CryptoCurrency(title: 'TRX', fullName: 'TRON', raw: 11, name: 'trx', iconPath: 'assets/images/crypto_assets/trx_icon.svg'); static const usdt = CryptoCurrency(title: 'USDT', tag: 'OMNI', fullName: 'USDT Tether', raw: 12, name: 'usdt', iconPath: 'assets/images/crypto_assets/usdt_icon.svg'); static const usdterc20 = CryptoCurrency(title: 'USDT', tag: 'ETH', fullName: 'USDT Tether', raw: 13, name: 'usdterc20', iconPath: 'assets/images/crypto_assets/usdterc20_icon.svg'); diff --git a/lib/src/screens/contact/contact_list_page.dart b/lib/src/screens/contact/contact_list_page.dart index b551875f9..f95a0a8ca 100644 --- a/lib/src/screens/contact/contact_list_page.dart +++ b/lib/src/screens/contact/contact_list_page.dart @@ -16,6 +16,7 @@ import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart'; import 'package:cake_wallet/src/widgets/collapsible_standart_list.dart'; +import 'package:flutter_svg/flutter_svg.dart'; class ContactListPage extends BasePage { ContactListPage(this.contactListViewModel, this.authService); @@ -112,10 +113,7 @@ class ContactListPage extends BasePage { } Widget generateRaw(BuildContext context, ContactBase contact) { - final image = contact.type.iconPath; - final currencyIcon = image != null - ? Image.asset(image, height: 24, width: 24) - : const SizedBox(height: 24, width: 24); + final currencyIcon = getIcon(contact.type.iconPath); return GestureDetector( onTap: () async { @@ -156,6 +154,25 @@ class ContactListPage extends BasePage { ); } + Widget getIcon(String? image) { + if (image != null && image.contains('svg')) { + return SvgPicture.asset( + image, + height: 24, + width: 24, + fit: BoxFit.contain, + ); + } else if (image != null && image.isNotEmpty) { + return Image.asset( + image, + height: 24, + width: 24, + ); + } else { + return const SizedBox(height: 24, width: 24); + } + } + Future showAlertDialog(BuildContext context) async { return await showPopUp( context: context,