diff --git a/lib/models/isar/stack_theme.dart b/lib/models/isar/stack_theme.dart index d68494d3b..cd05a2279 100644 --- a/lib/models/isar/stack_theme.dart +++ b/lib/models/isar/stack_theme.dart @@ -18,8 +18,6 @@ import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart'; import 'package:stackwallet/utilities/extensions/impl/gradient.dart'; import 'package:stackwallet/utilities/extensions/impl/string.dart'; -part 'stack_theme.g.dart'; - @Collection(inheritance: false) class StackTheme { Id id = Isar.autoIncrement; @@ -2104,8 +2102,6 @@ class ThemeAssetsV2 implements IThemeAssets { late final String? loadingGif; @override late final String? background; - @override - late final String? walletSummaryCardBackground; late final String coinPlaceholder; @@ -2137,6 +2133,16 @@ class ThemeAssetsV2 implements IThemeAssets { Map? _coinSecondaryImages; late final String coinSecondaryImagesString; + @ignore + Map? get coinCardImages => + _coinCardImages ??= parseCoinAssetsString( + coinCardImagesString!, + placeHolder: coinPlaceholder, + ); + @ignore + Map? _coinCardImages; + late final String? coinCardImagesString; + ThemeAssetsV2(); factory ThemeAssetsV2.fromJson({ @@ -2195,15 +2201,15 @@ class ThemeAssetsV2 implements IThemeAssets { "$applicationThemesDirectoryPath/$themeId/assets", Map.from(json["coins"]["secondaries"] as Map), ) + ..coinCardImagesString = createCoinAssetsString( + "$applicationThemesDirectoryPath/$themeId/assets", + Map.from(json["coins"]["cards"] as Map), + ) ..loadingGif = json["loading_gif"] is String ? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}" : null ..background = json["background"] is String ? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}" - : null - ..walletSummaryCardBackground = json["walletSummaryCardBackground"] - is String - ? "$applicationThemesDirectoryPath/$themeId/assets/${json["walletSummaryCardBackground"] as String}" : null; } @@ -2254,11 +2260,11 @@ class ThemeAssetsV2 implements IThemeAssets { 'txExchangeFailed: $txExchangeFailed, ' 'loadingGif: $loadingGif, ' 'background: $background, ' - 'walletSummaryCardBackground: $walletSummaryCardBackground, ' 'coinPlaceholder: $coinPlaceholder, ' 'coinIcons: $coinIcons, ' 'coinImages: $coinImages, ' - 'coinSecondaryImages: $coinSecondaryImages' + 'coinSecondaryImages: $coinSecondaryImages, ' + 'coinCardImages: $coinCardImages' ')'; } } @@ -2285,5 +2291,4 @@ abstract class IThemeAssets { String? get loadingGif; String? get background; - String? get walletSummaryCardBackground; } diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary.dart index 129368344..215c62ae9 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary.dart @@ -8,6 +8,9 @@ * */ +// import 'dart:html'; +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -18,7 +21,10 @@ import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; -class WalletSummary extends StatelessWidget { +import '../../../themes/coin_card_provider.dart'; +import '../../../utilities/enums/coin_enum.dart'; + +class WalletSummary extends ConsumerWidget { const WalletSummary({ Key? key, required this.walletId, @@ -42,7 +48,12 @@ class WalletSummary extends StatelessWidget { final double maxWidth; @override - Widget build(BuildContext context) { + Widget build(BuildContext context, WidgetRef ref) { + final bool hasCardImageBg = + ref.watch(managerProvider.select((value) => value.coin)) != null; + + final Coin coin = ref.watch(managerProvider.select((value) => value.coin)); + return AspectRatio( aspectRatio: aspectRatio, child: ConstrainedBox( @@ -54,68 +65,80 @@ class WalletSummary extends StatelessWidget { ), child: Stack( children: [ - Consumer( - builder: (_, ref, __) { - return Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .colorForCoin(ref.watch( - managerProvider.select((value) => value.coin))), - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - ); - }, - ), - Positioned.fill( - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Spacer( - flex: 5, - ), - Expanded( - flex: 6, - child: SvgPicture.asset( - Assets.svg.ellipse1, - // fit: BoxFit.fitWidth, - // clipBehavior: Clip.none, - ), - ), - const SizedBox( - width: 25, - ), - ], + if (hasCardImageBg) + SvgPicture.file( + File( + ref.watch( + coinCardProvider(coin) as ProviderListenable), + ), + height: 24, + width: 24, + ), + if (!hasCardImageBg) + Consumer( + builder: (_, ref, __) { + return Container( + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .colorForCoin(ref.watch( + managerProvider.select((value) => value.coin))), + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + ); + }, + ), + if (!hasCardImageBg) + Positioned.fill( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Spacer( + flex: 5, + ), + Expanded( + flex: 6, + child: SvgPicture.asset( + Assets.svg.ellipse1, + // fit: BoxFit.fitWidth, + // clipBehavior: Clip.none, + ), + ), + const SizedBox( + width: 25, + ), + ], + ), ), - ), // Positioned.fill( // child: // Column( // mainAxisAlignment: MainAxisAlignment.end, // children: [ - Align( - alignment: Alignment.bottomCenter, - child: Row( - children: [ - const Spacer( - flex: 1, - ), - Expanded( - flex: 3, - child: SvgPicture.asset( - Assets.svg.ellipse2, - // fit: BoxFit.f, - // clipBehavior: Clip.none, + if (!hasCardImageBg) + Align( + alignment: Alignment.bottomCenter, + child: Row( + children: [ + const Spacer( + flex: 1, ), - ), - const SizedBox( - width: 13, - ), - ], + Expanded( + flex: 3, + child: SvgPicture.asset( + Assets.svg.ellipse2, + // fit: BoxFit.f, + // clipBehavior: Clip.none, + ), + ), + const SizedBox( + width: 13, + ), + ], + ), ), - ), // ], // ), // ), diff --git a/lib/themes/coin_card_provider.dart b/lib/themes/coin_card_provider.dart new file mode 100644 index 000000000..ac54b3023 --- /dev/null +++ b/lib/themes/coin_card_provider.dart @@ -0,0 +1,63 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ + +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/isar/stack_theme.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +final coinCardProvider = Provider.family((ref, coin) { + final assets = ref.watch(themeAssetsProvider); + + if (assets is ThemeAssets) { + switch (coin) { + // case Coin.bitcoin: + // return assets.bitcoinImage; + // case Coin.litecoin: + // case Coin.litecoinTestNet: + // return assets.litecoinImage; + // case Coin.bitcoincash: + // return assets.bitcoincashImage; + // case Coin.dogecoin: + // return assets.dogecoinImage; + // case Coin.eCash: + // return assets.bitcoinImage; + // case Coin.epicCash: + // return assets.epicCashImage; + // case Coin.firo: + // return assets.firoImage; + // case Coin.monero: + // return assets.moneroImage; + // case Coin.wownero: + // return assets.wowneroImage; + // case Coin.namecoin: + // return assets.namecoinImage; + // case Coin.particl: + // return assets.particlImage; + // case Coin.bitcoinTestNet: + // return assets.bitcoinImage; + // case Coin.bitcoincashTestnet: + // return assets.bitcoincashImage; + // case Coin.firoTestNet: + // return assets.firoImage; + // case Coin.dogecoinTestNet: + // return assets.dogecoinImage; + // case Coin.ethereum: + // return assets.ethereumImage; + default: + return null; + } + } + else { + if(assets != null) { + return (assets as ThemeAssetsV2).coinCardImages?[coin.mainNetVersion]!; + } + } +});