Skip to content

Commit

Permalink
Merge pull request #270 from abhisheksharma010/main
Browse files Browse the repository at this point in the history
Task Deadline Countdown #252
  • Loading branch information
Pavel401 authored Jan 30, 2024
2 parents 1135738 + 12924f8 commit b6681df
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 119 deletions.
5 changes: 5 additions & 0 deletions lib/drawer/nav_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class _NavDrawerState extends State<NavDrawer> {
onTap: () async {
bool syncOnStart = false;
bool syncOnTaskCreate = false;
bool delaytask= false;


///check if auto sync is on or off
final SharedPreferences prefs =
Expand All @@ -127,6 +129,8 @@ class _NavDrawerState extends State<NavDrawer> {
syncOnStart = prefs.getBool('sync-onStart') ?? false;
syncOnTaskCreate =
prefs.getBool('sync-OnTaskCreate') ?? false;
delaytask =
prefs.getBool('delaytask') ?? false;
});
// print(syncOnStart);
// print(syncOnTaskCreate);
Expand All @@ -135,6 +139,7 @@ class _NavDrawerState extends State<NavDrawer> {
builder: (context) => SettingsPage(
isSyncOnStartActivel: syncOnStart,
isSyncOnTaskCreateActivel: syncOnTaskCreate,
delaytask: delaytask,
),
),
);
Expand Down
108 changes: 55 additions & 53 deletions lib/services/task_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class _DetailRouteState extends State<DetailRoute> {

await Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const HomePage()),
(Route<dynamic> route) => false);
(Route<dynamic> route) => false);
}
// ignore: use_build_context_synchronously
return showDialog(
Expand All @@ -84,7 +84,9 @@ class _DetailRouteState extends State<DetailRoute> {
saveChanges();
Navigator.of(context).pushNamedAndRemoveUntil(
HomePage.routeName,
(route) => false,

(route) => false,

);
setState(() {});
},
Expand All @@ -94,7 +96,7 @@ class _DetailRouteState extends State<DetailRoute> {
onPressed: () {
Navigator.of(context).pushNamedAndRemoveUntil(
HomePage.routeName,
(route) => false,
(route) => false,
);
},
child: const Text('No'),
Expand Down Expand Up @@ -156,46 +158,46 @@ class _DetailRouteState extends State<DetailRoute> {
floatingActionButton: (modify.changes.isEmpty)
? null
: FloatingActionButton(
heroTag: "btn1",
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
scrollable: true,
title: const Text('Review changes:'),
content: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Text(
modify.changes.entries
.map((entry) => '${entry.key}:\n'
' old: ${entry.value['old']}\n'
' new: ${entry.value['new']}')
.toList()
.join('\n'),
style: GoogleFonts.poppins(),
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Cancel'),
),
ElevatedButton(
onPressed: () {
saveChanges();
},
child: const Text('Submit'),
),
],
);
},
);
},
child: const Icon(Icons.save),
),
heroTag: "btn1",
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
scrollable: true,
title: const Text('Review changes:'),
content: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Text(
modify.changes.entries
.map((entry) => '${entry.key}:\n'
' old: ${entry.value['old']}\n'
' new: ${entry.value['new']}')
.toList()
.join('\n'),
style: GoogleFonts.poppins(),
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Cancel'),
),
ElevatedButton(
onPressed: () {
saveChanges();
},
child: const Text('Submit'),
),
],
);
},
);
},
child: const Icon(Icons.save),
),
),
);
}
Expand Down Expand Up @@ -274,12 +276,12 @@ class AttributeWidget extends StatelessWidget {
value: localValue,
callback: callback,
);
// case 'annotations':
// return AnnotationsWidget(
// name: name,
// value: localValue,
// callback: callback,
// );
// case 'annotations':
// return AnnotationsWidget(
// name: name,
// value: localValue,
// callback: callback,
// );
default:
return Card(
color: AppSettings.isDarkMode
Expand All @@ -299,15 +301,15 @@ class AttributeWidget extends StatelessWidget {
fontWeight: FontWeight.bold,
fontSize: 15,
color:
AppSettings.isDarkMode ? Colors.white : Colors.black,
AppSettings.isDarkMode ? Colors.white : Colors.black,
),
),
Text(
localValue?.toString() ?? "not selected",
style: GoogleFonts.poppins(
fontSize: 15,
color:
AppSettings.isDarkMode ? Colors.white : Colors.black,
AppSettings.isDarkMode ? Colors.white : Colors.black,
),
)
],
Expand Down Expand Up @@ -359,7 +361,7 @@ class TagsWidget extends StatelessWidget {
),
TextSpan(
text:
'${(value as ListBuilder?)?.build() ?? 'not selected'}',
'${(value as ListBuilder?)?.build() ?? 'not selected'}',
style: GoogleFonts.poppins(
fontSize: 15,
color: AppSettings.isDarkMode
Expand Down Expand Up @@ -431,4 +433,4 @@ class TagsWidget extends StatelessWidget {
// ),
// );
// }
// }
// }
41 changes: 18 additions & 23 deletions lib/services/task_list_tem.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import 'package:flutter/material.dart';

import 'package:google_fonts/google_fonts.dart';

import 'package:shared_preferences/shared_preferences.dart';
import 'package:taskwarrior/model/json.dart';
import 'package:taskwarrior/widgets/taskw.dart';

import '../model/storage/storage_widget.dart';

class TaskListItem extends StatefulWidget {
const TaskListItem(this.task,
{this.pendingFilter = false, super.key, required this.darkmode});
Expand All @@ -22,16 +19,19 @@ class TaskListItem extends StatefulWidget {
class _TaskListItemState extends State<TaskListItem> {
late Modify modify;
bool isChecked = false;
bool useDelayTask = false; // Default value

void setStatus(String newValue, String id) {
var storageWidget = StorageWidget.of(context);
modify = Modify(
getTask: storageWidget.getTask,
mergeTask: storageWidget.mergeTask,
uuid: id,
);
modify.set('status', newValue);
saveChanges();
@override
void initState() {
super.initState();
loadDelayTask();
}

Future<void> loadDelayTask() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
useDelayTask = prefs.getBool('delaytask') ?? false;
});
}

bool isDueWithinOneDay(DateTime dueDate) {
Expand All @@ -51,8 +51,6 @@ class _TaskListItemState extends State<TaskListItem> {
));
}

//dynamic status_value = StatusWidgetData.value;

@override
Widget build(BuildContext context) {
MaterialColor colours = Colors.grey;
Expand All @@ -70,18 +68,16 @@ class _TaskListItemState extends State<TaskListItem> {
}

if ((widget.task.status[0].toUpperCase()) == 'P') {
// to differentiate between pending and completed tasks
// pending tasks will be having the check boxes, on the other hand completed one's doesn't
// Pending tasks
return Container(
decoration: BoxDecoration(
border: Border.all(
color: (widget.task.due != null &&
isDueWithinOneDay(widget.task.due!))
? Colors.red // Set border color to red if due within 1 day
isDueWithinOneDay(widget.task.due!) && useDelayTask)
? Colors.red // Set border color to red if due within 1 day and useDelayTask is true
: dimColor, // Set default border color
),
borderRadius: BorderRadius.circular(
8.0), // You can adjust the border radius as needed
borderRadius: BorderRadius.circular(8.0),
),
child: ListTile(
title: Row(
Expand Down Expand Up @@ -221,7 +217,6 @@ class _TaskListItemState extends State<TaskListItem> {
],
),
);

}
}
}
}
Loading

0 comments on commit b6681df

Please sign in to comment.