diff --git a/lib/application/authentication/authentication.dart b/lib/application/authentication/authentication.dart index 301a217d4..dc5540c1f 100644 --- a/lib/application/authentication/authentication.dart +++ b/lib/application/authentication/authentication.dart @@ -5,6 +5,7 @@ import 'package:aewallet/application/utils.dart'; import 'package:aewallet/domain/models/authentication.dart'; import 'package:aewallet/domain/repositories/authentication.dart'; import 'package:aewallet/domain/usecases/authentication/authentication.dart'; +import 'package:aewallet/infrastructure/datasources/vault/vault.dart'; import 'package:aewallet/infrastructure/repositories/authentication.nonweb.dart'; import 'package:aewallet/infrastructure/repositories/authentication.web.dart'; import 'package:aewallet/model/authentication_method.dart'; diff --git a/lib/application/authentication/startup_authent.dart b/lib/application/authentication/startup_authent.dart index 6fa01910b..cf07077dc 100644 --- a/lib/application/authentication/startup_authent.dart +++ b/lib/application/authentication/startup_authent.dart @@ -149,6 +149,12 @@ class AuthenticationGuardNotifier return null; } + Future lock() async { + final vault = Vault.instance(); + await vault.lock(); + await vault.ensureVaultIsUnlocked(); + } + Future scheduleNextStartupAutolock() async { log( 'Schedule next startup Autolock', diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 34d5381dc..92f84e7da 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -82,6 +82,7 @@ "manage": "Manage", "invalidSeedPaste": "Pasted seed is not valid.", "unlockBiometrics": "Authenticate to Unlock", + "manualLockAction": "Lock Application", "lockAppSetting": "Activate auto lock", "locked": "Locked", "unlock": "Unlock", diff --git a/lib/l10n/intl_fr.arb b/lib/l10n/intl_fr.arb index 40e3adf68..f0d360284 100644 --- a/lib/l10n/intl_fr.arb +++ b/lib/l10n/intl_fr.arb @@ -82,6 +82,7 @@ "manage": "Gérer", "invalidSeedPaste": "La phrase secrète que vous souhaitez coller n'est pas valide.", "unlockBiometrics": "Authentifier pour déverrouiller", + "manualLockAction": "Verouiller l'application", "lockAppSetting": "Activation du verouillage auto", "locked": "Bloqué", "unlock": "Ouvrir", diff --git a/lib/ui/menu/settings/components/settings_list_item.dart b/lib/ui/menu/settings/components/settings_list_item.dart index 2fec06ca0..474141126 100644 --- a/lib/ui/menu/settings/components/settings_list_item.dart +++ b/lib/ui/menu/settings/components/settings_list_item.dart @@ -14,6 +14,7 @@ abstract class _SettingsListItem extends ConsumerWidget { required String heading, required TextStyle headingStyle, required IconData icon, + bool? displayChevron, VoidCallback? onPressed, }) = _SettingsListItemSingleLine; diff --git a/lib/ui/menu/settings/components/settings_list_item_singleline.dart b/lib/ui/menu/settings/components/settings_list_item_singleline.dart index 6991f954b..cc378774b 100644 --- a/lib/ui/menu/settings/components/settings_list_item_singleline.dart +++ b/lib/ui/menu/settings/components/settings_list_item_singleline.dart @@ -118,6 +118,7 @@ class _SettingsListItemSingleLine extends _SettingsListItem { required this.heading, required this.headingStyle, required this.icon, + this.displayChevron = true, this.onPressed, }); @@ -125,6 +126,7 @@ class _SettingsListItemSingleLine extends _SettingsListItem { final TextStyle headingStyle; final IconData icon; final VoidCallback? onPressed; + final bool? displayChevron; @override Widget build(BuildContext context, WidgetRef ref) { @@ -166,13 +168,14 @@ class _SettingsListItemSingleLine extends _SettingsListItem { ), ), const Spacer(), - Icon( - Symbols.chevron_right, - color: ArchethicTheme.iconDrawer, - weight: IconSize.weightM, - opticalSize: IconSize.opticalSizeM, - grade: IconSize.gradeM, - ), + if (displayChevron != null && displayChevron == true) + Icon( + Symbols.chevron_right, + color: ArchethicTheme.iconDrawer, + weight: IconSize.weightM, + opticalSize: IconSize.opticalSizeM, + grade: IconSize.gradeM, + ), ], ), ), diff --git a/lib/ui/menu/settings/main_settings_view.dart b/lib/ui/menu/settings/main_settings_view.dart index c0fec8e0b..3036ca299 100644 --- a/lib/ui/menu/settings/main_settings_view.dart +++ b/lib/ui/menu/settings/main_settings_view.dart @@ -130,6 +130,22 @@ class MainMenuView extends ConsumerWidget { ], ), const _SettingsListItem.spacer(), + _SettingsListItem.singleLine( + heading: localizations.manualLockAction, + headingStyle: + ArchethicThemeStyles.textStyleSize16W600Primary, + icon: Symbols.lock, + displayChevron: false, + onPressed: () { + ref + .read( + AuthenticationProviders + .authenticationGuard.notifier, + ) + .lock(); + }, + ), + const _SettingsListItem.spacer(), _SettingsListItem.title(text: localizations.information), const _SettingsListItem.spacer(), if (connectivityStatusProvider == diff --git a/lib/ui/views/authenticate/auto_lock_guard.dart b/lib/ui/views/authenticate/auto_lock_guard.dart index b6ee9c567..86cf7aa91 100644 --- a/lib/ui/views/authenticate/auto_lock_guard.dart +++ b/lib/ui/views/authenticate/auto_lock_guard.dart @@ -123,9 +123,9 @@ class _AutoLockGuardState extends ConsumerState timer = RestartableTimer( durationBeforeLock, () async { - final vault = Vault.instance(); - await vault.lock(); - await vault.ensureVaultIsUnlocked(); + await ref + .read(AuthenticationProviders.authenticationGuard.notifier) + .lock(); }, ); }