1
0
forked from firka/firka

feat: shorten teacher's name

This commit is contained in:
checkedear
2026-06-11 13:29:20 +02:00
parent c67ce7472a
commit e211d64ffb
3 changed files with 24 additions and 2 deletions

View File

@@ -294,4 +294,26 @@ extension StringExtension on String {
if (length == 1) this[0].toUpperCase();
return this[0].toUpperCase() + substring(1, length);
}
String shortenName([int start = 0]) {
if (length <= 16 || start >= length) {
return this;
}
int index = indexOf(" ", start);
if (index == -1) {
return this;
}
String string = substring(start, index);
if (string.endsWith(".")) {
return this;
}
return replaceRange(
start,
index,
"${string[0]}.",
).shortenName(index - string.length + 2 + 1);
}
}

View File

@@ -166,7 +166,7 @@ class LessonWidget extends StatelessWidget {
),
showSubstitutions
? Text(
lesson.substituteTeacher!,
lesson.substituteTeacher!.shortenName(),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
),

View File

@@ -204,7 +204,7 @@ class LessonBigWidget extends StatelessWidget {
),
if (isSubstituted)
Text(
lesson.substituteTeacher!,
lesson.substituteTeacher!.shortenName(),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
),