Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated chan card images #619

Merged
merged 5 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions lib/models/isar/stack_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2341,8 +2341,6 @@ class ThemeAssetsV3 implements IThemeAssets {

// Added some future proof params in case we want to add anything else
// This should provide some buffer in stead of creating assetsV4 etc
@Name("otherStringParam1")
late final String? dummy1;
@Name("otherStringParam2")
late final String? dummy2;
@Name("otherStringParam3")
Expand Down Expand Up @@ -2388,6 +2386,19 @@ class ThemeAssetsV3 implements IThemeAssets {
Map<Coin, String>? _coinCardImages;
late final String? coinCardImagesString;

@ignore
Map<Coin, String>? get coinCardFavoritesImages =>
_coinCardFavoritesImages ??= coinCardFavoritesImagesString == null
? null
: parseCoinAssetsString(
coinCardFavoritesImagesString!,
placeHolder: coinPlaceholder,
);
@ignore
Map<Coin, String>? _coinCardFavoritesImages;
@Name("otherStringParam1")
late final String? coinCardFavoritesImagesString;

ThemeAssetsV3();

factory ThemeAssetsV3.fromJson({
Expand Down Expand Up @@ -2443,13 +2454,18 @@ class ThemeAssetsV3 implements IThemeAssets {
Map<String, dynamic>.from(json["coins"]["cards"] as Map),
)
: null
..coinCardFavoritesImagesString = json["coins"]["favoriteCards"] is Map
? createCoinAssetsString(
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["favoriteCards"] as Map),
)
: null
..loadingGifRelative = json["loading_gif"] is String
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..backgroundRelative = json["background"] is String
? "$themeId/assets/${json["background"] as String}"
: null
..dummy1 = null
..dummy2 = null
..dummy3 = null;
}
Expand Down Expand Up @@ -2528,6 +2544,7 @@ class ThemeAssetsV3 implements IThemeAssets {
'coinImages: $coinImages, '
'coinSecondaryImages: $coinSecondaryImages, '
'coinCardImages: $coinCardImages'
'coinCardFavoritesImages: $coinCardFavoritesImages'
')';
}
}
Expand Down
32 changes: 17 additions & 15 deletions lib/models/isar/stack_theme.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/pages/wallet_view/sub_widgets/wallet_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class WalletSummary extends StatelessWidget {
walletId: walletId,
width: constraints.maxWidth,
height: constraints.maxHeight,
isFavorite: false,
),
Positioned.fill(
child: Padding(
Expand Down
1 change: 1 addition & 0 deletions lib/pages/wallets_view/sub_widgets/favorite_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
walletId: widget.walletId,
width: widget.width,
height: widget.height,
isFavorite: true,
),
child: Padding(
padding: const EdgeInsets.all(12.0),
Expand Down
11 changes: 11 additions & 0 deletions lib/themes/coin_card_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,14 @@ final coinCardProvider = Provider.family<String?, Coin>((ref, coin) {
return null;
}
});

final coinCardFavoritesProvider = Provider.family<String?, Coin>((ref, coin) {
final assets = ref.watch(themeAssetsProvider);

if (assets is ThemeAssetsV3) {
return assets.coinCardFavoritesImages?[coin.mainNetVersion] ??
assets.coinCardImages?[coin.mainNetVersion];
} else {
return null;
}
});
8 changes: 6 additions & 2 deletions lib/widgets/coin_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ class CoinCard extends ConsumerWidget {
required this.walletId,
required this.width,
required this.height,
required this.isFavorite,
});

final String walletId;
final double width;
final double height;
final bool isFavorite;

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand All @@ -38,7 +40,7 @@ class CoinCard extends ConsumerWidget {
.select((value) => value.getManager(walletId).coin),
);

final bool hasCardImageBg = ref.watch(coinCardProvider(coin)) != null;
final bool hasCardImageBg = (isFavorite) ? ref.watch(coinCardFavoritesProvider(coin)) != null : ref.watch(coinCardProvider(coin)) != null;

return Stack(
children: [
Expand All @@ -54,7 +56,9 @@ class CoinCard extends ConsumerWidget {
fit: BoxFit.cover,
image: FileImage(
File(
ref.watch(coinCardProvider(coin))!,
(isFavorite)
? ref.watch(coinCardFavoritesProvider(coin))!
: ref.watch(coinCardProvider(coin))!,
),
),
),
Expand Down
Loading