fix coin card color

This commit is contained in:
julian 2024-05-14 10:26:03 -06:00
parent 738cb55a40
commit 37cb83a2d4
7 changed files with 252 additions and 238 deletions

View file

@ -13,11 +13,11 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/themes/color_theme.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart'; 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';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/stack_file_system.dart'; import 'package:stackwallet/utilities/stack_file_system.dart';
part 'stack_theme.g.dart'; part 'stack_theme.g.dart';
@ -1857,13 +1857,16 @@ class StackTheme {
final Map<Coin, Color> result = {}; final Map<Coin, Color> result = {};
for (final coin in Coin.values) { for (final coin in Coin.values.map((e) => e.mainNetVersion)) {
if (map[coin.name] is String) { if (map[coin.name] is String) {
result[coin] = Color( result[coin] = Color(
(map[coin.name] as String).toBigIntFromHex.toInt(), (map[coin.name] as String).toBigIntFromHex.toInt(),
); );
} else { } else {
result[coin] = kCoinThemeColorDefaults.forCoin(coin); Logging.instance.log(
"Color not found in theme for $coin",
level: LogLevel.Error,
);
} }
} }

View file

@ -15,7 +15,7 @@ import 'package:stackwallet/widgets/coin_card.dart';
class WalletSummary extends StatelessWidget { class WalletSummary extends StatelessWidget {
const WalletSummary({ const WalletSummary({
Key? key, super.key,
required this.walletId, required this.walletId,
required this.initialSyncStatus, required this.initialSyncStatus,
this.aspectRatio = 2.0, this.aspectRatio = 2.0,
@ -23,7 +23,7 @@ class WalletSummary extends StatelessWidget {
this.minWidth = 200.0, this.minWidth = 200.0,
this.maxHeight = 250.0, this.maxHeight = 250.0,
this.maxWidth = 400.0, this.maxWidth = 400.0,
}) : super(key: key); });
final String walletId; final String walletId;
final WalletSyncStatus initialSyncStatus; final WalletSyncStatus initialSyncStatus;

View file

@ -63,18 +63,21 @@ class WalletSummaryInfo extends ConsumerWidget {
debugPrint("BUILD: $runtimeType"); debugPrint("BUILD: $runtimeType");
final externalCalls = ref.watch( final externalCalls = ref.watch(
prefsChangeNotifierProvider.select((value) => value.externalCalls)); prefsChangeNotifierProvider.select((value) => value.externalCalls),
);
final coin = ref.watch(pWalletCoin(walletId)); final coin = ref.watch(pWalletCoin(walletId));
final balance = ref.watch(pWalletBalance(walletId)); final balance = ref.watch(pWalletBalance(walletId));
final locale = ref.watch( final locale = ref.watch(
localeServiceChangeNotifierProvider.select((value) => value.locale)); localeServiceChangeNotifierProvider.select((value) => value.locale),
);
final baseCurrency = ref final baseCurrency = ref
.watch(prefsChangeNotifierProvider.select((value) => value.currency)); .watch(prefsChangeNotifierProvider.select((value) => value.currency));
final priceTuple = ref.watch(priceAnd24hChangeNotifierProvider final priceTuple = ref.watch(
.select((value) => value.getPrice(coin))); priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin)),
);
final _showAvailable = final _showAvailable =
ref.watch(walletBalanceToggleStateProvider.state).state == ref.watch(walletBalanceToggleStateProvider.state).state ==
@ -206,7 +209,7 @@ class WalletSummaryInfo extends ConsumerWidget {
initialSyncStatus: initialSyncStatus, initialSyncStatus: initialSyncStatus,
), ),
], ],
) ),
], ],
), ),
); );

View file

@ -99,11 +99,11 @@ import 'package:tuple/tuple.dart';
/// [eventBus] should only be set during testing /// [eventBus] should only be set during testing
class WalletView extends ConsumerStatefulWidget { class WalletView extends ConsumerStatefulWidget {
const WalletView({ const WalletView({
Key? key, super.key,
required this.walletId, required this.walletId,
this.eventBus, this.eventBus,
this.clipboardInterface = const ClipboardWrapper(), this.clipboardInterface = const ClipboardWrapper(),
}) : super(key: key); });
static const String routeName = "/wallet"; static const String routeName = "/wallet";
static const double navBarHeight = 65.0; static const double navBarHeight = 65.0;

View file

@ -8,10 +8,12 @@
* *
*/ */
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/isar/stack_theme.dart'; import 'package:stackwallet/models/isar/stack_theme.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_service.dart'; import 'package:stackwallet/themes/theme_service.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
final applicationThemesDirectoryPathProvider = StateProvider((ref) => ""); final applicationThemesDirectoryPathProvider = StateProvider((ref) => "");
@ -38,3 +40,11 @@ final themeAssetsProvider = StateProvider<IThemeAssets>(
), ),
), ),
); );
final pCoinColor = StateProvider.family<Color, Coin>(
(ref, coin) =>
ref.watch(
themeProvider.select((value) => value.coinColors[coin.mainNetVersion]),
) ??
Colors.deepOrangeAccent,
);

View file

@ -29,7 +29,7 @@ final pThemeService = Provider<ThemeService>((ref) {
}); });
class ThemeService { class ThemeService {
static const _currentDefaultThemeVersion = 9; static const _currentDefaultThemeVersion = 10;
ThemeService._(); ThemeService._();
static ThemeService? _instance; static ThemeService? _instance;
static ThemeService get instance => _instance ??= ThemeService._(); static ThemeService get instance => _instance ??= ThemeService._();

View file

@ -14,7 +14,7 @@ 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';
import 'package:stackwallet/themes/coin_card_provider.dart'; import 'package:stackwallet/themes/coin_card_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/theme_providers.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';
import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart';
@ -68,9 +68,7 @@ class CoinCard extends ConsumerWidget {
width: width, width: width,
height: height, height: height,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context) color: ref.watch(pCoinColor(coin)),
.extension<StackColors>()!
.colorForCoin(coin),
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius, Constants.size.circularBorderRadius,
), ),