-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneratingTasks.dart
267 lines (243 loc) · 9.12 KB
/
GeneratingTasks.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
import 'package:flutter/material.dart';
import 'package:smart_schedule_creator/GenerateSchedule3.dart';
import 'package:smart_schedule_creator/TaskRow3.dart';
import 'package:smart_schedule_creator/UnavailableTimes.dart';
class GeneratingTasks extends StatefulWidget {
final List unavTimesSun;
final List unavTimesMon;
final List unavTimesTue;
final List unavTimesWed;
final List unavTimesThu;
final List unavTimesFri;
final List unavTimesSat;
final TimeOfDay bedtime;
final TimeOfDay waketime;
final Set positionSun;
final Set positionMon;
final Set positionTue;
final Set positionWed;
final Set positionThu;
final Set positionFri;
final Set positionSat;
GeneratingTasks({
Key key,
@required this.unavTimesSun,
@required this.unavTimesMon,
@required this.unavTimesTue,
@required this.unavTimesWed,
@required this.unavTimesThu,
@required this.unavTimesFri,
@required this.unavTimesSat,
@required this.bedtime,
@required this.waketime,
@required this.positionSun,
@required this.positionMon,
@required this.positionTue,
@required this.positionWed,
@required this.positionThu,
@required this.positionFri,
@required this.positionSat,
}) : super(key: key);
@override
_GeneratingTasksState createState() => _GeneratingTasksState();
}
class _GeneratingTasksState extends State<GeneratingTasks> {
int count = 1;
List newTimes = [];
List newTasks = [];
Set newDaysSun = {};
Set newDaysMon = {};
Set newDaysTue = {};
Set newDaysWed = {};
Set newDaysThu = {};
Set newDaysFri = {};
Set newDaysSat = {};
@override
Widget build(BuildContext context) {
TimeOfDay bedtime = widget.bedtime;
TimeOfDay waketime = widget.waketime;
List unavTimesSun = widget.unavTimesSun;
List unavTimesMon = widget.unavTimesMon;
List unavTimesTue = widget.unavTimesTue;
List unavTimesWed = widget.unavTimesWed;
List unavTimesThu = widget.unavTimesThu;
List unavTimesFri = widget.unavTimesFri;
List unavTimesSat = widget.unavTimesSat;
Set positionSun = widget.positionSun;
Set positionMon = widget.positionMon;
Set positionTue = widget.positionTue;
Set positionWed = widget.positionWed;
Set positionThu = widget.positionThu;
Set positionFri = widget.positionFri;
Set positionSat = widget.positionSat;
int thisTime;
int maxTimeLimit;
List<TaskRow3> _tasks = new List.generate(count, (int i) => new TaskRow3());
for (var i = 0; i < _tasks.length; i++) {
newTimes?.add(_tasks[i].times);
}
for (var i = 0; i < _tasks.length; i++) {
newTasks?.add(_tasks[i].tasks);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysSun?.add(_tasks[i].daysSun);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysMon?.add(_tasks[i].daysMon);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysTue?.add(_tasks[i].daysTue);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysWed?.add(_tasks[i].daysWed);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysThu?.add(_tasks[i].daysThu);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysFri?.add(_tasks[i].daysFri);
}
for (var i = 0; i < _tasks.length; i++) {
newDaysSat?.add(_tasks[i].daysSat);
}
int maxLimit (thisTime) {
double _numberofgrids;
double _newwaketime = waketime.hour.toDouble();
double _newbedtime = bedtime.hour.toDouble();
double endbedtime = _newbedtime -= 1; //end schedule 1 hour before
double endwaketime = _newwaketime += 1; // start schedule 1 hour after
if (endwaketime < endbedtime) {
_numberofgrids = endbedtime -= endwaketime;
} else {
_numberofgrids = endwaketime -= endbedtime;
}
return _numberofgrids.toInt();
}
maxTimeLimit = maxLimit(thisTime);
String textHolder = "You have a maximum time limit of $maxTimeLimit hours per day. Please do not exceed this.";
void _addNewTask () {
setState(() {
count = count + 1;
});
}
return Scaffold(
appBar: AppBar(
title: Text("Add activities",
style: TextStyle(fontFamily: 'Acme')),
backgroundColor: Colors.redAccent[400],
),
floatingActionButton: FloatingActionButton(
onPressed: _addNewTask,
backgroundColor: Colors.redAccent[400],
child: Icon(Icons.add),
),
bottomNavigationBar:
BottomNavigationBar(backgroundColor: Colors.redAccent[400],
items: [
new BottomNavigationBarItem(
icon: new IconButton(
icon: Icon(Icons.chevron_left, color: Colors.white),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => UnavailableTimes(
bedtime: bedtime,
waketime: waketime,
)));
},
),
title: new Text(
"Back",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white),
),
),
new BottomNavigationBarItem(
icon: new IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GenerateSchedule3(
bedtime: bedtime,
waketime: waketime,
positionSun: positionSun,
positionMon: positionMon,
positionTue: positionTue,
positionWed: positionWed,
positionThu: positionThu,
positionFri: positionFri,
positionSat: positionSat,
unavTimesSun: unavTimesSun,
unavTimesMon: unavTimesMon,
unavTimesTue: unavTimesTue,
unavTimesWed: unavTimesWed,
unavTimesThu: unavTimesThu,
unavTimesFri: unavTimesFri,
unavTimesSat: unavTimesSat,
)));
},
icon: Icon(
Icons.chevron_right,
color: Colors.white,
),
),
title: new Text(
"Next",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white,),
),
)
]),
body: ListView(scrollDirection: Axis.vertical,
children: [
Column(mainAxisSize: MainAxisSize.min,
children: [
Padding(padding: const EdgeInsets.fromLTRB(16.0,25.0,16.0,16.0),
child: SizedBox(
height: 100.0,
width: 400.0,
child: Material(
borderRadius: BorderRadius.circular(24.0),
color: Colors.lightBlue[100],
elevation: 14.0,
shadowColor: Colors.blueGrey,
child: Container(
padding: const EdgeInsets.fromLTRB(25.0, 20.0, 25.0, 13.0),
child: Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
"Enter activities to add to your auto-generated schedule by clicking the plus icon at the bottom right.",
textAlign: TextAlign.center,
style: TextStyle(fontSize: 18, color: Colors.black,fontWeight: FontWeight.bold,),
),
],
)
)
)
),
),
Padding(padding: const EdgeInsets.fromLTRB(16.0, 25.0, 16.0, 16.0),
child: SizedBox(
height: 75,
width: 400,
child: Material(
borderRadius: BorderRadius.circular(24.0),
color: Colors.lightBlue[100],
elevation: 14.0,
shadowColor: Colors.blueGrey,
child: Container(
padding: const EdgeInsets.fromLTRB(25.0, 20.0, 25.0, 13.0),
child: Text("$textHolder", textAlign: TextAlign.center,style: TextStyle(fontFamily: 'Acme', fontSize: 17,)),
)
),
)
),
Column(mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: _tasks,
),
],),
]
)
);
}
}