mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +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:async';
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:bip47/bip47.dart';
|
import 'package:bip47/bip47.dart';
|
||||||
import 'package:cw_core/monero_transaction_priority.dart';
|
import 'package:cw_core/monero_transaction_priority.dart';
|
||||||
|
@ -462,27 +461,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
|
|
||||||
void _cryptoAmountChanged() async {
|
void _cryptoAmountChanged() async {
|
||||||
if (!_cryptoAmountChangeLock) {
|
if (!_cryptoAmountChangeLock) {
|
||||||
String cryptoAmount = cryptoAmountController.text;
|
final cryptoAmount = ref.read(pAmountFormatter(coin)).tryParse(
|
||||||
if (cryptoAmount.isNotEmpty &&
|
cryptoAmountController.text,
|
||||||
cryptoAmount != "." &&
|
);
|
||||||
cryptoAmount != ",") {
|
if (cryptoAmount != null) {
|
||||||
if (cryptoAmount.startsWith("~")) {
|
_amountToSend = cryptoAmount;
|
||||||
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);
|
|
||||||
if (_cachedAmountToSend != null &&
|
if (_cachedAmountToSend != null &&
|
||||||
_cachedAmountToSend == _amountToSend) {
|
_cachedAmountToSend == _amountToSend) {
|
||||||
return;
|
return;
|
||||||
|
@ -677,15 +660,12 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void fiatTextFieldOnChanged(String baseAmountString) {
|
void fiatTextFieldOnChanged(String baseAmountString) {
|
||||||
if (baseAmountString.isNotEmpty &&
|
final baseAmount = Amount.tryParseFiatString(
|
||||||
baseAmountString != "." &&
|
baseAmountString,
|
||||||
baseAmountString != ",") {
|
locale: ref.read(localeServiceChangeNotifierProvider).locale,
|
||||||
final baseAmount = baseAmountString.contains(",")
|
);
|
||||||
? Decimal.parse(baseAmountString.replaceFirst(",", "."))
|
if (baseAmount != null) {
|
||||||
.toAmount(fractionDigits: 2)
|
final _price =
|
||||||
: Decimal.parse(baseAmountString).toAmount(fractionDigits: 2);
|
|
||||||
|
|
||||||
var _price =
|
|
||||||
ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1;
|
ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1;
|
||||||
|
|
||||||
if (_price == Decimal.zero) {
|
if (_price == Decimal.zero) {
|
||||||
|
|
Loading…
Reference in a new issue