From cfc8f2ab9df36726e9c9747974078e22288a9c37 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 17 Oct 2022 15:56:03 -0600 Subject: [PATCH] hide price values on favorite card when incognito mode enabled --- .../sub_widgets/favorite_card.dart | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/lib/pages/wallets_view/sub_widgets/favorite_card.dart b/lib/pages/wallets_view/sub_widgets/favorite_card.dart index bc95d51b5..924e904f3 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_card.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_card.dart @@ -49,6 +49,8 @@ class _FavoriteCardState extends ConsumerState { @override Widget build(BuildContext context) { final coin = ref.watch(managerProvider.select((value) => value.coin)); + final externalCalls = ref.watch( + prefsChangeNotifierProvider.select((value) => value.externalCalls)); return GestureDetector( onTap: () { @@ -70,7 +72,9 @@ class _FavoriteCardState extends ConsumerState { width: widget.width, height: widget.height, decoration: BoxDecoration( - color: Theme.of(context).extension()!.colorForCoin(coin), + color: Theme.of(context) + .extension()! + .colorForCoin(coin), borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), @@ -138,7 +142,9 @@ class _FavoriteCardState extends ConsumerState { ref.watch(managerProvider .select((value) => value.walletName)), style: STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context).extension()!.textFavoriteCard, + color: Theme.of(context) + .extension()! + .textFavoriteCard, ), overflow: TextOverflow.fade, ), @@ -159,14 +165,16 @@ class _FavoriteCardState extends ConsumerState { snapshot.hasData) { if (snapshot.data != null) { _cachedBalance = snapshot.data!; - _cachedFiatValue = _cachedBalance * - ref - .watch( - priceAnd24hChangeNotifierProvider.select( - (value) => value.getPrice(coin), - ), - ) - .item1; + if (externalCalls) { + _cachedFiatValue = _cachedBalance * + ref + .watch( + priceAnd24hChangeNotifierProvider.select( + (value) => value.getPrice(coin), + ), + ) + .item1; + } } } return Column( @@ -185,30 +193,36 @@ class _FavoriteCardState extends ConsumerState { )} ${coin.ticker}", style: STextStyles.titleBold12(context).copyWith( fontSize: 16, - color: Theme.of(context).extension()!.textFavoriteCard, + color: Theme.of(context) + .extension()! + .textFavoriteCard, ), ), ), - const SizedBox( - height: 4, - ), - Text( - "${Format.localizedStringAsFixed( - decimalPlaces: 2, - value: _cachedFiatValue, - locale: ref.watch( - localeServiceChangeNotifierProvider - .select((value) => value.locale), - ), - )} ${ref.watch( - prefsChangeNotifierProvider - .select((value) => value.currency), - )}", - style: STextStyles.itemSubtitle12(context).copyWith( - fontSize: 10, - color: Theme.of(context).extension()!.textFavoriteCard, + if (externalCalls) + const SizedBox( + height: 4, + ), + if (externalCalls) + Text( + "${Format.localizedStringAsFixed( + decimalPlaces: 2, + value: _cachedFiatValue, + locale: ref.watch( + localeServiceChangeNotifierProvider + .select((value) => value.locale), + ), + )} ${ref.watch( + prefsChangeNotifierProvider + .select((value) => value.currency), + )}", + style: STextStyles.itemSubtitle12(context).copyWith( + fontSize: 10, + color: Theme.of(context) + .extension()! + .textFavoriteCard, + ), ), - ), ], ); },