mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-25 08:38:45 +00:00
desktop eth token send view fixes
This commit is contained in:
parent
36c4221185
commit
57ac4d4747
1 changed files with 10 additions and 25 deletions
|
@ -17,8 +17,6 @@ import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart';
|
import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart';
|
||||||
import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart';
|
import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart';
|
||||||
import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart';
|
|
||||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
|
||||||
import 'package:stackwallet/services/coins/manager.dart';
|
import 'package:stackwallet/services/coins/manager.dart';
|
||||||
import 'package:stackwallet/utilities/address_utils.dart';
|
import 'package:stackwallet/utilities/address_utils.dart';
|
||||||
import 'package:stackwallet/utilities/amount.dart';
|
import 'package:stackwallet/utilities/amount.dart';
|
||||||
|
@ -43,6 +41,8 @@ import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
||||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||||
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||||
|
|
||||||
|
const _kCryptoAmountRegex = r'^([0-9]*[,.]?[0-9]{0,8}|[,.][0-9]{0,8})$';
|
||||||
|
|
||||||
class DesktopTokenSend extends ConsumerStatefulWidget {
|
class DesktopTokenSend extends ConsumerStatefulWidget {
|
||||||
const DesktopTokenSend({
|
const DesktopTokenSend({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -543,27 +543,9 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> sendAllTapped() async {
|
Future<void> sendAllTapped() async {
|
||||||
if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
cryptoAmountController.text =
|
||||||
final firoWallet = ref
|
(ref.read(tokenServiceProvider)!.balance.getSpendable())
|
||||||
.read(walletsChangeNotifierProvider)
|
|
||||||
.getManager(walletId)
|
|
||||||
.wallet as FiroWallet;
|
|
||||||
if (ref.read(publicPrivateBalanceStateProvider.state).state ==
|
|
||||||
"Private") {
|
|
||||||
cryptoAmountController.text = (firoWallet.availablePrivateBalance())
|
|
||||||
.toStringAsFixed(Constants.decimalPlacesForCoin(coin));
|
.toStringAsFixed(Constants.decimalPlacesForCoin(coin));
|
||||||
} else {
|
|
||||||
cryptoAmountController.text = (firoWallet.availablePublicBalance())
|
|
||||||
.toStringAsFixed(Constants.decimalPlacesForCoin(coin));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cryptoAmountController.text = (ref
|
|
||||||
.read(walletsChangeNotifierProvider)
|
|
||||||
.getManager(walletId)
|
|
||||||
.balance
|
|
||||||
.getSpendable())
|
|
||||||
.toStringAsFixed(Constants.decimalPlacesForCoin(coin));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -696,9 +678,12 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
// regex to validate a crypto amount with 8 decimal places
|
// regex to validate a crypto amount with 8 decimal places
|
||||||
TextInputFormatter.withFunction((oldValue, newValue) =>
|
TextInputFormatter.withFunction((oldValue, newValue) => RegExp(
|
||||||
RegExp(r'^([0-9]*[,.]?[0-9]{0,8}|[,.][0-9]{0,18})$')
|
_kCryptoAmountRegex.replaceAll(
|
||||||
.hasMatch(newValue.text)
|
"0,8",
|
||||||
|
"0,${tokenContract.decimals}",
|
||||||
|
),
|
||||||
|
).hasMatch(newValue.text)
|
||||||
? newValue
|
? newValue
|
||||||
: oldValue),
|
: oldValue),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue