From a5145a25278bffdcb8f9a70fb3837c07bf16950a Mon Sep 17 00:00:00 2001 From: Sewmina Date: Thu, 7 Apr 2022 19:07:07 +0530 Subject: [PATCH] Todo summary --- lib/DebugHelper.dart | 11 ++++-- lib/Journal.dart | 2 +- lib/Todos.dart | 8 ++++- lib/User.dart | 7 ++++ lib/main.dart | 81 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 4 deletions(-) diff --git a/lib/DebugHelper.dart b/lib/DebugHelper.dart index 997e38a..0eeb9e2 100644 --- a/lib/DebugHelper.dart +++ b/lib/DebugHelper.dart @@ -1,7 +1,8 @@ class Debug{ static bool enableLogging = true; - static bool enableResponseLogging = true; + static bool enableResponseLogging = false; static bool enableErrorLoggin = true; + static bool enableTestLogging = true; static void LogResponse(Object? response, {Object src= ''}){ if(!enableLogging){return;} @@ -16,8 +17,14 @@ class Debug{ } static void Log(Object? msg){ - if(!enableErrorLoggin) {return;} + if(!enableLogging) {return;} print('\x1B[36m$msg\x1B[0m'); } + static void LogTest(Object? msg){ + if(!enableLogging){return;} + if(!enableTestLogging) {return;} + print('\x1B[35m$msg\x1B[0m'); + } + } \ No newline at end of file diff --git a/lib/Journal.dart b/lib/Journal.dart index 66ca34c..ccef21b 100644 --- a/lib/Journal.dart +++ b/lib/Journal.dart @@ -164,7 +164,7 @@ class _JournalPageState extends State{ SizedBox(height: 5,), if (User.journal[index].description != null && User.journal[index].description!.isNotEmpty) (charCount > maxCharCount && expandedIndex != index) ? - Text(User.journal[index].description!.substring(0,maxCharCount) + '...') : + Text(User.journal[index].description!.substring(0,maxCharCount.clamp(0,User.journal[index].description!.length)) + '...') : Text(User.journal[index].description!), if(charCount>maxCharCount) Row( diff --git a/lib/Todos.dart b/lib/Todos.dart index 3a31db1..7da7067 100644 --- a/lib/Todos.dart +++ b/lib/Todos.dart @@ -8,6 +8,7 @@ import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import 'package:tasktracker/NewJournal.dart'; import 'package:tasktracker/NewTodo.dart'; import 'package:tasktracker/main.dart'; +import 'package:tasktracker/newActivity.dart'; import 'Data.dart'; import 'DebugHelper.dart'; import 'User.dart' as User; @@ -267,8 +268,10 @@ class _TodosPageState extends State { } setState(() {}); } else { + Navigator.of(context).push(MaterialPageRoute(builder: (context)=> NewActivity(selectedTask: TaskType.getDisplayName(todo.task!), metadata: todo.metadata ,))); + setState(() { - setState(() {}); + }); } }, onLongPress: () { @@ -380,6 +383,9 @@ class _TodosPageState extends State { )); } + void onClickTodo(Todo todo){ + + } void deleteTodos() async{ if(selectedProjects.length > 0){ diff --git a/lib/User.dart b/lib/User.dart index cb7b3c7..b47c3ca 100644 --- a/lib/User.dart +++ b/lib/User.dart @@ -143,12 +143,19 @@ Future refreshUserData({bool forceOffline = false}) async { refreshStream.add(false); } else { + Debug.LogTest('updating cats ${DateTime.now()}'); categories = await GetCategories(false); + Debug.LogTest('updating projs ${DateTime.now()}'); projects = await GetProjects(false); + Debug.LogTest('updating tasks ${DateTime.now()}'); taskTypes = await GetTaskTypes(false); + Debug.LogTest('updating acts ${DateTime.now()}'); activities = await GetActivities(false); + Debug.LogTest('updating journals ${DateTime.now()}'); journal = await GetJournals(false); + Debug.LogTest('updating todos ${DateTime.now()}'); todos= await GetTodos(false); + Debug.LogTest('done refreshing ${DateTime.now()}'); } m_refreshing = false; diff --git a/lib/main.dart b/lib/main.dart index 259a1c1..5bfc6f0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -152,6 +152,8 @@ List dailyData = [ List hourglassCatData = []; +List relativeTodos = []; + class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @@ -293,6 +295,7 @@ class _MyHomePageState extends State { } } bool loadingStats = false; + DateFormat dFormat = DateFormat("yyyy-MM-dd"); void LoadStats() async { // return; @@ -482,6 +485,22 @@ class _MyHomePageState extends State { catsData.add(CatMapData(key.name, value, barCol)); }); catsData.sort((a, b) => a.time.compareTo(b.time)); + + + //relative TOdos + List relativeTodoDays = []; + relativeTodos=[]; + for(int i =0; i < 2; i++){ + relativeTodoDays.add(dFormat.format(DateTime.now().add(Duration(days: i)))); + } + + User.todos.forEach((element) { + if(relativeTodoDays.contains(dFormat.format(element.dueDate))){ + //Suitaable + relativeTodos.add(element); + } + }); + //curDay = days[0]; if (this.mounted) { setState(() { @@ -642,6 +661,68 @@ class _MyHomePageState extends State { ), )), ), + Container( + padding: EdgeInsets.all(10), + child: Card( + color: Colors.white10, + elevation: 20, + shadowColor: Colors.black, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('Close To-Do',style: TextStyle(fontSize: 16)), + MaterialButton(height: 30, + color: Colors.green, + onPressed: (){ + Navigator.of(context).pushNamed('/Todos'); + }, + child: Row( + children: [ + Text('More'), + Icon(Icons.keyboard_arrow_right) + ], + ), + + ) + ], + ), + LimitedBox( + maxHeight: 250, + child: ListView.builder( + shrinkWrap: true, + itemCount: relativeTodos.length, + itemBuilder: (context, index){ + return Container( + padding: EdgeInsets.all(10), + margin: EdgeInsets.symmetric(vertical: 2), + decoration: BoxDecoration( + color: Colors.black26, + borderRadius: BorderRadius.circular(10) + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + FittedBox(child: Text('${relativeTodos[index].task!.name} -> ${relativeTodos[index].metadata}')), + Container( + padding: EdgeInsets.symmetric(horizontal: 5), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: Colors.blue), + child: Text(DateFormat('MM/dd').format(relativeTodos[index].dueDate)) + ) + ], + ), + ); + }, + ), + ) + ], + ), + )), + ), Container( padding: EdgeInsets.all(10), child: Card(