replaced generic "Event" label with substitution or lesson text

This commit is contained in:
2026-09-24 22:22:43 +02:00
parent 498d195138
commit 4f31e68456
4 changed files with 81 additions and 4 deletions
@@ -1,4 +1,5 @@
import '../../../../api/marianumconnect/queries/timetable_get_week/timetable_get_week_response.dart';
import 'lesson_labels.dart';
/// Derives a human-readable title from the Marianum-Connect `lessonType` for
/// lessons that have no subject of their own (Aufsicht, Sprechstunde, …).
@@ -10,10 +11,20 @@ class LessonTypeLabel {
static String forEntry(McTimetableEntry lesson) {
final base = baseLabel(lesson.lessonType);
if (base == fallback) {
final text = entryText(lesson);
if (text != null) return text;
}
final room = (lesson.rooms.firstOrNull ?? '').trim();
return room.isEmpty ? base : '$room $base';
}
/// Webuntis-Freitext eines fachlosen Eintrags („Klassenfahrt 8a“), der
/// aussagekräftiger ist als das generische „Event“.
static String? entryText(McTimetableEntry lesson) =>
collapseWhitespace(lesson.substitutionText) ??
collapseWhitespace(lesson.lessonText);
/// Returns just the type wording without the room — useful when the caller
/// renders the room separately (e.g. as a subtitle line).
static String baseLabel(String lessonType) {
@@ -10,6 +10,7 @@ import '../../../../state/app/modules/timetable/bloc/timetable_bloc.dart';
import '../../../../state/app/modules/timetable/bloc/timetable_state.dart';
import '../../../../widget/debug/debug_tile.dart';
import '../../../../widget/details_bottom_sheet.dart';
import '../data/lesson_labels.dart';
import '../data/lesson_type_label.dart';
import '../subject_colors/subject_color_picker.dart';
@@ -226,10 +227,13 @@ class LessonSheet {
}
static List<Widget> _optionalTextTiles(McTimetableEntry lesson) {
final sameText =
collapseWhitespace(lesson.lessonText) ==
collapseWhitespace(lesson.substitutionText);
return <Widget?>[
_textTile(Icons.info_outline, 'Info', lesson.infoText),
_textTile(Icons.swap_horiz, 'Vertretungstext', lesson.substitutionText),
_textTile(Icons.subject, 'Stundentext', lesson.lessonText),
if (!sameText) _textTile(Icons.subject, 'Stundentext', lesson.lessonText),
_textTile(
Icons.category_outlined,
'Stundentyp',
+6 -3
View File
@@ -14,6 +14,7 @@ import '../view/pages/timetable/data/lesson_labels.dart';
import '../view/pages/timetable/data/lesson_merger.dart';
import '../view/pages/timetable/data/lesson_period_schedule.dart';
import '../view/pages/timetable/data/lesson_status.dart';
import '../view/pages/timetable/data/lesson_type_label.dart';
import 'widget_data.dart';
class WidgetDataMapper {
@@ -326,9 +327,11 @@ class WidgetDataMapper {
LessonStatusClassifier.classify(lesson, start, end, now),
);
final subjectShortRaw = lesson.subjects.firstOrNull?.trim() ?? '';
// Webuntis sometimes ships subject-less entries (Wandertag etc.). Fall
// back to "Event" so the tile isn't just a dash.
final subjectShort = subjectShortRaw.isEmpty ? 'Event' : subjectShortRaw;
// Webuntis sometimes ships subject-less entries (Wandertag etc.). Prefer
// their free text, else "Event" so the tile isn't just a dash.
final subjectShort = subjectShortRaw.isEmpty
? LessonTypeLabel.entryText(lesson) ?? LessonTypeLabel.fallback
: subjectShortRaw;
String? subjectLong;
if (subjects != null && subjectShortRaw.isNotEmpty) {
subjectLong = subjects.result