diff --git a/lib/timetable/lesson.dart b/lib/timetable/lesson.dart index a5dc0955d24616c9afb1ab0c6d5528829aee99ec..885bd6efbfa0e195443f611651d9cbcbe80ff0f2 100644 --- a/lib/timetable/lesson.dart +++ b/lib/timetable/lesson.dart @@ -4,6 +4,7 @@ import '../context.dart'; import '../util/simultaneous.dart'; import '../untis/lesson.dart'; import 'lesson_dialog.dart'; +import 'lesson_label.dart'; typedef FloatingLesson = SimultaneousInstance<Lesson>; @@ -19,11 +20,6 @@ class LessonWidget extends StatelessWidget { : floatingLesson.fractionPosition / (floatingLesson.simultaneousCount - 1); - String get text => [ - lesson.lecture.name, - lesson.rooms.firstOrNull?.name ?? '(Kein Raum)', - ].join('\n'); - const LessonWidget({ super.key, required this.floatingLesson, @@ -50,7 +46,7 @@ class LessonWidget extends StatelessWidget { widthFactor: 1 / floatingLesson.simultaneousCount, alignment: Alignment(-1 + 2 * widthFactor, 0), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 2), + padding: const EdgeInsets.symmetric(horizontal: 1), child: Material( elevation: 2, color: Theme.of(context).primaryColor, @@ -60,14 +56,11 @@ class LessonWidget extends StatelessWidget { onTap: () => onTap(context), child: Container( height: (lesson.endMinutes - lesson.startMinutes) * zoom, - padding: const EdgeInsets.all(8), - child: Center( - child: Text( - text, - textAlign: TextAlign.center, - style: Theme.of(context).primaryTextTheme.bodySmall!, - ), + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 8, ), + child: LessonLabel(lesson: lesson), ), ), ), diff --git a/lib/timetable/lesson_label.dart b/lib/timetable/lesson_label.dart new file mode 100644 index 0000000000000000000000000000000000000000..7831b542b7e0b49f6533f4dc1cc5b8624e4596bd --- /dev/null +++ b/lib/timetable/lesson_label.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; + +import '../untis/lesson.dart'; + +class LessonLabel extends StatelessWidget { + final Lesson lesson; + + String get room => lesson.rooms.firstOrNull?.nameSplit ?? '(Kein Raum)'; + String get lecture => lesson.lecture.name; + + const LessonLabel({super.key, required this.lesson}); + + @override + Widget build(BuildContext context) { + return RichText( + text: TextSpan( + children: [ + TextSpan( + text: room, + style: const TextStyle(fontWeight: FontWeight.bold), + ), + const TextSpan(text: '\n\n'), + WidgetSpan( + child: Text( + lecture.substring(0, lecture.length - 5), + style: const TextStyle(overflow: TextOverflow.ellipsis), + )), + TextSpan(text: lecture.substring(lecture.length - 5)), + ], + style: Theme.of(context).primaryTextTheme.bodySmall!, + ), + textAlign: TextAlign.center, + ); + } +} diff --git a/lib/timetable/time_indicator.dart b/lib/timetable/time_indicator.dart index b370ba3f86805f1d8ad31a81f995d724aca0d1af..42b569e9fa6b21cd908ce4152e33bd3c8606fd48 100644 --- a/lib/timetable/time_indicator.dart +++ b/lib/timetable/time_indicator.dart @@ -7,7 +7,6 @@ import '../untis/lesson.dart'; import 'lesson.dart'; class TimeIndicator extends StatefulWidget { - static const double indicatorHeightPx = 2; final int progressInMinutes; const TimeIndicator({super.key, required this.progressInMinutes}); @@ -25,17 +24,9 @@ class _TimeIndicatorState extends State<TimeIndicator> { @override Widget build(BuildContext context) { - return Column( - children: [ - Container( - color: passedTimeOverlayColor, - height: max(0, yPosition - TimeIndicator.indicatorHeightPx), - ), - Container( - height: TimeIndicator.indicatorHeightPx, - color: Theme.of(context).colorScheme.primaryContainer, - ), - ], + return Container( + color: passedTimeOverlayColor, + height: max(0, yPosition), ); } } diff --git a/lib/untis/room.dart b/lib/untis/room.dart index a7a46cb04ec21a47c13ae3bc1a278825a2a15a98..82e895baad38f5ef42fb0fe733c658cd3f6cf0f4 100644 --- a/lib/untis/room.dart +++ b/lib/untis/room.dart @@ -8,5 +8,7 @@ class Room extends UntisElement { ? fullName.substring(0, fullName.indexOf('(')).trimRight() : fullName; + String get nameSplit => name.replaceFirst('-', ' - '); + Room(super.json); }