mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +00:00
clear send form on successful send
This commit is contained in:
parent
b5cb0b067f
commit
1121949f56
8 changed files with 137 additions and 64 deletions
|
@ -154,6 +154,9 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
routeOnSuccessName: PaynymHomeView.routeName,
|
||||
isPaynymNotificationTransaction: true,
|
||||
txData: preparedTx,
|
||||
onSuccess: () {
|
||||
// do nothing extra
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -126,6 +126,9 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
walletId: widget.walletId,
|
||||
isPaynymNotificationTransaction: true,
|
||||
txData: preparedTx,
|
||||
onSuccess: () {
|
||||
// do nothing extra
|
||||
},
|
||||
onSuccessInsteadOfRouteOnSuccess: () {
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
|
|
|
@ -58,6 +58,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
|||
Key? key,
|
||||
required this.txData,
|
||||
required this.walletId,
|
||||
required this.onSuccess,
|
||||
this.routeOnSuccessName = WalletView.routeName,
|
||||
this.isTradeTransaction = false,
|
||||
this.isPaynymTransaction = false,
|
||||
|
@ -76,6 +77,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
|||
final bool isPaynymNotificationTransaction;
|
||||
final bool isTokenTx;
|
||||
final VoidCallback? onSuccessInsteadOfRouteOnSuccess;
|
||||
final VoidCallback onSuccess;
|
||||
|
||||
@override
|
||||
ConsumerState<ConfirmTransactionView> createState() =>
|
||||
|
@ -205,6 +207,8 @@ class _ConfirmTransactionViewState
|
|||
unawaited(wallet.refresh());
|
||||
}
|
||||
|
||||
widget.onSuccess.call();
|
||||
|
||||
// pop back to wallet
|
||||
if (mounted) {
|
||||
if (widget.onSuccessInsteadOfRouteOnSuccess == null) {
|
||||
|
|
|
@ -762,55 +762,75 @@ class _SendViewState extends ConsumerState<SendView> {
|
|||
// pop building dialog
|
||||
Navigator.of(context).pop();
|
||||
|
||||
unawaited(Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => ConfirmTransactionView(
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
isPaynymTransaction: isPaynymSend,
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name: ConfirmTransactionView.routeName,
|
||||
unawaited(
|
||||
Navigator.of(context).push(
|
||||
RouteGenerator.getRoute(
|
||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||
builder: (_) => ConfirmTransactionView(
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
isPaynymTransaction: isPaynymSend,
|
||||
onSuccess: clearSendForm,
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name: ConfirmTransactionView.routeName,
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
// pop building dialog
|
||||
Navigator.of(context).pop();
|
||||
|
||||
unawaited(showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return StackDialog(
|
||||
title: "Transaction failed",
|
||||
message: e.toString(),
|
||||
rightButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonStyle(context),
|
||||
child: Text(
|
||||
"Ok",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return StackDialog(
|
||||
title: "Transaction failed",
|
||||
message: e.toString(),
|
||||
rightButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonStyle(context),
|
||||
child: Text(
|
||||
"Ok",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
));
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearSendForm() {
|
||||
sendToController.text = "";
|
||||
cryptoAmountController.text = "";
|
||||
baseAmountController.text = "";
|
||||
noteController.text = "";
|
||||
onChainNoteController.text = "";
|
||||
feeController.text = "";
|
||||
memoController.text = "";
|
||||
_address = "";
|
||||
_addressToggleFlag = false;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
bool get isPaynymSend => widget.accountLite != null;
|
||||
|
||||
bool isCustomFee = false;
|
||||
|
|
|
@ -507,6 +507,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
txData: txData,
|
||||
walletId: walletId,
|
||||
isTokenTx: true,
|
||||
onSuccess: clearSendForm,
|
||||
),
|
||||
settings: const RouteSettings(
|
||||
name: ConfirmTransactionView.routeName,
|
||||
|
@ -519,36 +520,51 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
|||
// pop building dialog
|
||||
Navigator.of(context).pop();
|
||||
|
||||
unawaited(showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return StackDialog(
|
||||
title: "Transaction failed",
|
||||
message: e.toString(),
|
||||
rightButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonStyle(context),
|
||||
child: Text(
|
||||
"Ok",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
unawaited(
|
||||
showDialog<dynamic>(
|
||||
context: context,
|
||||
useSafeArea: false,
|
||||
barrierDismissible: true,
|
||||
builder: (context) {
|
||||
return StackDialog(
|
||||
title: "Transaction failed",
|
||||
message: e.toString(),
|
||||
rightButton: TextButton(
|
||||
style: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.getSecondaryEnabledButtonStyle(context),
|
||||
child: Text(
|
||||
"Ok",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
));
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearSendForm() {
|
||||
sendToController.text = "";
|
||||
cryptoAmountController.text = "";
|
||||
baseAmountController.text = "";
|
||||
noteController.text = "";
|
||||
feeController.text = "";
|
||||
_address = "";
|
||||
_addressToggleFlag = false;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
ref.refresh(feeSheetSessionCacheProvider);
|
||||
|
|
|
@ -435,6 +435,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
|||
child: ConfirmTransactionView(
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
onSuccess: clearSendForm,
|
||||
isPaynymTransaction: isPaynymSend,
|
||||
routeOnSuccessName: DesktopHomeView.routeName,
|
||||
),
|
||||
|
@ -525,6 +526,18 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
|||
}
|
||||
}
|
||||
|
||||
void clearSendForm() {
|
||||
sendToController.text = "";
|
||||
cryptoAmountController.text = "";
|
||||
baseAmountController.text = "";
|
||||
memoController.text = "";
|
||||
_address = "";
|
||||
_addressToggleFlag = false;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void _cryptoAmountChanged() async {
|
||||
if (!_cryptoAmountChangeLock) {
|
||||
final cryptoAmount = ref.read(pAmountFormatter(coin)).tryParse(
|
||||
|
|
|
@ -277,6 +277,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
|
|||
child: ConfirmTransactionView(
|
||||
txData: txData,
|
||||
walletId: walletId,
|
||||
onSuccess: clearSendForm,
|
||||
isTokenTx: true,
|
||||
routeOnSuccessName: DesktopHomeView.routeName,
|
||||
),
|
||||
|
@ -366,6 +367,18 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
|
|||
}
|
||||
}
|
||||
|
||||
void clearSendForm() {
|
||||
sendToController.text = "";
|
||||
cryptoAmountController.text = "";
|
||||
baseAmountController.text = "";
|
||||
nonceController.text = "";
|
||||
_address = "";
|
||||
_addressToggleFlag = false;
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
void _cryptoAmountChanged() async {
|
||||
if (!_cryptoAmountChangeLock) {
|
||||
final String cryptoAmount = cryptoAmountController.text;
|
||||
|
|
|
@ -1463,12 +1463,13 @@ class RouteGenerator {
|
|||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case ConfirmTransactionView.routeName:
|
||||
if (args is Tuple2<TxData, String>) {
|
||||
if (args is (TxData, String, VoidCallback)) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => ConfirmTransactionView(
|
||||
txData: args.item1,
|
||||
walletId: args.item2,
|
||||
txData: args.$1,
|
||||
walletId: args.$2,
|
||||
onSuccess: args.$3,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
|
|
Loading…
Reference in a new issue