Merge branch 'refilc:dev' into dev

This commit is contained in:
Tihanyi Marcell 2023-08-29 13:28:14 +02:00 committed by GitHub
commit e732b36cb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 24 deletions

View File

@ -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),
);
}

View File

@ -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(

View File

@ -66,11 +66,13 @@ 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);
_status.triggerRequest(res);
@ -123,13 +125,16 @@ 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);
if (res.statusCode == 401) {
@ -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,9 +207,10 @@ class KretaClient {
refreshToken: refreshToken!,
instituteCode: loginUser.instituteCode));
if (refreshRes != null) {
if (refreshRes.containsKey("id_token"))
if (refreshRes.containsKey("id_token")) {
idToken = refreshRes["id_token"];
}
}
}
}
}

View File

@ -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;

View File

@ -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,

View File

@ -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;
}

View File

@ -104,7 +104,6 @@ class _ModifyTeacherNamesState extends State<ModifyTeacherNames> {
.toSet()
.toList()
..sort((a, b) => a.name.compareTo(b.name)));
print(teachers.map((e) => e.name));
user = Provider.of<UserProvider>(context, listen: false);
dbProvider = Provider.of<DatabaseProvider>(context, listen: false);
}