diff --git a/catalyst_voices/apps/voices/lib/configs/bootstrap.dart b/catalyst_voices/apps/voices/lib/configs/bootstrap.dart index cd9c386c5fb..3c5b9a0a97e 100644 --- a/catalyst_voices/apps/voices/lib/configs/bootstrap.dart +++ b/catalyst_voices/apps/voices/lib/configs/bootstrap.dart @@ -88,6 +88,8 @@ Future bootstrap() async { GoRouter.optionURLReflectsImperativeAPIs = true; setPathUrlStrategy(); + await Dependencies.instance.init(); + final router = AppRouter.init( guards: const [ MilestoneGuard(), @@ -96,8 +98,6 @@ Future bootstrap() async { Bloc.observer = AppBlocObserver(); - await Dependencies.instance.init(); - return BootstrapArgs(routerConfig: router); } diff --git a/catalyst_voices/apps/voices/lib/pages/account/account_page.dart b/catalyst_voices/apps/voices/lib/pages/account/account_page.dart index c08b4fed1c3..c288bbfaaf8 100644 --- a/catalyst_voices/apps/voices/lib/pages/account/account_page.dart +++ b/catalyst_voices/apps/voices/lib/pages/account/account_page.dart @@ -4,10 +4,10 @@ import 'package:catalyst_voices/common/ext/account_role_ext.dart'; import 'package:catalyst_voices/pages/account/account_page_header.dart'; import 'package:catalyst_voices/pages/account/delete_keychain_dialog.dart'; import 'package:catalyst_voices/pages/account/keychain_deleted_dialog.dart'; +import 'package:catalyst_voices/routes/routes.dart'; import 'package:catalyst_voices/widgets/buttons/voices_icon_button.dart'; import 'package:catalyst_voices/widgets/buttons/voices_text_button.dart'; import 'package:catalyst_voices/widgets/list/bullet_list.dart'; -import 'package:catalyst_voices/widgets/modals/voices_dialog.dart'; import 'package:catalyst_voices_assets/catalyst_voices_assets.dart'; import 'package:catalyst_voices_blocs/catalyst_voices_blocs.dart'; import 'package:catalyst_voices_brands/catalyst_voices_brands.dart'; @@ -16,9 +16,14 @@ import 'package:catalyst_voices_models/catalyst_voices_models.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -final class AccountPage extends StatelessWidget { +final class AccountPage extends StatefulWidget { const AccountPage({super.key}); + @override + State createState() => _AccountPageState(); +} + +class _AccountPageState extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -44,7 +49,7 @@ final class AccountPage extends StatelessWidget { AccountRole.drep, ], defaultRole: AccountRole.voter, - onRemoveKeychain: () => unawaited(_removeKeychain(context)), + onRemoveKeychain: () => unawaited(_removeKeychain()), ), ], ), @@ -55,19 +60,22 @@ final class AccountPage extends StatelessWidget { ); } - // Note. probably should redirect somewhere. - Future _removeKeychain(BuildContext context) async { + Future _removeKeychain() async { final confirmed = await DeleteKeychainDialog.show(context); + if (!confirmed) { + return; + } - if (confirmed && context.mounted) { - unawaited(context.read().removeKeychain()); + if (mounted) { + await context.read().removeKeychain(); + } + + if (mounted) { + await KeychainDeletedDialog.show(context); + } - await VoicesDialog.show( - context: context, - builder: (context) { - return const KeychainDeletedDialog(); - }, - ); + if (mounted) { + const DiscoveryRoute().go(context); } } } diff --git a/catalyst_voices/apps/voices/lib/pages/account/delete_keychain_dialog.dart b/catalyst_voices/apps/voices/lib/pages/account/delete_keychain_dialog.dart index d8645dcec12..bfb3a7e89b0 100644 --- a/catalyst_voices/apps/voices/lib/pages/account/delete_keychain_dialog.dart +++ b/catalyst_voices/apps/voices/lib/pages/account/delete_keychain_dialog.dart @@ -9,14 +9,12 @@ import 'package:catalyst_voices_localization/catalyst_voices_localization.dart'; import 'package:flutter/material.dart'; class DeleteKeychainDialog extends StatefulWidget { - const DeleteKeychainDialog({ - super.key, - }); + const DeleteKeychainDialog._(); static Future show(BuildContext context) async { final result = await VoicesDialog.show( context: context, - builder: (context) => const DeleteKeychainDialog(), + builder: (context) => const DeleteKeychainDialog._(), ); return result ?? false; diff --git a/catalyst_voices/apps/voices/lib/pages/account/keychain_deleted_dialog.dart b/catalyst_voices/apps/voices/lib/pages/account/keychain_deleted_dialog.dart index 76671de82c1..eaf1145e3d8 100644 --- a/catalyst_voices/apps/voices/lib/pages/account/keychain_deleted_dialog.dart +++ b/catalyst_voices/apps/voices/lib/pages/account/keychain_deleted_dialog.dart @@ -1,11 +1,17 @@ -import 'package:catalyst_voices/widgets/buttons/voices_filled_button.dart'; -import 'package:catalyst_voices/widgets/modals/voices_desktop_dialog.dart'; +import 'package:catalyst_voices/widgets/widgets.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 KeychainDeletedDialog extends StatelessWidget { - const KeychainDeletedDialog({super.key}); + const KeychainDeletedDialog._(); + + static Future show(BuildContext context) { + return VoicesDialog.show( + context: context, + builder: (context) => const KeychainDeletedDialog._(), + ); + } @override Widget build(BuildContext context) { diff --git a/catalyst_voices/apps/voices/lib/routes/app_router.dart b/catalyst_voices/apps/voices/lib/routes/app_router.dart index 54eeefd38ed..5fb2fa2623d 100644 --- a/catalyst_voices/apps/voices/lib/routes/app_router.dart +++ b/catalyst_voices/apps/voices/lib/routes/app_router.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:catalyst_voices/routes/guards/route_guard.dart'; +import 'package:catalyst_voices/routes/routes.dart'; import 'package:catalyst_voices/routes/routing/routes.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -13,6 +14,7 @@ abstract final class AppRouter { static GoRouter init({ List guards = const [], + Listenable? refreshListenable, }) { return GoRouter( navigatorKey: _rootNavigatorKey, @@ -21,6 +23,7 @@ abstract final class AppRouter { observers: [ SentryNavigatorObserver(), ], + refreshListenable: refreshListenable, routes: Routes.routes, // always true. We're deciding whether to print // them or not in LoggingService @@ -28,16 +31,15 @@ abstract final class AppRouter { ); } - static FutureOr _guard( + static Future _guard( BuildContext context, GoRouterState state, List guards, ) async { for (final guard in guards) { - final redirect = await guard.redirect(context, state); - - if (redirect != null) { - return redirect; + final location = await guard.redirect(context, state); + if (location != null) { + return location; } } diff --git a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart index 97407e607c5..f4e0147a5a0 100644 --- a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart +++ b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations.dart @@ -1348,22 +1348,22 @@ abstract class VoicesLocalizations { /// **'Dark'** String get themeDark; - /// A title on keychain deleted dialog + /// No description provided for @keychainDeletedDialogTitle. /// /// In en, this message translates to: /// **'Catalyst keychain removed'** String get keychainDeletedDialogTitle; - /// A subtitle on keychain deleted dialog + /// No description provided for @keychainDeletedDialogSubtitle. /// /// In en, this message translates to: - /// **'Catalyst keychain removed'** + /// **'Your Catalyst Keychain is removed successfully from this device.'** String get keychainDeletedDialogSubtitle; - /// An info on keychain deleted dialog + /// No description provided for @keychainDeletedDialogInfo. /// /// In en, this message translates to: - /// **'Catalyst keychain removed'** + /// **'We reverted this device to Catalyst first use.'** String get keychainDeletedDialogInfo; /// No description provided for @registrationCompletedTitle. diff --git a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart index b35c281e55b..345aef42d7a 100644 --- a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart +++ b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_en.dart @@ -717,10 +717,10 @@ class VoicesLocalizationsEn extends VoicesLocalizations { String get keychainDeletedDialogTitle => 'Catalyst keychain removed'; @override - String get keychainDeletedDialogSubtitle => 'Catalyst keychain removed'; + String get keychainDeletedDialogSubtitle => 'Your Catalyst Keychain is removed successfully from this device.'; @override - String get keychainDeletedDialogInfo => 'Catalyst keychain removed'; + String get keychainDeletedDialogInfo => 'We reverted this device to Catalyst first use.'; @override String get registrationCompletedTitle => 'Catalyst account setup'; diff --git a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart index fb7b6d95846..d14cd878643 100644 --- a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart +++ b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/generated/catalyst_voices_localizations_es.dart @@ -717,10 +717,10 @@ class VoicesLocalizationsEs extends VoicesLocalizations { String get keychainDeletedDialogTitle => 'Catalyst keychain removed'; @override - String get keychainDeletedDialogSubtitle => 'Catalyst keychain removed'; + String get keychainDeletedDialogSubtitle => 'Your Catalyst Keychain is removed successfully from this device.'; @override - String get keychainDeletedDialogInfo => 'Catalyst keychain removed'; + String get keychainDeletedDialogInfo => 'We reverted this device to Catalyst first use.'; @override String get registrationCompletedTitle => 'Catalyst account setup'; diff --git a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/l10n/intl_en.arb b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/l10n/intl_en.arb index 5c8841c5260..fa5e3dc116b 100644 --- a/catalyst_voices/packages/internal/catalyst_voices_localization/lib/l10n/intl_en.arb +++ b/catalyst_voices/packages/internal/catalyst_voices_localization/lib/l10n/intl_en.arb @@ -812,17 +812,8 @@ "description": "Refers to a dark theme mode." }, "keychainDeletedDialogTitle": "Catalyst keychain removed", - "@keychainDeletedDialogTitle": { - "description": "A title on keychain deleted dialog" - }, - "keychainDeletedDialogSubtitle": "Catalyst keychain removed", - "@keychainDeletedDialogSubtitle": { - "description": "A subtitle on keychain deleted dialog" - }, - "keychainDeletedDialogInfo": "Catalyst keychain removed", - "@keychainDeletedDialogInfo": { - "description": "An info on keychain deleted dialog" - }, + "keychainDeletedDialogSubtitle": "Your Catalyst Keychain is removed successfully from this device.", + "keychainDeletedDialogInfo": "We reverted this device to Catalyst first use.", "registrationCompletedTitle": "Catalyst account setup", "registrationCompletedSubtitle": "Completed!", "registrationCompletedSummaryHeader": "Summary",