mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 19:05:51 +00:00
WIP: rename coin image provider + add coin icon provider
This commit is contained in:
parent
93441bdf4d
commit
301f4b5cf5
10 changed files with 58 additions and 18 deletions
|
@ -8,6 +8,7 @@ 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/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
@ -76,7 +77,7 @@ class CoinSelectItem extends ConsumerWidget {
|
|||
height: 26,
|
||||
)
|
||||
: SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: entity.coin),
|
||||
ref.watch(coinIconProvider(entity.coin)),
|
||||
width: 26,
|
||||
height: 26,
|
||||
),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/themes/theme_coin_provider.dart';
|
||||
import 'package:stackwallet/themes/coin_image_provider.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/theme/color_theme.dart';
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||
import 'package:stackwallet/themes/theme_coin_provider.dart';
|
||||
import 'package:stackwallet/themes/coin_image_provider.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:stackwallet/pages/address_book_views/subviews/coin_select_sheet.
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
// import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart';
|
||||
import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/utilities/address_utils.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/barcode_scanner_interface.dart';
|
||||
|
@ -141,7 +142,7 @@ class _NewContactAddressEntryFormState
|
|||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: coin),
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
height: 24,
|
||||
width: 24,
|
||||
),
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/stack_back
|
|||
import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart';
|
||||
import 'package:stackwallet/providers/stack_restore/stack_restoring_ui_state_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/enums/stack_restoring_status.dart';
|
||||
|
@ -81,9 +82,7 @@ class _RestoringWalletCardState extends ConsumerState<RestoringWalletCard> {
|
|||
.colorForCoin(coin),
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.iconFor(
|
||||
coin: coin,
|
||||
),
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
height: 20,
|
||||
width: 20,
|
||||
),
|
||||
|
|
|
@ -3,8 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/wallets_view/wallets_overview.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
|
@ -58,7 +58,7 @@ class _WalletTableState extends ConsumerState<WalletSummaryTable> {
|
|||
}
|
||||
}
|
||||
|
||||
class DesktopWalletSummaryRow extends StatefulWidget {
|
||||
class DesktopWalletSummaryRow extends ConsumerStatefulWidget {
|
||||
const DesktopWalletSummaryRow({
|
||||
Key? key,
|
||||
required this.coin,
|
||||
|
@ -69,11 +69,12 @@ class DesktopWalletSummaryRow extends StatefulWidget {
|
|||
final int walletCount;
|
||||
|
||||
@override
|
||||
State<DesktopWalletSummaryRow> createState() =>
|
||||
ConsumerState<DesktopWalletSummaryRow> createState() =>
|
||||
_DesktopWalletSummaryRowState();
|
||||
}
|
||||
|
||||
class _DesktopWalletSummaryRowState extends State<DesktopWalletSummaryRow> {
|
||||
class _DesktopWalletSummaryRowState
|
||||
extends ConsumerState<DesktopWalletSummaryRow> {
|
||||
bool _hovering = false;
|
||||
|
||||
void _onPressed() {
|
||||
|
@ -141,7 +142,7 @@ class _DesktopWalletSummaryRowState extends State<DesktopWalletSummaryRow> {
|
|||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: widget.coin),
|
||||
ref.watch(coinIconProvider(widget.coin)),
|
||||
width: 28,
|
||||
height: 28,
|
||||
),
|
||||
|
|
|
@ -19,6 +19,7 @@ import 'package:stackwallet/providers/providers.dart';
|
|||
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
|
||||
|
@ -184,7 +185,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
width: 15,
|
||||
),
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: coin),
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
|
@ -240,7 +241,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
child: Row(
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: coin),
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
width: 40,
|
||||
height: 40,
|
||||
),
|
||||
|
|
36
lib/themes/coin_icon_provider.dart
Normal file
36
lib/themes/coin_icon_provider.dart
Normal file
|
@ -0,0 +1,36 @@
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/themes/theme_providers.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
||||
final coinIconProvider = Provider.family<String, Coin>((ref, coin) {
|
||||
final assets = ref.watch(themeProvider).assets;
|
||||
switch (coin) {
|
||||
case Coin.bitcoin:
|
||||
case Coin.bitcoinTestNet:
|
||||
return assets.bitcoin;
|
||||
case Coin.litecoin:
|
||||
case Coin.litecoinTestNet:
|
||||
return assets.litecoin;
|
||||
case Coin.bitcoincash:
|
||||
case Coin.bitcoincashTestnet:
|
||||
return assets.bitcoincash;
|
||||
case Coin.dogecoin:
|
||||
case Coin.dogecoinTestNet:
|
||||
return assets.dogecoin;
|
||||
case Coin.epicCash:
|
||||
return assets.epicCash;
|
||||
case Coin.firo:
|
||||
case Coin.firoTestNet:
|
||||
return assets.firo;
|
||||
case Coin.monero:
|
||||
return assets.monero;
|
||||
case Coin.wownero:
|
||||
return assets.wownero;
|
||||
case Coin.namecoin:
|
||||
return assets.namecoin;
|
||||
case Coin.particl:
|
||||
return assets.particl;
|
||||
case Coin.ethereum:
|
||||
return assets.ethereum;
|
||||
}
|
||||
});
|
|
@ -1,15 +1,16 @@
|
|||
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/isar/exchange_cache/currency.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/themes/coin_icon_provider.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
|
||||
class WalletInfoCoinIcon extends StatelessWidget {
|
||||
class WalletInfoCoinIcon extends ConsumerWidget {
|
||||
const WalletInfoCoinIcon({
|
||||
Key? key,
|
||||
required this.coin,
|
||||
|
@ -22,7 +23,7 @@ class WalletInfoCoinIcon extends StatelessWidget {
|
|||
final double size;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
Currency? currency;
|
||||
if (contractAddress != null) {
|
||||
currency = ExchangeDataLoadingService.instance.isar.currencies
|
||||
|
@ -59,7 +60,7 @@ class WalletInfoCoinIcon extends StatelessWidget {
|
|||
height: 20,
|
||||
)
|
||||
: SvgPicture.asset(
|
||||
Assets.svg.iconFor(coin: coin),
|
||||
ref.watch(coinIconProvider(coin)),
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue