cake_wallet/lib/view_model/settings/security_settings_view_model.dart

26 lines
905 B
Dart
Raw Normal View History

2022-11-23 17:06:41 +00:00
import 'package:cake_wallet/entities/biometric_auth.dart';
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 {
2022-12-01 19:21:51 +00:00
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
@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-01 19:21:51 +00:00
void setAllowBiometricalAuthentication(bool value) => _settingsStore.allowBiometricalAuthentication = value;
}