mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-04 04:06:34 +00:00
Update security settings view model
This commit is contained in:
parent
65cbdd3fbb
commit
23358e1318
2 changed files with 19 additions and 3 deletions
|
@ -434,7 +434,7 @@ Future setup(
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.registerFactory(() {
|
getIt.registerFactory(() {
|
||||||
return SecuritySettingsViewModel(getIt.get<SettingsStore>());
|
return SecuritySettingsViewModel(getIt.get<SettingsStore>(), getIt.get<AuthService>());
|
||||||
});
|
});
|
||||||
|
|
||||||
getIt.registerFactory(() => WalletSeedViewModel(getIt.get<AppStore>().wallet!));
|
getIt.registerFactory(() => WalletSeedViewModel(getIt.get<AppStore>().wallet!));
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
import 'package:cake_wallet/core/auth_service.dart';
|
||||||
import 'package:cake_wallet/entities/biometric_auth.dart';
|
import 'package:cake_wallet/entities/biometric_auth.dart';
|
||||||
|
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
|
||||||
|
@ -7,19 +9,33 @@ part 'security_settings_view_model.g.dart';
|
||||||
class SecuritySettingsViewModel = SecuritySettingsViewModelBase with _$SecuritySettingsViewModel;
|
class SecuritySettingsViewModel = SecuritySettingsViewModelBase with _$SecuritySettingsViewModel;
|
||||||
|
|
||||||
abstract class SecuritySettingsViewModelBase with Store {
|
abstract class SecuritySettingsViewModelBase with Store {
|
||||||
SecuritySettingsViewModelBase(this._settingsStore) : _biometricAuth = BiometricAuth();
|
SecuritySettingsViewModelBase(
|
||||||
|
this._settingsStore,
|
||||||
|
this._authService,
|
||||||
|
) : _biometricAuth = BiometricAuth();
|
||||||
|
|
||||||
final BiometricAuth _biometricAuth;
|
final BiometricAuth _biometricAuth;
|
||||||
final SettingsStore _settingsStore;
|
final SettingsStore _settingsStore;
|
||||||
|
final AuthService _authService;
|
||||||
|
|
||||||
@computed
|
@computed
|
||||||
bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication;
|
bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication;
|
||||||
|
|
||||||
|
@computed
|
||||||
|
PinCodeRequiredDuration get pinCodeRequiredDuration => _settingsStore.pinTimeOutDuration;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
Future<bool> biometricAuthenticated() async {
|
Future<bool> biometricAuthenticated() async {
|
||||||
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
|
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
void setAllowBiometricalAuthentication(bool value) => _settingsStore.allowBiometricalAuthentication = value;
|
void setAllowBiometricalAuthentication(bool value) =>
|
||||||
|
_settingsStore.allowBiometricalAuthentication = value;
|
||||||
|
|
||||||
|
@action
|
||||||
|
setPinCodeRequiredDuration(PinCodeRequiredDuration duration) =>
|
||||||
|
_settingsStore.pinTimeOutDuration = duration;
|
||||||
|
|
||||||
|
bool checkPinCodeRiquired() => _authService.requireAuth();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue