diff --git a/lib/app/transactions/form/transaction_form.page.dart b/lib/app/transactions/form/transaction_form.page.dart index 03e5b6c1..96785e58 100644 --- a/lib/app/transactions/form/transaction_form.page.dart +++ b/lib/app/transactions/form/transaction_form.page.dart @@ -474,6 +474,7 @@ class _TransactionFormPageState extends State { ), child: CurrencyDisplayer( amountToConvert: transactionAmount, + followPrivateMode: false, currency: fromAccount?.currency, ), ), @@ -651,6 +652,7 @@ class _TransactionFormPageState extends State { const SizedBox(height: 8), CurrencyDisplayer( amountToConvert: exchangeRateSnapshot.data!, + followPrivateMode: false, integerStyle: Theme.of(context).textTheme.bodyLarge!.copyWith( color: AppColors.of(context).onSurface.withAlpha(200)), ), diff --git a/lib/core/presentation/widgets/number_ui_formatters/currency_displayer.dart b/lib/core/presentation/widgets/number_ui_formatters/currency_displayer.dart index 5dad8640..56c00f8b 100644 --- a/lib/core/presentation/widgets/number_ui_formatters/currency_displayer.dart +++ b/lib/core/presentation/widgets/number_ui_formatters/currency_displayer.dart @@ -23,10 +23,15 @@ class CurrencyDisplayer extends StatelessWidget { this.integerStyle = const TextStyle(inherit: true), this.decimalsStyle, this.currencyStyle, + this.followPrivateMode = true, }); final double amountToConvert; + /// If `true` (the default value), the widget will display the amount with a + /// blurred effect if the user has the private mode activated + final bool followPrivateMode; + /// The currency of the amount, used to display the symbol. /// If not specified, will be the user preferred currency final CurrencyInDB? currency; @@ -46,6 +51,20 @@ class CurrencyDisplayer extends StatelessWidget { final bool showDecimals; + Widget _amountDisplayer( + BuildContext context, { + required CurrencyInDB currency, + }) { + return UINumberFormatter.currency( + amountToConvert: amountToConvert, + currency: currency, + showDecimals: showDecimals, + integerStyle: integerStyle, + decimalsStyle: decimalsStyle, + currencyStyle: currencyStyle, + ).getTextWidget(context); + } + @override Widget build(BuildContext context) { final valueFontSize = (integerStyle.fontSize ?? @@ -53,35 +72,30 @@ class CurrencyDisplayer extends StatelessWidget { 16; if (currency != null) { - return BlurBasedOnPrivateMode( - child: UINumberFormatter.currency( - amountToConvert: amountToConvert, - currency: currency, - showDecimals: showDecimals, - integerStyle: integerStyle, - decimalsStyle: decimalsStyle, - currencyStyle: currencyStyle, - ).getTextWidget(context), - ); + final displayer = _amountDisplayer(context, currency: currency!); + + if (followPrivateMode) { + return BlurBasedOnPrivateMode(child: displayer); + } else { + return displayer; + } } - return BlurBasedOnPrivateMode( - child: StreamBuilder( - stream: CurrencyService.instance.getUserPreferredCurrency(), - builder: (context, snapshot) { - if (!snapshot.hasData) { - return Skeleton(width: 50, height: valueFontSize); - } - - return UINumberFormatter.currency( - amountToConvert: amountToConvert, - currency: snapshot.data!, - showDecimals: showDecimals, - integerStyle: integerStyle, - decimalsStyle: decimalsStyle, - currencyStyle: currencyStyle, - ).getTextWidget(context); - }), + return StreamBuilder( + stream: CurrencyService.instance.getUserPreferredCurrency(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return Skeleton(width: 50, height: valueFontSize); + } + + final displayer = _amountDisplayer(context, currency: snapshot.data!); + + if (followPrivateMode) { + return BlurBasedOnPrivateMode(child: displayer); + } else { + return displayer; + } + }, ); } }