Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ class ExamMonthTimeline extends ConsumerWidget {
super.key,
required this.now,
required this.monthDate,
required this.weekday,
required this.exams,
this.hiddenExams,
this.onToggleHidden,
});

final DateTime now;
final DateTime monthDate;
final String Function(DateTime) weekday;
final List<Exam> exams;
final List<String>? hiddenExams;
final void Function(String)? onToggleHidden;
Expand Down Expand Up @@ -47,7 +49,7 @@ class ExamMonthTimeline extends ConsumerWidget {
),
const SizedBox(height: 14),
CardTimeline(
items: _buildTimelineItems(exams, context, ref, appLocale),
items: _buildTimelineItems(exams, context, ref, appLocale, weekday),
),
],
),
Expand All @@ -59,13 +61,14 @@ class ExamMonthTimeline extends ConsumerWidget {
BuildContext context,
WidgetRef ref,
AppLocale appLocale,
String Function(DateTime) weekdayOf,
) {
return exams.map((exam) {
final isActive = _isExamActive(exam);
return TimelineItem(
isActive: isActive,
title: exam.start.day.toString(),
subtitle: exam.monthAcronym(appLocale),
subtitle: weekdayOf(exam.start),
lineHeight: 55,
card: ExamCard(
name: exam.subject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class ExamsPageView extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final locale = ref.watch(localeProvider.select((value) => value));
final localeNotifier = ref.read(localeProvider.notifier);
final daysOfTheWeek = localeNotifier.getWeekdaysWithLocale();

final examsByMonth = _examsByMonth(exams);
final now = DateTime.now();
Expand Down Expand Up @@ -72,6 +74,8 @@ class ExamsPageView extends ConsumerWidget {
exams: examsForMonth,
hiddenExams: hiddenExams,
onToggleHidden: onToggleHidden,
weekday: (dateTime) =>
_toShortVersion(daysOfTheWeek[dateTime.weekday - 1]),
);
}).toList();

Expand Down Expand Up @@ -103,4 +107,16 @@ class ExamsPageView extends ConsumerWidget {
}
return months;
}

String _toShortVersion(String dayOfTheWeek) {
final match = RegExp(r'^\p{L}+', unicode: true).firstMatch(dayOfTheWeek);
if (match != null) {
final matchedString = match.group(0)!;
final shortened = matchedString.length >= 3
? matchedString.substring(0, 3)
: matchedString;
return shortened[0].toUpperCase() + shortened.substring(1).toLowerCase();
}
return 'Blank';
}
}
Loading