Adaptive Notifications + before enabling desktop
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user