Skip to content

Commit b6681df

Browse files
authored
Merge pull request #270 from abhisheksharma010/main
Task Deadline Countdown #252
2 parents 1135738 + 12924f8 commit b6681df

File tree

4 files changed

+136
-119
lines changed

4 files changed

+136
-119
lines changed

lib/drawer/nav_drawer.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class _NavDrawerState extends State<NavDrawer> {
119119
onTap: () async {
120120
bool syncOnStart = false;
121121
bool syncOnTaskCreate = false;
122+
bool delaytask= false;
123+
122124

123125
///check if auto sync is on or off
124126
final SharedPreferences prefs =
@@ -127,6 +129,8 @@ class _NavDrawerState extends State<NavDrawer> {
127129
syncOnStart = prefs.getBool('sync-onStart') ?? false;
128130
syncOnTaskCreate =
129131
prefs.getBool('sync-OnTaskCreate') ?? false;
132+
delaytask =
133+
prefs.getBool('delaytask') ?? false;
130134
});
131135
// print(syncOnStart);
132136
// print(syncOnTaskCreate);
@@ -135,6 +139,7 @@ class _NavDrawerState extends State<NavDrawer> {
135139
builder: (context) => SettingsPage(
136140
isSyncOnStartActivel: syncOnStart,
137141
isSyncOnTaskCreateActivel: syncOnTaskCreate,
142+
delaytask: delaytask,
138143
),
139144
),
140145
);

