Skip to content

Commit

Permalink
[timetable] supporting multi-layer course?
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Mar 19, 2024
1 parent 58dce9a commit 70456a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lib/timetable/entity/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ class SitTimetableLessonSlot {
final List<SitTimetableLessonPart> lessons;

SitTimetableLessonSlot({required this.lessons});

SitTimetableLessonPart? lessonAt(int index){
return lessons.elementAtOrNull(index);
}
}

class SitTimetableDay {
Expand Down
3 changes: 2 additions & 1 deletion lib/timetable/page/details.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:rettulf/rettulf.dart';
import 'package:sit/design/widgets/card.dart';
import 'package:sit/l10n/time.dart';
import 'package:text_scroll/text_scroll.dart';

Expand Down Expand Up @@ -99,6 +100,6 @@ class CourseDescCard extends StatelessWidget {
...weekNumbers.map((n) => n.text()),
].column(mas: MainAxisSize.min, caa: CrossAxisAlignment.start),
trailing: course.teachers.length == 1 ? course.teachers.first.text() : null,
);
).inFilledCard();
}
}
16 changes: 8 additions & 8 deletions lib/timetable/widgets/timetable/weekly.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,30 +294,30 @@ class TimetableOneWeek extends StatelessWidget {
));
for (int timeslot = 0; timeslot < day.timeslot2LessonSlot.length; timeslot++) {
final lessonSlot = day.timeslot2LessonSlot[timeslot];
if (lessonSlot.lessons.isEmpty) {

/// TODO: Multi-layer lessonSlot
final lesson = lessonSlot.lessonAt(0);
if (lesson == null) {
cells.add(DashLined(
top: timeslot != 0,
bottom: timeslot != day.timeslot2LessonSlot.length - 1,
child: SizedBox(width: cellSize.width, height: cellSize.height),
));
} else {
/// TODO: Multi-layer lessonSlot
final firstLayerLesson = lessonSlot.lessons[0];

/// TODO: Range checking
final course = firstLayerLesson.course;
final course = lesson.course;
cells.add(SizedBox(
width: cellSize.width,
height: cellSize.height * firstLayerLesson.type.timeslotDuration,
height: cellSize.height * lesson.type.timeslotDuration,
child: cellBuilder(
context: context,
lesson: firstLayerLesson,
lesson: lesson,
timetable: timetable,
),
));

/// Skip to the end
timeslot = firstLayerLesson.type.endIndex;
timeslot = lesson.type.endIndex;
}
}

Expand Down

0 comments on commit 70456a5

Please sign in to comment.