diff --git a/firka/lib/helpers/extensions.dart b/firka/lib/helpers/extensions.dart index 0ba7198..dc330aa 100644 --- a/firka/lib/helpers/extensions.dart +++ b/firka/lib/helpers/extensions.dart @@ -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); + } } diff --git a/firka/lib/helpers/ui/common_bottom_sheets.dart b/firka/lib/helpers/ui/common_bottom_sheets.dart index ba40fb4..a6957dd 100644 --- a/firka/lib/helpers/ui/common_bottom_sheets.dart +++ b/firka/lib/helpers/ui/common_bottom_sheets.dart @@ -106,7 +106,9 @@ Future showLessonBottomSheet( size: 20, uid: lesson.uid, className: lesson.name, - category: lesson.subject?.name ?? '', + category: lesson.subject?.name != null + ? lesson.subject!.name.firstUpper() + : '', ), ), ), diff --git a/firka/lib/l10n b/firka/lib/l10n index 2d47545..572abf7 160000 --- a/firka/lib/l10n +++ b/firka/lib/l10n @@ -1 +1 @@ -Subproject commit 2d4754563d1e88031fa182d66d5c219a1712021a +Subproject commit 572abf7d8ddaa718f80750294f863d62ef55045d diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index 2e9c6c5..e38cff3 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -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 { .isEmpty) { subjects.add(Subject( uid: lesson.subjectId?.toString() ?? '', - name: lesson.subjectName, + name: lesson.subjectName.firstUpper(), teacherName: lesson.teacherName, category: NameUidDesc( uid: lesson.subjectCategoryId?.toString() ?? '', diff --git a/firka/lib/ui/phone/pages/home/home_grades_subject.dart b/firka/lib/ui/phone/pages/home/home_grades_subject.dart index d4bf985..846fa97 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -101,7 +101,9 @@ class _HomeGradesSubjectScreen extends FirkaState { 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 { ? 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), ), diff --git a/firka/lib/ui/phone/pages/home/home_main.dart b/firka/lib/ui/phone/pages/home/home_main.dart index 8a65ecb..c27a761 100644 --- a/firka/lib/ui/phone/pages/home/home_main.dart +++ b/firka/lib/ui/phone/pages/home/home_main.dart @@ -247,7 +247,9 @@ class _HomeMainScreen extends FirkaState { 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 { ? 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), ), diff --git a/firka/lib/ui/phone/widgets/lesson.dart b/firka/lib/ui/phone/widgets/lesson.dart index d2132d7..8483767 100644 --- a/firka/lib/ui/phone/widgets/lesson.dart +++ b/firka/lib/ui/phone/widgets/lesson.dart @@ -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)) ], diff --git a/firka/lib/ui/phone/widgets/lesson_small.dart b/firka/lib/ui/phone/widgets/lesson_small.dart index 08caa60..6e0d4dd 100644 --- a/firka/lib/ui/phone/widgets/lesson_small.dart +++ b/firka/lib/ui/phone/widgets/lesson_small.dart @@ -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,