lib/services/task_details.dart

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class _DetailRouteState extends State<DetailRoute> {
7070

7171
await Navigator.of(context).pushAndRemoveUntil(
7272
MaterialPageRoute(builder: (context) => const HomePage()),
73-
(Route<dynamic> route) => false);
73+
(Route<dynamic> route) => false);
7474
}
7575
// ignore: use_build_context_synchronously
7676
return showDialog(
@@ -84,7 +84,9 @@ class _DetailRouteState extends State<DetailRoute> {
8484
saveChanges();
8585
Navigator.of(context).pushNamedAndRemoveUntil(
8686
HomePage.routeName,
87-
(route) => false,
87+
88+
(route) => false,
89+
8890
);
8991
setState(() {});
9092
},
@@ -94,7 +96,7 @@ class _DetailRouteState extends State<DetailRoute> {
9496
onPressed: () {
9597
Navigator.of(context).pushNamedAndRemoveUntil(
9698
HomePage.routeName,
97-
(route) => false,
99+
(route) => false,
98100
);
99101
},
100102
child: const Text('No'),
@@ -156,46 +158,46 @@ class _DetailRouteState extends State<DetailRoute> {
156158
floatingActionButton: (modify.changes.isEmpty)
157159
? null
158160
: FloatingActionButton(
159-
heroTag: "btn1",
160-
onPressed: () {
161-
showDialog(
162-
context: context,
163-
builder: (context) {
164-
return AlertDialog(
165-
scrollable: true,
166-
title: const Text('Review changes:'),
167-
content: SingleChildScrollView(
168-
scrollDirection: Axis.horizontal,
169-
child: Text(
170-
modify.changes.entries
171-
.map((entry) => '${entry.key}:\n'
172-
' old: ${entry.value['old']}\n'
173-
' new: ${entry.value['new']}')
174-
.toList()
175-
.join('\n'),
176-
style: GoogleFonts.poppins(),
177-
),
178-
),
179-
actions: [
180-
TextButton(
181-
onPressed: () {
182-
Navigator.of(context).pop();
183-
},
184-
child: const Text('Cancel'),
185-
),
186-
ElevatedButton(
187-
onPressed: () {
188-
saveChanges();
189-
},
190-
child: const Text('Submit'),
191-
),
192-
],
193-
);
194-
},
195-
);
196-
},
197-
child: const Icon(Icons.save),
198-
),
161+
heroTag: "btn1",
162+
onPressed: () {
163+
showDialog(
164+
context: context,
165+
builder: (context) {
166+
return AlertDialog(
167+
scrollable: true,
168+
title: const Text('Review changes:'),
169+
content: SingleChildScrollView(
170+
scrollDirection: Axis.horizontal,
171+
child: Text(
172+
modify.changes.entries
173+
.map((entry) => '${entry.key}:\n'
174+
' old: ${entry.value['old']}\n'
175+
' new: ${entry.value['new']}')
176+
.toList()
177+
.join('\n'),
178+
style: GoogleFonts.poppins(),
179+
),
180+
),
181+
actions: [
182+
TextButton(
183+
onPressed: () {
184+
Navigator.of(context).pop();
185+
},
186+
child: const Text('Cancel'),
187+
),
188+
ElevatedButton(
189+
onPressed: () {
190+
saveChanges();
191+
},
192+
child: const Text('Submit'),
193+
),
194+
],
195+
);
196+
},
197+
);
198+
},
199+
child: const Icon(Icons.save),
200+
),
199201
),
200202
);
201203
}
@@ -274,12 +276,12 @@ class AttributeWidget extends StatelessWidget {
274276
value: localValue,
275277
callback: callback,
276278
);
277-
// case 'annotations':
278-
// return AnnotationsWidget(
279-
// name: name,
280-
// value: localValue,
281-
// callback: callback,
282-
// );
279+
// case 'annotations':
280+
// return AnnotationsWidget(
281+
// name: name,
282+
// value: localValue,
283+
// callback: callback,
284+
// );
283285
default:
284286
return Card(
285287
color: AppSettings.isDarkMode
@@ -299,15 +301,15 @@ class AttributeWidget extends StatelessWidget {
299301
fontWeight: FontWeight.bold,
300302
fontSize: 15,
301303
color:
302-
AppSettings.isDarkMode ? Colors.white : Colors.black,
304+
AppSettings.isDarkMode ? Colors.white : Colors.black,
303305
),
304306
),
305307
Text(
306308
localValue?.toString() ?? "not selected",
307309
style: GoogleFonts.poppins(
308310
fontSize: 15,
309311
color:
310-
AppSettings.isDarkMode ? Colors.white : Colors.black,
312+
AppSettings.isDarkMode ? Colors.white : Colors.black,
311313
),
312314
)
313315
],
@@ -359,7 +361,7 @@ class TagsWidget extends StatelessWidget {
359361
),
360362
TextSpan(
361363
text:
362-
'${(value as ListBuilder?)?.build() ?? 'not selected'}',
364+
'${(value as ListBuilder?)?.build() ?? 'not selected'}',
363365
style: GoogleFonts.poppins(
364366
fontSize: 15,
365367
color: AppSettings.isDarkMode
@@ -431,4 +433,4 @@ class TagsWidget extends StatelessWidget {
431433
// ),
432434
// );
433435
// }
434-
// }
436+
// }

lib/services/task_list_tem.dart

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import 'package:flutter/material.dart';
2-
32
import 'package:google_fonts/google_fonts.dart';
4-
3+
import 'package:shared_preferences/shared_preferences.dart';
54
import 'package:taskwarrior/model/json.dart';
65
import 'package:taskwarrior/widgets/taskw.dart';
76

8-
import '../model/storage/storage_widget.dart';
9-
107
class TaskListItem extends StatefulWidget {
118
const TaskListItem(this.task,
129
{this.pendingFilter = false, super.key, required this.darkmode});
@@ -22,16 +19,19 @@ class TaskListItem extends StatefulWidget {
2219
class _TaskListItemState extends State<TaskListItem> {
2320
late Modify modify;
2421
bool isChecked = false;
22+
bool useDelayTask = false; // Default value
2523

26-
void setStatus(String newValue, String id) {
27-
var storageWidget = StorageWidget.of(context);
28-
modify = Modify(
29-
getTask: storageWidget.getTask,
30-
mergeTask: storageWidget.mergeTask,
31-
uuid: id,
32-
);
33-
modify.set('status', newValue);
34-
saveChanges();
24+
@override
25+
void initState() {
26+
super.initState();
27+
loadDelayTask();
28+
}
29+
30+
Future<void> loadDelayTask() async {
31+
final SharedPreferences prefs = await SharedPreferences.getInstance();
32+
setState(() {
33+
useDelayTask = prefs.getBool('delaytask') ?? false;
34+
});
3535
}
3636

3737
bool isDueWithinOneDay(DateTime dueDate) {
@@ -51,8 +51,6 @@ class _TaskListItemState extends State<TaskListItem> {
5151
));
5252
}
5353

54-
//dynamic status_value = StatusWidgetData.value;
55-
5654
@override
5755
Widget build(BuildContext context) {
5856
MaterialColor colours = Colors.grey;
@@ -70,18 +68,16 @@ class _TaskListItemState extends State<TaskListItem> {
7068
}
7169

7270
if ((widget.task.status[0].toUpperCase()) == 'P') {
73-
// to differentiate between pending and completed tasks
74-
// pending tasks will be having the check boxes, on the other hand completed one's doesn't
71+
// Pending tasks
7572
return Container(
7673
decoration: BoxDecoration(
7774
border: Border.all(
7875
color: (widget.task.due != null &&
79-
isDueWithinOneDay(widget.task.due!))
80-
? Colors.red // Set border color to red if due within 1 day
76+
isDueWithinOneDay(widget.task.due!) && useDelayTask)
77+
? Colors.red // Set border color to red if due within 1 day and useDelayTask is true
8178
: dimColor, // Set default border color
8279
),
83-
borderRadius: BorderRadius.circular(
84-
8.0), // You can adjust the border radius as needed
80+
borderRadius: BorderRadius.circular(8.0),
8581
),
8682
child: ListTile(
8783
title: Row(
@@ -221,7 +217,6 @@ class _TaskListItemState extends State<TaskListItem> {
221217
],
222218
),
223219
);
224-
225220
}
226221
}
227-
}
222+
}

0 commit comments

Comments
 (0)