Merge branch 'CW-659-Automated-Integrated-Tests' of https://github.com/cake-tech/cake_wallet into CW-659-Restore-Wallets-Automated-Tests

This commit is contained in:
Blazebrain 2024-08-13 18:33:11 +01:00
commit 929c046868
2 changed files with 106 additions and 82 deletions

View file

@ -25,6 +25,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
import 'package:cake_wallet/entities/seed_type.dart';
class NewWalletPage extends BasePage {
NewWalletPage(this._walletNewVM, this._seedTypeViewModel);
@ -74,6 +75,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
_walletNewVM.hasWalletPassword ? TextEditingController() : null;
static const aspectRatioImage = 1.22;
static bool formProcessing = false;
final GlobalKey<FormState> _formKey;
final GlobalKey<SeedLanguageSelectorState> _languageSelectorKey;
@ -347,12 +349,16 @@ class _WalletNameFormState extends State<WalletNameForm> {
);
}
void _confirmForm() {
void _confirmForm() async {
if (formProcessing) return;
formProcessing = true;
try {
if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
formProcessing = false;
return;
}
if (_walletNewVM.nameExists(_walletNewVM.name)) {
showPopUp<void>(
await showPopUp<void>(
context: context,
builder: (_) {
return AlertWithOneAction(
@ -362,11 +368,16 @@ class _WalletNameFormState extends State<WalletNameForm> {
buttonAction: () => Navigator.of(context).pop());
});
} else {
_walletNewVM.create(
await _walletNewVM.create(
options: _walletNewVM.hasLanguageSelector
? [_languageSelectorKey.currentState!.selected, isPolyseed]
: null);
}
} catch (e) {
formProcessing = false;
rethrow;
}
formProcessing = false;
}
bool get isPolyseed => widget._seedTypeViewModel.moneroSeedType == SeedType.polyseed;

View file

@ -2,6 +2,7 @@ import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/new_wallet/new_wallet_page.dart';
import 'package:cake_wallet/src/screens/restore/wallet_restore_from_keys_form.dart';
import 'package:cake_wallet/src/screens/restore/wallet_restore_from_seed_form.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
@ -80,6 +81,8 @@ class WalletRestorePage extends BasePage {
});
}
static bool formProcessing = false;
@override
Widget middle(BuildContext context) => Observer(
builder: (_) => Text(
@ -352,6 +355,9 @@ class WalletRestorePage extends BasePage {
}
Future<void> _confirmForm(BuildContext context) async {
if (formProcessing) return;
formProcessing = true;
try {
// Dismissing all visible keyboard to provide context for navigation
FocusManager.instance.primaryFocus?.unfocus();
@ -369,11 +375,13 @@ class WalletRestorePage extends BasePage {
}
if (!formKey!.currentState!.validate()) {
formProcessing = false;
return;
}
if (walletRestoreViewModel.nameExists(name)) {
showNameExistsAlert(formContext!);
formProcessing = false;
return;
}
@ -420,7 +428,12 @@ class WalletRestorePage extends BasePage {
this.derivationInfo = walletRestoreViewModel.getDefaultDerivation();
}
walletRestoreViewModel.create(options: _credentials());
await walletRestoreViewModel.create(options: _credentials());
} catch (e) {
formProcessing = false;
rethrow;
}
formProcessing = false;
}
Future<void> showNameExistsAlert(BuildContext context) {