@@ -8,8 +8,9 @@ import 'package:taskwarrior/app/utils/constants/utilites.dart';
88import 'package:taskwarrior/app/utils/themes/theme_extension.dart' ;
99import 'package:taskwarrior/app/utils/language/sentence_manager.dart' ;
1010import 'package:taskwarrior/app/v3/db/task_database.dart' ;
11- import 'package:taskwarrior/app/v3/models/task.dart' ;
12- import 'package:taskwarrior/app/v3/net/modify.dart' ;
11+ import 'package:taskwarrior/app/v3/models/annotation.dart' ;
12+ import 'package:taskwarrior/app/v3/models/task.dart' ; // Ensure this path is correct for your new model
13+ // import 'package:taskwarrior/app/v3/net/modify.dart';
1314
1415class TaskDetails extends StatefulWidget {
1516 final TaskForC task;
@@ -25,6 +26,14 @@ class _TaskDetailsState extends State<TaskDetails> {
2526 late String status;
2627 late String priority;
2728 late String due;
29+ late String start;
30+ late String wait;
31+ late List <String > tags;
32+ late List <String > depends;
33+ late String rtype;
34+ late String recur;
35+ late List <Annotation > annotations;
36+
2837 late TaskDatabase taskDatabase;
2938
3039 bool hasChanges = false ;
@@ -33,11 +42,22 @@ class _TaskDetailsState extends State<TaskDetails> {
3342 void initState () {
3443 super .initState ();
3544 description = widget.task.description;
36- project = widget.task.project! ;
45+ project = widget.task.project ?? '-' ;
3746 status = widget.task.status;
38- priority = widget.task.priority! ;
47+ priority = widget.task.priority ?? '-' ;
3948 due = widget.task.due ?? '-' ;
40- due = _buildDate (due);
49+ start = widget.task.start ?? '-' ;
50+ wait = widget.task.wait ?? '-' ;
51+ tags = widget.task.tags ?? [];
52+ depends = widget.task.depends ?? [];
53+ rtype = widget.task.rtype ?? '-' ;
54+ recur = widget.task.recur ?? '-' ;
55+ annotations = widget.task.annotations ?? [];
56+
57+ due = _buildDate (due); // Format the date for display
58+ start = _buildDate (start);
59+ wait = _buildDate (wait);
60+
4161 setState (() {
4262 taskDatabase = TaskDatabase ();
4363 taskDatabase.open ();
@@ -47,6 +67,10 @@ class _TaskDetailsState extends State<TaskDetails> {
4767 @override
4868 void didChangeDependencies () {
4969 super .didChangeDependencies ();
70+ // This part seems redundant if taskDatabase.open() is already in initState
71+ // and ideally, the database connection should be managed more robustly
72+ // (e.g., singleton, provider, or passed down).
73+ // However, keeping it as per original logic, but be aware of potential multiple openings.
5074 taskDatabase = TaskDatabase ();
5175 taskDatabase.open ();
5276 }
@@ -109,7 +133,7 @@ class _TaskDetailsState extends State<TaskDetails> {
109133 _buildSelectableDetail (
110134 '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPagePriority }:' ,
111135 priority,
112- ['H' , 'M' , 'L' ], (value) {
136+ ['H' , 'M' , 'L' , '-' ], (value) {
113137 setState (() {
114138 priority = value;
115139 hasChanges = true ;
@@ -123,10 +147,52 @@ class _TaskDetailsState extends State<TaskDetails> {
123147 hasChanges = true ;
124148 });
125149 }),
126- _buildDetail ('UUID:' , widget.task.uuid! ),
150+ _buildDatePickerDetail (
151+ '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPageStart }:' ,
152+ start, (value) {
153+ setState (() {
154+ start = value;
155+ hasChanges = true ;
156+ });
157+ }),
158+ _buildDatePickerDetail (
159+ '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPageWait }:' ,
160+ wait, (value) {
161+ setState (() {
162+ wait = value;
163+ hasChanges = true ;
164+ });
165+ }),
166+ _buildEditableDetail (
167+ '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPageTags }:' ,
168+ tags.join (', ' ), (value) {
169+ setState (() {
170+ tags = value.split (',' ).map ((e) => e.trim ()).toList ();
171+ hasChanges = true ;
172+ });
173+ }),
174+ _buildEditableDetail ('Depends:' , depends.join (', ' ), (value) {
175+ setState (() {
176+ depends = value.split (',' ).map ((e) => e.trim ()).toList ();
177+ hasChanges = true ;
178+ });
179+ }),
180+ _buildEditableDetail ('Rtype:' , rtype, (value) {
181+ setState (() {
182+ rtype = value;
183+ hasChanges = true ;
184+ });
185+ }),
186+ _buildEditableDetail ('Recur:' , recur, (value) {
187+ setState (() {
188+ recur = value;
189+ hasChanges = true ;
190+ });
191+ }),
192+ _buildDetail ('UUID:' , widget.task.uuid ?? '-' ),
127193 _buildDetail (
128194 '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPageUrgency }:' ,
129- widget.task.urgency. toString () ),
195+ widget.task.urgency? . toStringAsFixed ( 2 ) ?? '-' ),
130196 _buildDetail (
131197 '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPageEnd }:' ,
132198 _buildDate (widget.task.end)),
@@ -136,6 +202,11 @@ class _TaskDetailsState extends State<TaskDetails> {
136202 _buildDetail (
137203 '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences .detailPageModified }:' ,
138204 _buildDate (widget.task.modified)),
205+ _buildDetail (
206+ '${SentenceManager (currentLanguage : AppSettings .selectedLanguage ).sentences }:' ,
207+ annotations.isNotEmpty
208+ ? annotations.map ((e) => e.description).join ('\n ' )
209+ : '-' ),
139210 ],
140211 ),
141212 ),
@@ -183,7 +254,9 @@ class _TaskDetailsState extends State<TaskDetails> {
183254 onTap: () async {
184255 final DateTime ? pickedDate = await showDatePicker (
185256 context: context,
186- initialDate: value != '-' ? DateTime .parse (value) : DateTime .now (),
257+ initialDate: value != '-'
258+ ? DateTime .tryParse (value) ?? DateTime .now ()
259+ : DateTime .now (),
187260 firstDate: DateTime (2000 ),
188261 lastDate: DateTime (2101 ),
189262 builder: (BuildContext context, Widget ? child) {
@@ -196,8 +269,9 @@ class _TaskDetailsState extends State<TaskDetails> {
196269 if (pickedDate != null ) {
197270 final TimeOfDay ? pickedTime = await showTimePicker (
198271 context: context,
199- initialTime: TimeOfDay .fromDateTime (
200- value != '-' ? DateTime .parse (value) : DateTime .now ()),
272+ initialTime: TimeOfDay .fromDateTime (value != '-'
273+ ? DateTime .tryParse (value) ?? DateTime .now ()
274+ : DateTime .now ()),
201275 );
202276 if (pickedTime != null ) {
203277 final DateTime fullDateTime = DateTime (
@@ -207,6 +281,9 @@ class _TaskDetailsState extends State<TaskDetails> {
207281 pickedTime.hour,
208282 pickedTime.minute);
209283 onChanged (DateFormat ('yyyy-MM-dd HH:mm:ss' ).format (fullDateTime));
284+ } else {
285+ // If only date is picked, use current time
286+ onChanged (DateFormat ('yyyy-MM-dd HH:mm:ss' ).format (pickedDate));
210287 }
211288 }
212289 },
@@ -414,25 +491,36 @@ class _TaskDetailsState extends State<TaskDetails> {
414491 }
415492
416493 Future <void > _saveTask () async {
417- await taskDatabase.saveEditedTaskInDB (
418- widget.task.uuid! ,
419- description,
420- project,
421- status,
422- priority,
423- due,
424- );
494+ // Update the TaskForC object with the new values
495+ // final updatedTask = TaskForC(
496+ // id: widget.task.id,
497+ // description: description,
498+ // project: project == '-' ? null : project,
499+ // status: status,
500+ // uuid: widget.task.uuid,
501+ // urgency: widget
502+ // .task.urgency, // Urgency is typically calculated, not edited directly
503+ // priority: priority == '-' ? null : priority,
504+ // due: due == '-' ? null : due,
505+ // start: start == '-' ? null : start,
506+ // end: widget
507+ // .task.end, // 'end' is usually set when completed, not edited directly
508+ // entry: widget.task.entry, // 'entry' is static
509+ // wait: wait == '-' ? null : wait,
510+ // modified: DateFormat('yyyy-MM-dd HH:mm:ss')
511+ // .format(DateTime.now()), // Update modified time
512+ // tags: tags.isEmpty ? null : tags,
513+ // depends: depends.isEmpty ? null : depends,
514+ // rtype: rtype == '-' ? null : rtype,
515+ // recur: recur == '-' ? null : recur,
516+ // annotations: annotations.isEmpty ? null : annotations,
517+ // );
518+
425519 setState (() {
426520 hasChanges = false ;
427521 });
428- modifyTaskOnTaskwarrior (
429- description,
430- project,
431- due,
432- priority,
433- status,
434- widget.task.uuid! ,
435- );
522+ // Assuming modifyTaskOnTaskwarrior takes the updated TaskForC object
523+ // await modifyTaskOnTaskwarrior(updatedTask);
436524 }
437525}
438526
0 commit comments