mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +00:00
exchange form localisation number parsing fix
This commit is contained in:
parent
7eec4b9f2f
commit
cdfeb95fdf
1 changed files with 17 additions and 2 deletions
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
||||||
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
|
||||||
|
@ -109,7 +110,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
_sendFieldOnChangedTimer?.cancel();
|
_sendFieldOnChangedTimer?.cancel();
|
||||||
|
|
||||||
_sendFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
_sendFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
||||||
final newFromAmount = Decimal.tryParse(value);
|
final newFromAmount = _localizedStringToNum(value);
|
||||||
|
|
||||||
await ref
|
await ref
|
||||||
.read(exchangeFormStateProvider)
|
.read(exchangeFormStateProvider)
|
||||||
|
@ -123,7 +124,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
_receiveFieldOnChangedTimer?.cancel();
|
_receiveFieldOnChangedTimer?.cancel();
|
||||||
|
|
||||||
_receiveFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
_receiveFieldOnChangedTimer = Timer(_valueCheckInterval, () async {
|
||||||
final newToAmount = Decimal.tryParse(value);
|
final newToAmount = _localizedStringToNum(value);
|
||||||
|
|
||||||
await ref
|
await ref
|
||||||
.read(exchangeFormStateProvider)
|
.read(exchangeFormStateProvider)
|
||||||
|
@ -131,6 +132,20 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Decimal? _localizedStringToNum(String? value) {
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final numFromLocalised = NumberFormat.decimalPattern(
|
||||||
|
ref.read(localeServiceChangeNotifierProvider).locale)
|
||||||
|
.parse(value);
|
||||||
|
return Decimal.tryParse(numFromLocalised.toString());
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<AggregateCurrency> _getAggregateCurrency(Currency currency) async {
|
Future<AggregateCurrency> _getAggregateCurrency(Currency currency) async {
|
||||||
final rateType = ref.read(exchangeFormStateProvider).exchangeRateType;
|
final rateType = ref.read(exchangeFormStateProvider).exchangeRateType;
|
||||||
final currencies = await ExchangeDataLoadingService.instance.isar.currencies
|
final currencies = await ExchangeDataLoadingService.instance.isar.currencies
|
||||||
|
|
Loading…
Reference in a new issue