CWA-169 | created check_amount then added to transaction_info and to trade

This commit is contained in:
Oleksandr Sobol 2020-02-07 14:06:15 +02:00
parent 7c83a71916
commit ad241ca1db
4 changed files with 15 additions and 3 deletions

View file

@ -0,0 +1,8 @@
String checkAmount(String amount) {
if (!amount.contains('.')) {
return amount + '.00';
} else if (amount.endsWith('.')) {
return amount + '00';
}
return amount;
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -577,7 +577,7 @@ class DashboardPageBodyState extends State<DashboardPageBody> {
final formattedAmount = trade.amount != null
? savedDisplayMode == BalanceDisplayMode.hiddenBalance
? '---'
: trade.amount
: trade.amountFormatted()
: trade.amount;
return TradeRow(