Adaptive Notifications + before enabling desktop

This commit is contained in:
warlock
2022-03-06 18:04:53 +05:30
parent 0272b2d1fd
commit f749c4ce8d
6 changed files with 141 additions and 28 deletions

View File

@@ -107,6 +107,7 @@ class Settings{
}
static String notification_key= "notification_interval";
static String adaptive_notification_key = "adaptive_notification";
static Future<int> getNotificationInterval() async{
final prefs = await SharedPreferences.getInstance();
@@ -125,8 +126,8 @@ class Settings{
final prefs = await SharedPreferences.getInstance();
prefs.setInt(notification_key, value);
}
static List<String> notificationOptions = <String>['Off','1 hour', '2 hour', '3 hour', '4 hour', '5 hour', '6 hour'];
static List<String> notificationOptions = <String>['Off','1 hour', '2 hour', '3 hour', '4 hour', '5 hour', '6 hour'];
static bool adaptiveNotificationAvailable() {
List<String> dates = [];
if(User.activities.length < 10){
@@ -141,7 +142,24 @@ class Settings{
}
return (dates.length > 2);
}
static Future<bool> getAdaptiveNotification() async{
final prefs = await SharedPreferences.getInstance();
bool _value = true;
if(prefs.containsKey(notification_key)){
_value = await prefs.getBool(adaptive_notification_key) ?? true;
}else{
prefs.setBool(adaptive_notification_key,_value);
}
return _value;
}
static Future<void> setAdaptiveNotification(bool value) async{
final prefs = await SharedPreferences.getInstance();
prefs.setBool(adaptive_notification_key, value);
}
}
final settings = Settings();