Commit 601db87d authored by wonko's avatar wonko

bug bei erster lecture zeitgleich mit eventbeginn behoben

parent b5ece9db
......@@ -73,7 +73,6 @@ class Lectures {
static final DateTime startTime = DateTime(2019, 6, 14, 17, 0);
static final DateTime endTime = startTime.add(Duration(hours: 10));
static List<DateTime> lectureHours() {
List<DateTime> times = [Lectures.startTime];
int i = 1;
......@@ -207,8 +206,13 @@ class Lecture {
final this.id);
factory Lecture.empty({DateTime start, DateTime end}) {
return Lecture(
null, null, null, null, null, null, start, end, Lecture._emptyID);
if (!end.isAtSameMomentAs(start)) {
return Lecture(
null, null, null, null, null, null, start, end, Lecture._emptyID);
} else {
print("fddddddddddddddddddddddddddddddddddddddddd");
return null;
}
}
@override
......@@ -222,7 +226,7 @@ class Lecture {
int hours = int.parse(timeHM[0]);
int minutes = int.parse(timeHM[1]);
DateTime dt = DateTime(date.year, date.month, date.day, hours, minutes);
if (hours > date.hour) {
if (hours >= date.hour) {
return dt;
} else {
return dt.add(Duration(days: 1));
......
......@@ -39,21 +39,21 @@ class _ScheduleWidgetState extends State<ScheduleWidget>
builder: (BuildContext context, AsyncSnapshot snapshot) {
return snapshot.hasData
? Stack(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 100.0),
child: TimesSlider(_timeScaleScrollController,
lectureData.data.rooms[0])),
NotificationListener<ScrollNotification>(
child: PageView(
children: roomViews(),
),
onNotification: (ScrollNotification scrollInfo) {
_timeScaleScrollController.jumpTo(
_scheduleScrollController.initialScrollOffset);
})
],
)
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 100.0),
child: TimesSlider(_timeScaleScrollController,
lectureData.data.rooms[0])),
NotificationListener<ScrollNotification>(
child: PageView(
children: roomViews(),
),
onNotification: (ScrollNotification scrollInfo) {
_timeScaleScrollController.jumpTo(
_scheduleScrollController.initialScrollOffset);
})
],
)
: Center(child: CircularProgressIndicator());
});
}
......@@ -61,7 +61,7 @@ class _ScheduleWidgetState extends State<ScheduleWidget>
List<Widget> roomViews() {
List<Widget> rv = [];
for (Room room in lectureData.data.rooms) {
rv.add(RoomSchedule(_scheduleScrollController, room));
rv.add(RoomSchedule.fromRoom(_scheduleScrollController, room));
}
return rv;
}
......@@ -78,8 +78,7 @@ class TimesSlider extends StatelessWidget {
return ListView.builder(
controller: this._scrollController,
itemCount: Lectures.lectureHours().length,
itemBuilder: (context, index) =>
Column(children: <Widget>[
itemBuilder: (context, index) => Column(children: <Widget>[
Divider(height: 1),
SizedBox(
height: ScheduleWidget.px_per_quarter - 1,
......@@ -87,10 +86,7 @@ class TimesSlider extends StatelessWidget {
alignment: Alignment.topLeft,
child: Text(
"${Lectures.lectureHours()[index].hour}:00",
style: Theme
.of(context)
.textTheme
.overline,
style: Theme.of(context).textTheme.overline,
textAlign: TextAlign.left,
))),
SizedBox(
......@@ -99,10 +95,7 @@ class TimesSlider extends StatelessWidget {
alignment: Alignment.topLeft,
child: Text(
"${Lectures.lectureHours()[index].hour}:15",
style: Theme
.of(context)
.textTheme
.overline,
style: Theme.of(context).textTheme.overline,
textAlign: TextAlign.left,
))),
SizedBox(
......@@ -111,10 +104,7 @@ class TimesSlider extends StatelessWidget {
alignment: Alignment.topLeft,
child: Text(
"${Lectures.lectureHours()[index].hour}:30",
style: Theme
.of(context)
.textTheme
.overline,
style: Theme.of(context).textTheme.overline,
textAlign: TextAlign.left,
))),
SizedBox(
......@@ -123,10 +113,7 @@ class TimesSlider extends StatelessWidget {
alignment: Alignment.topLeft,
child: Text(
"${Lectures.lectureHours()[index].hour}:45",
style: Theme
.of(context)
.textTheme
.overline,
style: Theme.of(context).textTheme.overline,
textAlign: TextAlign.left,
))),
]));
......@@ -137,9 +124,12 @@ class RoomSchedule extends StatelessWidget {
final ScrollController _scrollController;
final Room room;
List<Lecture> _roomSchedule = [];
final List<Lecture> roomSchedule;
RoomSchedule(this._scrollController, this.room, this.roomSchedule);
RoomSchedule(this._scrollController, final this.room) {
factory RoomSchedule.fromRoom(ScrollController scrollController, Room room) {
List<Lecture> _roomSchedule = [];
if (room.lectures.length > 0) {
DateTime lastEnd = Lectures.startTime;
DateTime nextStart;
......@@ -147,13 +137,17 @@ class RoomSchedule extends StatelessWidget {
do {
nextStart = room.lectures[i].start;
Lecture sparse = Lecture.empty(start: lastEnd, end: nextStart);
_roomSchedule.add(sparse);
if (sparse != null) {
_roomSchedule.add(sparse);
}
_roomSchedule.add(room.lectures[i]);
lastEnd = room.lectures[i].end;
i++;
} while (i < room.lectures.length);
}
print(_roomSchedule);
return RoomSchedule(scrollController, room, _roomSchedule);
}
@override
......@@ -172,11 +166,9 @@ class RoomSchedule extends StatelessWidget {
)),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) =>
Column(children: <Widget>[
LectureCard(_roomSchedule[index])
]),
childCount: _roomSchedule.length))
(context, index) => Column(
children: <Widget>[LectureCard(roomSchedule[index])]),
childCount: roomSchedule.length))
]));
}
}
......@@ -187,24 +179,21 @@ class _LectureCardState extends State<LectureCard> {
_LectureCardState(this.l);
double pxFromDureation(DateTime start, DateTime end) {
int minutes = start
.difference(end)
.inMinutes
.abs();
int minutes = start.difference(end).inMinutes.abs();
return ScheduleWidget.px_per_minute * minutes;
}
@override
Widget build(BuildContext context) {
print("Building Lecturecard $l");
if (!l.isEmpy()) {
IconData ico = Fachschaften().getIcon(l.fs);
return SizedBox(
height: pxFromDureation(l.start, l.end),
child: Container(padding:
EdgeInsets.only(left: 50.0, top: 0.0, right: 10.0, bottom: 0.0),
child: Container(
padding: EdgeInsets.only(
left: 50.0, top: 0.0, right: 10.0, bottom: 0.0),
child: Card(
color: Fachschaften().getColor(l.fs),
child: Column(
mainAxisSize: MainAxisSize.min,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment