Skip to content

Commit 0672cf8

Browse files
committed
feat: mask balances on every view that prints one
Wraps the wallet and token summaries, favourite cards, wallet list rows, the balance toggle sheet, the token list and manage favourites, so the preference holds on every screen reachable from a masked one.
1 parent 3af9516 commit 0672cf8

12 files changed

Lines changed: 557 additions & 332 deletions

File tree

‎lib/pages/token_view/sub_widgets/my_token_select_item.dart‎

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import '../../../wallets/wallet/impl/sub_wallets/eth_token_wallet.dart';
3232
import '../../../wallets/wallet/wallet.dart';
3333
import '../../../widgets/desktop/primary_button.dart';
3434
import '../../../widgets/dialogs/basic_dialog.dart';
35+
import '../../../widgets/hideable_balance.dart';
3536
import '../../../widgets/icon_widgets/eth_token_icon.dart';
3637
import '../../../widgets/rounded_white_container.dart';
3738
import '../token_view.dart';
@@ -189,33 +190,48 @@ class _MyTokenSelectItemState extends ConsumerState<MyTokenSelectItem> {
189190
: STextStyles.titleBold12(context),
190191
),
191192
const Spacer(),
192-
Text(
193-
ref
194-
.watch(
195-
pAmountFormatter(
196-
Ethereum(CryptoCurrencyNetwork.main),
197-
),
198-
)
199-
.format(
200-
ref
201-
.watch(
202-
pTokenBalance((
203-
walletId: widget.walletId,
204-
contractAddress: widget.token.address,
205-
)),
206-
)
207-
.total,
208-
tokenContract: widget.token,
209-
),
210-
style: isDesktop
211-
? STextStyles.desktopTextExtraSmall(
193+
HideableBalance(
194+
key: ValueKey(
195+
"hideBalance_${widget.walletId}_"
196+
"${widget.token.address}",
197+
),
198+
iconColor: isDesktop
199+
? Theme.of(
212200
context,
213-
).copyWith(
214-
color: Theme.of(
215-
context,
216-
).extension<StackColors>()!.textDark,
201+
).extension<StackColors>()!.textDark
202+
: Theme.of(
203+
context,
204+
).extension<StackColors>()!.infoItemLabel,
205+
iconSize: 16,
206+
child: Text(
207+
ref
208+
.watch(
209+
pAmountFormatter(
210+
Ethereum(CryptoCurrencyNetwork.main),
211+
),
217212
)
218-
: STextStyles.itemSubtitle(context),
213+
.format(
214+
ref
215+
.watch(
216+
pTokenBalance((
217+
walletId: widget.walletId,
218+
contractAddress:
219+
widget.token.address,
220+
)),
221+
)
222+
.total,
223+
tokenContract: widget.token,
224+
),
225+
style: isDesktop
226+
? STextStyles.desktopTextExtraSmall(
227+
context,
228+
).copyWith(
229+
color: Theme.of(
230+
context,
231+
).extension<StackColors>()!.textDark,
232+
)
233+
: STextStyles.itemSubtitle(context),
234+
),
219235
),
220236
],
221237
),

