Update security settings view model
Godwin Asuquo committed
Dec 5, 2022 at 13:38 UTC
23358e131876b4f4535e3074492da83df9fc1c2d
2 files changed
+19
-3
lib/di.dart
+1
-1
@@ -434,7 +434,7 @@ Future setup(
434
});
435
436
getIt.registerFactory(() {
437
- return SecuritySettingsViewModel(getIt.get<SettingsStore>());
437
+ return SecuritySettingsViewModel(getIt.get<SettingsStore>(), getIt.get<AuthService>());
438
});
439
440
getIt.registerFactory(() => WalletSeedViewModel(getIt.get<AppStore>().wallet!));
lib/view_model/settings/security_settings_view_model.dart
+18
-2
@@ -1,4 +1,6 @@
1
+import 'package:cake_wallet/core/auth_service.dart';
2
import 'package:cake_wallet/entities/biometric_auth.dart';
3
+import 'package:cake_wallet/entities/pin_code_required_duration.dart';
4
import 'package:cake_wallet/store/settings_store.dart';
5
import 'package:mobx/mobx.dart';
6
@@ -7,19 +9,33 @@ part 'security_settings_view_model.g.dart';
9
class SecuritySettingsViewModel = SecuritySettingsViewModelBase with _$SecuritySettingsViewModel;
10
11
abstract class SecuritySettingsViewModelBase with Store {
10
- SecuritySettingsViewModelBase(this._settingsStore) : _biometricAuth = BiometricAuth();
12
+ SecuritySettingsViewModelBase(
13
+ this._settingsStore,
14
+ this._authService,
15
+ ) : _biometricAuth = BiometricAuth();
16
17
final BiometricAuth _biometricAuth;
18
final SettingsStore _settingsStore;
19
+ final AuthService _authService;
20
21
@computed
22
bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication;
23
24
+ @computed
25
+ PinCodeRequiredDuration get pinCodeRequiredDuration => _settingsStore.pinTimeOutDuration;
26
+
27
@action
28
Future<bool> biometricAuthenticated() async {
29
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
30
}
31
32
@action
24
- void setAllowBiometricalAuthentication(bool value) => _settingsStore.allowBiometricalAuthentication = value;
33
+ void setAllowBiometricalAuthentication(bool value) =>
34
+ _settingsStore.allowBiometricalAuthentication = value;
35
+
36
+ @action
37
+ setPinCodeRequiredDuration(PinCodeRequiredDuration duration) =>
38
+ _settingsStore.pinTimeOutDuration = duration;
39
+
40
+ bool checkPinCodeRiquired() => _authService.requireAuth();
41
}