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); String category_id; String name; String color; bool productive; static String colCatId = "category_id"; static String colName = "name"; static String colColor = "color"; static String colProductive = "productive"; } class TaskType{ TaskType(this.id, this.name, this.category, [this.cat = null]); String id; String name; String category; Category? cat; static String colId = "id"; static String colName="name"; static String colCategory = "category_id"; } class Activity{ Activity(this.taskType, this.startTime, this.endTime, {this.metadata,DateTime? tEndTime,DateTime? tStartTime}){ trueStartTime = tStartTime ?? startTime; trueEndTime = tEndTime ?? endTime; } late DateTime trueStartTime; late DateTime trueEndTime; TaskType taskType; DateTime startTime; DateTime endTime; String? metadata; static String colType = "type"; static String colStartTime = "s_time"; static String colEndTime = "e_time"; static String colMetadata= "metadata"; } class InitialData{ static List getTaskTypes(String username){ List tasks =[ TaskType(username + 'Sleep','Sleep', 'Relax'), TaskType(username + 'Physics','Physics', 'Study'), TaskType(username + 'History','History','Study'), TaskType(username + 'Football','Football', 'Play'), TaskType(username + 'At work','At work', 'Work'), TaskType(username + 'Chores','Chores', 'Daily Activities'), TaskType(username + 'Eat','Eat','Daily Activities'), TaskType(username + 'Hang out','Hang out', 'Social') ]; return tasks; } static List getCategories(String username){ List cats = [ Category(username+'Relax','Relax', '#555555', false), Category(username+'Daily Activities','Daily Activities', '#009955',false), Category(username+'Study','Study', '#00FF00', true), Category(username+'Play','Play', '#FF0000', false), Category(username+'Work','Work', '#00AAFF', true), Category(username+'Social','Social', '#00AAAA', false) ]; return cats; } } class Queries{ static String colLink= "file"; static String colData = "data"; } class ProjectStep{ ProjectStep(this.stepName,this.eta); String stepName; int eta; } class Settings{ static Future UUID() async{ final prefs = await SharedPreferences.getInstance(); if(prefs.containsKey('uuid')){ return await Future.value(prefs.getString('uuid')); }else{ var uuid = Uuid(); String _uuid = uuid.v4(); await prefs.setString('uuid',_uuid); return Future.value(_uuid); } } static Future setTheme(int value) async{ final prefs = await SharedPreferences.getInstance(); await prefs.setInt("theme", value); } static String notification_key= "notification_interval"; static String adaptive_notification_key = "adaptive_notification"; static String untracked_unprod_key = "untracked_unproductive"; static Future 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 setNotificationInterval(int value) async{ final prefs = await SharedPreferences.getInstance(); prefs.setInt(notification_key, value); } static List notificationOptions = ['Off','1 hour', '2 hour', '3 hour', '4 hour', '5 hour', '6 hour']; static bool adaptiveNotificationAvailable() { List 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); } static Future 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 setAdaptiveNotification(bool value) async{ final prefs = await SharedPreferences.getInstance(); prefs.setBool(adaptive_notification_key, value); } static Future getUntrackedUnproductive() async{ final prefs = await SharedPreferences.getInstance(); bool _value = true; if(prefs.containsKey(untracked_unprod_key)){ _value = await prefs.getBool(untracked_unprod_key) ?? true; }else{ prefs.setBool(untracked_unprod_key,_value); } return _value; } static Future setUntrackedUnproductive(bool value) async{ final prefs = await SharedPreferences.getInstance(); prefs.setBool(untracked_unprod_key, value); } } final settings = Settings();