‎lib/pages/token_view/sub_widgets/token_summary.dart‎

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import '../../../wallets/isar/providers/eth/token_balance_provider.dart';
3636
import '../../../wallets/isar/providers/wallet_info_provider.dart';
3737
import '../../../widgets/coin_ticker_tag.dart';
3838
import '../../../widgets/conditional_parent.dart';
39+
import '../../../widgets/hideable_balance.dart';
3940
import '../../../widgets/rounded_container.dart';
4041
import '../../buy_view/buy_in_wallet_view.dart';
4142
import '../../exchange_view/wallet_initiated_exchange_view.dart';
@@ -104,18 +105,24 @@ class TokenSummary extends ConsumerWidget {
104105
Row(
105106
mainAxisAlignment: MainAxisAlignment.center,
106107
children: [
107-
Text(
108-
ref
109-
.watch(
110-
pAmountFormatter(
111-
Ethereum(CryptoCurrencyNetwork.main),
112-
),
113-
)
114-
.format(balance.total, tokenContract: token),
115-
style: STextStyles.pageTitleH1(context).copyWith(
116-
color: Theme.of(
117-
context,
118-
).extension<StackColors>()!.tokenSummaryTextPrimary,
108+
HideableBalance(
109+
iconColor: Theme.of(
110+
context,
111+
).extension<StackColors>()!.tokenSummaryTextPrimary,
112+
iconSize: 24,
113+
child: Text(
114+
ref
115+
.watch(
116+
pAmountFormatter(
117+
Ethereum(CryptoCurrencyNetwork.main),
118+
),
119+
)
120+
.format(balance.total, tokenContract: token),
121+
style: STextStyles.pageTitleH1(context).copyWith(
122+
color: Theme.of(
123+
context,
124+
).extension<StackColors>()!.tokenSummaryTextPrimary,
125+
),
119126
),
120127
),
121128
const SizedBox(width: 10),
@@ -128,12 +135,18 @@ class TokenSummary extends ConsumerWidget {
128135
),
129136
if (price != null) const SizedBox(height: 6),
130137
if (price != null)
131-
Text(
132-
"${(balance.total.decimal * price).toAmount(fractionDigits: 2).fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
133-
style: STextStyles.subtitle500(context).copyWith(
134-
color: Theme.of(
135-
context,
136-
).extension<StackColors>()!.tokenSummaryTextPrimary,
138+
HideableBalance(
139+
iconColor: Theme.of(
140+
context,
141+
).extension<StackColors>()!.tokenSummaryTextPrimary,
142+
iconSize: 16,
143+
child: Text(
144+
"${(balance.total.decimal * price).toAmount(fractionDigits: 2).fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
145+
style: STextStyles.subtitle500(context).copyWith(
146+
color: Theme.of(
147+
context,
148+
).extension<StackColors>()!.tokenSummaryTextPrimary,
149+
),
137150
),
138151
),
139152
const SizedBox(height: 20),

‎lib/pages/token_view/sub_widgets/token_summary_sol.dart‎

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import '../../../utilities/amount/amount.dart';
2323
import '../../../utilities/assets.dart';
2424
import '../../../utilities/constants.dart';
2525
import '../../../utilities/text_styles.dart';
26-
import '../../../wallets/crypto_currency/crypto_currency.dart';
2726
import '../../../wallets/isar/providers/solana/current_sol_token_wallet_provider.dart';
2827
import '../../../wallets/isar/providers/solana/sol_token_balance_provider.dart';
2928
import '../../../wallets/isar/providers/wallet_info_provider.dart';
3029
import '../../../widgets/coin_ticker_tag.dart';
3130
import '../../../widgets/conditional_parent.dart';
31+
import '../../../widgets/hideable_balance.dart';
3232
import '../../../widgets/rounded_container.dart';
3333
import '../../receive_view/sol_token_receive_view.dart';
3434
import '../../send_view/sol_token_send_view.dart';
@@ -63,8 +63,9 @@ class SolanaTokenSummary extends ConsumerWidget {
6363
child: Text(
6464
"Loading token data...",
6565
style: STextStyles.subtitle500(context).copyWith(
66-
color:
67-
Theme.of(context).extension<StackColors>()!.tokenSummaryTextPrimary,
66+
color: Theme.of(
67+
context,
68+
).extension<StackColors>()!.tokenSummaryTextPrimary,
6869
),
6970
),
7071
),
@@ -73,12 +74,7 @@ class SolanaTokenSummary extends ConsumerWidget {
7374

7475
// Watch the balance from the database provider.
7576
final balance = ref.watch(
76-
pSolanaTokenBalance(
77-
(
78-
walletId: walletId,
79-
tokenMint: tokenMint,
80-
),
81-
),
77+
pSolanaTokenBalance((walletId: walletId, tokenMint: tokenMint)),
8278
);
8379

8480
Decimal? price;
@@ -124,28 +120,40 @@ class SolanaTokenSummary extends ConsumerWidget {
124120
Row(
125121
mainAxisAlignment: MainAxisAlignment.center,
126122
children: [
127-
Text(
128-
balance.total.decimal.toStringAsFixed(tokenWallet.tokenDecimals),
129-
style: STextStyles.pageTitleH1(context).copyWith(
130-
color: Theme.of(
131-
context,
132-
).extension<StackColors>()!.tokenSummaryTextPrimary,
123+
HideableBalance(
124+
iconColor: Theme.of(
125+
context,
126+
).extension<StackColors>()!.tokenSummaryTextPrimary,
127+
iconSize: 24,
128+
child: Text(
129+
balance.total.decimal.toStringAsFixed(
130+
tokenWallet.tokenDecimals,
131+
),
132+
style: STextStyles.pageTitleH1(context).copyWith(
133+
color: Theme.of(
134+
context,
135+
).extension<StackColors>()!.tokenSummaryTextPrimary,
136+
),
133137
),
134138
),
135139
const SizedBox(width: 10),
136-
CoinTickerTag(
137-
ticker: tokenWallet.tokenSymbol,
138-
),
140+
CoinTickerTag(ticker: tokenWallet.tokenSymbol),
139141
],
140142
),
141143
if (price != null) const SizedBox(height: 6),
142144
if (price != null)
143-
Text(
144-
"${(balance.total.decimal * price).toAmount(fractionDigits: 2).fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
145-
style: STextStyles.subtitle500(context).copyWith(
146-
color: Theme.of(
147-
context,
148-
).extension<StackColors>()!.tokenSummaryTextPrimary,
145+
HideableBalance(
146+
iconColor: Theme.of(
147+
context,
148+
).extension<StackColors>()!.tokenSummaryTextPrimary,
149+
iconSize: 16,
150+
child: Text(
151+
"${(balance.total.decimal * price).toAmount(fractionDigits: 2).fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
152+
style: STextStyles.subtitle500(context).copyWith(
153+
color: Theme.of(
154+
context,
155+
).extension<StackColors>()!.tokenSummaryTextPrimary,
156+
),
149157
),
150158
),
151159
const SizedBox(height: 20),
@@ -163,8 +171,9 @@ class SolanaTokenSummary extends ConsumerWidget {
163171
walletId: walletId,
164172
initialSyncStatus: initialSyncStatus,
165173
tokenContractAddress: tokenMint,
166-
overrideIconColor:
167-
Theme.of(context).extension<StackColors>()!.topNavIconPrimary,
174+
overrideIconColor: Theme.of(
175+
context,
176+
).extension<StackColors>()!.topNavIconPrimary,
168177
),
169178
),
170179
],
@@ -250,8 +259,9 @@ class TokenOptionsButton extends StatelessWidget {
250259
crossAxisAlignment: CrossAxisAlignment.center,
251260
children: [
252261
RawMaterialButton(
253-
fillColor:
254-
Theme.of(context).extension<StackColors>()!.tokenSummaryButtonBG,
262+
fillColor: Theme.of(
263+
context,
264+
).extension<StackColors>()!.tokenSummaryButtonBG,
255265
elevation: 0,
256266
focusElevation: 0,
257267
hoverElevation: 0,
@@ -267,47 +277,41 @@ class TokenOptionsButton extends StatelessWidget {
267277
padding: const EdgeInsets.all(10),
268278
child: ConditionalParent(
269279
condition: iconSize < 24,
270-
builder:
271-
(child) => RoundedContainer(
272-
padding: const EdgeInsets.all(6),
273-
color: Theme.of(context)
274-
.extension<StackColors>()!
275-
.tokenSummaryIcon
276-
.withOpacity(0.4),
277-
radiusMultiplier: 10,
278-
child: Center(child: child),
279-
),
280-
child:
281-
iconAssetPathSVG.startsWith("assets/")
282-
? SvgPicture.asset(
283-
iconAssetPathSVG,
284-
color:
285-
Theme.of(
286-
context,
287-
).extension<StackColors>()!.tokenSummaryIcon,
288-
width: iconSize,
289-
height: iconSize,
290-
)
291-
: SvgPicture.file(
292-
File(iconAssetPathSVG),
293-
color:
294-
Theme.of(
295-
context,
296-
).extension<StackColors>()!.tokenSummaryIcon,
297-
width: iconSize,
298-
height: iconSize,
299-
),
280+
builder: (child) => RoundedContainer(
281+
padding: const EdgeInsets.all(6),
282+
color: Theme.of(
283+
context,
284+
).extension<StackColors>()!.tokenSummaryIcon.withOpacity(0.4),
285+
radiusMultiplier: 10,
286+
child: Center(child: child),
287+
),
288+
child: iconAssetPathSVG.startsWith("assets/")
289+
? SvgPicture.asset(
290+
iconAssetPathSVG,
291+
color: Theme.of(
292+
context,
293+
).extension<StackColors>()!.tokenSummaryIcon,
294+
width: iconSize,
295+
height: iconSize,
296+
)
297+
: SvgPicture.file(
298+
File(iconAssetPathSVG),
299+
color: Theme.of(
300+
context,
301+
).extension<StackColors>()!.tokenSummaryIcon,
302+
width: iconSize,
303+
height: iconSize,
304+
),
300305
),
301306
),
302307
),
303308
const SizedBox(height: 6),
304309
Text(
305310
subLabel,
306311
style: STextStyles.w500_12(context).copyWith(
307-
color:
308-
Theme.of(
309-
context,
310-
).extension<StackColors>()!.tokenSummaryTextPrimary,
312+
color: Theme.of(
313+
context,
314+
).extension<StackColors>()!.tokenSummaryTextPrimary,
311315
),
312316
),
313317
],

0 commit comments

Comments
 (0)