mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
WIP: chan cards
This commit is contained in:
parent
a047eac770
commit
8d823dc2e3
3 changed files with 158 additions and 67 deletions
|
@ -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/gradient.dart';
|
||||||
import 'package:stackwallet/utilities/extensions/impl/string.dart';
|
import 'package:stackwallet/utilities/extensions/impl/string.dart';
|
||||||
|
|
||||||
part 'stack_theme.g.dart';
|
|
||||||
|
|
||||||
@Collection(inheritance: false)
|
@Collection(inheritance: false)
|
||||||
class StackTheme {
|
class StackTheme {
|
||||||
Id id = Isar.autoIncrement;
|
Id id = Isar.autoIncrement;
|
||||||
|
@ -2104,8 +2102,6 @@ class ThemeAssetsV2 implements IThemeAssets {
|
||||||
late final String? loadingGif;
|
late final String? loadingGif;
|
||||||
@override
|
@override
|
||||||
late final String? background;
|
late final String? background;
|
||||||
@override
|
|
||||||
late final String? walletSummaryCardBackground;
|
|
||||||
|
|
||||||
late final String coinPlaceholder;
|
late final String coinPlaceholder;
|
||||||
|
|
||||||
|
@ -2137,6 +2133,16 @@ class ThemeAssetsV2 implements IThemeAssets {
|
||||||
Map<Coin, String>? _coinSecondaryImages;
|
Map<Coin, String>? _coinSecondaryImages;
|
||||||
late final String coinSecondaryImagesString;
|
late final String coinSecondaryImagesString;
|
||||||
|
|
||||||
|
@ignore
|
||||||
|
Map<Coin, String>? get coinCardImages =>
|
||||||
|
_coinCardImages ??= parseCoinAssetsString(
|
||||||
|
coinCardImagesString!,
|
||||||
|
placeHolder: coinPlaceholder,
|
||||||
|
);
|
||||||
|
@ignore
|
||||||
|
Map<Coin, String>? _coinCardImages;
|
||||||
|
late final String? coinCardImagesString;
|
||||||
|
|
||||||
ThemeAssetsV2();
|
ThemeAssetsV2();
|
||||||
|
|
||||||
factory ThemeAssetsV2.fromJson({
|
factory ThemeAssetsV2.fromJson({
|
||||||
|
@ -2195,15 +2201,15 @@ class ThemeAssetsV2 implements IThemeAssets {
|
||||||
"$applicationThemesDirectoryPath/$themeId/assets",
|
"$applicationThemesDirectoryPath/$themeId/assets",
|
||||||
Map<String, dynamic>.from(json["coins"]["secondaries"] as Map),
|
Map<String, dynamic>.from(json["coins"]["secondaries"] as Map),
|
||||||
)
|
)
|
||||||
|
..coinCardImagesString = createCoinAssetsString(
|
||||||
|
"$applicationThemesDirectoryPath/$themeId/assets",
|
||||||
|
Map<String, dynamic>.from(json["coins"]["cards"] as Map),
|
||||||
|
)
|
||||||
..loadingGif = json["loading_gif"] is String
|
..loadingGif = json["loading_gif"] is String
|
||||||
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
|
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
|
||||||
: null
|
: null
|
||||||
..background = json["background"] is String
|
..background = json["background"] is String
|
||||||
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
|
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
|
||||||
: null
|
|
||||||
..walletSummaryCardBackground = json["walletSummaryCardBackground"]
|
|
||||||
is String
|
|
||||||
? "$applicationThemesDirectoryPath/$themeId/assets/${json["walletSummaryCardBackground"] as String}"
|
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2254,11 +2260,11 @@ class ThemeAssetsV2 implements IThemeAssets {
|
||||||
'txExchangeFailed: $txExchangeFailed, '
|
'txExchangeFailed: $txExchangeFailed, '
|
||||||
'loadingGif: $loadingGif, '
|
'loadingGif: $loadingGif, '
|
||||||
'background: $background, '
|
'background: $background, '
|
||||||
'walletSummaryCardBackground: $walletSummaryCardBackground, '
|
|
||||||
'coinPlaceholder: $coinPlaceholder, '
|
'coinPlaceholder: $coinPlaceholder, '
|
||||||
'coinIcons: $coinIcons, '
|
'coinIcons: $coinIcons, '
|
||||||
'coinImages: $coinImages, '
|
'coinImages: $coinImages, '
|
||||||
'coinSecondaryImages: $coinSecondaryImages'
|
'coinSecondaryImages: $coinSecondaryImages, '
|
||||||
|
'coinCardImages: $coinCardImages'
|
||||||
')';
|
')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2285,5 +2291,4 @@ abstract class IThemeAssets {
|
||||||
|
|
||||||
String? get loadingGif;
|
String? get loadingGif;
|
||||||
String? get background;
|
String? get background;
|
||||||
String? get walletSummaryCardBackground;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// import 'dart:html';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.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/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.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({
|
const WalletSummary({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
|
@ -42,7 +48,12 @@ class WalletSummary extends StatelessWidget {
|
||||||
final double maxWidth;
|
final double maxWidth;
|
||||||
|
|
||||||
@override
|
@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(
|
return AspectRatio(
|
||||||
aspectRatio: aspectRatio,
|
aspectRatio: aspectRatio,
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
|
@ -54,68 +65,80 @@ class WalletSummary extends StatelessWidget {
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Consumer(
|
if (hasCardImageBg)
|
||||||
builder: (_, ref, __) {
|
SvgPicture.file(
|
||||||
return Container(
|
File(
|
||||||
decoration: BoxDecoration(
|
ref.watch(
|
||||||
color: Theme.of(context)
|
coinCardProvider(coin) as ProviderListenable<String>),
|
||||||
.extension<StackColors>()!
|
),
|
||||||
.colorForCoin(ref.watch(
|
height: 24,
|
||||||
managerProvider.select((value) => value.coin))),
|
width: 24,
|
||||||
borderRadius: BorderRadius.circular(
|
),
|
||||||
Constants.size.circularBorderRadius,
|
if (!hasCardImageBg)
|
||||||
),
|
Consumer(
|
||||||
),
|
builder: (_, ref, __) {
|
||||||
);
|
return Container(
|
||||||
},
|
decoration: BoxDecoration(
|
||||||
),
|
color: Theme.of(context)
|
||||||
Positioned.fill(
|
.extension<StackColors>()!
|
||||||
child: Row(
|
.colorForCoin(ref.watch(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
managerProvider.select((value) => value.coin))),
|
||||||
children: [
|
borderRadius: BorderRadius.circular(
|
||||||
const Spacer(
|
Constants.size.circularBorderRadius,
|
||||||
flex: 5,
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
);
|
||||||
flex: 6,
|
},
|
||||||
child: SvgPicture.asset(
|
),
|
||||||
Assets.svg.ellipse1,
|
if (!hasCardImageBg)
|
||||||
// fit: BoxFit.fitWidth,
|
Positioned.fill(
|
||||||
// clipBehavior: Clip.none,
|
child: Row(
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
),
|
children: [
|
||||||
const SizedBox(
|
const Spacer(
|
||||||
width: 25,
|
flex: 5,
|
||||||
),
|
),
|
||||||
],
|
Expanded(
|
||||||
|
flex: 6,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
Assets.svg.ellipse1,
|
||||||
|
// fit: BoxFit.fitWidth,
|
||||||
|
// clipBehavior: Clip.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 25,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
// Positioned.fill(
|
// Positioned.fill(
|
||||||
// child:
|
// child:
|
||||||
// Column(
|
// Column(
|
||||||
// mainAxisAlignment: MainAxisAlignment.end,
|
// mainAxisAlignment: MainAxisAlignment.end,
|
||||||
// children: [
|
// children: [
|
||||||
Align(
|
if (!hasCardImageBg)
|
||||||
alignment: Alignment.bottomCenter,
|
Align(
|
||||||
child: Row(
|
alignment: Alignment.bottomCenter,
|
||||||
children: [
|
child: Row(
|
||||||
const Spacer(
|
children: [
|
||||||
flex: 1,
|
const Spacer(
|
||||||
),
|
flex: 1,
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.svg.ellipse2,
|
|
||||||
// fit: BoxFit.f,
|
|
||||||
// clipBehavior: Clip.none,
|
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
const SizedBox(
|
flex: 3,
|
||||||
width: 13,
|
child: SvgPicture.asset(
|
||||||
),
|
Assets.svg.ellipse2,
|
||||||
],
|
// fit: BoxFit.f,
|
||||||
|
// clipBehavior: Clip.none,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 13,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
|
63
lib/themes/coin_card_provider.dart
Normal file
63
lib/themes/coin_card_provider.dart
Normal file
|
@ -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<String?, Coin>((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]!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue