Polished
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'theme_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'User.dart' as User;
|
||||
class Category{
|
||||
|
||||
Category(this.category_id, this.name, this.color, this.productive);
|
||||
@@ -99,10 +101,47 @@ class Settings{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Future<void> setTheme(int value) async{
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt("theme", value);
|
||||
}
|
||||
|
||||
static String notification_key= "notification_interval";
|
||||
|
||||
static Future<int> getNotificationInterval() async{
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
int _value = 1;
|
||||
if(prefs.containsKey(notification_key)){
|
||||
_value = await prefs.getInt(notification_key) ?? 1;
|
||||
}else{
|
||||
prefs.setInt(notification_key,_value);
|
||||
}
|
||||
|
||||
return _value;
|
||||
}
|
||||
|
||||
static Future<void> setNotificationInterval(int value) async{
|
||||
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 bool adaptiveNotificationAvailable() {
|
||||
List<String> dates = [];
|
||||
if(User.activities.length < 10){
|
||||
return false;
|
||||
}else{
|
||||
for (var element in User.activities) {
|
||||
String thisDate = DateFormat("MM/dd").format(element.startTime);
|
||||
if(!dates.contains(thisDate)){
|
||||
dates.add(thisDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (dates.length > 2);
|
||||
|
||||
}
|
||||
}
|
||||
final settings = Settings();
|
||||
Reference in New Issue
Block a user