cake_wallet/lib/view_model/settings/security_settings_view_model.dart

42 lines
1.4 KiB
Dart
Raw Permalink Normal View History

2022-11-23 17:06:41 +00:00
import 'package:cake_wallet/entities/biometric_auth.dart';
2022-12-05 19:14:46 +00:00
import 'package:cake_wallet/entities/pin_code_required_duration.dart';
2022-11-23 17:06:41 +00:00
import 'package:cake_wallet/store/settings_store.dart';
import 'package:mobx/mobx.dart';
part 'security_settings_view_model.g.dart';
2022-12-01 19:21:51 +00:00
class SecuritySettingsViewModel = SecuritySettingsViewModelBase with _$SecuritySettingsViewModel;
2022-11-23 17:06:41 +00:00
abstract class SecuritySettingsViewModelBase with Store {
SecuritySettingsViewModelBase(this._settingsStore) : _biometricAuth = BiometricAuth();
2022-11-23 17:06:41 +00:00
final BiometricAuth _biometricAuth;
final SettingsStore _settingsStore;
2022-12-01 19:21:51 +00:00
2022-11-23 17:06:41 +00:00
@computed
2022-12-01 19:21:51 +00:00
bool get allowBiometricalAuthentication => _settingsStore.allowBiometricalAuthentication;
2022-11-23 17:06:41 +00:00
@computed
bool get useTotp2FA => _settingsStore.useTOTP2FA;
@computed
bool get shouldRequireTOTP2FAForAllSecurityAndBackupSettings =>
_settingsStore.shouldRequireTOTP2FAForAllSecurityAndBackupSettings;
2022-12-05 19:14:46 +00:00
@computed
PinCodeRequiredDuration get pinCodeRequiredDuration => _settingsStore.pinTimeOutDuration;
2022-11-23 17:06:41 +00:00
@action
2022-12-01 19:21:51 +00:00
Future<bool> biometricAuthenticated() async {
return await _biometricAuth.canCheckBiometrics() && await _biometricAuth.isAuthenticated();
2022-11-23 17:06:41 +00:00
}
@action
2022-12-05 19:14:46 +00:00
void setAllowBiometricalAuthentication(bool value) =>
_settingsStore.allowBiometricalAuthentication = value;
@action
void setPinCodeRequiredDuration(PinCodeRequiredDuration duration) =>
2022-12-05 19:14:46 +00:00
_settingsStore.pinTimeOutDuration = duration;
2022-12-01 19:21:51 +00:00
}