mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
add transaction success info page (#1878)
Some checks failed
Cache Dependencies / test (push) Has been cancelled
Some checks failed
Cache Dependencies / test (push) Has been cancelled
This commit is contained in:
parent
3ad04227a4
commit
9a60b0146f
5 changed files with 100 additions and 90 deletions
|
@ -39,6 +39,7 @@ import 'package:cake_wallet/entities/wallet_manager.dart';
|
||||||
import 'package:cake_wallet/src/screens/buy/buy_sell_options_page.dart';
|
import 'package:cake_wallet/src/screens/buy/buy_sell_options_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/buy/payment_method_options_page.dart';
|
import 'package:cake_wallet/src/screens/buy/payment_method_options_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/receive/address_list_page.dart';
|
import 'package:cake_wallet/src/screens/receive/address_list_page.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/send/transaction_success_info_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/wallet_list/wallet_list_page.dart';
|
import 'package:cake_wallet/src/screens/wallet_list/wallet_list_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/mweb_logs_page.dart';
|
import 'package:cake_wallet/src/screens/settings/mweb_logs_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/mweb_node_page.dart';
|
import 'package:cake_wallet/src/screens/settings/mweb_node_page.dart';
|
||||||
|
@ -1175,6 +1176,9 @@ Future<void> setup({
|
||||||
getIt.registerFactoryParam<PreSeedPage, int, void>(
|
getIt.registerFactoryParam<PreSeedPage, int, void>(
|
||||||
(seedPhraseLength, _) => PreSeedPage(seedPhraseLength));
|
(seedPhraseLength, _) => PreSeedPage(seedPhraseLength));
|
||||||
|
|
||||||
|
getIt.registerFactoryParam<TransactionSuccessPage, String, void>(
|
||||||
|
(content, _) => TransactionSuccessPage(content: content));
|
||||||
|
|
||||||
getIt.registerFactoryParam<TradeDetailsViewModel, Trade, void>((trade, _) =>
|
getIt.registerFactoryParam<TradeDetailsViewModel, Trade, void>((trade, _) =>
|
||||||
TradeDetailsViewModel(
|
TradeDetailsViewModel(
|
||||||
tradeForDetails: trade,
|
tradeForDetails: trade,
|
||||||
|
|
|
@ -69,6 +69,7 @@ import 'package:cake_wallet/src/screens/seed/pre_seed_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
|
import 'package:cake_wallet/src/screens/seed/wallet_seed_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/send/send_page.dart';
|
import 'package:cake_wallet/src/screens/send/send_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/send/send_template_page.dart';
|
import 'package:cake_wallet/src/screens/send/send_template_page.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/send/transaction_success_info_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/connection_sync_page.dart';
|
import 'package:cake_wallet/src/screens/settings/connection_sync_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/desktop_settings/desktop_settings_page.dart';
|
import 'package:cake_wallet/src/screens/settings/desktop_settings/desktop_settings_page.dart';
|
||||||
import 'package:cake_wallet/src/screens/settings/display_settings_page.dart';
|
import 'package:cake_wallet/src/screens/settings/display_settings_page.dart';
|
||||||
|
@ -585,6 +586,10 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
||||||
return MaterialPageRoute<void>(
|
return MaterialPageRoute<void>(
|
||||||
builder: (_) => getIt.get<PreSeedPage>(param1: settings.arguments as int));
|
builder: (_) => getIt.get<PreSeedPage>(param1: settings.arguments as int));
|
||||||
|
|
||||||
|
case Routes.transactionSuccessPage:
|
||||||
|
return MaterialPageRoute<void>(
|
||||||
|
builder: (_) => getIt.get<TransactionSuccessPage>(param1: settings.arguments as String));
|
||||||
|
|
||||||
case Routes.backup:
|
case Routes.backup:
|
||||||
return CupertinoPageRoute<void>(
|
return CupertinoPageRoute<void>(
|
||||||
fullscreenDialog: true, builder: (_) => getIt.get<BackupPage>());
|
fullscreenDialog: true, builder: (_) => getIt.get<BackupPage>());
|
||||||
|
|
|
@ -53,6 +53,7 @@ class Routes {
|
||||||
static const restoreWalletType = '/restore_wallet_type';
|
static const restoreWalletType = '/restore_wallet_type';
|
||||||
static const restoreWallet = '/restore_wallet';
|
static const restoreWallet = '/restore_wallet';
|
||||||
static const preSeedPage = '/pre_seed_page';
|
static const preSeedPage = '/pre_seed_page';
|
||||||
|
static const transactionSuccessPage = '/transaction_success_info_page';
|
||||||
static const backup = '/backup';
|
static const backup = '/backup';
|
||||||
static const editBackupPassword = '/edit_backup_passowrd';
|
static const editBackupPassword = '/edit_backup_passowrd';
|
||||||
static const restoreFromBackup = '/restore_from_backup';
|
static const restoreFromBackup = '/restore_from_backup';
|
||||||
|
|
|
@ -500,95 +500,6 @@ class SendPage extends BasePage {
|
||||||
actionRightButton: () async {
|
actionRightButton: () async {
|
||||||
Navigator.of(_dialogContext).pop();
|
Navigator.of(_dialogContext).pop();
|
||||||
sendViewModel.commitTransaction(context);
|
sendViewModel.commitTransaction(context);
|
||||||
await showPopUp<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext _dialogContext) {
|
|
||||||
return Observer(builder: (_) {
|
|
||||||
final state = sendViewModel.state;
|
|
||||||
|
|
||||||
if (state is FailureState) {
|
|
||||||
Navigator.of(_dialogContext).pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state is TransactionCommitted) {
|
|
||||||
newContactAddress =
|
|
||||||
newContactAddress ?? sendViewModel.newContactAddress();
|
|
||||||
|
|
||||||
if (sendViewModel.coinTypeToSpendFrom != UnspentCoinType.any) {
|
|
||||||
newContactAddress = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final successMessage = S.of(_dialogContext).send_success(
|
|
||||||
sendViewModel.selectedCryptoCurrency.toString());
|
|
||||||
|
|
||||||
final waitMessage = sendViewModel.walletType == WalletType.solana
|
|
||||||
? '. ${S.of(_dialogContext).waitFewSecondForTxUpdate}'
|
|
||||||
: '';
|
|
||||||
|
|
||||||
final newContactMessage = newContactAddress != null && sendViewModel.showAddressBookPopup
|
|
||||||
? '\n${S.of(_dialogContext).add_contact_to_address_book}'
|
|
||||||
: '';
|
|
||||||
|
|
||||||
String alertContent =
|
|
||||||
"$successMessage$waitMessage$newContactMessage";
|
|
||||||
|
|
||||||
if (newContactMessage.isNotEmpty) {
|
|
||||||
return AlertWithTwoActions(
|
|
||||||
alertDialogKey: ValueKey('send_page_sent_dialog_key'),
|
|
||||||
alertTitle: '',
|
|
||||||
alertContent: alertContent,
|
|
||||||
rightButtonText: S.of(_dialogContext).add_contact,
|
|
||||||
leftButtonText: S.of(_dialogContext).ignor,
|
|
||||||
alertLeftActionButtonKey:
|
|
||||||
ValueKey('send_page_sent_dialog_ignore_button_key'),
|
|
||||||
alertRightActionButtonKey: ValueKey(
|
|
||||||
'send_page_sent_dialog_add_contact_button_key'),
|
|
||||||
actionRightButton: () {
|
|
||||||
Navigator.of(_dialogContext).pop();
|
|
||||||
RequestReviewHandler.requestReview();
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
Routes.addressBookAddContact,
|
|
||||||
arguments: newContactAddress);
|
|
||||||
newContactAddress = null;
|
|
||||||
},
|
|
||||||
actionLeftButton: () {
|
|
||||||
Navigator.of(_dialogContext).pop();
|
|
||||||
RequestReviewHandler.requestReview();
|
|
||||||
newContactAddress = null;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (initialPaymentRequest?.callbackMessage?.isNotEmpty ??
|
|
||||||
false) {
|
|
||||||
alertContent = initialPaymentRequest!.callbackMessage!;
|
|
||||||
}
|
|
||||||
return AlertWithOneAction(
|
|
||||||
alertTitle: '',
|
|
||||||
alertContent: alertContent,
|
|
||||||
buttonText: S.of(_dialogContext).ok,
|
|
||||||
buttonAction: () {
|
|
||||||
Navigator.of(_dialogContext).pop();
|
|
||||||
RequestReviewHandler.requestReview();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Offstage();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (state is TransactionCommitted) {
|
|
||||||
if (initialPaymentRequest?.callbackUrl?.isNotEmpty ?? false) {
|
|
||||||
// wait a second so it's not as jarring:
|
|
||||||
await Future.delayed(Duration(seconds: 1));
|
|
||||||
try {
|
|
||||||
launchUrl(
|
|
||||||
Uri.parse(initialPaymentRequest!.callbackUrl!),
|
|
||||||
mode: LaunchMode.externalApplication,
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
printV(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
actionLeftButton: () => Navigator.of(_dialogContext).pop());
|
actionLeftButton: () => Navigator.of(_dialogContext).pop());
|
||||||
});
|
});
|
||||||
|
@ -597,7 +508,64 @@ class SendPage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state is TransactionCommitted) {
|
if (state is TransactionCommitted) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
|
|
||||||
|
final successMessage = S.of(context).send_success(
|
||||||
|
sendViewModel.selectedCryptoCurrency.toString());
|
||||||
|
|
||||||
|
final waitMessage = sendViewModel.walletType == WalletType.solana
|
||||||
|
? '. ${S.of(context).waitFewSecondForTxUpdate}'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
String alertContent = "$successMessage$waitMessage";
|
||||||
|
|
||||||
|
await Navigator.of(context).pushNamed(
|
||||||
|
Routes.transactionSuccessPage,
|
||||||
|
arguments: alertContent
|
||||||
|
);
|
||||||
|
|
||||||
|
newContactAddress = newContactAddress ?? sendViewModel.newContactAddress();
|
||||||
|
if (sendViewModel.coinTypeToSpendFrom != UnspentCoinType.any) newContactAddress = null;
|
||||||
|
|
||||||
|
if (newContactAddress != null && sendViewModel.showAddressBookPopup) {
|
||||||
|
await showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext _dialogContext) => AlertWithTwoActions(
|
||||||
|
alertDialogKey: ValueKey('send_page_sent_dialog_key'),
|
||||||
|
alertTitle: '',
|
||||||
|
alertContent: S.of(_dialogContext).add_contact_to_address_book,
|
||||||
|
rightButtonText: S.of(_dialogContext).add_contact,
|
||||||
|
leftButtonText: S.of(_dialogContext).ignor,
|
||||||
|
alertLeftActionButtonKey: ValueKey('send_page_sent_dialog_ignore_button_key'),
|
||||||
|
alertRightActionButtonKey:
|
||||||
|
ValueKey('send_page_sent_dialog_add_contact_button_key'),
|
||||||
|
actionRightButton: () {
|
||||||
|
Navigator.of(_dialogContext).pop();
|
||||||
|
RequestReviewHandler.requestReview();
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.addressBookAddContact, arguments: newContactAddress);
|
||||||
|
newContactAddress = null;
|
||||||
|
},
|
||||||
|
actionLeftButton: () {
|
||||||
|
Navigator.of(_dialogContext).pop();
|
||||||
|
RequestReviewHandler.requestReview();
|
||||||
|
newContactAddress = null;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initialPaymentRequest?.callbackUrl?.isNotEmpty ?? false) {
|
||||||
|
// wait a second so it's not as jarring:
|
||||||
|
await Future.delayed(Duration(seconds: 1));
|
||||||
|
try {
|
||||||
|
launchUrl(
|
||||||
|
Uri.parse(initialPaymentRequest!.callbackUrl!),
|
||||||
|
mode: LaunchMode.externalApplication,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
printV(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendViewModel.clearOutputs();
|
sendViewModel.clearOutputs();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
32
lib/src/screens/send/transaction_success_info_page.dart
Normal file
32
lib/src/screens/send/transaction_success_info_page.dart
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import 'package:cake_wallet/generated/i18n.dart';
|
||||||
|
import 'package:cake_wallet/src/screens/Info_page.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
|
class TransactionSuccessPage extends InfoPage {
|
||||||
|
TransactionSuccessPage({required this.content})
|
||||||
|
: super(
|
||||||
|
imageLightPath: 'assets/images/birthday_cake.png',
|
||||||
|
imageDarkPath: 'assets/images/birthday_cake.png',
|
||||||
|
);
|
||||||
|
|
||||||
|
final String content;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool get onWillPop => false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get pageTitle => 'Transaction Sent Successfully';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get pageDescription => content;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get buttonText => S.current.ok;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Key? get buttonKey => ValueKey('transaction_success_info_page_button_key');
|
||||||
|
|
||||||
|
@override
|
||||||
|
void Function(BuildContext) get onPressed =>
|
||||||
|
(BuildContext context) => Navigator.of(context).pop();
|
||||||
|
}
|
Loading…
Reference in a new issue