mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 11:15:58 +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,
|
routeOnSuccessName: PaynymHomeView.routeName,
|
||||||
isPaynymNotificationTransaction: true,
|
isPaynymNotificationTransaction: true,
|
||||||
txData: preparedTx,
|
txData: preparedTx,
|
||||||
|
onSuccess: () {
|
||||||
|
// do nothing extra
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -126,6 +126,9 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
walletId: widget.walletId,
|
walletId: widget.walletId,
|
||||||
isPaynymNotificationTransaction: true,
|
isPaynymNotificationTransaction: true,
|
||||||
txData: preparedTx,
|
txData: preparedTx,
|
||||||
|
onSuccess: () {
|
||||||
|
// do nothing extra
|
||||||
|
},
|
||||||
onSuccessInsteadOfRouteOnSuccess: () {
|
onSuccessInsteadOfRouteOnSuccess: () {
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
Navigator.of(context, rootNavigator: true).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
|
@ -58,6 +58,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.txData,
|
required this.txData,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
|
required this.onSuccess,
|
||||||
this.routeOnSuccessName = WalletView.routeName,
|
this.routeOnSuccessName = WalletView.routeName,
|
||||||
this.isTradeTransaction = false,
|
this.isTradeTransaction = false,
|
||||||
this.isPaynymTransaction = false,
|
this.isPaynymTransaction = false,
|
||||||
|
@ -76,6 +77,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget {
|
||||||
final bool isPaynymNotificationTransaction;
|
final bool isPaynymNotificationTransaction;
|
||||||
final bool isTokenTx;
|
final bool isTokenTx;
|
||||||
final VoidCallback? onSuccessInsteadOfRouteOnSuccess;
|
final VoidCallback? onSuccessInsteadOfRouteOnSuccess;
|
||||||
|
final VoidCallback onSuccess;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<ConfirmTransactionView> createState() =>
|
ConsumerState<ConfirmTransactionView> createState() =>
|
||||||
|
@ -205,6 +207,8 @@ class _ConfirmTransactionViewState
|
||||||
unawaited(wallet.refresh());
|
unawaited(wallet.refresh());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widget.onSuccess.call();
|
||||||
|
|
||||||
// pop back to wallet
|
// pop back to wallet
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
if (widget.onSuccessInsteadOfRouteOnSuccess == null) {
|
if (widget.onSuccessInsteadOfRouteOnSuccess == null) {
|
||||||
|
|
|
@ -762,26 +762,30 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
// pop building dialog
|
// pop building dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
unawaited(Navigator.of(context).push(
|
unawaited(
|
||||||
|
Navigator.of(context).push(
|
||||||
RouteGenerator.getRoute(
|
RouteGenerator.getRoute(
|
||||||
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute,
|
||||||
builder: (_) => ConfirmTransactionView(
|
builder: (_) => ConfirmTransactionView(
|
||||||
txData: txData,
|
txData: txData,
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
isPaynymTransaction: isPaynymSend,
|
isPaynymTransaction: isPaynymSend,
|
||||||
|
onSuccess: clearSendForm,
|
||||||
),
|
),
|
||||||
settings: const RouteSettings(
|
settings: const RouteSettings(
|
||||||
name: ConfirmTransactionView.routeName,
|
name: ConfirmTransactionView.routeName,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
// pop building dialog
|
// pop building dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
unawaited(showDialog<dynamic>(
|
unawaited(
|
||||||
|
showDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
|
@ -806,11 +810,27 @@ class _SendViewState extends ConsumerState<SendView> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 get isPaynymSend => widget.accountLite != null;
|
||||||
|
|
||||||
bool isCustomFee = false;
|
bool isCustomFee = false;
|
||||||
|
|
|
@ -507,6 +507,7 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
||||||
txData: txData,
|
txData: txData,
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
isTokenTx: true,
|
isTokenTx: true,
|
||||||
|
onSuccess: clearSendForm,
|
||||||
),
|
),
|
||||||
settings: const RouteSettings(
|
settings: const RouteSettings(
|
||||||
name: ConfirmTransactionView.routeName,
|
name: ConfirmTransactionView.routeName,
|
||||||
|
@ -519,7 +520,8 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
||||||
// pop building dialog
|
// pop building dialog
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
unawaited(showDialog<dynamic>(
|
unawaited(
|
||||||
|
showDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
|
@ -544,11 +546,25 @@ class _TokenSendViewState extends ConsumerState<TokenSendView> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
));
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearSendForm() {
|
||||||
|
sendToController.text = "";
|
||||||
|
cryptoAmountController.text = "";
|
||||||
|
baseAmountController.text = "";
|
||||||
|
noteController.text = "";
|
||||||
|
feeController.text = "";
|
||||||
|
_address = "";
|
||||||
|
_addressToggleFlag = false;
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
ref.refresh(feeSheetSessionCacheProvider);
|
ref.refresh(feeSheetSessionCacheProvider);
|
||||||
|
|
|
@ -435,6 +435,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
|
||||||
child: ConfirmTransactionView(
|
child: ConfirmTransactionView(
|
||||||
txData: txData,
|
txData: txData,
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
|
onSuccess: clearSendForm,
|
||||||
isPaynymTransaction: isPaynymSend,
|
isPaynymTransaction: isPaynymSend,
|
||||||
routeOnSuccessName: DesktopHomeView.routeName,
|
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 {
|
void _cryptoAmountChanged() async {
|
||||||
if (!_cryptoAmountChangeLock) {
|
if (!_cryptoAmountChangeLock) {
|
||||||
final cryptoAmount = ref.read(pAmountFormatter(coin)).tryParse(
|
final cryptoAmount = ref.read(pAmountFormatter(coin)).tryParse(
|
||||||
|
|
|
@ -277,6 +277,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
|
||||||
child: ConfirmTransactionView(
|
child: ConfirmTransactionView(
|
||||||
txData: txData,
|
txData: txData,
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
|
onSuccess: clearSendForm,
|
||||||
isTokenTx: true,
|
isTokenTx: true,
|
||||||
routeOnSuccessName: DesktopHomeView.routeName,
|
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 {
|
void _cryptoAmountChanged() async {
|
||||||
if (!_cryptoAmountChangeLock) {
|
if (!_cryptoAmountChangeLock) {
|
||||||
final String cryptoAmount = cryptoAmountController.text;
|
final String cryptoAmount = cryptoAmountController.text;
|
||||||
|
|
|
@ -1463,12 +1463,13 @@ class RouteGenerator {
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
case ConfirmTransactionView.routeName:
|
case ConfirmTransactionView.routeName:
|
||||||
if (args is Tuple2<TxData, String>) {
|
if (args is (TxData, String, VoidCallback)) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => ConfirmTransactionView(
|
builder: (_) => ConfirmTransactionView(
|
||||||
txData: args.item1,
|
txData: args.$1,
|
||||||
walletId: args.item2,
|
walletId: args.$2,
|
||||||
|
onSuccess: args.$3,
|
||||||
),
|
),
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
|
|
Loading…
Reference in a new issue