mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
fff77519d9
* fix: Crypto amout formatting when calculating fiat amount * fix: Issue with some token symbols coming up with a dollar sign * feat: Split transactions to display on history screen token byh token * fix: Remove restriction on balance length * fix: error when a particular token is not available * fix: Remove token transactions when a token is deleted * fix: Revert previous change * make added spl tokens enabled by default fix issue when entering invalid contract address --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
28 lines
686 B
Dart
28 lines
686 B
Dart
String calculateFiatAmount({double? price, String? cryptoAmount}) {
|
|
if (price == null || cryptoAmount == null) {
|
|
return '0.00';
|
|
}
|
|
|
|
cryptoAmount = cryptoAmount.replaceAll(',', '.');
|
|
|
|
final _amount = double.parse(cryptoAmount);
|
|
final _result = price * _amount;
|
|
final result = _result < 0 ? _result * -1 : _result;
|
|
|
|
if (result == 0.0) {
|
|
return '0.00';
|
|
}
|
|
|
|
var formatted = '';
|
|
final parts = result.toString().split('.');
|
|
|
|
if (parts.length >= 2) {
|
|
if (parts[1].length > 2) {
|
|
formatted = parts[0] + '.' + parts[1].substring(0, 2);
|
|
} else {
|
|
formatted = parts[0] + '.' + parts[1];
|
|
}
|
|
}
|
|
|
|
return result > 0.01 ? formatted : '< 0.01';
|
|
}
|