Todo summary

This commit is contained in:
Sewmina
2022-04-07 19:07:07 +05:30
parent 7aa8712c16
commit a5145a2527
5 changed files with 105 additions and 4 deletions

View File

@@ -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');
}
}

View File

@@ -164,7 +164,7 @@ class _JournalPageState extends State<JournalPage>{
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(

View File

@@ -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<TodosPage> {
}
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<TodosPage> {
));
}
void onClickTodo(Todo todo){
}
void deleteTodos() async{
if(selectedProjects.length > 0){

View File

@@ -143,12 +143,19 @@ Future<void> 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;

View File

@@ -152,6 +152,8 @@ List<CatMapData> dailyData = <CatMapData>[
List<CatMapData> hourglassCatData = <CatMapData>[];
List<Todo> relativeTodos = [];
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key}) : super(key: key);
@@ -293,6 +295,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
}
bool loadingStats = false;
DateFormat dFormat = DateFormat("yyyy-MM-dd");
void LoadStats() async {
// return;
@@ -482,6 +485,22 @@ class _MyHomePageState extends State<MyHomePage> {
catsData.add(CatMapData(key.name, value, barCol));
});
catsData.sort((a, b) => a.time.compareTo(b.time));
//relative TOdos
List<String> 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<MyHomePage> {
),
)),
),
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(