From 458cfdd8a709f82668cddf1f5307dddc245f134c Mon Sep 17 00:00:00 2001 From: Kima Date: Tue, 29 Aug 2023 11:10:37 +0200 Subject: [PATCH 1/2] added db col for live activity color --- filcnaplo/lib/database/init.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/filcnaplo/lib/database/init.dart b/filcnaplo/lib/database/init.dart index e87209c..7c29324 100644 --- a/filcnaplo/lib/database/init.dart +++ b/filcnaplo/lib/database/init.dart @@ -28,6 +28,7 @@ const settingsDB = DatabaseStruct("settings", { "last_account_id": String, "renamed_subjects_enabled": int, "renamed_subjects_italics": int, "renamed_teachers_enabled": int, "renamed_teachers_italics": int, + "live_activity_color": String, }); // DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING // YOU'VE BEEN WARNED!!! From b4be0f66dce614af711b101be99d4792e3dc7735 Mon Sep 17 00:00:00 2001 From: Kima Date: Tue, 29 Aug 2023 11:16:17 +0200 Subject: [PATCH 2/2] fixed warnings --- filcnaplo/lib/models/settings.dart | 4 +--- .../lib/ui/widgets/lesson/lesson_tile.dart | 12 ++++++---- filcnaplo_kreta_api/lib/client/client.dart | 24 ++++++++++++------- .../lib/controllers/timetable_controller.dart | 3 ++- .../widgets/lesson/changed_lesson_tile.dart | 16 +++++++++---- .../common/widgets/lesson/lesson_view.dart | 2 +- .../mobile/settings/modify_teacher_names.dart | 1 - 7 files changed, 38 insertions(+), 24 deletions(-) diff --git a/filcnaplo/lib/models/settings.dart b/filcnaplo/lib/models/settings.dart index 2e4785f..6673228 100644 --- a/filcnaplo/lib/models/settings.dart +++ b/filcnaplo/lib/models/settings.dart @@ -161,8 +161,6 @@ class SettingsProvider extends ChangeNotifier { log("[ERROR] SettingsProvider.fromMap: $e"); } - print(map['seen_news']); - return SettingsProvider( database: database, language: map["language"], @@ -302,7 +300,7 @@ class SettingsProvider extends ChangeNotifier { renameSubjectsItalics: false, renameTeachersEnabled: false, renameTeachersItalics: false, - liveActivityColor: Color(0xFF676767), + liveActivityColor: const Color(0xFF676767), ); } diff --git a/filcnaplo/lib/ui/widgets/lesson/lesson_tile.dart b/filcnaplo/lib/ui/widgets/lesson/lesson_tile.dart index d8c4c19..2cae242 100644 --- a/filcnaplo/lib/ui/widgets/lesson/lesson_tile.dart +++ b/filcnaplo/lib/ui/widgets/lesson/lesson_tile.dart @@ -31,7 +31,7 @@ class LessonTile extends StatelessWidget { bool fill = false; bool fillLeading = false; String lessonIndexTrailing = ""; - + SettingsProvider settingsProvider = Provider.of(context); // Only put a trailing . if its a digit @@ -44,7 +44,7 @@ class LessonTile extends StatelessWidget { fillLeading = true; } - if (lesson.substituteTeacher != "") { + if (lesson.substituteTeacher?.name != "") { fill = true; accent = AppColors.of(context).yellow; } @@ -113,7 +113,7 @@ class LessonTile extends StatelessWidget { if (lesson.isChanged) { if (lesson.status?.name == "Elmaradt") { description = 'cancelled'.i18n; - } else if (lesson.substituteTeacher != "") { + } else if (lesson.substituteTeacher?.name != "") { description = 'substitution'.i18n; } } @@ -161,8 +161,10 @@ class LessonTile extends StatelessWidget { color: AppColors.of(context) .text .withOpacity(!lesson.isEmpty ? 1.0 : 0.5), - fontStyle: - lesson.subject.isRenamed && settingsProvider.renamedSubjectsItalics ? FontStyle.italic : null), + fontStyle: lesson.subject.isRenamed && + settingsProvider.renamedSubjectsItalics + ? FontStyle.italic + : null), ), subtitle: description != "" ? Text( diff --git a/filcnaplo_kreta_api/lib/client/client.dart b/filcnaplo_kreta_api/lib/client/client.dart index d980d0f..5217a76 100644 --- a/filcnaplo_kreta_api/lib/client/client.dart +++ b/filcnaplo_kreta_api/lib/client/client.dart @@ -66,10 +66,12 @@ class KretaClient { for (int i = 0; i < 3; i++) { if (autoHeader) { - if (!headerMap.containsKey("authorization") && accessToken != null) + if (!headerMap.containsKey("authorization") && accessToken != null) { headerMap["authorization"] = "Bearer $accessToken"; - if (!headerMap.containsKey("user-agent") && userAgent != null) + } + if (!headerMap.containsKey("user-agent") && userAgent != null) { headerMap["user-agent"] = "$userAgent"; + } } res = await client.get(Uri.parse(url), headers: headerMap); @@ -123,12 +125,15 @@ class KretaClient { for (int i = 0; i < 3; i++) { if (autoHeader) { - if (!headerMap.containsKey("authorization") && accessToken != null) + if (!headerMap.containsKey("authorization") && accessToken != null) { headerMap["authorization"] = "Bearer $accessToken"; - if (!headerMap.containsKey("user-agent") && userAgent != null) + } + if (!headerMap.containsKey("user-agent") && userAgent != null) { headerMap["user-agent"] = "$userAgent"; - if (!headerMap.containsKey("content-type")) + } + if (!headerMap.containsKey("content-type")) { headerMap["content-type"] = "application/json"; + } } res = await client.post(Uri.parse(url), headers: headerMap, body: body); @@ -183,10 +188,12 @@ class KretaClient { )); if (loginRes != null) { - if (loginRes.containsKey("access_token")) + if (loginRes.containsKey("access_token")) { accessToken = loginRes["access_token"]; - if (loginRes.containsKey("refresh_token")) + } + if (loginRes.containsKey("refresh_token")) { refreshToken = loginRes["refresh_token"]; + } // Update role loginUser.role = @@ -200,8 +207,9 @@ class KretaClient { refreshToken: refreshToken!, instituteCode: loginUser.instituteCode)); if (refreshRes != null) { - if (refreshRes.containsKey("id_token")) + if (refreshRes.containsKey("id_token")) { idToken = refreshRes["id_token"]; + } } } } diff --git a/filcnaplo_kreta_api/lib/controllers/timetable_controller.dart b/filcnaplo_kreta_api/lib/controllers/timetable_controller.dart index 77e79e8..f552062 100644 --- a/filcnaplo_kreta_api/lib/controllers/timetable_controller.dart +++ b/filcnaplo_kreta_api/lib/controllers/timetable_controller.dart @@ -119,8 +119,9 @@ class TimetableController extends ChangeNotifier { if (id < 0) return true; // Min 1. // Set week start to Sept. 1 of first week - if (!_differentDate(week.start, Week.fromId(0).start)) + if (!_differentDate(week.start, Week.fromId(0).start)) { week.start = TimetableController.getSchoolYearStart(); + } currentWeek = week; previousWeekId = currentWeekId; diff --git a/filcnaplo_mobile_ui/lib/common/widgets/lesson/changed_lesson_tile.dart b/filcnaplo_mobile_ui/lib/common/widgets/lesson/changed_lesson_tile.dart index bd0425d..68540ab 100755 --- a/filcnaplo_mobile_ui/lib/common/widgets/lesson/changed_lesson_tile.dart +++ b/filcnaplo_mobile_ui/lib/common/widgets/lesson/changed_lesson_tile.dart @@ -6,7 +6,8 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart'; import 'changed_lesson_tile.i18n.dart'; class ChangedLessonTile extends StatelessWidget { - const ChangedLessonTile(this.lesson, {Key? key, this.onTap, this.padding}) : super(key: key); + const ChangedLessonTile(this.lesson, {Key? key, this.onTap, this.padding}) + : super(key: key); final Lesson lesson; final void Function()? onTap; @@ -21,7 +22,7 @@ class ChangedLessonTile extends StatelessWidget { Color accent = Theme.of(context).colorScheme.secondary; - if (lesson.substituteTeacher != "") { + if (lesson.substituteTeacher?.name != '') { accent = AppColors.of(context).yellow; } @@ -38,7 +39,8 @@ class ChangedLessonTile extends StatelessWidget { visualDensity: VisualDensity.compact, contentPadding: const EdgeInsets.only(left: 8.0, right: 12.0), onTap: onTap, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)), + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(14.0)), leading: SizedBox( width: 44.0, height: 44.0, @@ -55,7 +57,9 @@ class ChangedLessonTile extends StatelessWidget { ), ), title: Text( - lesson.substituteTeacher != "" ? "substituted".i18n : "cancelled".i18n, + lesson.substituteTeacher?.name != "" + ? "substituted".i18n + : "cancelled".i18n, maxLines: 2, overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.w600), @@ -64,7 +68,9 @@ class ChangedLessonTile extends StatelessWidget { lesson.subject.renamedTo ?? lesson.subject.name.capital(), maxLines: 1, overflow: TextOverflow.ellipsis, - style: TextStyle(fontWeight: FontWeight.w500, fontStyle: lesson.subject.isRenamed ? FontStyle.italic : null), + style: TextStyle( + fontWeight: FontWeight.w500, + fontStyle: lesson.subject.isRenamed ? FontStyle.italic : null), ), trailing: const Icon(FeatherIcons.arrowRight), minLeadingWidth: 0, diff --git a/filcnaplo_mobile_ui/lib/common/widgets/lesson/lesson_view.dart b/filcnaplo_mobile_ui/lib/common/widgets/lesson/lesson_view.dart index 222e05f..dc2d560 100755 --- a/filcnaplo_mobile_ui/lib/common/widgets/lesson/lesson_view.dart +++ b/filcnaplo_mobile_ui/lib/common/widgets/lesson/lesson_view.dart @@ -22,7 +22,7 @@ class LessonView extends StatelessWidget { if (RegExp(r'\d').hasMatch(lesson.lessonIndex)) lessonIndexTrailing = "."; - if (lesson.substituteTeacher != "") { + if (lesson.substituteTeacher?.name != "") { accent = AppColors.of(context).yellow; } diff --git a/filcnaplo_premium/lib/ui/mobile/settings/modify_teacher_names.dart b/filcnaplo_premium/lib/ui/mobile/settings/modify_teacher_names.dart index ea89227..84c631c 100644 --- a/filcnaplo_premium/lib/ui/mobile/settings/modify_teacher_names.dart +++ b/filcnaplo_premium/lib/ui/mobile/settings/modify_teacher_names.dart @@ -104,7 +104,6 @@ class _ModifyTeacherNamesState extends State { .toSet() .toList() ..sort((a, b) => a.name.compareTo(b.name))); - print(teachers.map((e) => e.name)); user = Provider.of(context, listen: false); dbProvider = Provider.of(context, listen: false); }