new option: Lock on Startup Only

This commit is contained in:
Fabian Freund
2026-07-07 17:58:30 +02:00
parent f902ad97fd
commit fde915826c
6 changed files with 19 additions and 3 deletions
@@ -41,7 +41,7 @@ final class TabRepositoryProvider
}
}
String _$tabRepositoryHash() => r'749b131347685933ac36a3afcdd49f7def7155a9';
String _$tabRepositoryHash() => r'e80c972b0d1a328c170354c123d2730028a774b2';
abstract class _$TabRepository extends $Notifier<void> {
void build();
@@ -41,7 +41,7 @@ final class TabDataRepositoryProvider
}
}
String _$tabDataRepositoryHash() => r'cb923fb0723271cd64d66a720dc3e1aed2d86c71';
String _$tabDataRepositoryHash() => r'adc1c664b492e41a96a0310d92252dbbacc1a089';
abstract class _$TabDataRepository extends $Notifier<void> {
void build();
@@ -23,7 +23,7 @@ import 'package:json_annotation/json_annotation.dart';
part 'auth_settings.g.dart';
enum AutoLockMode { background, timeout }
enum AutoLockMode { background, timeout, startup }
@CopyWith()
@JsonSerializable()
@@ -56,6 +56,10 @@ class AuthSettings with FastEquatable {
return copyWith(autoLockMode: AutoLockMode.timeout, timeout: value);
}
AuthSettings withStartupLock() {
return copyWith(autoLockMode: AutoLockMode.startup);
}
factory AuthSettings.fromJson(Map<String, dynamic> json) =>
_$AuthSettingsFromJson(json);
@@ -105,4 +105,5 @@ Map<String, dynamic> _$AuthSettingsToJson(AuthSettings instance) =>
const _$AutoLockModeEnumMap = {
AutoLockMode.background: 'background',
AutoLockMode.timeout: 'timeout',
AutoLockMode.startup: 'startup',
};
@@ -68,6 +68,7 @@ class ProfileEditScreen extends HookConsumerWidget {
.authenticate(
authKey: profileAccessAuthKey(profile!.id),
localizedReason: 'Require authentication for profile',
settings: authSettings,
);
if (!authResult) {
@@ -222,6 +223,14 @@ class _AuthSection extends StatelessWidget {
title: Text('Lock After Timeout'),
subtitle: Text('Lock after a period of inactivity'),
),
RadioListTile.adaptive(
value: AutoLockMode.startup,
title: Text('Lock on Startup Only'),
subtitle: Text(
'Unlock once when the app starts; stay unlocked '
'until the app is fully closed',
),
),
],
),
),
@@ -46,6 +46,8 @@ class LocalAuthenticationService extends _$LocalAuthenticationService {
}
// Background mode cache stays valid until app background eviction.
// Startup mode cache is never evicted, so it stays valid for the whole
// process lifetime.
return true;
}