mirror of
https://github.com/MoxiFoxi411/QuickSSH.git
synced 2026-11-08 19:34:55 +00:00
Added ads
This commit is contained in:
1 parent
eed999d2ab
commit
7c47298cd7
13 files changed
+258
-29
No files matched your search
@@ -1,25 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
|
||||
class SettingsController extends ChangeNotifier {
|
||||
bool _vibrationEnabled = true;
|
||||
bool get vibrationEnabled => _vibrationEnabled;
|
||||
|
||||
bool _biometricEnabled = false;
|
||||
bool get biometricEnabled => _biometricEnabled;
|
||||
|
||||
bool _adsEnabled = true;
|
||||
bool get adsEnabled => _adsEnabled;
|
||||
|
||||
final LocalAuthentication auth = LocalAuthentication();
|
||||
|
||||
late Future<void> initializationFuture;
|
||||
|
||||
SettingsController() {
|
||||
_loadSettings();
|
||||
initializationFuture = _loadSettings();
|
||||
}
|
||||
|
||||
Future<void> _loadSettings() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_vibrationEnabled = prefs.getBool('vibration_enabled') ?? true;
|
||||
_biometricEnabled = prefs.getBool('biometric_enabled') ?? false;
|
||||
_adsEnabled = prefs.getBool('ads_enabled') ?? true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> toggleVibration(bool value) async {
|
||||
print("Toggling vibration to: $value");
|
||||
_vibrationEnabled = value;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('vibration_enabled', value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> toggleBiometric(bool value) async {
|
||||
_biometricEnabled = value;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('biometric_enabled', value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> toggleAds(bool value) async {
|
||||
_adsEnabled = value;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('ads_enabled', value);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool> checkSecurity() async {
|
||||
await initializationFuture;
|
||||
|
||||
if (!_biometricEnabled) return true;
|
||||
|
||||
bool canCheck = await auth.canCheckBiometrics;
|
||||
bool isSupported = await auth.isDeviceSupported();
|
||||
|
||||
if (!canCheck && !isSupported) return true;
|
||||
|
||||
try {
|
||||
return await auth.authenticate(
|
||||
localizedReason: 'Unlock QuickSSH',
|
||||
biometricOnly: false,
|
||||
);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user