From 8ddb9b03a8fe31d81354a18837038ab54faa480d Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Wed, 16 Oct 2024 15:16:56 +0200 Subject: [PATCH 01/10] feat: Upload SeedPhrase --- .../stage/seed_phrase_check_panel.dart | 8 +- .../seed_phrase/seed_phrase_input_panel.dart | 8 +- .../show_upload_confirmation_dialog.dart | 133 ++++++++++++++++++ .../assets/images/2.0x/key_incorrect.webp | Bin 0 -> 5280 bytes .../assets/images/3.0x/key_incorrect.webp | Bin 0 -> 10990 bytes .../assets/images/key_incorrect.webp | Bin 0 -> 1946 bytes .../lib/generated/assets.gen.dart | 5 + 7 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart create mode 100644 catalyst_voices/packages/catalyst_voices_assets/assets/images/2.0x/key_incorrect.webp create mode 100644 catalyst_voices/packages/catalyst_voices_assets/assets/images/3.0x/key_incorrect.webp create mode 100644 catalyst_voices/packages/catalyst_voices_assets/assets/images/key_incorrect.webp diff --git a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart index d2698b84a30..cacd58d986c 100644 --- a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart +++ b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart @@ -1,4 +1,5 @@ import 'package:catalyst_voices/pages/registration/create_keychain/bloc_seed_phrase_builder.dart'; +import 'package:catalyst_voices/pages/registration/show_upload_confirmation_dialog.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_navigation.dart'; import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.dart'; import 'package:catalyst_voices/widgets/widgets.dart'; @@ -38,7 +39,12 @@ class _SeedPhraseCheckPanelState extends State { } Future _uploadSeedPhrase() async { - // TODO(damian-molinski): open upload dialog + await showUploadConfirmationDialog( + context, + onUploadSuccessful: (words) { + _onWordsSequenceChanged(words); + }, + ); } void _clearUserWords() { diff --git a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart index 761f5d5a80f..435336f383d 100644 --- a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart +++ b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:catalyst_voices/pages/registration/recover/bloc_recover_builder.dart'; +import 'package:catalyst_voices/pages/registration/show_upload_confirmation_dialog.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_message.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_navigation.dart'; import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.dart'; @@ -78,7 +79,12 @@ class _SeedPhraseInputPanelState extends State { } Future _uploadSeedPhrase() async { - // TODO(damian-molinski): Import implementation for KeychainCreation + await showUploadConfirmationDialog( + context, + onUploadSuccessful: (words) { + RegistrationCubit.of(context).recover.setSeedPhraseWords(words); + }, + ); } void _resetControllerWords() { diff --git a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart new file mode 100644 index 00000000000..5aadab33913 --- /dev/null +++ b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart @@ -0,0 +1,133 @@ +import 'dart:convert'; + +import 'package:catalyst_voices/widgets/avatars/voices_avatar.dart'; +import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart'; +import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; +import 'package:catalyst_voices/widgets/modals/voices_alert_dialog.dart'; +import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; +import 'package:catalyst_voices/widgets/modals/voices_upload_file_dialog.dart'; +import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; +import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; +import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; +import 'package:catalyst_voices_models/catalyst_voices_models.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; + +Future showUploadConfirmationDialog( + BuildContext rootContext, { + ValueChanged>? onUploadSuccessful, +}) async { + await VoicesDialog.show( + context: rootContext, + builder: (context) { + return VoicesAlertDialog( + title: const Text('ALERT'), + icon: VoicesAvatar( + radius: 40, + backgroundColor: Colors.transparent, + icon: VoicesAssets.icons.exclamation.buildIcon( + size: 36, + color: Theme.of(context).colors.iconsError, + ), + border: Border.all( + color: Theme.of(context).colors.iconsError!, + width: 3, + ), + ), + subtitle: const Text('SWITCH TO FILE UPLOAD'), + content: const Text( + 'Do you want to cancel manual input, and switch to Catalyst key upload?', + ), + buttons: [ + VoicesFilledButton( + child: const Text('Yes, switch to Catalyst key upload'), + onTap: () async { + Navigator.of(context).pop(); + await _showUploadDialog(rootContext, onUploadSuccessful); + }, + ), + VoicesTextButton( + child: const Text('Resume manual input'), + onTap: () => Navigator.of(context).pop(), + ), + ], + ); + }, + ); +} + +Future _showUploadDialog( + BuildContext rootContext, + ValueChanged>? onUploadSuccessful, +) async { + await VoicesUploadFileDialog.show( + rootContext, + title: rootContext.l10n.uploadKeychainTitle, + itemNameToUpload: rootContext.l10n.key, + info: rootContext.l10n.uploadKeychainInfo, + allowedExtensions: ['txt'], + onUpload: (file) async { + final bytes = file.bytes; + final decodedText = utf8.decode(bytes); + final words = decodedText + .split(' ') + .mapIndexed((i, e) => SeedPhraseWord(e, nr: i)) + .toList(); + final isValid = SeedPhrase.isValid( + words: words, + ); + + if (isValid) { + onUploadSuccessful?.call(words); + } else { + Navigator.of(rootContext).pop(); + await _showIncorrectUploadDialog( + rootContext, + onUploadSuccessful, + ); + } + }, + onCancel: () => debugPrint( + 'onCancel, we can cancel upload here', + ), + ); +} + +Future _showIncorrectUploadDialog( + BuildContext rootContext, + ValueChanged>? onUploadSuccessful, +) async { + await VoicesDialog.show( + context: rootContext, + builder: (context) { + return VoicesAlertDialog( + title: const Text('WARNING'), + icon: CatalystImage.asset( + VoicesAssets.images.keyIncorrect.path, + width: 80, + height: 80, + ), + subtitle: const Text('CATALYST KEY INCORRECT'), + content: const Text( + 'The Catalyst keychain that you entered or uploaded is incorrect, please try again.', + ), + buttons: [ + VoicesFilledButton( + child: const Text('Try again'), + onTap: () async { + Navigator.of(context).pop(); + await _showUploadDialog( + rootContext, + onUploadSuccessful, + ); + }, + ), + VoicesTextButton( + child: const Text('Cancel'), + onTap: () => Navigator.of(context).pop(), + ), + ], + ); + }, + ); +} diff --git a/catalyst_voices/packages/catalyst_voices_assets/assets/images/2.0x/key_incorrect.webp b/catalyst_voices/packages/catalyst_voices_assets/assets/images/2.0x/key_incorrect.webp new file mode 100644 index 0000000000000000000000000000000000000000..d8e2154b6890096766932a19a0f433aa6b150ce7 GIT binary patch literal 5280 zcmV;R6kqF7Nk&GP6aWBMMM6+kP&iDB6aWA($3QX=$G|p{d+|z6eHbBsua9e~6pYYmdSy0670o?|lE4HV^^B=-MLRcA!C5T_IMh}FrtGj2u zVac}Jwvm&lH*X90CoYzar_YsDE6=5MBGQ7|Z#7kE`-30Ma;dIF`u(eq3d? zN8c16T0iY)7W{=1z*j~GTP`Tz5~OyaZzpAtMItIKh?J`rS zRsi{rtdl$ZSo2Nuu?LV4kE)rrF6j?-f3((}c$)zXA+BOXuN;cz+ zy=z#h|0<6ohf&36ls%m7uceUfNBs?-Dz>N$dH7JkPtf%mK7Rq7#300?zit#d0pdhF zc8a%B4PY*-t9Z*7K0X(S@mZ$P8Fc4V2bg=8Rc3a=ddv3YVyNA8b1mR~x$I(`t}}(a z>td4qJs}*$DxgPNLop`0SWhq*E#9m&PyoU3iACo?O znSr^)Haa``gj^){m?Uu4Y3ca&Ssr^;pWkzyv#g44uZu5UA*7Hi9U?y{EWVF_Rl)aM zjbdd1Osp>bjYSN)>%SNC^CbW^WO^fT)d6PYXRqR zO4RhRd^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zRAA8iv_lrVAh>KITNnF$=L`@&nD4UIs}~@^-Q(Hn9;gS&Tu0DQf{-l?)i)5Yf%0zW zW{+iopw6ep$`6_BQezyoO=NFrqNe6Wv`1j>=N%xK4#!C23T41!a6GVID@f47wL*bl zC+6AL-%_R!!XOl8$^^j)sN(FEx72;pM!d?b)yc393)yNK;PHxYI)kvz>V^YRaKZL2 z7TAV2GR9kfH5wD^WjTHov|vqA=zdvvMXW`?M83f0z9(x*!3i9WNjj7$BGwDU04ND- zr)(knRmcMtpm+E#$t3QrI5C<}G`Xu&CEu~}s;PCm)FwFs_ioH#OjcK}xJm8B0u7ex zl5L@H<8RR>4hT>NcJ)HZjA&53@X?T)d;gMJ#U*u%*n-p+Gpv;w1|=_Ma?^2_JVA;| zH+O~JT`H5$$>!FlyIotiaGSfg?v%1iNtwF$Zo0CXuBVi#SR|LP6OVl%%oK}gJCa2w z!ieTVi9x@5j94Qe>4F<`L;fbkI0>?n-5ZxC_Z6Ngv{ddwVtDwu^sHE0C7ne!Jli)B zmG+smUb-=9zud%_iIb>)1aQ67Tl>Ar8+TFfZ^piS;qG>e*TQauQCC|`2HDpYa00CR zkSGKy;9YFoqz1Wum`J9uCnXo|_6osTgEl7u>tUXwarH4exZrgQD;MX{bT z)sM+bn2@8k-+>Y1Aw+(MpTzd|4&+tfMy(MhNiOXfM(}W(A%m@sk?)hO-%ZbL;06-c zi%U1c?=n<-g@GudHy3jWgSELE)U~_8R+&)r0F-gC9K8%S%&X1mUNniX@i*bW(&7cN cs4NOoRdq&)-g%&w_UePs_sb>m^M5oi0ElbV+5i9m literal 0 HcmV?d00001 diff --git a/catalyst_voices/packages/catalyst_voices_assets/assets/images/key_incorrect.webp b/catalyst_voices/packages/catalyst_voices_assets/assets/images/key_incorrect.webp new file mode 100644 index 0000000000000000000000000000000000000000..8b28554c5dcfb40ca88685a559345b5937333527 GIT binary patch literal 1946 zcmV;L2W9wDNk&GJ2LJ$9MM6+kP&iD52LJ#sWB?fu7r~&BBt^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n~%vQ<^jc_LlAgtDKqGb6Qvu<2qEt(*fI|n2Ti0ez_!)%SyrZxJs&! zUQ*JfHgU_sc^jLg22I@!r-ctgQV?s0;V$i?*b*2yxWxT-uIi~D&$qjz{F?@1azV-H z*F3p`rLZJzFqnU$AA9204~OGrsjEowDbHV1K!&N5EE6$E0^Dl8x8i*FDbW4}QWvF7 z#{NpcduBA1)V#UG0+?3kMogyQYXV(mBE_HM$RHZzMxqvK6 zQXrG0_A;JAF}Y1m(Q3(c)E`htxYeG@n5RFnHx}dP3fI!yc z#gwxxaJxjO0$m_7Br!%lZ}Z`crx{u)(GAoLoZT9+=Ml$D$~jRScmpTzB*wzFse?9C zZh|ytCg3?Ujz^W1vS8M>S<&pif`BY1ky}bEE7L7i$*Ktih@?@K8xn<6urjHrn)eCS zD3yDy>0o5Yq5 const SvgGenImage('assets/images/fallback_logo_icon.svg'); + /// File path: assets/images/key_incorrect.webp + AssetGenImage get keyIncorrect => + const AssetGenImage('assets/images/key_incorrect.webp'); + /// File path: assets/images/keychain.svg SvgGenImage get keychain => const SvgGenImage('assets/images/keychain.svg'); @@ -1285,6 +1289,7 @@ class $AssetsImagesGen { facebookMono, fallbackLogo, fallbackLogoIcon, + keyIncorrect, keychain, linkedin, linkedinMono, From 1b8e5070b3a4b6fd2969d73971856da1f5020a2c Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Wed, 16 Oct 2024 16:33:36 +0200 Subject: [PATCH 02/10] feat: Upload SeedPhrase - translations --- .../show_upload_confirmation_dialog.dart | 27 +++++------ .../catalyst_voices_localizations.dart | 48 +++++++++++++++++++ .../catalyst_voices_localizations_en.dart | 24 ++++++++++ .../catalyst_voices_localizations_es.dart | 24 ++++++++++ .../lib/l10n/intl_en.arb | 10 +++- 5 files changed, 116 insertions(+), 17 deletions(-) diff --git a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart index 5aadab33913..144dab64582 100644 --- a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart +++ b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart @@ -21,7 +21,7 @@ Future showUploadConfirmationDialog( context: rootContext, builder: (context) { return VoicesAlertDialog( - title: const Text('ALERT'), + title: Text(context.l10n.alert.toUpperCase()), icon: VoicesAvatar( radius: 40, backgroundColor: Colors.transparent, @@ -34,20 +34,18 @@ Future showUploadConfirmationDialog( width: 3, ), ), - subtitle: const Text('SWITCH TO FILE UPLOAD'), - content: const Text( - 'Do you want to cancel manual input, and switch to Catalyst key upload?', - ), + subtitle: Text(context.l10n.uploadConfirmDialogSubtitle), + content: Text(context.l10n.uploadConfirmDialogContent), buttons: [ VoicesFilledButton( - child: const Text('Yes, switch to Catalyst key upload'), + child: Text(context.l10n.uploadConfirmDialogYesButton), onTap: () async { Navigator.of(context).pop(); await _showUploadDialog(rootContext, onUploadSuccessful); }, ), VoicesTextButton( - child: const Text('Resume manual input'), + child: Text(context.l10n.uploadConfirmDialogResumeButton), onTap: () => Navigator.of(context).pop(), ), ], @@ -87,9 +85,6 @@ Future _showUploadDialog( ); } }, - onCancel: () => debugPrint( - 'onCancel, we can cancel upload here', - ), ); } @@ -101,19 +96,19 @@ Future _showIncorrectUploadDialog( context: rootContext, builder: (context) { return VoicesAlertDialog( - title: const Text('WARNING'), + title: Text(context.l10n.warning.toUpperCase()), icon: CatalystImage.asset( VoicesAssets.images.keyIncorrect.path, width: 80, height: 80, ), - subtitle: const Text('CATALYST KEY INCORRECT'), - content: const Text( - 'The Catalyst keychain that you entered or uploaded is incorrect, please try again.', + subtitle: Text(context.l10n.incorrectUploadDialogSubtitle), + content: Text( + context.l10n.incorrectUploadDialogContent, ), buttons: [ VoicesFilledButton( - child: const Text('Try again'), + child: Text(context.l10n.incorrectUploadDialogTryAgainButton), onTap: () async { Navigator.of(context).pop(); await _showUploadDialog( @@ -123,7 +118,7 @@ Future _showIncorrectUploadDialog( }, ), VoicesTextButton( - child: const Text('Cancel'), + child: Text(context.l10n.cancelButtonText), onTap: () => Navigator.of(context).pop(), ), ], diff --git a/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart b/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart index c3c0f2037aa..b4ecc6d7c4e 100644 --- a/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart +++ b/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart @@ -1606,6 +1606,12 @@ abstract class VoicesLocalizations { /// **'Warning'** String get warning; + /// No description provided for @alert. + /// + /// In en, this message translates to: + /// **'Alert'** + String get alert; + /// No description provided for @registrationExitConfirmDialogSubtitle. /// /// In en, this message translates to: @@ -1773,6 +1779,48 @@ abstract class VoicesLocalizations { /// In en, this message translates to: /// **'Continue recovery process'** String get recoveryExitConfirmDialogContinue; + + /// No description provided for @uploadConfirmDialogSubtitle. + /// + /// In en, this message translates to: + /// **'SWITCH TO FILE UPLOAD'** + String get uploadConfirmDialogSubtitle; + + /// No description provided for @uploadConfirmDialogContent. + /// + /// In en, this message translates to: + /// **'Do you want to cancel manual input, and switch to Catalyst key upload?'** + String get uploadConfirmDialogContent; + + /// No description provided for @uploadConfirmDialogYesButton. + /// + /// In en, this message translates to: + /// **'Yes, switch to Catalyst key upload'** + String get uploadConfirmDialogYesButton; + + /// No description provided for @uploadConfirmDialogResumeButton. + /// + /// In en, this message translates to: + /// **'Resume manual inputs'** + String get uploadConfirmDialogResumeButton; + + /// No description provided for @incorrectUploadDialogSubtitle. + /// + /// In en, this message translates to: + /// **'CATALYST KEY INCORRECT'** + String get incorrectUploadDialogSubtitle; + + /// No description provided for @incorrectUploadDialogContent. + /// + /// In en, this message translates to: + /// **'The Catalyst keychain that you entered or uploaded is incorrect, please try again.'** + String get incorrectUploadDialogContent; + + /// No description provided for @incorrectUploadDialogTryAgainButton. + /// + /// In en, this message translates to: + /// **'Try again'** + String get incorrectUploadDialogTryAgainButton; } class _VoicesLocalizationsDelegate extends LocalizationsDelegate { diff --git a/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart b/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart index b3457c1ea51..9ad764343e5 100644 --- a/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart +++ b/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart @@ -848,6 +848,9 @@ class VoicesLocalizationsEn extends VoicesLocalizations { @override String get warning => 'Warning'; + @override + String get alert => 'Alert'; + @override String get registrationExitConfirmDialogSubtitle => 'Account creation incomplete!'; @@ -931,4 +934,25 @@ class VoicesLocalizationsEn extends VoicesLocalizations { @override String get recoveryExitConfirmDialogContinue => 'Continue recovery process'; + + @override + String get uploadConfirmDialogSubtitle => 'SWITCH TO FILE UPLOAD'; + + @override + String get uploadConfirmDialogContent => 'Do you want to cancel manual input, and switch to Catalyst key upload?'; + + @override + String get uploadConfirmDialogYesButton => 'Yes, switch to Catalyst key upload'; + + @override + String get uploadConfirmDialogResumeButton => 'Resume manual inputs'; + + @override + String get incorrectUploadDialogSubtitle => 'CATALYST KEY INCORRECT'; + + @override + String get incorrectUploadDialogContent => 'The Catalyst keychain that you entered or uploaded is incorrect, please try again.'; + + @override + String get incorrectUploadDialogTryAgainButton => 'Try again'; } diff --git a/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart b/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart index 9c23eb5e9e6..d549c024ad6 100644 --- a/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart +++ b/catalyst_voices/packages/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart @@ -848,6 +848,9 @@ class VoicesLocalizationsEs extends VoicesLocalizations { @override String get warning => 'Warning'; + @override + String get alert => 'Alert'; + @override String get registrationExitConfirmDialogSubtitle => 'Account creation incomplete!'; @@ -931,4 +934,25 @@ class VoicesLocalizationsEs extends VoicesLocalizations { @override String get recoveryExitConfirmDialogContinue => 'Continue recovery process'; + + @override + String get uploadConfirmDialogSubtitle => 'SWITCH TO FILE UPLOAD'; + + @override + String get uploadConfirmDialogContent => 'Do you want to cancel manual input, and switch to Catalyst key upload?'; + + @override + String get uploadConfirmDialogYesButton => 'Yes, switch to Catalyst key upload'; + + @override + String get uploadConfirmDialogResumeButton => 'Resume manual inputs'; + + @override + String get incorrectUploadDialogSubtitle => 'CATALYST KEY INCORRECT'; + + @override + String get incorrectUploadDialogContent => 'The Catalyst keychain that you entered or uploaded is incorrect, please try again.'; + + @override + String get incorrectUploadDialogTryAgainButton => 'Try again'; } diff --git a/catalyst_voices/packages/catalyst_voices_localization/lib/l10n/intl_en.arb b/catalyst_voices/packages/catalyst_voices_localization/lib/l10n/intl_en.arb index 9d49d04bbc9..3459b24df39 100644 --- a/catalyst_voices/packages/catalyst_voices_localization/lib/l10n/intl_en.arb +++ b/catalyst_voices/packages/catalyst_voices_localization/lib/l10n/intl_en.arb @@ -887,6 +887,7 @@ "description": "When user confirms password but it does not match original one." }, "warning": "Warning", + "alert": "Alert", "registrationExitConfirmDialogSubtitle": "Account creation incomplete!", "registrationExitConfirmDialogContent": "If attempt to leave without creating your keychain - account creation will be incomplete. \u2028\u2028You are not able to login without \u2028completing your keychain.", "registrationExitConfirmDialogContinue": "Continue keychain creation", @@ -914,5 +915,12 @@ "recoverySuccessGoAccount": "Check my account", "recoveryExitConfirmDialogSubtitle": "12 word keychain restoration incomplete", "recoveryExitConfirmDialogContent": "Please continue your Catalyst Keychain restoration, if you cancel all input will be lost.", - "recoveryExitConfirmDialogContinue": "Continue recovery process" + "recoveryExitConfirmDialogContinue": "Continue recovery process", + "uploadConfirmDialogSubtitle": "SWITCH TO FILE UPLOAD", + "uploadConfirmDialogContent": "Do you want to cancel manual input, and switch to Catalyst key upload?", + "uploadConfirmDialogYesButton": "Yes, switch to Catalyst key upload", + "uploadConfirmDialogResumeButton": "Resume manual inputs", + "incorrectUploadDialogSubtitle": "CATALYST KEY INCORRECT", + "incorrectUploadDialogContent": "The Catalyst keychain that you entered or uploaded is incorrect, please try again.", + "incorrectUploadDialogTryAgainButton": "Try again" } \ No newline at end of file From d453e583613a705194aba6a6535ea6cbcddf7cc5 Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Thu, 17 Oct 2024 11:40:01 +0200 Subject: [PATCH 03/10] feat: Upload SeedPhrase - fix index --- .../lib/pages/registration/show_upload_confirmation_dialog.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart index 144dab64582..32c6c72407b 100644 --- a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart +++ b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart @@ -69,7 +69,7 @@ Future _showUploadDialog( final decodedText = utf8.decode(bytes); final words = decodedText .split(' ') - .mapIndexed((i, e) => SeedPhraseWord(e, nr: i)) + .mapIndexed((i, e) => SeedPhraseWord(e, nr: i + 1)) .toList(); final isValid = SeedPhrase.isValid( words: words, From 21bc01af8ced5484eff5f965527066dee8d4663a Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Thu, 17 Oct 2024 12:20:32 +0200 Subject: [PATCH 04/10] feat: Upload SeedPhrase - fix recovery flow --- .../recover/seed_phrase/seed_phrase_input_panel.dart | 2 +- .../lib/widgets/text_field/seed_phrase_field.dart | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart index 435336f383d..f53d5463851 100644 --- a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart +++ b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart @@ -82,7 +82,7 @@ class _SeedPhraseInputPanelState extends State { await showUploadConfirmationDialog( context, onUploadSuccessful: (words) { - RegistrationCubit.of(context).recover.setSeedPhraseWords(words); + _controller.words = words; }, ); } diff --git a/catalyst_voices/lib/widgets/text_field/seed_phrase_field.dart b/catalyst_voices/lib/widgets/text_field/seed_phrase_field.dart index 524f22b3655..22319666c03 100644 --- a/catalyst_voices/lib/widgets/text_field/seed_phrase_field.dart +++ b/catalyst_voices/lib/widgets/text_field/seed_phrase_field.dart @@ -12,6 +12,14 @@ final class SeedPhraseFieldController extends ValueNotifier> { SeedPhraseFieldController([super._value = const []]); + set words(List words) { + value = words; + } + + List get words { + return value; + } + void clear() { value = const []; } From 3c2f48d28f6f0c983f597f083cf5ed4be7f00fd2 Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Thu, 17 Oct 2024 13:34:29 +0200 Subject: [PATCH 05/10] feat: Upload SeedPhrase - better validation for seedphrase --- .../stage/seed_phrase_check_panel.dart | 14 ++++++++++++-- .../seed_phrase/seed_phrase_input_panel.dart | 6 ++++++ .../show_upload_confirmation_dialog.dart | 15 +++++++++++---- .../cubits/keychain_creation_cubit.dart | 7 +++++++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart index cacd58d986c..a5f1d4ddcd8 100644 --- a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart +++ b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart @@ -41,8 +41,18 @@ class _SeedPhraseCheckPanelState extends State { Future _uploadSeedPhrase() async { await showUploadConfirmationDialog( context, - onUploadSuccessful: (words) { - _onWordsSequenceChanged(words); + onUploadSuccessful: _onWordsSequenceChanged, + onValidate: (words) { + final shuffledWords = + RegistrationCubit.of(context).keychainCreation.getShuffledWords(); + final mappedWords = words.map((e) => e.data).toList()..sort(); + final mappedShuffledWords = shuffledWords.map((e) => e.data).toList() + ..sort(); + + return (mappedWords.toString() == mappedShuffledWords.toString()) && + SeedPhrase.isValid( + words: words, + ); }, ); } diff --git a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart index f53d5463851..a36eb32f49e 100644 --- a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart +++ b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart @@ -8,6 +8,7 @@ import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.d import 'package:catalyst_voices/widgets/widgets.dart'; import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart'; import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; +import 'package:catalyst_voices_models/catalyst_voices_models.dart'; import 'package:flutter/material.dart'; class SeedPhraseInputPanel extends StatefulWidget { @@ -84,6 +85,11 @@ class _SeedPhraseInputPanelState extends State { onUploadSuccessful: (words) { _controller.words = words; }, + onValidate: (words) { + return SeedPhrase.isValid( + words: words, + ); + }, ); } diff --git a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart index 32c6c72407b..abeb7ac42a0 100644 --- a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart +++ b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart @@ -16,6 +16,7 @@ import 'package:flutter/material.dart'; Future showUploadConfirmationDialog( BuildContext rootContext, { ValueChanged>? onUploadSuccessful, + bool Function(List value)? onValidate, }) async { await VoicesDialog.show( context: rootContext, @@ -41,7 +42,11 @@ Future showUploadConfirmationDialog( child: Text(context.l10n.uploadConfirmDialogYesButton), onTap: () async { Navigator.of(context).pop(); - await _showUploadDialog(rootContext, onUploadSuccessful); + await _showUploadDialog( + rootContext, + onUploadSuccessful, + onValidate, + ); }, ), VoicesTextButton( @@ -57,6 +62,7 @@ Future showUploadConfirmationDialog( Future _showUploadDialog( BuildContext rootContext, ValueChanged>? onUploadSuccessful, + bool Function(List value)? onValidate, ) async { await VoicesUploadFileDialog.show( rootContext, @@ -71,9 +77,7 @@ Future _showUploadDialog( .split(' ') .mapIndexed((i, e) => SeedPhraseWord(e, nr: i + 1)) .toList(); - final isValid = SeedPhrase.isValid( - words: words, - ); + final isValid = onValidate?.call(words) ?? false; if (isValid) { onUploadSuccessful?.call(words); @@ -82,6 +86,7 @@ Future _showUploadDialog( await _showIncorrectUploadDialog( rootContext, onUploadSuccessful, + onValidate, ); } }, @@ -91,6 +96,7 @@ Future _showUploadDialog( Future _showIncorrectUploadDialog( BuildContext rootContext, ValueChanged>? onUploadSuccessful, + bool Function(List value)? onValidate, ) async { await VoicesDialog.show( context: rootContext, @@ -114,6 +120,7 @@ Future _showIncorrectUploadDialog( await _showUploadDialog( rootContext, onUploadSuccessful, + onValidate, ); }, ), diff --git a/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart b/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart index 1d280e53b77..daa19eadea7 100644 --- a/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart +++ b/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart @@ -26,6 +26,8 @@ abstract interface class KeychainCreationManager Future downloadSeedPhrase(); + List getShuffledWords(); + Future createKeychain(); } @@ -169,4 +171,9 @@ final class KeychainCreationCubit extends Cubit _buildSeedPhrase(); } } + + @override + List getShuffledWords() { + return state.seedPhraseStateData.shuffledWords; + } } From c2e2e2876bd43c565dc9e3548e1db5f49fd50dbc Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Thu, 17 Oct 2024 14:33:18 +0200 Subject: [PATCH 06/10] feat: Upload SeedPhrase - areWordsMatching function in cubit --- .../create_keychain/stage/seed_phrase_check_panel.dart | 10 ++++------ .../registration/cubits/keychain_creation_cubit.dart | 10 +++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart index a5f1d4ddcd8..598e9cd3611 100644 --- a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart +++ b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart @@ -43,13 +43,11 @@ class _SeedPhraseCheckPanelState extends State { context, onUploadSuccessful: _onWordsSequenceChanged, onValidate: (words) { - final shuffledWords = - RegistrationCubit.of(context).keychainCreation.getShuffledWords(); - final mappedWords = words.map((e) => e.data).toList()..sort(); - final mappedShuffledWords = shuffledWords.map((e) => e.data).toList() - ..sort(); + final areWordsMatching = RegistrationCubit.of(context) + .keychainCreation + .areWordsMatching(words); - return (mappedWords.toString() == mappedShuffledWords.toString()) && + return areWordsMatching && SeedPhrase.isValid( words: words, ); diff --git a/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart b/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart index daa19eadea7..733dc01ccdf 100644 --- a/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart +++ b/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart @@ -26,7 +26,7 @@ abstract interface class KeychainCreationManager Future downloadSeedPhrase(); - List getShuffledWords(); + bool areWordsMatching(List words); Future createKeychain(); } @@ -173,7 +173,11 @@ final class KeychainCreationCubit extends Cubit } @override - List getShuffledWords() { - return state.seedPhraseStateData.shuffledWords; + bool areWordsMatching(List words) { + final mappedWords = words.map((e) => e.data).toList()..sort(); + final mappedShuffledWords = + _seedPhraseStateData.shuffledWords.map((e) => e.data).toList()..sort(); + + return mappedWords.toString() == mappedShuffledWords.toString(); } } From e8b4680f30b13e3a0c7e866fd196c51462329298 Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Fri, 18 Oct 2024 12:21:32 +0200 Subject: [PATCH 07/10] feat: Upload SeedPhrase - use listEquals --- .../lib/src/registration/cubits/keychain_creation_cubit.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart b/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart index 733dc01ccdf..be96390c77e 100644 --- a/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart +++ b/catalyst_voices/packages/catalyst_voices_blocs/lib/src/registration/cubits/keychain_creation_cubit.dart @@ -178,6 +178,6 @@ final class KeychainCreationCubit extends Cubit final mappedShuffledWords = _seedPhraseStateData.shuffledWords.map((e) => e.data).toList()..sort(); - return mappedWords.toString() == mappedShuffledWords.toString(); + return listEquals(mappedWords, mappedShuffledWords); } } From 622913a8a4faf7860a676e4bf09aa52c9ed262ef Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Fri, 18 Oct 2024 13:10:11 +0200 Subject: [PATCH 08/10] feat: Upload SeedPhrase - change dialogs pattern --- .../stage/seed_phrase_check_panel.dart | 45 ++++-- .../incorrect_seedphrase_dialog.dart | 48 +++++++ .../seed_phrase/seed_phrase_input_panel.dart | 36 +++-- .../show_upload_confirmation_dialog.dart | 135 ------------------ ...upload_seedphrase_confirmation_dialog.dart | 55 +++++++ .../upload_seedphrase_dialog.dart | 32 +++++ 6 files changed, 190 insertions(+), 161 deletions(-) create mode 100644 catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart delete mode 100644 catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart create mode 100644 catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart create mode 100644 catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart diff --git a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart index 598e9cd3611..8a374dc689f 100644 --- a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart +++ b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart @@ -1,5 +1,7 @@ import 'package:catalyst_voices/pages/registration/create_keychain/bloc_seed_phrase_builder.dart'; -import 'package:catalyst_voices/pages/registration/show_upload_confirmation_dialog.dart'; +import 'package:catalyst_voices/pages/registration/incorrect_seedphrase_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seedphrase_confirmation_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seedphrase_dialog.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_navigation.dart'; import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.dart'; import 'package:catalyst_voices/widgets/widgets.dart'; @@ -39,20 +41,33 @@ class _SeedPhraseCheckPanelState extends State { } Future _uploadSeedPhrase() async { - await showUploadConfirmationDialog( - context, - onUploadSuccessful: _onWordsSequenceChanged, - onValidate: (words) { - final areWordsMatching = RegistrationCubit.of(context) - .keychainCreation - .areWordsMatching(words); - - return areWordsMatching && - SeedPhrase.isValid( - words: words, - ); - }, - ); + final showUpload = await UploadSeedphraseConfirmationDialog.show(context); + if (showUpload) { + await _showUploadDialog(); + } + } + + Future _showUploadDialog() async { + final words = await UploadSeedphraseDialog.show(context); + + if (!mounted) return; + + final areWordsMatching = + RegistrationCubit.of(context).keychainCreation.areWordsMatching(words); + + final isValid = areWordsMatching && + SeedPhrase.isValid( + words: words, + ); + + if (isValid) { + _onWordsSequenceChanged(words); + } else { + final showUpload = await IncorrectSeedphraseDialog.show(context); + if (showUpload) { + await _showUploadDialog(); + } + } } void _clearUserWords() { diff --git a/catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart b/catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart new file mode 100644 index 00000000000..66f37f2876e --- /dev/null +++ b/catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart @@ -0,0 +1,48 @@ +import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart'; +import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; +import 'package:catalyst_voices/widgets/modals/voices_alert_dialog.dart'; +import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; +import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; +import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; +import 'package:flutter/material.dart'; + +class IncorrectSeedphraseDialog extends StatelessWidget { + const IncorrectSeedphraseDialog({ + super.key, + }); + + static Future show(BuildContext context) async { + final result = await VoicesDialog.show( + context: context, + builder: (context) => const IncorrectSeedphraseDialog(), + ); + + return result ?? false; + } + + @override + Widget build(BuildContext context) { + return VoicesAlertDialog( + title: Text(context.l10n.warning.toUpperCase()), + icon: CatalystImage.asset( + VoicesAssets.images.keyIncorrect.path, + width: 80, + height: 80, + ), + subtitle: Text(context.l10n.incorrectUploadDialogSubtitle), + content: Text( + context.l10n.incorrectUploadDialogContent, + ), + buttons: [ + VoicesFilledButton( + child: Text(context.l10n.incorrectUploadDialogTryAgainButton), + onTap: () => Navigator.of(context).pop(true), + ), + VoicesTextButton( + child: Text(context.l10n.cancelButtonText), + onTap: () => Navigator.of(context).pop(false), + ), + ], + ); + } +} diff --git a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart index a36eb32f49e..a5d6722588f 100644 --- a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart +++ b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart @@ -1,7 +1,9 @@ import 'dart:async'; +import 'package:catalyst_voices/pages/registration/incorrect_seedphrase_dialog.dart'; import 'package:catalyst_voices/pages/registration/recover/bloc_recover_builder.dart'; -import 'package:catalyst_voices/pages/registration/show_upload_confirmation_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seedphrase_confirmation_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seedphrase_dialog.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_message.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_navigation.dart'; import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.dart'; @@ -80,17 +82,29 @@ class _SeedPhraseInputPanelState extends State { } Future _uploadSeedPhrase() async { - await showUploadConfirmationDialog( - context, - onUploadSuccessful: (words) { - _controller.words = words; - }, - onValidate: (words) { - return SeedPhrase.isValid( - words: words, - ); - }, + final showUpload = await UploadSeedphraseConfirmationDialog.show(context); + if (showUpload) { + await _showUploadDialog(); + } + } + + Future _showUploadDialog() async { + final words = await UploadSeedphraseDialog.show(context); + + final isValid = SeedPhrase.isValid( + words: words, ); + + if (isValid) { + _controller.words = words; + } else { + if (!mounted) return; + + final showUpload = await IncorrectSeedphraseDialog.show(context); + if (showUpload) { + await _showUploadDialog(); + } + } } void _resetControllerWords() { diff --git a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart deleted file mode 100644 index abeb7ac42a0..00000000000 --- a/catalyst_voices/lib/pages/registration/show_upload_confirmation_dialog.dart +++ /dev/null @@ -1,135 +0,0 @@ -import 'dart:convert'; - -import 'package:catalyst_voices/widgets/avatars/voices_avatar.dart'; -import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart'; -import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; -import 'package:catalyst_voices/widgets/modals/voices_alert_dialog.dart'; -import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; -import 'package:catalyst_voices/widgets/modals/voices_upload_file_dialog.dart'; -import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; -import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; -import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; -import 'package:catalyst_voices_models/catalyst_voices_models.dart'; -import 'package:collection/collection.dart'; -import 'package:flutter/material.dart'; - -Future showUploadConfirmationDialog( - BuildContext rootContext, { - ValueChanged>? onUploadSuccessful, - bool Function(List value)? onValidate, -}) async { - await VoicesDialog.show( - context: rootContext, - builder: (context) { - return VoicesAlertDialog( - title: Text(context.l10n.alert.toUpperCase()), - icon: VoicesAvatar( - radius: 40, - backgroundColor: Colors.transparent, - icon: VoicesAssets.icons.exclamation.buildIcon( - size: 36, - color: Theme.of(context).colors.iconsError, - ), - border: Border.all( - color: Theme.of(context).colors.iconsError!, - width: 3, - ), - ), - subtitle: Text(context.l10n.uploadConfirmDialogSubtitle), - content: Text(context.l10n.uploadConfirmDialogContent), - buttons: [ - VoicesFilledButton( - child: Text(context.l10n.uploadConfirmDialogYesButton), - onTap: () async { - Navigator.of(context).pop(); - await _showUploadDialog( - rootContext, - onUploadSuccessful, - onValidate, - ); - }, - ), - VoicesTextButton( - child: Text(context.l10n.uploadConfirmDialogResumeButton), - onTap: () => Navigator.of(context).pop(), - ), - ], - ); - }, - ); -} - -Future _showUploadDialog( - BuildContext rootContext, - ValueChanged>? onUploadSuccessful, - bool Function(List value)? onValidate, -) async { - await VoicesUploadFileDialog.show( - rootContext, - title: rootContext.l10n.uploadKeychainTitle, - itemNameToUpload: rootContext.l10n.key, - info: rootContext.l10n.uploadKeychainInfo, - allowedExtensions: ['txt'], - onUpload: (file) async { - final bytes = file.bytes; - final decodedText = utf8.decode(bytes); - final words = decodedText - .split(' ') - .mapIndexed((i, e) => SeedPhraseWord(e, nr: i + 1)) - .toList(); - final isValid = onValidate?.call(words) ?? false; - - if (isValid) { - onUploadSuccessful?.call(words); - } else { - Navigator.of(rootContext).pop(); - await _showIncorrectUploadDialog( - rootContext, - onUploadSuccessful, - onValidate, - ); - } - }, - ); -} - -Future _showIncorrectUploadDialog( - BuildContext rootContext, - ValueChanged>? onUploadSuccessful, - bool Function(List value)? onValidate, -) async { - await VoicesDialog.show( - context: rootContext, - builder: (context) { - return VoicesAlertDialog( - title: Text(context.l10n.warning.toUpperCase()), - icon: CatalystImage.asset( - VoicesAssets.images.keyIncorrect.path, - width: 80, - height: 80, - ), - subtitle: Text(context.l10n.incorrectUploadDialogSubtitle), - content: Text( - context.l10n.incorrectUploadDialogContent, - ), - buttons: [ - VoicesFilledButton( - child: Text(context.l10n.incorrectUploadDialogTryAgainButton), - onTap: () async { - Navigator.of(context).pop(); - await _showUploadDialog( - rootContext, - onUploadSuccessful, - onValidate, - ); - }, - ), - VoicesTextButton( - child: Text(context.l10n.cancelButtonText), - onTap: () => Navigator.of(context).pop(), - ), - ], - ); - }, - ); -} diff --git a/catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart new file mode 100644 index 00000000000..e6189fd19c7 --- /dev/null +++ b/catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart @@ -0,0 +1,55 @@ +import 'package:catalyst_voices/widgets/avatars/voices_avatar.dart'; +import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart'; +import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; +import 'package:catalyst_voices/widgets/modals/voices_alert_dialog.dart'; +import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; +import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; +import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; +import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; +import 'package:flutter/material.dart'; + +class UploadSeedphraseConfirmationDialog extends StatelessWidget { + const UploadSeedphraseConfirmationDialog({ + super.key, + }); + + static Future show(BuildContext context) async { + final result = await VoicesDialog.show( + context: context, + builder: (context) => const UploadSeedphraseConfirmationDialog(), + ); + + return result ?? false; + } + + @override + Widget build(BuildContext context) { + return VoicesAlertDialog( + title: Text(context.l10n.alert.toUpperCase()), + icon: VoicesAvatar( + radius: 40, + backgroundColor: Colors.transparent, + icon: VoicesAssets.icons.exclamation.buildIcon( + size: 36, + color: Theme.of(context).colors.iconsError, + ), + border: Border.all( + color: Theme.of(context).colors.iconsError!, + width: 3, + ), + ), + subtitle: Text(context.l10n.uploadConfirmDialogSubtitle), + content: Text(context.l10n.uploadConfirmDialogContent), + buttons: [ + VoicesFilledButton( + child: Text(context.l10n.uploadConfirmDialogYesButton), + onTap: () => Navigator.of(context).pop(true), + ), + VoicesTextButton( + child: Text(context.l10n.uploadConfirmDialogResumeButton), + onTap: () => Navigator.of(context).pop(false), + ), + ], + ); + } +} diff --git a/catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart b/catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart new file mode 100644 index 00000000000..fee7db6b691 --- /dev/null +++ b/catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart @@ -0,0 +1,32 @@ +import 'dart:convert'; + +import 'package:catalyst_voices/widgets/modals/voices_upload_file_dialog.dart'; +import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; +import 'package:catalyst_voices_models/catalyst_voices_models.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; + +class UploadSeedphraseDialog { + static Future> show(BuildContext rootContext) async { + final file = await VoicesUploadFileDialog.show( + rootContext, + title: rootContext.l10n.uploadKeychainTitle, + itemNameToUpload: rootContext.l10n.key, + info: rootContext.l10n.uploadKeychainInfo, + allowedExtensions: ['txt'], + ); + + final bytes = file?.bytes; + if (bytes != null) { + final decodedText = utf8.decode(bytes); + final words = decodedText + .split(' ') + .mapIndexed((i, e) => SeedPhraseWord(e, nr: i + 1)) + .toList(); + + return words; + } else { + return []; + } + } +} From d771e6338bc4c0a7533042ce35bbd763f4f4b794 Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Fri, 18 Oct 2024 15:06:51 +0200 Subject: [PATCH 09/10] feat: Upload SeedPhrase - seed phrase, separate words --- .../stage/seed_phrase_check_panel.dart | 12 ++++++------ ...dialog.dart => incorrect_seed_phrase_dialog.dart} | 6 +++--- .../recover/seed_phrase/seed_phrase_input_panel.dart | 12 ++++++------ ...t => upload_seed_phrase_confirmation_dialog.dart} | 6 +++--- ...se_dialog.dart => upload_seed_phrase_dialog.dart} | 12 ++++++------ 5 files changed, 24 insertions(+), 24 deletions(-) rename catalyst_voices/lib/pages/registration/{incorrect_seedphrase_dialog.dart => incorrect_seed_phrase_dialog.dart} (90%) rename catalyst_voices/lib/pages/registration/{upload_seedphrase_confirmation_dialog.dart => upload_seed_phrase_confirmation_dialog.dart} (91%) rename catalyst_voices/lib/pages/registration/{upload_seedphrase_dialog.dart => upload_seed_phrase_dialog.dart} (72%) diff --git a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart index 8a374dc689f..d876a49f50f 100644 --- a/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart +++ b/catalyst_voices/lib/pages/registration/create_keychain/stage/seed_phrase_check_panel.dart @@ -1,7 +1,7 @@ import 'package:catalyst_voices/pages/registration/create_keychain/bloc_seed_phrase_builder.dart'; -import 'package:catalyst_voices/pages/registration/incorrect_seedphrase_dialog.dart'; -import 'package:catalyst_voices/pages/registration/upload_seedphrase_confirmation_dialog.dart'; -import 'package:catalyst_voices/pages/registration/upload_seedphrase_dialog.dart'; +import 'package:catalyst_voices/pages/registration/incorrect_seed_phrase_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seed_phrase_confirmation_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seed_phrase_dialog.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_navigation.dart'; import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.dart'; import 'package:catalyst_voices/widgets/widgets.dart'; @@ -41,14 +41,14 @@ class _SeedPhraseCheckPanelState extends State { } Future _uploadSeedPhrase() async { - final showUpload = await UploadSeedphraseConfirmationDialog.show(context); + final showUpload = await UploadSeedPhraseConfirmationDialog.show(context); if (showUpload) { await _showUploadDialog(); } } Future _showUploadDialog() async { - final words = await UploadSeedphraseDialog.show(context); + final words = await UploadSeedPhraseDialog.show(context); if (!mounted) return; @@ -63,7 +63,7 @@ class _SeedPhraseCheckPanelState extends State { if (isValid) { _onWordsSequenceChanged(words); } else { - final showUpload = await IncorrectSeedphraseDialog.show(context); + final showUpload = await IncorrectSeedPhraseDialog.show(context); if (showUpload) { await _showUploadDialog(); } diff --git a/catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart b/catalyst_voices/lib/pages/registration/incorrect_seed_phrase_dialog.dart similarity index 90% rename from catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart rename to catalyst_voices/lib/pages/registration/incorrect_seed_phrase_dialog.dart index 66f37f2876e..f0657ca805f 100644 --- a/catalyst_voices/lib/pages/registration/incorrect_seedphrase_dialog.dart +++ b/catalyst_voices/lib/pages/registration/incorrect_seed_phrase_dialog.dart @@ -6,15 +6,15 @@ import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; import 'package:flutter/material.dart'; -class IncorrectSeedphraseDialog extends StatelessWidget { - const IncorrectSeedphraseDialog({ +class IncorrectSeedPhraseDialog extends StatelessWidget { + const IncorrectSeedPhraseDialog({ super.key, }); static Future show(BuildContext context) async { final result = await VoicesDialog.show( context: context, - builder: (context) => const IncorrectSeedphraseDialog(), + builder: (context) => const IncorrectSeedPhraseDialog(), ); return result ?? false; diff --git a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart index a5d6722588f..1201bca3880 100644 --- a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart +++ b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart @@ -1,9 +1,9 @@ import 'dart:async'; -import 'package:catalyst_voices/pages/registration/incorrect_seedphrase_dialog.dart'; +import 'package:catalyst_voices/pages/registration/incorrect_seed_phrase_dialog.dart'; import 'package:catalyst_voices/pages/registration/recover/bloc_recover_builder.dart'; -import 'package:catalyst_voices/pages/registration/upload_seedphrase_confirmation_dialog.dart'; -import 'package:catalyst_voices/pages/registration/upload_seedphrase_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seed_phrase_confirmation_dialog.dart'; +import 'package:catalyst_voices/pages/registration/upload_seed_phrase_dialog.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_message.dart'; import 'package:catalyst_voices/pages/registration/widgets/registration_stage_navigation.dart'; import 'package:catalyst_voices/pages/registration/widgets/seed_phrase_actions.dart'; @@ -82,14 +82,14 @@ class _SeedPhraseInputPanelState extends State { } Future _uploadSeedPhrase() async { - final showUpload = await UploadSeedphraseConfirmationDialog.show(context); + final showUpload = await UploadSeedPhraseConfirmationDialog.show(context); if (showUpload) { await _showUploadDialog(); } } Future _showUploadDialog() async { - final words = await UploadSeedphraseDialog.show(context); + final words = await UploadSeedPhraseDialog.show(context); final isValid = SeedPhrase.isValid( words: words, @@ -100,7 +100,7 @@ class _SeedPhraseInputPanelState extends State { } else { if (!mounted) return; - final showUpload = await IncorrectSeedphraseDialog.show(context); + final showUpload = await IncorrectSeedPhraseDialog.show(context); if (showUpload) { await _showUploadDialog(); } diff --git a/catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart b/catalyst_voices/lib/pages/registration/upload_seed_phrase_confirmation_dialog.dart similarity index 91% rename from catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart rename to catalyst_voices/lib/pages/registration/upload_seed_phrase_confirmation_dialog.dart index e6189fd19c7..d5fec619e9e 100644 --- a/catalyst_voices/lib/pages/registration/upload_seedphrase_confirmation_dialog.dart +++ b/catalyst_voices/lib/pages/registration/upload_seed_phrase_confirmation_dialog.dart @@ -8,15 +8,15 @@ import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; import 'package:flutter/material.dart'; -class UploadSeedphraseConfirmationDialog extends StatelessWidget { - const UploadSeedphraseConfirmationDialog({ +class UploadSeedPhraseConfirmationDialog extends StatelessWidget { + const UploadSeedPhraseConfirmationDialog({ super.key, }); static Future show(BuildContext context) async { final result = await VoicesDialog.show( context: context, - builder: (context) => const UploadSeedphraseConfirmationDialog(), + builder: (context) => const UploadSeedPhraseConfirmationDialog(), ); return result ?? false; diff --git a/catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart b/catalyst_voices/lib/pages/registration/upload_seed_phrase_dialog.dart similarity index 72% rename from catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart rename to catalyst_voices/lib/pages/registration/upload_seed_phrase_dialog.dart index fee7db6b691..83a88c2e541 100644 --- a/catalyst_voices/lib/pages/registration/upload_seedphrase_dialog.dart +++ b/catalyst_voices/lib/pages/registration/upload_seed_phrase_dialog.dart @@ -6,13 +6,13 @@ import 'package:catalyst_voices_models/catalyst_voices_models.dart'; import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; -class UploadSeedphraseDialog { - static Future> show(BuildContext rootContext) async { +class UploadSeedPhraseDialog { + static Future> show(BuildContext context) async { final file = await VoicesUploadFileDialog.show( - rootContext, - title: rootContext.l10n.uploadKeychainTitle, - itemNameToUpload: rootContext.l10n.key, - info: rootContext.l10n.uploadKeychainInfo, + context, + title: context.l10n.uploadKeychainTitle, + itemNameToUpload: context.l10n.key, + info: context.l10n.uploadKeychainInfo, allowedExtensions: ['txt'], ); From 0f0631fbcff1249187dac032e22623afea968f7a Mon Sep 17 00:00:00 2001 From: digitalheartxs Date: Mon, 21 Oct 2024 10:06:34 +0200 Subject: [PATCH 10/10] feat: Upload SeedPhrase - check if (!mounted) --- .../recover/seed_phrase/seed_phrase_input_panel.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart index 1201bca3880..007fa5d297a 100644 --- a/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart +++ b/catalyst_voices/lib/pages/registration/recover/seed_phrase/seed_phrase_input_panel.dart @@ -95,11 +95,11 @@ class _SeedPhraseInputPanelState extends State { words: words, ); - if (isValid) { + if (!mounted) { + return; + } else if (isValid) { _controller.words = words; } else { - if (!mounted) return; - final showUpload = await IncorrectSeedPhraseDialog.show(context); if (showUpload) { await _showUploadDialog();