Skip to content

Commit 3630747

Browse files
committed
feat: show/hide balances toggle
closes #168
1 parent 51db6c7 commit 3630747

10 files changed

Lines changed: 364 additions & 84 deletions

File tree

lib/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,63 @@ class AppearanceSettingsView extends ConsumerWidget {
113113
),
114114
),
115115
const SizedBox(height: 10),
116+
RoundedWhiteContainer(
117+
child: Consumer(
118+
builder: (_, ref, __) {
119+
return RawMaterialButton(
120+
splashColor:
121+
Theme.of(
122+
context,
123+
).extension<StackColors>()!.highlight,
124+
materialTapTargetSize:
125+
MaterialTapTargetSize.shrinkWrap,
126+
shape: RoundedRectangleBorder(
127+
borderRadius: BorderRadius.circular(
128+
Constants.size.circularBorderRadius,
129+
),
130+
),
131+
onPressed: null,
132+
child: Padding(
133+
padding: const EdgeInsets.symmetric(
134+
vertical: 8,
135+
),
136+
child: Row(
137+
mainAxisAlignment:
138+
MainAxisAlignment.spaceBetween,
139+
children: [
140+
Text(
141+
"Hide balances",
142+
style: STextStyles.titleBold12(
143+
context,
144+
),
145+
textAlign: TextAlign.left,
146+
),
147+
SizedBox(
148+
height: 20,
149+
width: 40,
150+
child: DraggableSwitchButton(
151+
isOn: ref.watch(
152+
prefsChangeNotifierProvider.select(
153+
(value) => value.hideBalances,
154+
),
155+
),
156+
onValueChanged: (newValue) {
157+
ref
158+
.read(
159+
prefsChangeNotifierProvider,
160+
)
161+
.hideBalances = newValue;
162+
},
163+
),
164+
),
165+
],
166+
),
167+
),
168+
);
169+
},
170+
),
171+
),
172+
const SizedBox(height: 10),
116173
RoundedWhiteContainer(
117174
child: Column(
118175
children: [

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/wallet_view/sub_widgets/wallet_summary_info.dart

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import '../../../wallets/crypto_currency/coins/firo.dart';
3333
import '../../../wallets/isar/providers/wallet_info_provider.dart';
3434
import '../../../wallets/wallet/impl/banano_wallet.dart';
3535
import '../../../widgets/conditional_parent.dart';
36+
import '../../../widgets/hideable_balance.dart';
3637
import 'wallet_balance_toggle_sheet.dart';
3738
import 'wallet_refresh_button.dart';
3839

@@ -206,25 +207,39 @@ class WalletSummaryInfo extends ConsumerWidget {
206207
const Spacer(),
207208
FittedBox(
208209
fit: BoxFit.scaleDown,
209-
child: SelectableText(
210-
ref.watch(pAmountFormatter(coin)).format(balanceToShow),
211-
style: STextStyles.pageTitleH1(context).copyWith(
212-
fontSize: 24,
213-
color:
214-
Theme.of(
215-
context,
216-
).extension<StackColors>()!.textFavoriteCard,
210+
child: HideableBalance(
211+
iconColor:
212+
Theme.of(
213+
context,
214+
).extension<StackColors>()!.textFavoriteCard,
215+
iconSize: 24,
216+
child: SelectableText(
217+
ref.watch(pAmountFormatter(coin)).format(balanceToShow),
218+
style: STextStyles.pageTitleH1(context).copyWith(
219+
fontSize: 24,
220+
color:
221+
Theme.of(
222+
context,
223+
).extension<StackColors>()!.textFavoriteCard,
224+
),
217225
),
218226
),
219227
),
220228
if (price != null)
221-
Text(
222-
"${(price.value * balanceToShow.decimal).toAmount(fractionDigits: 2).fiatString(locale: locale)} $baseCurrency",
223-
style: STextStyles.subtitle500(context).copyWith(
224-
color:
225-
Theme.of(
226-
context,
227-
).extension<StackColors>()!.textFavoriteCard,
229+
HideableBalance(
230+
iconColor:
231+
Theme.of(
232+
context,
233+
).extension<StackColors>()!.textFavoriteCard,
234+
iconSize: 16,
235+
child: Text(
236+
"${(price.value * balanceToShow.decimal).toAmount(fractionDigits: 2).fiatString(locale: locale)} $baseCurrency",
237+
style: STextStyles.subtitle500(context).copyWith(
238+
color:
239+
Theme.of(
240+
context,
241+
).extension<StackColors>()!.textFavoriteCard,
242+
),
228243
),
229244
),
230245
],

lib/pages/wallets_view/sub_widgets/favorite_card.dart

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import '../../../wallets/isar/providers/wallet_info_provider.dart';
3131
import '../../../wallets/wallet/intermediate/external_wallet.dart';
3232
import '../../../widgets/coin_card.dart';
3333
import '../../../widgets/conditional_parent.dart';
34+
import '../../../widgets/hideable_balance.dart';
3435
import '../../wallet_view/wallet_view.dart';
3536

3637
class FavoriteCard extends ConsumerStatefulWidget {
@@ -241,30 +242,45 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
241242
children: [
242243
FittedBox(
243244
fit: BoxFit.scaleDown,
244-
child: Text(
245-
ref.watch(pAmountFormatter(coin)).format(total),
246-
style: STextStyles.titleBold12(context).copyWith(
247-
fontSize: 16,
248-
color:
249-
Theme.of(context)
250-
.extension<StackColors>()!
251-
.textFavoriteCard,
245+
child: HideableBalance(
246+
iconColor:
247+
Theme.of(context)
248+
.extension<StackColors>()!
249+
.textFavoriteCard,
250+
iconSize: 16,
251+
child: Text(
252+
ref.watch(pAmountFormatter(coin)).format(total),
253+
style:
254+
STextStyles.titleBold12(context).copyWith(
255+
fontSize: 16,
256+
color:
257+
Theme.of(context)
258+
.extension<StackColors>()!
259+
.textFavoriteCard,
260+
),
252261
),
253262
),
254263
),
255264
if (externalCalls && price != null)
256265
const SizedBox(height: 4),
257266
if (externalCalls && price != null)
258-
Text(
259-
"${fiatTotal.fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
260-
style: STextStyles.itemSubtitle12(
261-
context,
262-
).copyWith(
263-
fontSize: 10,
264-
color:
265-
Theme.of(context)
266-
.extension<StackColors>()!
267-
.textFavoriteCard,
267+
HideableBalance(
268+
iconColor:
269+
Theme.of(context)
270+
.extension<StackColors>()!
271+
.textFavoriteCard,
272+
iconSize: 10,
273+
child: Text(
274+
"${fiatTotal.fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
275+
style: STextStyles.itemSubtitle12(
276+
context,
277+
).copyWith(
278+
fontSize: 10,
279+
color:
280+
Theme.of(context)
281+
.extension<StackColors>()!
282+
.textFavoriteCard,
283+
),
268284
),
269285
),
270286
],

lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import '../../../../wallets/isar/providers/eth/token_balance_provider.dart';
3333
import '../../../../wallets/isar/providers/solana/current_sol_token_wallet_provider.dart';
3434
import '../../../../wallets/isar/providers/solana/sol_token_balance_provider.dart';
3535
import '../../../../wallets/isar/providers/wallet_info_provider.dart';
36+
import '../../../../widgets/hideable_balance.dart';
3637
import 'desktop_balance_toggle_button.dart';
3738

3839
class DesktopWalletSummary extends ConsumerStatefulWidget {
@@ -171,20 +172,30 @@ class _WDesktopWalletSummaryState extends ConsumerState<DesktopWalletSummary> {
171172
children: [
172173
FittedBox(
173174
fit: BoxFit.scaleDown,
174-
child: SelectableText(
175-
ref
176-
.watch(pAmountFormatter(coin))
177-
.format(balanceToShow, tokenContract: tokenContract),
178-
style: STextStyles.desktopH3(context),
175+
child: HideableBalance(
176+
iconSize: 24,
177+
child: SelectableText(
178+
ref
179+
.watch(pAmountFormatter(coin))
180+
.format(balanceToShow, tokenContract: tokenContract),
181+
style: STextStyles.desktopH3(context),
182+
),
179183
),
180184
),
181185
if (externalCalls && price != null)
182-
SelectableText(
183-
"${Amount.fromDecimal(price.value * balanceToShow.decimal, fractionDigits: 2).fiatString(locale: locale)} $baseCurrency",
184-
style: STextStyles.desktopTextExtraSmall(context).copyWith(
185-
color: Theme.of(
186-
context,
187-
).extension<StackColors>()!.textSubtitle1,
186+
HideableBalance(
187+
iconColor: Theme.of(
188+
context,
189+
).extension<StackColors>()!.textSubtitle1,
190+
iconSize: 16,
191+
child: SelectableText(
192+
"${Amount.fromDecimal(price.value * balanceToShow.decimal, fractionDigits: 2).fiatString(locale: locale)} $baseCurrency",
193+
style:
194+
STextStyles.desktopTextExtraSmall(context).copyWith(
195+
color: Theme.of(
196+
context,
197+
).extension<StackColors>()!.textSubtitle1,
198+
),
188199
),
189200
),
190201
// if (coin is Firo)

lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/firo_desktop_wallet_summary.dart

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import '../../../../utilities/extensions/extensions.dart';
2727
import '../../../../utilities/text_styles.dart';
2828
import '../../../../wallets/crypto_currency/coins/firo.dart';
2929
import '../../../../wallets/isar/providers/wallet_info_provider.dart';
30+
import '../../../../widgets/hideable_balance.dart';
3031
import 'desktop_balance_toggle_button.dart';
3132

3233
class FiroDesktopWalletSummary extends ConsumerStatefulWidget {
@@ -194,10 +195,13 @@ class _Balance extends ConsumerWidget {
194195

195196
@override
196197
Widget build(BuildContext context, WidgetRef ref) {
197-
return SelectableText(
198-
ref.watch(pAmountFormatter(coin)).format(amount, tokenContract: null),
199-
style: STextStyles.desktopH3(context),
200-
textAlign: TextAlign.end,
198+
return HideableBalance(
199+
iconSize: 24,
200+
child: SelectableText(
201+
ref.watch(pAmountFormatter(coin)).format(amount, tokenContract: null),
202+
style: STextStyles.desktopH3(context),
203+
textAlign: TextAlign.end,
204+
),
201205
);
202206
}
203207
}
@@ -218,14 +222,17 @@ class _Price extends ConsumerWidget {
218222
Widget build(BuildContext context, WidgetRef ref) {
219223
return Padding(
220224
padding: const EdgeInsets.only(left: 16),
221-
child: SelectableText(
222-
"${Amount.fromDecimal(price * amount.decimal, fractionDigits: 2).fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} "
223-
"${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
224-
style: STextStyles.desktopTextExtraSmall(context).copyWith(
225-
color: Theme.of(context).extension<StackColors>()!.textSubtitle1,
225+
child: HideableBalance(
226+
iconColor: Theme.of(context).extension<StackColors>()!.textSubtitle1,
227+
iconSize: 16,
228+
child: SelectableText(
229+
"${Amount.fromDecimal(price * amount.decimal, fractionDigits: 2).fiatString(locale: ref.watch(localeServiceChangeNotifierProvider.select((value) => value.locale)))} "
230+
"${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}",
231+
style: STextStyles.desktopTextExtraSmall(context).copyWith(
232+
color: Theme.of(context).extension<StackColors>()!.textSubtitle1,
233+
),
234+
textAlign: TextAlign.end,
226235
),
227-
228-
textAlign: TextAlign.end,
229236
),
230237
);
231238
}

0 commit comments

Comments
 (0)