diff --git a/lib/src/domain/common/check_amount.dart b/lib/src/domain/common/check_amount.dart new file mode 100644 index 000000000..77e0e5a62 --- /dev/null +++ b/lib/src/domain/common/check_amount.dart @@ -0,0 +1,8 @@ +String checkAmount(String amount) { + if (!amount.contains('.')) { + return amount + '.00'; + } else if (amount.endsWith('.')) { + return amount + '00'; + } + return amount; +} \ No newline at end of file diff --git a/lib/src/domain/common/transaction_info.dart b/lib/src/domain/common/transaction_info.dart index 08fcd2372..e72f022d0 100644 --- a/lib/src/domain/common/transaction_info.dart +++ b/lib/src/domain/common/transaction_info.dart @@ -2,6 +2,7 @@ import 'package:cake_wallet/src/domain/monero/monero_amount_format.dart'; import 'package:cw_monero/structs/transaction_info_row.dart'; import 'package:cake_wallet/src/domain/common/parseBoolFromString.dart'; import 'package:cake_wallet/src/domain/common/transaction_direction.dart'; +import 'package:cake_wallet/src/domain/common/check_amount.dart'; class TransactionInfo { TransactionInfo(this.id, this.height, this.direction, this.date, @@ -40,9 +41,9 @@ class TransactionInfo { String _fiatAmount; - String amountFormatted() => '${moneroAmountToString(amount: amount)} XMR'; + String amountFormatted() => '${checkAmount(moneroAmountToString(amount: amount))} XMR'; String fiatAmount() => _fiatAmount ?? ''; - void changeFiatAmount(String amount) => _fiatAmount = amount; + void changeFiatAmount(String amount) => _fiatAmount = checkAmount(amount); } diff --git a/lib/src/domain/exchange/trade.dart b/lib/src/domain/exchange/trade.dart index 3554d340a..9f3f1cb77 100644 --- a/lib/src/domain/exchange/trade.dart +++ b/lib/src/domain/exchange/trade.dart @@ -2,6 +2,7 @@ import 'package:hive/hive.dart'; import 'package:cake_wallet/src/domain/common/crypto_currency.dart'; import 'package:cake_wallet/src/domain/exchange/exchange_provider_description.dart'; import 'package:cake_wallet/src/domain/exchange/trade_state.dart'; +import 'package:cake_wallet/src/domain/common/check_amount.dart'; part 'trade.g.dart'; @@ -101,4 +102,6 @@ class Trade extends HiveObject { 'wallet_id': walletId }; } + + String amountFormatted() => checkAmount(amount); } diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index e13a25161..23d5a3f8f 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -577,7 +577,7 @@ class DashboardPageBodyState extends State { final formattedAmount = trade.amount != null ? savedDisplayMode == BalanceDisplayMode.hiddenBalance ? '---' - : trade.amount + : trade.amountFormatted() : trade.amount; return TradeRow(