moved due date check to task.dart

This commit is contained in:
Paul Nettleton 2022-08-05 00:56:27 -05:00
parent e73daab38e
commit b697944a6e
3 changed files with 4 additions and 2 deletions

View File

@ -99,7 +99,7 @@ class _BucketTaskCardState extends State<BucketTaskCard> with AutomaticKeepAlive
),
],
);
if (widget.task.dueDate.year > 2) {
if (widget.task.hasDueDate) {
final duration = widget.task.dueDate.difference(DateTime.now());
final pastDue = duration.isNegative && !widget.task.done;
titleRow.children.add(Container(

View File

@ -77,7 +77,7 @@ class TaskTileState extends State<TaskTile> with AutomaticKeepAliveClientMixin {
) : Text(_currentTask.title),
controlAffinity: ListTileControlAffinity.leading,
value: _currentTask.done ?? false,
subtitle: widget.showInfo && _currentTask.dueDate.year > 2 ?
subtitle: widget.showInfo && _currentTask.hasDueDate ?
Text("Due " + durationToHumanReadable(durationUntilDue), style: TextStyle(color: durationUntilDue.isNegative ? Colors.red : null),)
: _currentTask.description == null || _currentTask.description.isEmpty
? null

View File

@ -141,6 +141,8 @@ class Task {
return false;
}
bool get hasDueDate => dueDate.year != 1;
Task copyWith({
int id, int parentTaskId, int priority, int listId, int bucketId,
DateTime created, DateTime updated, DateTime dueDate, DateTime startDate, DateTime endDate,