disable send all for eth + tokens

This commit is contained in:
julian 2023-03-31 15:42:28 -06:00
parent d4cba56e81
commit 521a9bb0a3
2 changed files with 98 additions and 95 deletions

View file

@ -364,7 +364,8 @@ class _SendViewState extends ConsumerState<SendView> {
final coinControlEnabled =
ref.read(prefsChangeNotifierProvider).enableCoinControl;
if (!(manager.hasCoinControlSupport && coinControlEnabled) ||
if (coin != Coin.ethereum &&
!(manager.hasCoinControlSupport && coinControlEnabled) ||
(manager.hasCoinControlSupport &&
coinControlEnabled &&
selectedUTXOs.isEmpty)) {
@ -1395,43 +1396,45 @@ class _SendViewState extends ConsumerState<SendView> {
style: STextStyles.smallMed12(context),
textAlign: TextAlign.left,
),
CustomTextButton(
text: "Send all ${coin.ticker}",
onTap: () async {
if (coin == Coin.firo ||
coin == Coin.firoTestNet) {
final firoWallet =
ref.read(provider).wallet as FiroWallet;
if (ref
.read(
publicPrivateBalanceStateProvider
.state)
.state ==
"Private") {
cryptoAmountController.text = firoWallet
.availablePrivateBalance()
.toStringAsFixed(
Constants.decimalPlacesForCoin(
coin));
if (coin != Coin.ethereum)
CustomTextButton(
text: "Send all ${coin.ticker}",
onTap: () async {
if (coin == Coin.firo ||
coin == Coin.firoTestNet) {
final firoWallet = ref
.read(provider)
.wallet as FiroWallet;
if (ref
.read(
publicPrivateBalanceStateProvider
.state)
.state ==
"Private") {
cryptoAmountController.text = firoWallet
.availablePrivateBalance()
.toStringAsFixed(
Constants.decimalPlacesForCoin(
coin));
} else {
cryptoAmountController.text = firoWallet
.availablePublicBalance()
.toStringAsFixed(
Constants.decimalPlacesForCoin(
coin));
}
} else {
cryptoAmountController.text = firoWallet
.availablePublicBalance()
cryptoAmountController.text = (ref
.read(provider)
.balance
.getSpendable())
.toStringAsFixed(
Constants.decimalPlacesForCoin(
coin));
}
} else {
cryptoAmountController.text = (ref
.read(provider)
.balance
.getSpendable())
.toStringAsFixed(
Constants.decimalPlacesForCoin(
coin));
}
_cryptoAmountChanged();
},
),
_cryptoAmountChanged();
},
),
],
),
const SizedBox(

View file

@ -402,56 +402,56 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
fractionDigits: tokenContract.decimals,
);
// confirm send all
if (amount == availableBalance) {
bool? shouldSendAll;
if (mounted) {
shouldSendAll = await showDialog<bool>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return StackDialog(
title: "Confirm send all",
message:
"You are about to send your entire balance. Would you like to continue?",
leftButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonStyle(context),
child: Text(
"Cancel",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
onPressed: () {
Navigator.of(context).pop(false);
},
),
rightButton: TextButton(
style: Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonStyle(context),
child: Text(
"Yes",
style: STextStyles.button(context),
),
onPressed: () {
Navigator.of(context).pop(true);
},
),
);
},
);
}
if (shouldSendAll == null || shouldSendAll == false) {
// cancel preview
return;
}
}
// // confirm send all
// if (amount == availableBalance) {
// bool? shouldSendAll;
// if (mounted) {
// shouldSendAll = await showDialog<bool>(
// context: context,
// useSafeArea: false,
// barrierDismissible: true,
// builder: (context) {
// return StackDialog(
// title: "Confirm send all",
// message:
// "You are about to send your entire balance. Would you like to continue?",
// leftButton: TextButton(
// style: Theme.of(context)
// .extension<StackColors>()!
// .getSecondaryEnabledButtonStyle(context),
// child: Text(
// "Cancel",
// style: STextStyles.button(context).copyWith(
// color: Theme.of(context)
// .extension<StackColors>()!
// .accentColorDark),
// ),
// onPressed: () {
// Navigator.of(context).pop(false);
// },
// ),
// rightButton: TextButton(
// style: Theme.of(context)
// .extension<StackColors>()!
// .getPrimaryEnabledButtonStyle(context),
// child: Text(
// "Yes",
// style: STextStyles.button(context),
// ),
// onPressed: () {
// Navigator.of(context).pop(true);
// },
// ),
// );
// },
// );
// }
//
// if (shouldSendAll == null || shouldSendAll == false) {
// // cancel preview
// return;
// }
// }
try {
bool wasCancelled = false;
@ -908,18 +908,18 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
style: STextStyles.smallMed12(context),
textAlign: TextAlign.left,
),
CustomTextButton(
text: "Send all ${tokenContract.symbol}",
onTap: () async {
cryptoAmountController.text = ref
.read(tokenServiceProvider)!
.balance
.getSpendable()
.toStringAsFixed(tokenContract.decimals);
_cryptoAmountChanged();
},
),
// CustomTextButton(
// text: "Send all ${tokenContract.symbol}",
// onTap: () async {
// cryptoAmountController.text = ref
// .read(tokenServiceProvider)!
// .balance
// .getSpendable()
// .toStringAsFixed(tokenContract.decimals);
//
// _cryptoAmountChanged();
// },
// ),
],
),
const SizedBox(