mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
fix: amount string parse bug on desktop send view
This commit is contained in:
parent
14bf1ab3e3
commit
2b228f736e
1 changed files with 11 additions and 31 deletions
|
@ -9,7 +9,6 @@
|
|||
*/
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:bip47/bip47.dart';
|
||||
import 'package:cw_core/monero_transaction_priority.dart';
|
||||
|
@ -462,27 +461,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
|||
|
||||
void _cryptoAmountChanged() async {
|
||||
if (!_cryptoAmountChangeLock) {
|
||||
String cryptoAmount = cryptoAmountController.text;
|
||||
if (cryptoAmount.isNotEmpty &&
|
||||
cryptoAmount != "." &&
|
||||
cryptoAmount != ",") {
|
||||
if (cryptoAmount.startsWith("~")) {
|
||||
cryptoAmount = cryptoAmount.substring(1);
|
||||
}
|
||||
if (cryptoAmount.contains(" ")) {
|
||||
cryptoAmount = cryptoAmount.split(" ").first;
|
||||
}
|
||||
|
||||
// ensure we don't shift past minimum atomic value
|
||||
final shift = min(ref.read(pAmountUnit(coin)).shift, coin.decimals);
|
||||
|
||||
_amountToSend = cryptoAmount.contains(",")
|
||||
? Decimal.parse(cryptoAmount.replaceFirst(",", "."))
|
||||
.shift(0 - shift)
|
||||
.toAmount(fractionDigits: coin.decimals)
|
||||
: Decimal.parse(cryptoAmount)
|
||||
.shift(0 - shift)
|
||||
.toAmount(fractionDigits: coin.decimals);
|
||||
final cryptoAmount = ref.read(pAmountFormatter(coin)).tryParse(
|
||||
cryptoAmountController.text,
|
||||
);
|
||||
if (cryptoAmount != null) {
|
||||
_amountToSend = cryptoAmount;
|
||||
if (_cachedAmountToSend != null &&
|
||||
_cachedAmountToSend == _amountToSend) {
|
||||
return;
|
||||
|
@ -677,15 +660,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
|||
}
|
||||
|
||||
void fiatTextFieldOnChanged(String baseAmountString) {
|
||||
if (baseAmountString.isNotEmpty &&
|
||||
baseAmountString != "." &&
|
||||
baseAmountString != ",") {
|
||||
final baseAmount = baseAmountString.contains(",")
|
||||
? Decimal.parse(baseAmountString.replaceFirst(",", "."))
|
||||
.toAmount(fractionDigits: 2)
|
||||
: Decimal.parse(baseAmountString).toAmount(fractionDigits: 2);
|
||||
|
||||
var _price =
|
||||
final baseAmount = Amount.tryParseFiatString(
|
||||
baseAmountString,
|
||||
locale: ref.read(localeServiceChangeNotifierProvider).locale,
|
||||
);
|
||||
if (baseAmount != null) {
|
||||
final _price =
|
||||
ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1;
|
||||
|
||||
if (_price == Decimal.zero) {
|
||||
|
|
Loading…
Reference in a new issue