rollback to material + app usage init

This commit is contained in:
2023-01-27 18:50:44 +05:30
parent fd60fca746
commit ecb59d8b52
8 changed files with 1915 additions and 992 deletions

View File

@@ -8,8 +8,8 @@ import 'package:uuid/uuid.dart';
import 'theme_provider.dart';
import 'package:provider/provider.dart';
import 'User.dart' as User;
class Category{
class Category {
Category(this.category_id, this.name, this.color, this.productive);
String category_id;
@@ -23,9 +23,8 @@ class Category{
static String colProductive = "productive";
}
class TaskType{
TaskType(this.id, this.name, this.category,{this.relatedProject, this.cat});
class TaskType {
TaskType(this.id, this.name, this.category, {this.relatedProject, this.cat});
String id;
String name;
@@ -34,18 +33,21 @@ class TaskType{
Project? relatedProject;
static String colId = "id";
static String colName="name";
static String colName = "name";
static String colCategory = "category_id";
static String colRelatedProject = "related_project";
static String getDisplayName(TaskType taskType){
return (taskType.name + ((taskType.relatedProject != null) ? ' [${taskType.relatedProject!.name}]' : ''));
static String getDisplayName(TaskType taskType) {
return (taskType.name +
((taskType.relatedProject != null)
? ' [${taskType.relatedProject!.name}]'
: ''));
}
}
class Activity{
Activity(this.taskType, this.startTime, this.endTime, {this.metadata,DateTime? tEndTime,DateTime? tStartTime}){
class Activity {
Activity(this.taskType, this.startTime, this.endTime,
{this.metadata, DateTime? tEndTime, DateTime? tStartTime}) {
trueStartTime = tStartTime ?? startTime;
trueEndTime = tEndTime ?? endTime;
}
@@ -56,65 +58,66 @@ class Activity{
DateTime endTime;
String? metadata;
Activity.fromJson(Map<String,dynamic> json): taskType=json['taskType'], startTime=json['sTime'], endTime=json['eTime'];
Activity.fromJson(Map<String, dynamic> json)
: taskType = json['taskType'],
startTime = json['sTime'],
endTime = json['eTime'];
Map<String, dynamic> toJson()=>{
'taskType': taskType,
'sTime':startTime,
'eTime':endTime
};
Map<String, dynamic> toJson() =>
{'taskType': taskType, 'sTime': startTime, 'eTime': endTime};
static String colType = "type";
static String colStartTime = "s_time";
static String colEndTime = "e_time";
static String colMetadata= "metadata";
static String colMetadata = "metadata";
}
class InitialData{
static List<TaskType> getTaskTypes(String username){
List<TaskType> 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')
];
class InitialData {
static List<TaskType> getTaskTypes(String username) {
List<TaskType> 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<Category> getCategories(String username){
static List<Category> getCategories(String username) {
List<Category> 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)
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{
Queries(this.link,this.data);
class Queries {
Queries(this.link, this.data);
String link;
String data;
static String colLink= "file";
static String colLink = "file";
static String colData = "data";
}
class Project{
Project(this.name, this.category, this.steps,this.eta, this.deadline,{this.cat});
class Project {
Project(this.name, this.category, this.steps, this.eta, this.deadline,
{this.cat});
String name;
String getName()=> name.replaceAll(User.username, "");
String getName() => name.replaceAll(User.username, "");
String category;
Category? cat;
List<ProjectStep> steps;
@@ -122,23 +125,29 @@ class Project{
DateTime deadline;
static String colName = "name";
static String colCat="category_id";
static String colCat = "category_id";
static String colSteps = "steps";
static String colDeadline = "deadline";
static String colEta = "eta";
}
class ProjectStep{
ProjectStep(this.stepName,this.eta,this.progress);
class ProjectStep {
ProjectStep(this.stepName, this.eta, this.progress);
ProjectStep.fromJson(Map<String,dynamic> json): stepName=json['name'], eta=json['eta'], progress=json['progress'], finishedDate=(json['finishedDate']!=null) ? DateTime.parse(json['finishedDate']) : null;
ProjectStep.fromJson(Map<String, dynamic> json)
: stepName = json['name'],
eta = json['eta'],
progress = json['progress'],
finishedDate = (json['finishedDate'] != null)
? DateTime.parse(json['finishedDate'])
: null;
Map<String, dynamic> toJson()=>{
'name': stepName,
'eta':eta,
'progress':progress,
if(finishedDate!=null) 'finishedDate':finishedDate.toString()
};
Map<String, dynamic> toJson() => {
'name': stepName,
'eta': eta,
'progress': progress,
if (finishedDate != null) 'finishedDate': finishedDate.toString()
};
String stepName;
int eta;
@@ -146,8 +155,7 @@ class ProjectStep{
DateTime? finishedDate;
}
class Journal{
class Journal {
Journal(this.id, this.day, {this.title, this.description});
String id;
@@ -159,8 +167,9 @@ class Journal{
static String colDescription = 'Desc';
}
class Todo{
Todo(this.id, this.category,this.metadata, this.dueDate, {this.notificationTime, this.task});
class Todo {
Todo(this.id, this.category, this.metadata, this.dueDate,
{this.notificationTime, this.task});
String id;
String category;
@@ -175,101 +184,128 @@ class Todo{
static String colNotificationTime = 'notification_time';
}
class Settings{
static Future<String> UUID() async{
class Settings {
static Future<String> UUID() async {
final prefs = await SharedPreferences.getInstance();
if(prefs.containsKey('uuid')){
if (prefs.containsKey('uuid')) {
return await Future.value(prefs.getString('uuid'));
}else{
var uuid = Uuid();
String _uuid = uuid.v4();
// if(Platform.isAndroid){
//
// }
await prefs.setString('uuid',_uuid);
return Future.value(_uuid);
} else {
var uuid = Uuid();
String _uuid = uuid.v4();
// if(Platform.isAndroid){
//
// }
await prefs.setString('uuid', _uuid);
return Future.value(_uuid);
}
}
static Future<void> setTheme(int value) async{
static Future<void> setTheme(int value) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setInt("theme", value);
}
static String notification_key= "notification_interval";
static String notification_key = "notification_interval";
static String adaptive_notification_key = "adaptive_notification";
static String untracked_unprod_key = "untracked_unproductive";
static String auto_log_key = "auto_log";
static Future<int> getNotificationInterval() async{
static Future<int> getNotificationInterval() async {
final prefs = await SharedPreferences.getInstance();
int _value = 1;
if(prefs.containsKey(notification_key)){
if (prefs.containsKey(notification_key)) {
_value = await prefs.getInt(notification_key) ?? 1;
}else{
prefs.setInt(notification_key,_value);
} else {
prefs.setInt(notification_key, _value);
}
return _value;
}
static Future<void> setNotificationInterval(int value) async{
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 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);
}
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);
return (dates.length > 2);
}
static Future<bool> getAdaptiveNotification() async{
static Future<bool> getAdaptiveNotification() async {
final prefs = await SharedPreferences.getInstance();
bool _value = true;
if(prefs.containsKey(notification_key)){
if (prefs.containsKey(notification_key)) {
_value = await prefs.getBool(adaptive_notification_key) ?? true;
}else{
prefs.setBool(adaptive_notification_key,_value);
} else {
prefs.setBool(adaptive_notification_key, _value);
}
return _value;
}
static Future<void> setAdaptiveNotification(bool value) async{
static Future<void> setAdaptiveNotification(bool value) async {
final prefs = await SharedPreferences.getInstance();
prefs.setBool(adaptive_notification_key, value);
}
static Future<bool> getUntrackedUnproductive() async{
static Future<bool> getUntrackedUnproductive() async {
final prefs = await SharedPreferences.getInstance();
bool _value = true;
if(prefs.containsKey(untracked_unprod_key)){
if (prefs.containsKey(untracked_unprod_key)) {
_value = await prefs.getBool(untracked_unprod_key) ?? true;
}else{
prefs.setBool(untracked_unprod_key,_value);
} else {
prefs.setBool(untracked_unprod_key, _value);
}
return _value;
}
static Future<void> setUntrackedUnproductive(bool value) async{
static Future<bool> getAutoLog() async {
final prefs = await SharedPreferences.getInstance();
bool _value = true;
if (prefs.containsKey(auto_log_key)) {
_value = await prefs.getBool(auto_log_key) ?? true;
} else {
prefs.setBool(auto_log_key, _value);
}
return _value;
}
static Future<void> setUntrackedUnproductive(bool value) async {
final prefs = await SharedPreferences.getInstance();
prefs.setBool(untracked_unprod_key, value);
}
static Future<void> setAutoLog(bool value) async {
final prefs = await SharedPreferences.getInstance();
prefs.setBool(auto_log_key, value);
}
}
final settings = Settings();
final settings = Settings();