From 9fc73e3c5cab1e1eddc9d8f6e6222bfa7e78c25a Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Sun, 1 Mar 2026 14:57:24 +0100 Subject: [PATCH] firka_wear: use kreta_api for API models --- firka_wear/lib/helpers/api/consts.dart | 22 -- firka_wear/lib/helpers/api/model/generic.dart | 64 ------ firka_wear/lib/helpers/api/model/grade.dart | 123 ----------- .../lib/helpers/api/model/guardian.dart | 52 ----- .../lib/helpers/api/model/homework.dart | 70 ------- .../lib/helpers/api/model/institution.dart | 100 --------- .../lib/helpers/api/model/notice_board.dart | 42 ---- .../lib/helpers/api/model/omission.dart | 98 --------- firka_wear/lib/helpers/api/model/student.dart | 133 ------------ firka_wear/lib/helpers/api/model/subject.dart | 50 ----- firka_wear/lib/helpers/api/model/test.dart | 60 ------ .../lib/helpers/api/model/timetable.dart | 195 ------------------ .../lib/helpers/api/resp/token_grant.dart | 54 ----- firka_wear/lib/helpers/extensions.dart | 39 ++-- firka_wear/lib/helpers/icon_helper.dart | 38 ++-- .../lib/helpers/sync/wear_sync_store.dart | 3 +- firka_wear/lib/helpers/ui/grade.dart | 49 +++-- firka_wear/lib/helpers/ui/grade_helpers.dart | 3 +- .../helpers/ui/stateless_async_widget.dart | 21 +- firka_wear/lib/ui/model/style.dart | 147 ++++++------- .../lib/ui/wear/screens/home/home_screen.dart | 3 +- .../ui/wear/screens/login/login_screen.dart | 3 +- .../widgets/circular_progress_indicator.dart | 6 +- firka_wear/lib/ui/widget/class_icon.dart | 28 +-- firka_wear/lib/ui/widget/counter_digit.dart | 5 +- firka_wear/lib/ui/widget/firka_icon.dart | 14 +- .../lib/ui/widget/grade_small_card.dart | 40 ++-- firka_wear/pubspec.yaml | 2 + 28 files changed, 227 insertions(+), 1237 deletions(-) delete mode 100644 firka_wear/lib/helpers/api/consts.dart delete mode 100644 firka_wear/lib/helpers/api/model/generic.dart delete mode 100644 firka_wear/lib/helpers/api/model/grade.dart delete mode 100644 firka_wear/lib/helpers/api/model/guardian.dart delete mode 100644 firka_wear/lib/helpers/api/model/homework.dart delete mode 100644 firka_wear/lib/helpers/api/model/institution.dart delete mode 100644 firka_wear/lib/helpers/api/model/notice_board.dart delete mode 100644 firka_wear/lib/helpers/api/model/omission.dart delete mode 100644 firka_wear/lib/helpers/api/model/student.dart delete mode 100644 firka_wear/lib/helpers/api/model/subject.dart delete mode 100644 firka_wear/lib/helpers/api/model/test.dart delete mode 100644 firka_wear/lib/helpers/api/model/timetable.dart delete mode 100644 firka_wear/lib/helpers/api/resp/token_grant.dart diff --git a/firka_wear/lib/helpers/api/consts.dart b/firka_wear/lib/helpers/api/consts.dart deleted file mode 100644 index f12c4626..00000000 --- a/firka_wear/lib/helpers/api/consts.dart +++ /dev/null @@ -1,22 +0,0 @@ -/* - Firka, alternative e-Kréta client. - Copyright (C) 2025 QwIT Development - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -/// Watch no longer calls Kréta API; data comes from phone via init_data/sync_data. -class Constants { - static const clientId = "kreta-ellenorzo-student-mobile-ios"; -} diff --git a/firka_wear/lib/helpers/api/model/generic.dart b/firka_wear/lib/helpers/api/model/generic.dart deleted file mode 100644 index cb2d276d..00000000 --- a/firka_wear/lib/helpers/api/model/generic.dart +++ /dev/null @@ -1,64 +0,0 @@ -class NameUidDesc { - final String uid; - final String? name; - final String? description; - - NameUidDesc({ - required this.uid, - required this.name, - required this.description, - }); - - factory NameUidDesc.fromJson(Map json) { - return NameUidDesc( - uid: json['Uid'], - name: json['Nev'], - description: json['Leiras'], - ); - } - - Map toJson() { - return {'Uid': uid, 'Nev': name, 'Leiras': description}; - } - - @override - String toString() { - return 'NameUidDesc(' - 'uid: "$uid", ' - 'name: "$name", ' - 'description: "$description"' - ')'; - } -} - -class NameUid { - final String uid; - final String name; - - NameUid({required this.uid, required this.name}); - - factory NameUid.fromJson(Map json) { - return NameUid(uid: json['Uid'], name: json['Nev']); - } - - Map toJson() { - return {'Uid': uid, 'Nev': name}; - } -} - -class UidObj { - final String uid; - - UidObj({required this.uid}); - - factory UidObj.fromJson(Map json) { - return UidObj(uid: json['Uid']); - } - - @override - String toString() { - return 'UidObj(' - 'uid: "$uid"' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/grade.dart b/firka_wear/lib/helpers/api/model/grade.dart deleted file mode 100644 index 0b0d5c37..00000000 --- a/firka_wear/lib/helpers/api/model/grade.dart +++ /dev/null @@ -1,123 +0,0 @@ -import 'package:firka_wear/helpers/api/model/generic.dart'; -import 'package:firka_wear/helpers/api/model/subject.dart'; - -class Grade { - final String uid; - final DateTime recordDate; - final DateTime creationDate; - final DateTime? ackDate; - final Subject subject; - final String? topic; - final NameUidDesc type; - final NameUidDesc? mode; - NameUidDesc valueType; - final String teacher; - final String? kind; - int? numericValue; - final String strValue; - final int? weightPercentage; - final String? shortStrValue; - final UidObj? classGroup; - final int sortIndex; - - Grade({ - required this.uid, - required this.recordDate, - required this.creationDate, - this.ackDate, - required this.subject, - this.topic, - required this.type, - this.mode, - required this.valueType, - required this.teacher, - this.kind, - this.numericValue, - required this.strValue, - this.weightPercentage, - this.shortStrValue, - this.classGroup, - required this.sortIndex, - }); - - factory Grade.fromJson(Map json) { - return Grade( - uid: json['Uid'], - recordDate: DateTime.parse(json['RogzitesDatuma']).toLocal(), - creationDate: DateTime.parse(json['KeszitesDatuma']).toLocal(), - ackDate: json['LattamozasDatuma'] != null - ? DateTime.parse(json['LattamozasDatuma']).toLocal() - : null, - subject: Subject.fromJson( - Map.from(json['Tantargy'] as Map), - ), - topic: json['Tema'], - type: NameUidDesc.fromJson( - Map.from(json['Tipus'] as Map), - ), - mode: json['Mod'] != null - ? NameUidDesc.fromJson(Map.from(json['Mod'] as Map)) - : null, - valueType: NameUidDesc.fromJson( - Map.from(json['ErtekFajta'] as Map), - ), - teacher: json['ErtekeloTanarNeve'], - kind: json['Kind'], - numericValue: json['SzamErtek'], - strValue: json['SzovegesErtek'], - weightPercentage: json['SulySzazalekErteke'], - shortStrValue: json['SzovegesErtekelesRovidNev'], - classGroup: json['OsztalyCsoport'] != null - ? UidObj.fromJson( - Map.from(json['OsztalyCsoport'] as Map), - ) - : null, - sortIndex: json['SortIndex'], - ); - } - - Map toJson() { - return { - 'Uid': uid, - 'RogzitesDatuma': recordDate.toUtc().toIso8601String(), - 'KeszitesDatuma': creationDate.toUtc().toIso8601String(), - 'LattamozasDatuma': ackDate?.toUtc().toIso8601String(), - 'Tantargy': subject.toJson(), - 'Tema': topic, - 'Tipus': type.toJson(), - 'Mod': mode?.toJson(), - 'ErtekFajta': valueType.toJson(), - 'ErtekeloTanarNeve': teacher, - 'Kind': kind, - 'SzamErtek': numericValue, - 'SzovegesErtek': strValue, - 'SulySzazalekErteke': weightPercentage, - 'SzovegesErtekelesRovidNev': shortStrValue, - 'OsztalyCsoport': classGroup != null ? {'Uid': classGroup!.uid} : null, - 'SortIndex': sortIndex, - }; - } - - @override - String toString() { - return 'Grade(' - 'uid: "$uid", ' - 'recordDate: "$recordDate", ' - 'creationDate: "$creationDate", ' - 'ackDate: "${ackDate ?? 'null'}", ' - 'subject: $subject, ' - 'topic: "${topic ?? 'null'}", ' - 'type: $type, ' - 'mode: ${mode ?? 'null'}, ' - 'valueType: $valueType, ' - 'teacher: "$teacher", ' - 'kind: "${kind ?? 'null'}", ' - 'numericValue: ${numericValue ?? 'null'}, ' - 'strValue: "$strValue", ' - 'weightPercentage: ${weightPercentage ?? 'null'}, ' - 'shortStrValue: "${shortStrValue ?? 'null'}", ' - 'classGroup: ${classGroup ?? 'null'}, ' - 'sortIndex: $sortIndex' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/guardian.dart b/firka_wear/lib/helpers/api/model/guardian.dart deleted file mode 100644 index a324abfb..00000000 --- a/firka_wear/lib/helpers/api/model/guardian.dart +++ /dev/null @@ -1,52 +0,0 @@ -/* - Firka, alternative e-Kréta client. - Copyright (C) 2025 QwIT Development - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -class Guardian { - final String? email; - final bool isLegalRepresentative; - final String? name; - final String? phoneNumber; - final String uid; - - Guardian( - {required this.email, - required this.isLegalRepresentative, - required this.name, - required this.phoneNumber, - required this.uid}); - - factory Guardian.fromJson(Map json) { - return Guardian( - email: json['EmailCim'], - isLegalRepresentative: json['IsTorvenyesKepviselo'], - name: json['Nev'], - phoneNumber: json['Telefonszam'], - uid: json['Uid']); - } - - @override - String toString() { - return 'Guardian(' - 'email: "$email", ' - 'isLegalRepresentative: $isLegalRepresentative, ' - 'name: "$name", ' - 'phoneNumber: "$phoneNumber", ' - 'uid: "$uid"' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/homework.dart b/firka_wear/lib/helpers/api/model/homework.dart deleted file mode 100644 index eafdabe7..00000000 --- a/firka_wear/lib/helpers/api/model/homework.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'package:firka_wear/helpers/api/model/subject.dart'; - -import 'generic.dart'; - -class Homework { - final String uid; - final Subject subject; - final String subjectName; - final String teacherName; - final String description; - final DateTime startDate; - final DateTime dueDate; - final DateTime creationDate; - final bool isCreatedByTeacher; - final bool isDone; - final bool canBeSubmitted; - final UidObj classGroup; - final bool canAttach; - - Homework( - {required this.uid, - required this.subject, - required this.subjectName, - required this.teacherName, - required this.description, - required this.startDate, - required this.dueDate, - required this.creationDate, - required this.isCreatedByTeacher, - required this.isDone, - required this.canBeSubmitted, - required this.classGroup, - required this.canAttach}); - - factory Homework.fromJson(Map json) { - return Homework( - uid: json["Uid"], - subject: Subject.fromJson(json["Tantargy"]), - subjectName: json["TantargyNeve"], - teacherName: json["RogzitoTanarNeve"], - description: json["Szoveg"], - startDate: DateTime.parse(json["FeladasDatuma"]).toLocal(), - dueDate: DateTime.parse(json["HataridoDatuma"]).toLocal(), - creationDate: DateTime.parse(json["RogzitesIdopontja"]).toLocal(), - isCreatedByTeacher: json["IsTanarRogzitette"], - isDone: json["IsMegoldva"], - canBeSubmitted: json["IsBeadhato"], - classGroup: UidObj.fromJson(json["OsztalyCsoport"]), - canAttach: json["IsCsatolasEngedelyezes"]); - } - - @override - String toString() { - return 'Homework(' - 'uid: "$uid", ' - 'subject: $subject, ' - 'subjectName: "$subjectName", ' - 'teacherName: "$teacherName", ' - 'description: "$description", ' - 'startDate: $startDate, ' - 'dueDate: $dueDate, ' - 'creationDate: $creationDate, ' - 'isCreatedByTeacher: $isCreatedByTeacher, ' - 'isDone: $isDone, ' - 'canBeSubmitted: $canBeSubmitted, ' - 'classGroup: $classGroup, ' - 'canAttach: $canAttach' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/institution.dart b/firka_wear/lib/helpers/api/model/institution.dart deleted file mode 100644 index d390ab7a..00000000 --- a/firka_wear/lib/helpers/api/model/institution.dart +++ /dev/null @@ -1,100 +0,0 @@ -/* - Firka, alternative e-Kréta client. - Copyright (C) 2025 QwIT Development - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -class Institution { - final CustomizationSettings customizationSettings; - final String shortName; - final List systemModuleList; - final String uid; - - Institution( - {required this.customizationSettings, - required this.shortName, - required this.systemModuleList, - required this.uid}); - - factory Institution.fromJson(Map json) { - var systemModuleList = List.empty(growable: true); - - for (var item in json['Rendszermodulok']) { - systemModuleList.add(SystemModule.fromJson(item)); - } - - return Institution( - customizationSettings: - CustomizationSettings.fromJson(json['TestreszabasBeallitasok']), - shortName: json['RovidNev'], - systemModuleList: systemModuleList, - uid: json['Uid'], - ); - } -} - -class CustomizationSettings { - final int delayForNotifications; - final bool isClassAverageVisible; - final bool isLessonsThemeVisible; - final String nextServerDeployAsString; - - CustomizationSettings( - {required this.delayForNotifications, - required this.isClassAverageVisible, - required this.isLessonsThemeVisible, - required this.nextServerDeployAsString}); - - factory CustomizationSettings.fromJson(Map json) { - return CustomizationSettings( - delayForNotifications: - json['ErtekelesekMegjelenitesenekKesleltetesenekMerteke'], - isClassAverageVisible: json['IsOsztalyAtlagMegjeleniteseEllenorzoben'], - isLessonsThemeVisible: json['IsTanorakTemajaMegtekinthetoEllenorzoben'], - nextServerDeployAsString: json['KovetkezoTelepitesDatuma']); - } - - @override - String toString() { - return 'CustomizationSettings(' - 'delayForNotifications: $delayForNotifications, ' - 'isClassAverageVisible: $isClassAverageVisible, ' - 'isLessonsThemeVisible: $isLessonsThemeVisible, ' - 'nextServerDeployAsString: "$nextServerDeployAsString"' - ')'; - } -} - -class SystemModule { - final bool isActive; - final String type; - final String? url; - - SystemModule({required this.isActive, required this.type, required this.url}); - - factory SystemModule.fromJson(Map json) { - return SystemModule( - isActive: json['IsAktiv'], type: json['Tipus'], url: json['Url']); - } - - @override - String toString() { - return 'SystemModule(' - 'isActive: $isActive, ' - 'type: "$type", ' - 'url: "$url"' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/notice_board.dart b/firka_wear/lib/helpers/api/model/notice_board.dart deleted file mode 100644 index ad709f5d..00000000 --- a/firka_wear/lib/helpers/api/model/notice_board.dart +++ /dev/null @@ -1,42 +0,0 @@ -class NoticeBoardItem { - final String uid; - final String author; - final DateTime validFrom; - final DateTime validTo; - final String title; - final String contentHTML; - final String contentText; - - NoticeBoardItem( - {required this.uid, - required this.author, - required this.validFrom, - required this.validTo, - required this.title, - required this.contentHTML, - required this.contentText}); - - factory NoticeBoardItem.fromJson(Map json) { - return NoticeBoardItem( - uid: json['Uid'], - author: json['RogzitoNeve'], - validFrom: DateTime.parse(json['ErvenyessegKezdete']), - validTo: DateTime.parse(json['ErvenyessegVege']), - title: json['Cim'], - contentHTML: json['Tartalom'], - contentText: json['TartalomText']); - } - - @override - String toString() { - return 'NoticeBoardItem(' - 'uid: "$uid", ' - 'author: "$author", ' - 'validFrom: "$validFrom", ' - 'validTo: "$validTo", ' - 'title: "$title", ' - 'contentHTML: "$contentHTML", ' - 'contentText: "$contentText"' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/omission.dart b/firka_wear/lib/helpers/api/model/omission.dart deleted file mode 100644 index 42fbd55c..00000000 --- a/firka_wear/lib/helpers/api/model/omission.dart +++ /dev/null @@ -1,98 +0,0 @@ -import 'package:firka_wear/helpers/api/model/generic.dart'; -import 'package:firka_wear/helpers/api/model/subject.dart'; - -class Omission { - final String uid; - final Subject subject; - final Class? c; - final DateTime date; - final String teacher; - final NameUidDesc? type; - final NameUidDesc? mode; - final int? lateForMin; - final DateTime createdAt; - final String state; - final NameUidDesc proofType; - final UidObj? classGroup; - - Omission({ - required this.uid, - required this.subject, - required this.c, - required this.date, - required this.teacher, - this.type, - this.mode, - this.lateForMin, - required this.createdAt, - required this.state, - required this.proofType, - this.classGroup, - }); - - factory Omission.fromJson(Map json) { - return Omission( - uid: json['Uid'], - subject: Subject.fromJson(json['Tantargy']), - c: json['Osztaly'] != null ? Class.fromJson(json['Osztaly']) : null, - date: DateTime.parse(json['Datum']), - teacher: json['RogzitoTanarNeve'], - type: json['Tipus'] != null ? NameUidDesc.fromJson(json['Tipus']) : null, - mode: json['Mod'] != null ? NameUidDesc.fromJson(json['Mod']) : null, - lateForMin: json['KesesPercben'], - createdAt: DateTime.parse(json['KeszitesDatuma']), - state: json['IgazolasAllapota'], - proofType: NameUidDesc.fromJson(json['IgazolasTipusa']), - classGroup: json['OsztalyCsoport'] != null - ? UidObj.fromJson(json['OsztalyCsoport']) - : null, - ); - } - - @override - String toString() { - return 'Omission(' - 'uid: "$uid", ' - 'subject: $subject, ' - 'c: $c, ' - 'date: $date, ' - 'teacher: "$teacher", ' - 'type: $type, ' - 'mode: $mode, ' - 'lateForMin: $lateForMin, ' - 'createdAt: $createdAt, ' - 'state: "$state", ' - 'proofType: $proofType, ' - 'classGroup: $classGroup' - ')'; - } -} - -class Class { - final DateTime start; - final DateTime end; - final int classNo; - - Class({ - required this.start, - required this.end, - required this.classNo, - }); - - factory Class.fromJson(Map json) { - return Class( - start: DateTime.parse(json['KezdoDatum']), - end: DateTime.parse(json['VegDatum']), - classNo: json['Oraszam'], - ); - } - - @override - String toString() { - return 'Class(' - 'start: "$start", ' - 'end: "$end", ' - 'classNo: $classNo' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/student.dart b/firka_wear/lib/helpers/api/model/student.dart deleted file mode 100644 index d2953631..00000000 --- a/firka_wear/lib/helpers/api/model/student.dart +++ /dev/null @@ -1,133 +0,0 @@ -/* - Firka, alternative e-Kréta client. - Copyright (C) 2025 QwIT Development - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -import 'package:firka_wear/helpers/api/model/guardian.dart'; -import 'package:firka_wear/helpers/api/model/institution.dart'; -import 'package:firka_wear/helpers/json_helper.dart'; -import 'package:intl/intl.dart'; - -class Student { - final List addressDataList; - final BankAccount bankAccount; - - // final int yearOfBirth; - // final int monthOfBirth; - // final int dayOfBirth; - final DateTime birthdate; - - final String? emailAddress; - final String name; - final String? phoneNumber; - - final String schoolYearUID; - final String uid; - - final List guardianList; - final String instituteCode; - final String instituteName; - - final Institution institution; - - Student( - {required this.addressDataList, - required this.bankAccount, - // required this.yearOfBirth, - // required this.monthOfBirth, - // required this.dayOfBirth, - required this.birthdate, - required this.emailAddress, - required this.name, - required this.phoneNumber, - required this.schoolYearUID, - required this.uid, - required this.guardianList, - required this.instituteCode, - required this.instituteName, - required this.institution}); - - factory Student.fromJson(Map json) { - var guardianList = List.empty(growable: true); - - for (var item in json['Gondviselok']) { - guardianList.add(Guardian.fromJson(item)); - } - - return Student( - addressDataList: listToTyped(json['Cimek']), - bankAccount: BankAccount.fromJson(json['Bankszamla']), - birthdate: DateFormat('yyyy-M-d').parse( - "${json['SzuletesiEv']}-${json['SzuletesiHonap']}-${json['SzuletesiNap']}"), - emailAddress: json['EmailCim'], - name: json['Nev'], - phoneNumber: json['Telefonszam'], - schoolYearUID: json['TanevUid'], - uid: json['Uid'], - guardianList: guardianList, - instituteCode: json['IntezmenyAzonosito'], - instituteName: json['IntezmenyNev'], - institution: Institution.fromJson(json['Intezmeny'])); - } - - @override - String toString() { - return 'Student(' - 'addressDataList: [$addressDataList], ' - 'bankAccount: $bankAccount, ' - 'birthDate: $birthdate, ' - 'emailAddress: "$emailAddress", ' - 'name: "$name", ' - 'phoneNumber: "$phoneNumber", ' - 'schoolYearUID: "$schoolYearUID", ' - 'uid: "$uid", ' - 'guardianList: [$guardianList], ' - 'instituteCode: "$instituteCode", ' - 'instituteName: "$instituteName", ' - ')'; - } -} - -class BankAccount { - final String? accountNumber; - final bool? isReadOnly; - final String? ownerName; - final int? ownerType; - - BankAccount( - {required this.accountNumber, - required this.isReadOnly, - required this.ownerName, - required this.ownerType}); - - factory BankAccount.fromJson(Map json) { - return BankAccount( - accountNumber: json['BankszamlaSzam'], - isReadOnly: json['IsReadOnly'], - ownerName: json['BankszamlaTulajdonosNeve'], - ownerType: json['BankszamlaTulajdonosTipusId']); - } - - @override - String toString() { - return 'BankAccount(' - 'accountNumber: "$accountNumber", ' - 'isReadOnly: "$isReadOnly", ' - 'ownerName: "$ownerName", ' - 'ownerType: "$ownerType"' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/subject.dart b/firka_wear/lib/helpers/api/model/subject.dart deleted file mode 100644 index 0bf02a04..00000000 --- a/firka_wear/lib/helpers/api/model/subject.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:firka_wear/helpers/api/model/generic.dart'; - -class Subject { - final String uid; - final String name; - final NameUidDesc category; - final int sortIndex; - final String? teacherName; - - Subject({ - required this.uid, - required this.name, - required this.category, - required this.sortIndex, - this.teacherName, - }); - - factory Subject.fromJson(Map json) { - return Subject( - uid: json['Uid'], - name: json['Nev'], - category: NameUidDesc.fromJson( - Map.from(json['Kategoria'] as Map), - ), - sortIndex: json['SortIndex'], - teacherName: json['alkalmazottNev'], - ); - } - - Map toJson() { - return { - 'Uid': uid, - 'Nev': name, - 'Kategoria': category.toJson(), - 'SortIndex': sortIndex, - 'alkalmazottNev': teacherName, - }; - } - - @override - String toString() { - return 'Subject(' - 'uid: "$uid", ' - 'name: "$name", ' - 'category: $category, ' - 'sortIndex: $sortIndex, ' - 'teacherName: $teacherName' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/test.dart b/firka_wear/lib/helpers/api/model/test.dart deleted file mode 100644 index 7d16de20..00000000 --- a/firka_wear/lib/helpers/api/model/test.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:firka_wear/helpers/api/model/subject.dart'; - -import 'generic.dart'; - -class Test { - final String uid; - final DateTime date; - final DateTime reportDate; - final String teacherName; - final int lessonNumber; - final Subject subject; - final String subjectName; - final String theme; - final NameUidDesc method; - final UidObj classGroup; - - Test({ - required this.uid, - required this.date, - required this.reportDate, - required this.teacherName, - required this.lessonNumber, - required this.subject, - required this.subjectName, - required this.theme, - required this.method, - required this.classGroup, - }); - - factory Test.fromJson(Map json) { - return Test( - uid: json['Uid'], - date: DateTime.parse(json['Datum']), - reportDate: DateTime.parse(json['BejelentesDatuma']), - teacherName: json['RogzitoTanarNeve'], - lessonNumber: json['OrarendiOraOraszama'], - subject: Subject.fromJson(json['Tantargy']), - subjectName: json['TantargyNeve'], - theme: json['Temaja'], - method: NameUidDesc.fromJson(json['Modja']), - classGroup: UidObj.fromJson(json['OsztalyCsoport']), - ); - } - - @override - String toString() { - return 'Test(' - 'uid: "$uid", ' - 'date: $date, ' - 'reportDate: $reportDate, ' - 'teacherName: "$teacherName", ' - 'lessonNumber: $lessonNumber, ' - 'subject: $subject, ' - 'subjectName: "$subjectName", ' - 'theme: "$theme", ' - 'method: $method, ' - 'classGroup: $classGroup' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/model/timetable.dart b/firka_wear/lib/helpers/api/model/timetable.dart deleted file mode 100644 index 04b43fae..00000000 --- a/firka_wear/lib/helpers/api/model/timetable.dart +++ /dev/null @@ -1,195 +0,0 @@ -import 'package:firka_wear/helpers/api/model/generic.dart'; -import 'package:firka_wear/helpers/api/model/subject.dart'; - -class Lesson { - final String uid; - final String date; - final DateTime start; - final DateTime end; - final String name; - final int? lessonNumber; - final int? lessonSeqNumber; - final NameUid? classGroup; - final String? teacher; - final Subject? subject; - final String? theme; - final String? roomName; - final NameUidDesc type; - final NameUidDesc? studentPresence; - final NameUidDesc state; - final String? substituteTeacher; - final String? homeworkUid; - final String? taskGroupUid; - final String? languageTaskGroupUid; - final String? assessmentUid; - final bool canStudentEditHomework; - final bool isHomeworkComplete; - final List attachments; - final bool isDigitalLesson; - final String? digitalDeviceList; - final String? digitalPlatformType; - final List digitalSupportDeviceTypeList; - final DateTime createdAt; - final DateTime lastModifiedAt; - - Lesson({ - required this.uid, - required this.date, - required this.start, - required this.end, - required this.name, - this.lessonNumber, - this.lessonSeqNumber, - this.classGroup, - this.teacher, - this.subject, - this.theme, - this.roomName, - required this.type, - this.studentPresence, - required this.state, - this.substituteTeacher, - this.homeworkUid, - this.taskGroupUid, - this.languageTaskGroupUid, - this.assessmentUid, - required this.canStudentEditHomework, - required this.isHomeworkComplete, - required this.attachments, - required this.isDigitalLesson, - this.digitalDeviceList, - this.digitalPlatformType, - required this.digitalSupportDeviceTypeList, - required this.createdAt, - required this.lastModifiedAt, - }); - - factory Lesson.fromJson(Map json) { - var attachments = List.empty(growable: true); - var rawAttachments = json['Csatolmanyok'] as List? ?? []; - - for (var attachment in rawAttachments) { - attachments.add( - NameUid.fromJson(Map.from(attachment as Map)), - ); - } - return Lesson( - uid: json['Uid'], - date: json['Datum'], - start: DateTime.parse(json['KezdetIdopont']).toLocal(), - end: DateTime.parse(json['VegIdopont']).toLocal(), - name: json['Nev'], - lessonNumber: json['Oraszam'], - lessonSeqNumber: json['OraEvesSorszama'], - classGroup: json['OsztalyCsoport'] != null - ? NameUid.fromJson( - Map.from(json['OsztalyCsoport'] as Map), - ) - : null, - teacher: json['TanarNeve'], - subject: json['Tantargy'] != null - ? Subject.fromJson(Map.from(json['Tantargy'] as Map)) - : null, - theme: json['Tema'], - roomName: json['TeremNeve'], - type: NameUidDesc.fromJson( - Map.from(json['Tipus'] as Map), - ), - studentPresence: json['TanuloJelenlet'] != null - ? NameUidDesc.fromJson( - Map.from(json['TanuloJelenlet'] as Map), - ) - : null, - state: NameUidDesc.fromJson( - Map.from(json['Allapot'] as Map), - ), - substituteTeacher: json['HelyettesTanarNeve'], - homeworkUid: json['HaziFeladatUid'], - taskGroupUid: json['FeladatGroupUid'], - languageTaskGroupUid: json['NyelviFeladatGroupUid'], - assessmentUid: json['BejelentettSzamonkeresUid'], - canStudentEditHomework: json['IsTanuloHaziFeladatEnabled'], - isHomeworkComplete: json['IsHaziFeladatMegoldva'], - attachments: attachments, - isDigitalLesson: json['IsDigitalisOra'], - digitalDeviceList: json['DigitalisEszkozTipus'], - digitalPlatformType: json['DigitalisPlatformTipus'], - digitalSupportDeviceTypeList: - json['DigitalisTamogatoEszkozTipusList'] != null - ? List.from(json['DigitalisTamogatoEszkozTipusList']) - : List.empty(), - createdAt: DateTime.parse(json['Letrehozas']).toLocal(), - lastModifiedAt: DateTime.parse(json['UtolsoModositas']).toLocal(), - ); - } - - Map toJson() { - final rawAttachments = attachments.map((e) => e.toJson()).toList(); - return { - 'Uid': uid, - 'Datum': date, - 'KezdetIdopont': start.toIso8601String(), - 'VegIdopont': end.toIso8601String(), - 'Nev': name, - 'Oraszam': lessonNumber, - 'OraEvesSorszama': lessonSeqNumber, - 'OsztalyCsoport': classGroup?.toJson(), - 'TanarNeve': teacher, - 'Tantargy': subject?.toJson(), - 'Tema': theme, - 'TeremNeve': roomName, - 'Tipus': type.toJson(), - 'TanuloJelenlet': studentPresence?.toJson(), - 'Allapot': state.toJson(), - 'HelyettesTanarNeve': substituteTeacher, - 'HaziFeladatUid': homeworkUid, - 'FeladatGroupUid': taskGroupUid, - 'NyelviFeladatGroupUid': languageTaskGroupUid, - 'BejelentettSzamonkeresUid': assessmentUid, - 'IsTanuloHaziFeladatEnabled': canStudentEditHomework, - 'IsHaziFeladatMegoldva': isHomeworkComplete, - 'Csatolmanyok': rawAttachments, - 'IsDigitalisOra': isDigitalLesson, - 'DigitalisEszkozTipus': digitalDeviceList, - 'DigitalisPlatformTipus': digitalPlatformType, - 'DigitalisTamogatoEszkozTipusList': digitalSupportDeviceTypeList, - 'Letrehozas': createdAt.toIso8601String(), - 'UtolsoModositas': lastModifiedAt.toIso8601String(), - }; - } - - @override - String toString() { - return 'Lesson(' - 'uid: "$uid", ' - 'date: "$date", ' - 'start: $start, ' - 'end: $end, ' - 'name: "$name", ' - 'lessonNumber: $lessonNumber, ' - 'lessonSeqNumber: $lessonSeqNumber, ' - 'classGroup: $classGroup, ' - 'teacher: "$teacher", ' - 'subject: $subject, ' - 'theme: "$theme", ' - 'roomName: "$roomName", ' - 'type: $type, ' - 'studentPresence: $studentPresence, ' - 'state: $state, ' - 'substituteTeacher: "$substituteTeacher", ' - 'homeworkUid: "$homeworkUid", ' - 'taskGroupUid: "$taskGroupUid", ' - 'languageTaskGroupUid: "$languageTaskGroupUid", ' - 'assessmentUid: "$assessmentUid", ' - 'canStudentEditHomework: $canStudentEditHomework, ' - 'isHomeworkComplete: $isHomeworkComplete, ' - 'attachments: $attachments, ' - 'isDigitalLesson: $isDigitalLesson, ' - 'digitalDeviceList: "$digitalDeviceList", ' - 'digitalPlatformType: "$digitalPlatformType", ' - 'digitalSupportDeviceTypeList: $digitalSupportDeviceTypeList, ' - 'create: $createdAt, ' - 'lastModified: $lastModifiedAt' - ')'; - } -} diff --git a/firka_wear/lib/helpers/api/resp/token_grant.dart b/firka_wear/lib/helpers/api/resp/token_grant.dart deleted file mode 100644 index 6c05232d..00000000 --- a/firka_wear/lib/helpers/api/resp/token_grant.dart +++ /dev/null @@ -1,54 +0,0 @@ -/* - Firka, alternative e-Kréta client. - Copyright (C) 2025 QwIT Development - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -class TokenGrantResponse { - final String idToken; - final String accessToken; - final int expiresIn; - final String tokenType; - final String refreshToken; - final String scope; - - TokenGrantResponse( - {required this.idToken, - required this.accessToken, - required this.expiresIn, - required this.tokenType, - required this.refreshToken, - required this.scope}); - - factory TokenGrantResponse.fromJson(Map json) { - return TokenGrantResponse( - idToken: json['id_token'], - accessToken: json['access_token'], - expiresIn: json['expires_in'], - tokenType: json['token_type'], - refreshToken: json['refresh_token'], - scope: json['scope']); - } - - @override - String toString() { - return 'TokenGrant(idToken: "$idToken", accessToken: "$accessToken", ' - 'expiresIn: $expiresIn, ' - 'tokenType: "$tokenType", ' - 'refreshToken: "$refreshToken", ' - 'scope: "$scope"' - ')'; - } -} diff --git a/firka_wear/lib/helpers/extensions.dart b/firka_wear/lib/helpers/extensions.dart index 26b487f9..b336d18f 100644 --- a/firka_wear/lib/helpers/extensions.dart +++ b/firka_wear/lib/helpers/extensions.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import '../l10n/app_localizations.dart'; -import 'api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'debug_helper.dart'; extension IterableExtensionMap on Iterable> { @@ -41,11 +41,14 @@ enum Cycle { morning, day, afternoon, night } extension DateExtension on DateTime { String format(BuildContext context, FormatMode mode) { var today = timeNow(); - today = today.subtract(Duration( + today = today.subtract( + Duration( hours: today.hour, minutes: today.minute, seconds: today.second, - milliseconds: today.millisecond)); + milliseconds: today.millisecond, + ), + ); var tomorrowLim = today.add(Duration(days: 2)); var tomorrow = today.add(Duration(days: 1)); @@ -86,11 +89,14 @@ extension DateExtension on DateTime { } DateTime getMidnight() { - return subtract(Duration( + return subtract( + Duration( hours: hour, minutes: minute, seconds: second, - milliseconds: millisecond)); + milliseconds: millisecond, + ), + ); } Cycle getDayCycle() { @@ -117,22 +123,28 @@ extension DateGrouper on Iterable { Map> newList = {}; var today = timeNow(); - today = today.subtract(Duration( + today = today.subtract( + Duration( hours: today.hour, minutes: today.minute, seconds: today.second, - milliseconds: today.millisecond)); + milliseconds: today.millisecond, + ), + ); var tomorrow = today.add(Duration(days: 1)); var yesterday = today.subtract(Duration(days: 1)); for (var elem in this) { var date = getDate(elem); - var day = date.subtract(Duration( + var day = date.subtract( + Duration( hours: date.hour, minutes: date.minute, seconds: date.second, - milliseconds: date.millisecond)); + milliseconds: date.millisecond, + ), + ); if (date.isAfter(tomorrow.add(Duration(days: 1)))) { if (newList[day] == null) { @@ -178,16 +190,19 @@ extension LessonExtension on List { Lesson? getCurrentLesson(DateTime now) { return firstWhereOrNull( - (lesson) => now.isAfter(lesson.start) && now.isBefore(lesson.end)); + (lesson) => now.isAfter(lesson.start) && now.isBefore(lesson.end), + ); } Lesson? getPrevLesson(DateTime now) { return firstWhereOrNull( - (lesson) => lesson.end.isBefore(now.add(Duration(milliseconds: 1)))); + (lesson) => lesson.end.isBefore(now.add(Duration(milliseconds: 1))), + ); } Lesson? getNextLesson(DateTime now) { return firstWhereOrNull( - (lesson) => lesson.start.isAfter(now.add(Duration(milliseconds: 1)))); + (lesson) => lesson.start.isAfter(now.add(Duration(milliseconds: 1))), + ); } } diff --git a/firka_wear/lib/helpers/icon_helper.dart b/firka_wear/lib/helpers/icon_helper.dart index 6221f33a..34d53431 100644 --- a/firka_wear/lib/helpers/icon_helper.dart +++ b/firka_wear/lib/helpers/icon_helper.dart @@ -34,7 +34,7 @@ enum ClassIcon { linux, database, applications, - project + project, } Map _descriptors = { @@ -49,8 +49,9 @@ Map _descriptors = { ClassIcon.pe: RegExp(r'^tes(i|tneveles)|sport|edzeselmelet'), ClassIcon.chemistry: RegExp(r'kemia'), ClassIcon.biology: RegExp(r'biologia'), - ClassIcon.env: - RegExp(r'kornyezet|termeszet ?(tudomany|ismeret)|hon( es nep)?ismeret'), + ClassIcon.env: RegExp( + r'kornyezet|termeszet ?(tudomany|ismeret)|hon( es nep)?ismeret', + ), ClassIcon.religion: RegExp(r'(hit|erkolcs)tan|vallas|etika|bibliaismeret'), ClassIcon.economics: RegExp(r'penzugy|gazdasag'), ClassIcon.it: RegExp(r'informatika|szoftver|iroda|digitalis'), @@ -66,12 +67,13 @@ Map _descriptors = { ClassIcon.ofo: RegExp(r'osztaly(fonoki|kozosseg)|kozossegi|neveles'), ClassIcon.diligence: RegExp(r'szorgalom'), ClassIcon.attitude: RegExp(r'magatartas'), - ClassIcon.language: - RegExp(r'angol|nemet|francia|olasz|orosz|spanyol|latin|kinai|nyelv'), + ClassIcon.language: RegExp( + r'angol|nemet|francia|olasz|orosz|spanyol|latin|kinai|nyelv', + ), ClassIcon.linux: RegExp(r'linux'), ClassIcon.database: RegExp(r'adatbazis.*'), ClassIcon.applications: RegExp(r'asztali alkalmazasok'), - ClassIcon.project: RegExp(r'projekt') + ClassIcon.project: RegExp(r'projekt'), }; Map _iconMap = { @@ -117,17 +119,19 @@ ClassIcon? getIconType(String uid, String className, String category) { if (icon == null) { for (var desc in _descriptors.entries) { - if (desc.value.hasMatch(className - .replaceAll("ö", "o") - .replaceAll("ü", "u") - .replaceAll("ó", "o") - .replaceAll("ő", "o") - .replaceAll("ú", "u") - .replaceAll("é", "e") - .replaceAll("á", "a") - .replaceAll("ű", "u") - .replaceAll("í", "i") - .toLowerCase())) { + if (desc.value.hasMatch( + className + .replaceAll("ö", "o") + .replaceAll("ü", "u") + .replaceAll("ó", "o") + .replaceAll("ő", "o") + .replaceAll("ú", "u") + .replaceAll("é", "e") + .replaceAll("á", "a") + .replaceAll("ű", "u") + .replaceAll("í", "i") + .toLowerCase(), + )) { icon = desc.key; break; diff --git a/firka_wear/lib/helpers/sync/wear_sync_store.dart b/firka_wear/lib/helpers/sync/wear_sync_store.dart index de533dd2..3146b65a 100644 --- a/firka_wear/lib/helpers/sync/wear_sync_store.dart +++ b/firka_wear/lib/helpers/sync/wear_sync_store.dart @@ -3,8 +3,7 @@ import 'dart:io'; import 'package:path_provider/path_provider.dart'; -import 'package:firka_wear/helpers/api/model/grade.dart'; -import 'package:firka_wear/helpers/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; const String _syncFileName = 'wear_sync_data.json'; diff --git a/firka_wear/lib/helpers/ui/grade.dart b/firka_wear/lib/helpers/ui/grade.dart index 74b33008..0cacedc1 100644 --- a/firka_wear/lib/helpers/ui/grade.dart +++ b/firka_wear/lib/helpers/ui/grade.dart @@ -1,4 +1,4 @@ -import 'package:firka_wear/helpers/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:flutter/material.dart'; import '../../ui/model/style.dart'; @@ -18,8 +18,9 @@ class GradeWidget extends StatelessWidget { if (grade.valueType.name == "Szazalekos") { gradeStr = grade.strValue.replaceAll("%", ""); if (grade.numericValue != null) { - gradeColor = - getGradeColor(percentageToGrade(grade.numericValue!).toDouble()); + gradeColor = getGradeColor( + percentageToGrade(grade.numericValue!).toDouble(), + ); } if (grade.numericValue != null && grade.numericValue == 100) { @@ -29,10 +30,14 @@ class GradeWidget extends StatelessWidget { color: gradeColor.withAlpha(38), child: Padding( padding: EdgeInsets.only(left: 8, right: 8), - child: Row(children: [ - Text("100", // TODO: Make this curved - style: appStyle.fonts.P_14.copyWith(color: gradeColor)) - ]), + child: Row( + children: [ + Text( + "100", // TODO: Make this curved + style: appStyle.fonts.P_14.copyWith(color: gradeColor), + ), + ], + ), ), ); } else { @@ -42,11 +47,18 @@ class GradeWidget extends StatelessWidget { color: gradeColor.withAlpha(38), child: Padding( padding: EdgeInsets.only(left: 8, right: 8), - child: Row(children: [ - Text(gradeStr, - style: appStyle.fonts.P_14.copyWith(color: gradeColor)), - Text("%", style: appStyle.fonts.P_12.copyWith(color: gradeColor)) - ]), + child: Row( + children: [ + Text( + gradeStr, + style: appStyle.fonts.P_14.copyWith(color: gradeColor), + ), + Text( + "%", + style: appStyle.fonts.P_12.copyWith(color: gradeColor), + ), + ], + ), ), ); } @@ -60,10 +72,15 @@ class GradeWidget extends StatelessWidget { shadowColor: Colors.transparent, color: gradeColor.withAlpha(38), child: Padding( - padding: EdgeInsets.only(left: 8, right: 8), - child: Text(gradeStr, - style: appStyle.fonts.H_H1 - .copyWith(fontSize: 24, color: gradeColor))), + padding: EdgeInsets.only(left: 8, right: 8), + child: Text( + gradeStr, + style: appStyle.fonts.H_H1.copyWith( + fontSize: 24, + color: gradeColor, + ), + ), + ), ); } } diff --git a/firka_wear/lib/helpers/ui/grade_helpers.dart b/firka_wear/lib/helpers/ui/grade_helpers.dart index 89e3ce03..1c80c279 100644 --- a/firka_wear/lib/helpers/ui/grade_helpers.dart +++ b/firka_wear/lib/helpers/ui/grade_helpers.dart @@ -1,8 +1,7 @@ import 'dart:ui'; import '../../ui/model/style.dart'; -import '../api/model/grade.dart'; -import '../api/model/subject.dart'; +import 'package:kreta_api/kreta_api.dart'; int roundGrade(double grade) { if (grade < 2) { diff --git a/firka_wear/lib/helpers/ui/stateless_async_widget.dart b/firka_wear/lib/helpers/ui/stateless_async_widget.dart index 2c078bad..98f88ee7 100644 --- a/firka_wear/lib/helpers/ui/stateless_async_widget.dart +++ b/firka_wear/lib/helpers/ui/stateless_async_widget.dart @@ -9,15 +9,16 @@ abstract class StatelessAsyncWidget extends StatelessWidget { @override Widget build(BuildContext context) { return FutureBuilder( - future: buildAsync(context), - builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Center(child: DelayedSpinnerWidget()); - } else if (snapshot.hasError) { - return Center(child: Text('Error: ${snapshot.error}')); - } else { - return snapshot.data!; - } - }); + future: buildAsync(context), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Center(child: DelayedSpinnerWidget()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else { + return snapshot.data!; + } + }, + ); } } diff --git a/firka_wear/lib/ui/model/style.dart b/firka_wear/lib/ui/model/style.dart index 5bee8988..5359a1d7 100644 --- a/firka_wear/lib/ui/model/style.dart +++ b/firka_wear/lib/ui/model/style.dart @@ -155,27 +155,30 @@ final _defaultFonts = FirkaFonts( fontVariations: [FontVariation("wght", 600)], ), B_16R: TextStyle( - fontSize: 16, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 600)]), + fontSize: 16, + fontFamily: 'Figtree', + fontVariations: [FontVariation("wght", 600)], + ), B_16SB: TextStyle( fontSize: 16, fontFamily: 'Figtree', fontVariations: [FontVariation("wght", 700)], ), B_14R: TextStyle( - fontSize: 14, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 600)]), + fontSize: 14, + fontFamily: 'Figtree', + fontVariations: [FontVariation("wght", 600)], + ), B_14SB: TextStyle( fontSize: 14, fontFamily: 'Figtree', fontVariations: [FontVariation("wght", 700)], ), B_12R: TextStyle( - fontSize: 12, - fontFamily: 'Figtree', - fontVariations: [FontVariation("wght", 600)]), + fontSize: 12, + fontFamily: 'Figtree', + fontVariations: [FontVariation("wght", 600)], + ), B_12SB: TextStyle( fontSize: 12, fontFamily: 'Figtree', @@ -194,70 +197,72 @@ final _defaultFonts = FirkaFonts( ); final FirkaStyle lightStyle = FirkaStyle( - colors: FirkaColors( - background: Color(0xFFFAFFF0), - backgroundAmoled: Colors.black, - background0p: Color(0x00fafff0), - success: Color(0xFF92EA3B), - shadowBlur: 2, - textPrimary: Color(0xFF394C0A), - textSecondary: Color(0xCC394C0A), - textTertiary: Color(0x80394C0A), - card: Color(0xFFF3FBDE), - cardTranslucent: Color(0x80F3FBDE), - buttonSecondaryFill: Color(0xFFFEFFFD), - accent: Color(0xFFA7DC22), - secondary: Color(0xFF6E8F1B), - shadowColor: Color(0x33647e22), - a15p: Color(0x26a7dc22), - warningAccent: Color(0xFFFFA046), - warningText: Color(0xFF8F531B), - warning15p: Color(0x26FFA046), - warningCard: Color(0xFFFAEBDC), - errorAccent: Color(0xFFFF54A1), - errorText: Color(0xFF8F1B4F), - error15p: Color(0x26FF54A1), - errorCard: Color(0xFFFADCE9), - grade5: Color(0xFF22CCAD), - grade4: Color(0xFF92EA3B), - grade3: Color(0xFFF9CF00), - grade2: Color(0xFFFFA046), - grade1: Color(0xFFFF54A1), - ), - fonts: _defaultFonts); + colors: FirkaColors( + background: Color(0xFFFAFFF0), + backgroundAmoled: Colors.black, + background0p: Color(0x00fafff0), + success: Color(0xFF92EA3B), + shadowBlur: 2, + textPrimary: Color(0xFF394C0A), + textSecondary: Color(0xCC394C0A), + textTertiary: Color(0x80394C0A), + card: Color(0xFFF3FBDE), + cardTranslucent: Color(0x80F3FBDE), + buttonSecondaryFill: Color(0xFFFEFFFD), + accent: Color(0xFFA7DC22), + secondary: Color(0xFF6E8F1B), + shadowColor: Color(0x33647e22), + a15p: Color(0x26a7dc22), + warningAccent: Color(0xFFFFA046), + warningText: Color(0xFF8F531B), + warning15p: Color(0x26FFA046), + warningCard: Color(0xFFFAEBDC), + errorAccent: Color(0xFFFF54A1), + errorText: Color(0xFF8F1B4F), + error15p: Color(0x26FF54A1), + errorCard: Color(0xFFFADCE9), + grade5: Color(0xFF22CCAD), + grade4: Color(0xFF92EA3B), + grade3: Color(0xFFF9CF00), + grade2: Color(0xFFFFA046), + grade1: Color(0xFFFF54A1), + ), + fonts: _defaultFonts, +); final FirkaStyle darkStyle = FirkaStyle( - colors: FirkaColors( - background: Color(0xFF0D1202), - backgroundAmoled: Colors.black, - background0p: Color(0x00fafff0), - success: Color(0xFF92EA3B), - shadowBlur: 0, - textPrimary: Color(0xFFEAF7CC), - textSecondary: Color(0xB3EAF7CC), - textTertiary: Color(0x80EAF7CC), - card: Color(0xFF141905), - cardTranslucent: Color(0x80141905), - buttonSecondaryFill: Color(0xFF20290B), - accent: Color(0xFFA7DC22), - secondary: Color(0xFFCBEE71), - shadowColor: Color(0x26CBEE71), - a15p: Color(0x26A7DC22), - warningAccent: Color(0xFFFFA046), - warningText: Color(0xFFF0B37A), - warning15p: Color(0x26FFA046), - warningCard: Color(0xFF201203), - errorAccent: Color(0xFFFF54A1), - errorText: Color(0xFFF59EC5), - error15p: Color(0x26FF54A1), - errorCard: Color(0xFF1E030F), - grade5: Color(0xFF22CCAD), - grade4: Color(0xFF92EA3B), - grade3: Color(0xFFF9CF00), - grade2: Color(0xFFFFA046), - grade1: Color(0xFFFF54A1), - ), - fonts: _defaultFonts); + colors: FirkaColors( + background: Color(0xFF0D1202), + backgroundAmoled: Colors.black, + background0p: Color(0x00fafff0), + success: Color(0xFF92EA3B), + shadowBlur: 0, + textPrimary: Color(0xFFEAF7CC), + textSecondary: Color(0xB3EAF7CC), + textTertiary: Color(0x80EAF7CC), + card: Color(0xFF141905), + cardTranslucent: Color(0x80141905), + buttonSecondaryFill: Color(0xFF20290B), + accent: Color(0xFFA7DC22), + secondary: Color(0xFFCBEE71), + shadowColor: Color(0x26CBEE71), + a15p: Color(0x26A7DC22), + warningAccent: Color(0xFFFFA046), + warningText: Color(0xFFF0B37A), + warning15p: Color(0x26FFA046), + warningCard: Color(0xFF201203), + errorAccent: Color(0xFFFF54A1), + errorText: Color(0xFFF59EC5), + error15p: Color(0x26FF54A1), + errorCard: Color(0xFF1E030F), + grade5: Color(0xFF22CCAD), + grade4: Color(0xFF92EA3B), + grade3: Color(0xFFF9CF00), + grade2: Color(0xFFFFA046), + grade1: Color(0xFFFF54A1), + ), + fonts: _defaultFonts, +); FirkaStyle appStyle = lightStyle; FirkaStyle wearStyle = darkStyle; diff --git a/firka_wear/lib/ui/wear/screens/home/home_screen.dart b/firka_wear/lib/ui/wear/screens/home/home_screen.dart index b46c057f..e326da7a 100644 --- a/firka_wear/lib/ui/wear/screens/home/home_screen.dart +++ b/firka_wear/lib/ui/wear/screens/home/home_screen.dart @@ -1,8 +1,7 @@ import 'dart:async'; import 'dart:math'; -import 'package:firka_wear/helpers/api/model/grade.dart'; -import 'package:firka_wear/helpers/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka_wear/helpers/extensions.dart'; import 'package:firka_wear/ui/widget/class_icon.dart'; import 'package:firka_wear/main.dart'; diff --git a/firka_wear/lib/ui/wear/screens/login/login_screen.dart b/firka_wear/lib/ui/wear/screens/login/login_screen.dart index b9d86f67..f86553cf 100644 --- a/firka_wear/lib/ui/wear/screens/login/login_screen.dart +++ b/firka_wear/lib/ui/wear/screens/login/login_screen.dart @@ -2,8 +2,7 @@ import 'dart:async'; -import 'package:firka_wear/helpers/api/model/grade.dart'; -import 'package:firka_wear/helpers/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka_wear/helpers/extensions.dart'; import 'package:flutter/material.dart'; import 'package:watch_connectivity/watch_connectivity.dart'; diff --git a/firka_wear/lib/ui/wear/widgets/circular_progress_indicator.dart b/firka_wear/lib/ui/wear/widgets/circular_progress_indicator.dart index 075b49e3..2d229cdd 100644 --- a/firka_wear/lib/ui/wear/widgets/circular_progress_indicator.dart +++ b/firka_wear/lib/ui/wear/widgets/circular_progress_indicator.dart @@ -34,8 +34,10 @@ class _CircularProgressIndicatorWidgetState duration: const Duration(milliseconds: 500), vsync: this, ); - _animation = - Tween(begin: 0.0, end: widget.progress).animate(_controller); + _animation = Tween( + begin: 0.0, + end: widget.progress, + ).animate(_controller); _controller.forward(); } diff --git a/firka_wear/lib/ui/widget/class_icon.dart b/firka_wear/lib/ui/widget/class_icon.dart index cacff20d..dedfbaee 100644 --- a/firka_wear/lib/ui/widget/class_icon.dart +++ b/firka_wear/lib/ui/widget/class_icon.dart @@ -10,22 +10,26 @@ class ClassIconWidget extends StatelessWidget { final Color color; final double? size; - const ClassIconWidget( - {super.key, - required String uid, - required String className, - required String category, - this.color = Colors.white, - this.size}) - : _className = className, - _uid = uid, - _category = category; + const ClassIconWidget({ + super.key, + required String uid, + required String className, + required String category, + this.color = Colors.white, + this.size, + }) : _className = className, + _uid = uid, + _category = category; @override Widget build(BuildContext context) { var iconCategory = getIconType(_uid, _className, _category); - return FirkaIconWidget(FirkaIconType.Majesticons, getIconData(iconCategory), - color: color, size: size); + return FirkaIconWidget( + FirkaIconType.Majesticons, + getIconData(iconCategory), + color: color, + size: size, + ); } } diff --git a/firka_wear/lib/ui/widget/counter_digit.dart b/firka_wear/lib/ui/widget/counter_digit.dart index 94823ebb..3e5bd0b3 100644 --- a/firka_wear/lib/ui/widget/counter_digit.dart +++ b/firka_wear/lib/ui/widget/counter_digit.dart @@ -14,10 +14,7 @@ class CounterDigitWidget extends StatelessWidget { color: appStyle.colors.buttonSecondaryFill, child: Padding( padding: EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), - child: Text( - c, - style: style, - ), + child: Text(c, style: style), ), ); } diff --git a/firka_wear/lib/ui/widget/firka_icon.dart b/firka_wear/lib/ui/widget/firka_icon.dart index fa66125e..b8e41a6b 100644 --- a/firka_wear/lib/ui/widget/firka_icon.dart +++ b/firka_wear/lib/ui/widget/firka_icon.dart @@ -4,10 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; -enum FirkaIconType { - Majesticons, - MajesticonsLocal, -} +enum FirkaIconType { Majesticons, MajesticonsLocal } class FirkaIconWidget extends StatelessWidget { final FirkaIconType iconType; @@ -15,8 +12,13 @@ class FirkaIconWidget extends StatelessWidget { final Color color; final double? size; - const FirkaIconWidget(this.iconType, this.iconData, - {super.key, this.color = Colors.white, this.size}); + const FirkaIconWidget( + this.iconType, + this.iconData, { + super.key, + this.color = Colors.white, + this.size, + }); @override Widget build(BuildContext context) { diff --git a/firka_wear/lib/ui/widget/grade_small_card.dart b/firka_wear/lib/ui/widget/grade_small_card.dart index 649d2ec0..33177e63 100644 --- a/firka_wear/lib/ui/widget/grade_small_card.dart +++ b/firka_wear/lib/ui/widget/grade_small_card.dart @@ -1,5 +1,4 @@ -import 'package:firka_wear/helpers/api/model/grade.dart'; -import 'package:firka_wear/helpers/api/model/subject.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka_wear/helpers/ui/firka_card.dart'; import 'package:firka_wear/helpers/ui/grade_helpers.dart'; import 'package:firka_wear/ui/widget/class_icon.dart'; @@ -12,41 +11,50 @@ class GradeSmallCard extends FirkaCard { final Subject subject; GradeSmallCard(this.grades, this.subject, {super.key}) - : super(left: [ + : super( + left: [ ClassIconWidget( uid: subject.uid, className: subject.name, category: subject.category.name!, color: appStyle.colors.accent, ), - SizedBox( - width: 4, - ), + SizedBox(width: 4), SizedBox( width: 200, child: Text( subject.name, - style: appStyle.fonts.B_16SB - .apply(color: appStyle.colors.textPrimary), + style: appStyle.fonts.B_16SB.apply( + color: appStyle.colors.textPrimary, + ), ), ), - ], right: [ + ], + right: [ grades.getAverageBySubject(subject).isNaN ? SizedBox() : Card( shadowColor: Colors.transparent, - color: getGradeColor(grades.getAverageBySubject(subject)) - .withAlpha(38), + color: getGradeColor( + grades.getAverageBySubject(subject), + ).withAlpha(38), child: Padding( - padding: - EdgeInsets.only(left: 8, right: 8, top: 4, bottom: 4), + padding: EdgeInsets.only( + left: 8, + right: 8, + top: 4, + bottom: 4, + ), child: Text( grades.getAverageBySubject(subject).toStringAsFixed(2), style: appStyle.fonts.B_16SB.apply( - color: getGradeColor( - grades.getAverageBySubject(subject))), + color: getGradeColor( + grades.getAverageBySubject(subject), + ), + ), ), ), ), - ]); + ], + ); } diff --git a/firka_wear/pubspec.yaml b/firka_wear/pubspec.yaml index b8dfba48..0da12164 100644 --- a/firka_wear/pubspec.yaml +++ b/firka_wear/pubspec.yaml @@ -33,6 +33,8 @@ environment: dependencies: flutter: sdk: flutter + kreta_api: + path: ../kreta_api cupertino_icons: ^1.0.8 flutter_launcher_icons: ^0.14.3