Commit b5ece9db authored by wonko's avatar wonko

lecture cards werden nach vortragszeiten skaliert

parent 6664b3e3
......@@ -70,7 +70,22 @@ class Lectures {
String version;
List<Room> rooms = [];
static DateTime startTime = DateTime(2019, 6, 14, 17, 0);
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;
DateTime nextTime;
do {
nextTime = times[i - 1].add(Duration(hours: 1));
times.add(nextTime);
i++;
} while (nextTime.isBefore(Lectures.endTime));
return times;
}
Lectures(final this.version, final this.rooms);
......@@ -197,7 +212,7 @@ class Lecture {
}
@override
String toString(){
String toString() {
return "Lecture $id ${start} ${end}";
}
......@@ -206,7 +221,12 @@ class Lecture {
List<String> timeHM = timeString.split('.');
int hours = int.parse(timeHM[0]);
int minutes = int.parse(timeHM[1]);
return DateTime(date.year, date.month, date.day, hours, minutes);
DateTime dt = DateTime(date.year, date.month, date.day, hours, minutes);
if (hours > date.hour) {
return dt;
} else {
return dt.add(Duration(days: 1));
}
}
factory Lecture.fromJSON(Map<String, dynamic> json) {
......@@ -214,7 +234,6 @@ class Lecture {
String time = json['time'];
List<String> times = time.split('-');
DateTime start = fromDateandTime(Lectures.startTime, times[0]);
DateTime end = fromDateandTime(Lectures.startTime, times[1]);
......
......@@ -71,18 +71,13 @@ class TimesSlider extends StatelessWidget {
final ScrollController _scrollController;
final Room room;
static List<String> hours = List<String>.generate(17, (i) {
int hr = i + 17;
return "$hr";
});
TimesSlider(this._scrollController, this.room);
@override
Widget build(BuildContext context) {
return ListView.builder(
controller: this._scrollController,
itemCount: 4 * 12,
itemCount: Lectures.lectureHours().length,
itemBuilder: (context, index) =>
Column(children: <Widget>[
Divider(height: 1),
......@@ -91,7 +86,7 @@ class TimesSlider extends StatelessWidget {
child: Align(
alignment: Alignment.topLeft,
child: Text(
hours[index],
"${Lectures.lectureHours()[index].hour}:00",
style: Theme
.of(context)
.textTheme
......@@ -103,7 +98,7 @@ class TimesSlider extends StatelessWidget {
child: Align(
alignment: Alignment.topLeft,
child: Text(
hours[index],
"${Lectures.lectureHours()[index].hour}:15",
style: Theme
.of(context)
.textTheme
......@@ -115,7 +110,7 @@ class TimesSlider extends StatelessWidget {
child: Align(
alignment: Alignment.topLeft,
child: Text(
hours[index],
"${Lectures.lectureHours()[index].hour}:30",
style: Theme
.of(context)
.textTheme
......@@ -127,7 +122,7 @@ class TimesSlider extends StatelessWidget {
child: Align(
alignment: Alignment.topLeft,
child: Text(
hours[index],
"${Lectures.lectureHours()[index].hour}:45",
style: Theme
.of(context)
.textTheme
......
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