home,grades,tt: capitalize titles

some school administrators enter everything as lower case
This commit is contained in:
2025-09-29 18:28:55 +02:00
parent a96be41d01
commit 894d897778
8 changed files with 43 additions and 14 deletions

View File

@@ -127,9 +127,10 @@ extension DateExtension on DateTime {
case FormatMode.d:
return DateFormat('d', l10n.localeName).format(this);
case FormatMode.da:
final s =
DateFormat('EEEE', l10n.localeName).format(this).substring(0, 2);
return s[0].toUpperCase() + s[1];
return DateFormat('EEEE', l10n.localeName)
.format(this)
.substring(0, 2)
.firstUpper();
case FormatMode.dd:
return DateFormat('dd', l10n.localeName).format(this);
case FormatMode.yyyymmddwedd:
@@ -273,4 +274,10 @@ extension StringExtension on String {
final regex = RegExp(r'^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$');
return regex.hasMatch(trim());
}
String firstUpper() {
if (isEmpty) return this;
if (length == 1) this[0].toUpperCase();
return this[0].toUpperCase() + substring(1, length);
}
}

View File

@@ -106,7 +106,9 @@ Future<void> showLessonBottomSheet(
size: 20,
uid: lesson.uid,
className: lesson.name,
category: lesson.subject?.name ?? '',
category: lesson.subject?.name != null
? lesson.subject!.name.firstUpper()
: '',
),
),
),

View File

@@ -1,6 +1,7 @@
import 'package:firka/helpers/api/client/kreta_client.dart';
import 'package:firka/helpers/api/model/all_lessons.dart';
import 'package:firka/helpers/api/model/generic.dart';
import 'package:firka/helpers/extensions.dart';
import 'package:firka/helpers/ui/firka_card.dart';
import 'package:firka/helpers/ui/grade_helpers.dart';
import 'package:firka/ui/widget/grade_small_card.dart';
@@ -132,7 +133,7 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
.isEmpty) {
subjects.add(Subject(
uid: lesson.subjectId?.toString() ?? '',
name: lesson.subjectName,
name: lesson.subjectName.firstUpper(),
teacherName: lesson.teacherName,
category: NameUidDesc(
uid: lesson.subjectCategoryId?.toString() ?? '',

View File

@@ -101,7 +101,9 @@ class _HomeGradesSubjectScreen extends FirkaState<HomeGradesSubjectScreen> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 1.45,
child: Text(grade.topic ?? grade.type.description!,
child: Text(
(grade.topic ?? grade.type.description!)
.firstUpper(),
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary)),
),
@@ -109,7 +111,7 @@ class _HomeGradesSubjectScreen extends FirkaState<HomeGradesSubjectScreen> {
? SizedBox(
width: MediaQuery.of(context).size.width / 1.45,
child: Text(
grade.mode!.description!,
grade.mode!.description!.firstUpper(),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary),
),

View File

@@ -247,7 +247,9 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 1.45,
child: Text(grade.topic ?? grade.type.description!,
child: Text(
(grade.topic ?? grade.type.description!)
.firstUpper(),
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textPrimary)),
),
@@ -255,7 +257,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
? SizedBox(
width: MediaQuery.of(context).size.width / 1.45,
child: Text(
grade.mode!.description!,
grade.mode!.description!.firstUpper(),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary),
),

View File

@@ -67,6 +67,7 @@ class LessonWidget extends StatelessWidget {
if (subjectName.length >= 25) {
subjectName = "${subjectName.substring(0, 25 - 3)}...";
}
subjectName = subjectName.firstUpper();
var roomName = lesson.roomName ?? '?';
if (roomName.length >= 8) {
@@ -121,7 +122,9 @@ class LessonWidget extends StatelessWidget {
size: 20,
uid: lesson.uid,
className: lesson.name,
category: lesson.subject?.name ?? '',
category: lesson.subject?.name != null
? lesson.subject!.name.firstUpper()
: '',
),
),
!showTests && test != null
@@ -183,6 +186,15 @@ class LessonWidget extends StatelessWidget {
}
if (test != null && showTests) {
var theme = test!.theme;
if (theme.length >= 25) {
theme = "${theme.substring(0, 25)}...";
}
var method = test!.method.description ?? 'N/A';
theme = theme.firstUpper();
method = method.firstUpper();
elements.add(FirkaCard(
left: [
FirkaIconWidget(
@@ -191,12 +203,12 @@ class LessonWidget extends StatelessWidget {
color: appStyle.colors.accent,
),
SizedBox(width: 6),
Text(test!.theme,
Text(theme,
style: appStyle.fonts.B_16SB
.apply(color: appStyle.colors.textSecondary))
],
right: [
Text(test!.method.description ?? "N/A",
Text(method,
style: appStyle.fonts.B_16R
.apply(color: appStyle.colors.textTertiary))
],

View File

@@ -21,6 +21,7 @@ class LessonSmallWidget extends StatelessWidget {
if (subjectName.length >= 25) {
subjectName = "${subjectName.substring(0, 25 - 3)}...";
}
subjectName = subjectName.firstUpper();
var roomName = lesson.roomName ?? '?';
if (roomName.length >= 8) {
@@ -38,7 +39,9 @@ class LessonSmallWidget extends StatelessWidget {
size: 20,
uid: lesson.uid,
className: lesson.name,
category: lesson.subject?.name ?? '',
category: lesson.subject?.name != null
? lesson.subject!.name.firstUpper()
: '',
),
SizedBox(width: 8),
Text(subjectName,