@@ -56,6 +56,7 @@ class StorageWidget extends StatefulWidget {
5656class _StorageWidgetState extends State <StorageWidget > {
5757 late Storage storage;
5858 late bool pendingFilter;
59+ late bool waitingFilter;
5960 late String projectFilter;
6061 late bool tagUnion;
6162 late String selectedSort;
@@ -89,6 +90,7 @@ class _StorageWidgetState extends State<StorageWidget> {
8990
9091 void _profileSet () {
9192 pendingFilter = Query (storage.tabs.tab ()).getPendingFilter ();
93+ waitingFilter = Query (storage.tabs.tab ()).getWaitingFilter ();
9294 projectFilter = Query (storage.tabs.tab ()).projectFilter ();
9395 tagUnion = Query (storage.tabs.tab ()).tagUnion ();
9496 selectedSort = Query (storage.tabs.tab ()).getSelectedSort ();
@@ -103,14 +105,16 @@ class _StorageWidgetState extends State<StorageWidget> {
103105
104106 void _refreshTasks () {
105107 if (pendingFilter) {
106- queriedTasks = storage.data
107- .pendingData ()
108- .where ((task) => task.status == 'pending' )
109- .toList ();
108+ queriedTasks = storage.data.pendingData ().where ((task) => task.status == 'pending' ).toList ();
110109 } else {
111110 queriedTasks = storage.data.completedData ();
112111 }
113112
113+ if (waitingFilter) {
114+ var currentTime = DateTime .now ();
115+ queriedTasks = queriedTasks.where ((task) => task.wait != null && task.wait! .isAfter (currentTime)).toList ();
116+ }
117+
114118 if (projectFilter.isNotEmpty) {
115119 queriedTasks = queriedTasks.where ((task) {
116120 if (task.project == null ) {
@@ -127,13 +131,11 @@ class _StorageWidgetState extends State<StorageWidget> {
127131 if (selectedTags.isEmpty) {
128132 return true ;
129133 }
130- return selectedTags.any ((tag) => (tag.startsWith ('+' ))
131- ? tags.contains (tag.substring (1 ))
132- : ! tags.contains (tag.substring (1 )));
134+ return selectedTags
135+ .any ((tag) => (tag.startsWith ('+' )) ? tags.contains (tag.substring (1 )) : ! tags.contains (tag.substring (1 )));
133136 } else {
134- return selectedTags.every ((tag) => (tag.startsWith ('+' ))
135- ? tags.contains (tag.substring (1 ))
136- : ! tags.contains (tag.substring (1 )));
137+ return selectedTags
138+ .every ((tag) => (tag.startsWith ('+' )) ? tags.contains (tag.substring (1 )) : ! tags.contains (tag.substring (1 )));
137139 }
138140 }).toList ();
139141
@@ -154,8 +156,7 @@ class _StorageWidgetState extends State<StorageWidget> {
154156 searchedTasks = searchedTasks
155157 .where ((task) =>
156158 task.description.contains (searchTerm) ||
157- (task.annotations? .asList () ?? []).any (
158- (annotation) => annotation.description.contains (searchTerm)))
159+ (task.annotations? .asList () ?? []).any ((annotation) => annotation.description.contains (searchTerm)))
159160 .toList ();
160161 }
161162 pendingTags = _pendingTags ();
@@ -201,6 +202,13 @@ class _StorageWidgetState extends State<StorageWidget> {
201202 setState (() {});
202203 }
203204
205+ void toggleWaitingFilter () {
206+ Query (storage.tabs.tab ()).toggleWaitingFilter ();
207+ waitingFilter = Query (storage.tabs.tab ()).getWaitingFilter ();
208+ _refreshTasks ();
209+ setState (() {});
210+ }
211+
204212 void toggleProjectFilter (String project) {
205213 Query (storage.tabs.tab ()).toggleProjectFilter (project);
206214 projectFilter = Query (storage.tabs.tab ()).projectFilter ();
@@ -365,6 +373,7 @@ class _StorageWidgetState extends State<StorageWidget> {
365373 void setInitialTabIndex (int index) {
366374 storage.tabs.setInitialTabIndex (index);
367375 pendingFilter = Query (storage.tabs.tab ()).getPendingFilter ();
376+ waitingFilter = Query (storage.tabs.tab ()).getWaitingFilter ();
368377 selectedSort = Query (storage.tabs.tab ()).getSelectedSort ();
369378 selectedTags = Query (storage.tabs.tab ()).getSelectedTags ();
370379 projectFilter = Query (storage.tabs.tab ()).projectFilter ();
@@ -388,6 +397,7 @@ class _StorageWidgetState extends State<StorageWidget> {
388397 void removeTab (int index) {
389398 storage.tabs.removeTab (index);
390399 pendingFilter = Query (storage.tabs.tab ()).getPendingFilter ();
400+ waitingFilter = Query (storage.tabs.tab ()).getWaitingFilter ();
391401 selectedSort = Query (storage.tabs.tab ()).getSelectedSort ();
392402 selectedTags = Query (storage.tabs.tab ()).getSelectedTags ();
393403 _refreshTasks ();
@@ -414,13 +424,15 @@ class _StorageWidgetState extends State<StorageWidget> {
414424 pendingTags: pendingTags,
415425 projects: projects,
416426 pendingFilter: pendingFilter,
427+ waitingFilter: waitingFilter,
417428 projectFilter: projectFilter,
418429 tagUnion: tagUnion,
419430 selectedSort: selectedSort,
420431 getTask: getTask,
421432 mergeTask: mergeTask,
422433 synchronize: synchronize,
423434 togglePendingFilter: togglePendingFilter,
435+ toggleWaitingFilter: toggleWaitingFilter,
424436 toggleProjectFilter: toggleProjectFilter,
425437 toggleTagUnion: toggleTagUnion,
426438 selectSort: selectSort,
@@ -454,6 +466,7 @@ class InheritedStorage extends InheritedModel<String> {
454466 required this .pendingTags,
455467 required this .projects,
456468 required this .pendingFilter,
469+ required this .waitingFilter,
457470 required this .projectFilter,
458471 required this .tagUnion,
459472 required this .selectedSort,
@@ -462,6 +475,7 @@ class InheritedStorage extends InheritedModel<String> {
462475 required this .mergeTask,
463476 required this .synchronize,
464477 required this .togglePendingFilter,
478+ required this .toggleWaitingFilter,
465479 required this .toggleProjectFilter,
466480 required this .toggleTagUnion,
467481 required this .toggleTagFilter,
@@ -488,6 +502,7 @@ class InheritedStorage extends InheritedModel<String> {
488502 final Map <String , TagMetadata > pendingTags;
489503 final Map <String , ProjectNode > projects;
490504 final bool pendingFilter;
505+ final bool waitingFilter;
491506 final String projectFilter;
492507 final bool tagUnion;
493508 final String selectedSort;
@@ -496,6 +511,7 @@ class InheritedStorage extends InheritedModel<String> {
496511 final void Function (Task ) mergeTask;
497512 final void Function (BuildContext , bool ) synchronize;
498513 final void Function () togglePendingFilter;
514+ final void Function () toggleWaitingFilter;
499515 final void Function (String ) toggleProjectFilter;
500516 final void Function () toggleTagUnion;
501517 final void Function (String ) selectSort;
@@ -521,8 +537,7 @@ class InheritedStorage extends InheritedModel<String> {
521537 }
522538
523539 @override
524- bool updateShouldNotifyDependent (
525- InheritedStorage oldWidget, Set <String > dependencies) {
540+ bool updateShouldNotifyDependent (InheritedStorage oldWidget, Set <String > dependencies) {
526541 return true ;
527542 }
528543}
0 commit comments