1
1
import 'package:flutter/material.dart' ;
2
2
import 'package:flutter_app/bloc/bloc_provider.dart' ;
3
- import 'package:flutter_app/db/app_db .dart' ;
3
+ import 'package:flutter_app/bloc/task_bloc .dart' ;
4
4
import 'package:flutter_app/db/label_db.dart' ;
5
5
import 'package:flutter_app/db/project_db.dart' ;
6
- import 'package:flutter_app/models/label.dart' ;
7
6
import 'package:flutter_app/models/project.dart' ;
8
7
import 'package:flutter_app/pages/about/about_us.dart' ;
9
- import 'package:flutter_app/pages/labels/add_label .dart' ;
8
+ import 'package:flutter_app/pages/home/home_bloc .dart' ;
10
9
import 'package:flutter_app/pages/labels/label_bloc.dart' ;
11
10
import 'package:flutter_app/pages/labels/label_widget.dart' ;
12
11
import 'package:flutter_app/pages/projects/project_bloc.dart' ;
13
12
import 'package:flutter_app/pages/projects/project_widget.dart' ;
14
13
15
- class SideDrawer extends StatefulWidget {
16
- ProjectSelection projectSelection;
17
- LabelSelection labelSelection;
18
- DateSelection dateSelection;
19
-
20
- SideDrawer ({this .projectSelection, this .labelSelection, this .dateSelection});
21
-
22
- @override
23
- _SideDrawerState createState () => new _SideDrawerState ();
24
- }
25
-
26
- class _SideDrawerState extends State <SideDrawer > {
27
- final List <Project > projectList = new List ();
28
- final List <Label > labelList = new List ();
29
-
30
- @override
31
- void initState () {
32
- super .initState ();
33
- }
34
-
14
+ class SideDrawer extends StatelessWidget {
35
15
@override
36
16
Widget build (BuildContext context) {
17
+ HomeBloc homeBloc = BlocProvider .of (context);
37
18
return new Drawer (
38
19
child: new ListView (
39
20
children: < Widget > [
@@ -50,7 +31,7 @@ class _SideDrawerState extends State<SideDrawer> {
50
31
onPressed: () {
51
32
Navigator .push (
52
33
context,
53
- new MaterialPageRoute <bool >(
34
+ MaterialPageRoute <bool >(
54
35
builder: (context) => new AboutUsScreen ()),
55
36
);
56
37
})
@@ -64,123 +45,36 @@ class _SideDrawerState extends State<SideDrawer> {
64
45
leading: new Icon (Icons .inbox),
65
46
title: new Text ("Inbox" ),
66
47
onTap: () {
67
- if (widget.projectSelection != null ) {
68
- var project = Project .getInbox ();
69
- widget.projectSelection (project);
70
- Navigator .pop (context);
71
- }
48
+ var project = Project .getInbox ();
49
+ homeBloc.applyFilter (
50
+ project.name, Filter .byProject (project.id));
51
+ Navigator .pop (context);
72
52
}),
73
53
new ListTile (
74
54
onTap: () {
75
- var dateTime = new DateTime .now ();
76
- var taskStartTime =
77
- new DateTime (dateTime.year, dateTime.month, dateTime.day)
78
- .millisecondsSinceEpoch;
79
- var taskEndTime = new DateTime (
80
- dateTime.year, dateTime.month, dateTime.day, 23 , 59 )
81
- .millisecondsSinceEpoch;
82
-
83
- if (widget.dateSelection != null ) {
84
- widget.dateSelection (taskStartTime, taskEndTime);
85
- }
55
+ homeBloc.applyFilter ("Today" , Filter .byToday ());
86
56
Navigator .pop (context);
87
57
},
88
58
leading: new Icon (Icons .calendar_today),
89
59
title: new Text ("Today" )),
90
60
new ListTile (
91
61
onTap: () {
92
- var dateTime = new DateTime .now ();
93
- var taskStartTime =
94
- new DateTime (dateTime.year, dateTime.month, dateTime.day)
95
- .millisecondsSinceEpoch;
96
- var taskEndTime = new DateTime (
97
- dateTime.year, dateTime.month, dateTime.day + 7 , 23 , 59 )
98
- .millisecondsSinceEpoch;
99
-
100
- if (widget.dateSelection != null ) {
101
- widget.dateSelection (taskStartTime, taskEndTime);
102
- }
62
+ homeBloc.applyFilter ("Next 7 Days" , Filter .byNextWeek ());
103
63
Navigator .pop (context);
104
64
},
105
65
leading: new Icon (Icons .calendar_today),
106
66
title: new Text ("Next 7 Days" ),
107
67
),
108
68
BlocProvider (
109
69
bloc: ProjectBloc (ProjectDB .get ()),
110
- child: ProjectPage (widget.projectSelection ),
70
+ child: ProjectPage (),
111
71
),
112
72
BlocProvider (
113
73
bloc: LabelBloc (LabelDB .get ()),
114
- child: LabelPage (widget.labelSelection ),
74
+ child: LabelPage (),
115
75
)
116
76
],
117
77
),
118
78
);
119
79
}
120
80
}
121
-
122
- class ProjectRow extends StatelessWidget {
123
- final Project project;
124
- final ProjectSelection projectSelection;
125
-
126
- ProjectRow (this .project, {this .projectSelection});
127
-
128
- @override
129
- Widget build (BuildContext context) {
130
- return new ListTile (
131
- onTap: () {
132
- if (projectSelection != null ) {
133
- projectSelection (project);
134
- }
135
- },
136
- leading: new Container (
137
- width: 24.0 ,
138
- height: 24.0 ,
139
- ),
140
- title: new Text (project.name),
141
- trailing: new Container (
142
- height: 10.0 ,
143
- width: 10.0 ,
144
- child: new CircleAvatar (
145
- backgroundColor: new Color (project.colorValue),
146
- ),
147
- ),
148
- );
149
- }
150
- }
151
-
152
- class LabelRow extends StatelessWidget {
153
- final Label label;
154
- final LabelSelection labelSelection;
155
-
156
- LabelRow (this .label, {this .labelSelection});
157
-
158
- @override
159
- Widget build (BuildContext context) {
160
- return new ListTile (
161
- onTap: () {
162
- if (labelSelection != null ) {
163
- labelSelection (label);
164
- }
165
- },
166
- leading: new Container (
167
- width: 24.0 ,
168
- height: 24.0 ,
169
- ),
170
- title: new Text ("@ ${label .name }" ),
171
- trailing: new Container (
172
- height: 10.0 ,
173
- width: 10.0 ,
174
- child: new Icon (
175
- Icons .label,
176
- size: 16.0 ,
177
- color: new Color (label.colorValue),
178
- ),
179
- ),
180
- );
181
- }
182
- }
183
-
184
- typedef void ProjectSelection (Project project);
185
- typedef void LabelSelection (Label label);
186
- typedef void DateSelection (int startDate, int endDate);
0 commit comments