forked from firka/firka
feat: notifications
This commit is contained in:
@@ -12,6 +12,7 @@ android {
|
||||
compileSdk = flutter.compileSdkVersion
|
||||
ndkVersion = flutter.ndkVersion
|
||||
compileOptions {
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
@@ -71,6 +72,7 @@ configurations.all {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
|
||||
implementation("androidx.glance:glance-appwidget:1.1.1")
|
||||
implementation("com.google.android.gms:play-services-wearable:18.1.0")
|
||||
}
|
||||
@@ -90,4 +92,4 @@ tasks.matching { it.name.startsWith("compileFlutterBuild") }.configureEach {
|
||||
}
|
||||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
}
|
||||
|
||||
3
firka/assets/majesticons/check.svg
Normal file
3
firka/assets/majesticons/check.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.7069 7.70643C19.8891 7.51783 19.9899 7.26523 19.9876 7.00303C19.9853 6.74083 19.8801 6.49002 19.6947 6.30461C19.5093 6.1192 19.2585 6.01403 18.9963 6.01176C18.7341 6.00948 18.4815 6.11027 18.2929 6.29243L8.99992 15.5854L5.70692 12.2924C5.51832 12.1103 5.26571 12.0095 5.00352 12.0118C4.74132 12.014 4.49051 12.1192 4.3051 12.3046C4.11969 12.49 4.01452 12.7408 4.01224 13.003C4.00997 13.2652 4.11076 13.5178 4.29292 13.7064L8.29292 17.7064C8.48045 17.8939 8.73476 17.9992 8.99992 17.9992C9.26508 17.9992 9.51939 17.8939 9.70692 17.7064L19.7069 7.70643Z" fill="#A7DC22"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 726 B |
10
firka/assets/majesticons/checkSolid.svg
Normal file
10
firka/assets/majesticons/checkSolid.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_2679_4048)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 0.5C1.96957 0.5 1.46086 0.710714 1.08579 1.08579C0.710714 1.46086 0.5 1.96957 0.5 2.5V9.5C0.5 10.0304 0.710714 10.5391 1.08579 10.9142C1.46086 11.2893 1.96957 11.5 2.5 11.5H9.5C10.0304 11.5 10.5391 11.2893 10.9142 10.9142C11.2893 10.5391 11.5 10.0304 11.5 9.5V2.5C11.5 1.96957 11.2893 1.46086 10.9142 1.08579C10.5391 0.710714 10.0304 0.5 9.5 0.5H2.5ZM9.8535 3.8535C9.94458 3.7592 9.99498 3.6329 9.99384 3.5018C9.9927 3.3707 9.94011 3.24529 9.84741 3.15259C9.75471 3.05989 9.6293 3.0073 9.4982 3.00616C9.3671 3.00502 9.2408 3.05542 9.1465 3.1465L4.5 7.793L2.8535 6.1465C2.7592 6.05542 2.6329 6.00502 2.5018 6.00616C2.3707 6.0073 2.24529 6.05989 2.15259 6.15259C2.05989 6.24529 2.0073 6.3707 2.00616 6.5018C2.00502 6.6329 2.05542 6.7592 2.1465 6.8535L4.1465 8.8535C4.24026 8.94724 4.36742 8.99989 4.5 8.99989C4.63258 8.99989 4.75974 8.94724 4.8535 8.8535L9.8535 3.8535Z" fill="#A7DC22"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_2679_4048">
|
||||
<rect width="12" height="12" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -3,7 +3,9 @@ import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/core/settings.dart';
|
||||
import 'package:firka/data/models/generic_cache_model.dart';
|
||||
import 'package:firka/data/models/timetable_cache_model.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
@@ -39,6 +41,65 @@ class KretaClient {
|
||||
|
||||
bool get needsReauth => _reauthCubit.state.needsReauth;
|
||||
|
||||
Future<Response<dynamic>> sendNotifReq(
|
||||
String method,
|
||||
TokenModel model,
|
||||
String? fcmToken, {
|
||||
bool auth = true,
|
||||
}) async {
|
||||
var isGuardian = model.studentId!.contains("G0");
|
||||
|
||||
return await dio.request(
|
||||
"https://kretaglobalmobileapi2.ekreta.hu/api/v3/Registration",
|
||||
options: Options(
|
||||
method: method,
|
||||
headers: {
|
||||
"accept": "*/*",
|
||||
"user-agent": Constants.userAgent,
|
||||
if (auth) "Authorization": "Bearer ${model.accessToken}",
|
||||
"apiKey": "7856d350-1fda-45f5-822d-e1a2f3f1acf0",
|
||||
},
|
||||
),
|
||||
queryParameters: <String, String>{
|
||||
"RegistrationId": ?model.registrationId,
|
||||
"Handle": ?fcmToken,
|
||||
"NotificationRole": isGuardian ? "2" : "1",
|
||||
"NotificationEnvironment": isGuardian
|
||||
? "Gondviselo_Native"
|
||||
: "Tanulo_Native",
|
||||
"NotificationType": "1",
|
||||
if (method == "POST") "Platform": "fcmv1",
|
||||
"NotificationSource": "Kreta",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateFCMToken({String? fcmToken}) async {
|
||||
fcmToken = fcmToken ?? (await FirebaseMessaging.instance.getToken())!;
|
||||
|
||||
Response<dynamic> resp;
|
||||
|
||||
if (model.registrationId == null) {
|
||||
resp = await sendNotifReq("POST", model, fcmToken, auth: true);
|
||||
|
||||
if (resp.statusCode == 200) {
|
||||
model.registrationId = resp.data["registrationId"];
|
||||
model.fcmToken = fcmToken;
|
||||
logger.info("New registr: ${model.registrationId}");
|
||||
} else {
|
||||
logger.info("POST RESP");
|
||||
logger.info(resp.statusCode);
|
||||
logger.info(resp);
|
||||
}
|
||||
} else if (fcmToken != model.fcmToken) {
|
||||
logger.info("FCM mismatch!");
|
||||
model.registrationId = null;
|
||||
await updateFCMToken(fcmToken: fcmToken);
|
||||
} else {
|
||||
logger.info("FCM already registered!");
|
||||
}
|
||||
}
|
||||
|
||||
void clearReauthFlag() {
|
||||
_reauthCubit.clear();
|
||||
debugPrint('[KretaClient] Reauth flag cleared');
|
||||
@@ -83,7 +144,9 @@ class KretaClient {
|
||||
}
|
||||
|
||||
final extended = await extendToken(sourceToken);
|
||||
return TokenModel.fromResp(extended);
|
||||
return TokenModel.fromResp(extended)
|
||||
..registrationId ??= sourceToken.registrationId
|
||||
..fcmToken ??= sourceToken.fcmToken;
|
||||
} finally {
|
||||
if (Platform.isIOS && studentIdNorm != null && leaseOperationId != null) {
|
||||
await WatchSyncHelper.releaseIPhoneRefreshLease(
|
||||
@@ -169,11 +232,13 @@ class KretaClient {
|
||||
try {
|
||||
var tokenModel = await _refreshModelWithCrossDeviceLease(model);
|
||||
|
||||
model = tokenModel;
|
||||
await updateFCMToken();
|
||||
|
||||
await isar.writeTxn(() async {
|
||||
await isar.tokenModels.put(tokenModel);
|
||||
});
|
||||
|
||||
model = tokenModel;
|
||||
await _syncTokenToAppleTargets(model);
|
||||
clearReauthFlag();
|
||||
logger.info("[Recovery] Step 1 SUCCESS: Local refresh succeeded");
|
||||
@@ -304,7 +369,7 @@ class KretaClient {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<T> _mutexCallback<T>(Future<T> Function() callback) async {
|
||||
Future<T> mutexCallback<T>(Future<T> Function() callback) async {
|
||||
const maxWaitTime = Duration(seconds: 30);
|
||||
|
||||
if (_tokenMutexCompleter != null) {
|
||||
@@ -337,7 +402,7 @@ class KretaClient {
|
||||
}
|
||||
|
||||
Future<Response> _authReq(String method, String url, [Object? data]) async {
|
||||
var localToken = await _mutexCallback<String>(() async {
|
||||
var localToken = await mutexCallback<String>(() async {
|
||||
var now = timeNow();
|
||||
|
||||
if (now.millisecondsSinceEpoch >=
|
||||
@@ -366,7 +431,11 @@ class KretaClient {
|
||||
|
||||
return await dio.get(
|
||||
url,
|
||||
options: Options(method: method, headers: headers),
|
||||
options: Options(
|
||||
method: method,
|
||||
headers: headers,
|
||||
receiveTimeout: Duration(seconds: 20),
|
||||
),
|
||||
data: data,
|
||||
);
|
||||
}
|
||||
@@ -381,7 +450,7 @@ class KretaClient {
|
||||
try {
|
||||
logger.finest("Sending authenticated request to: $url");
|
||||
resp = await _authReq(method, url, data);
|
||||
if (!url.endsWith("TanuloAdatlap")) {
|
||||
if (!isDebug() && !url.endsWith("TanuloAdatlap")) {
|
||||
logger.finest("Response: ${resp.statusCode} ${resp.data}");
|
||||
}
|
||||
|
||||
@@ -404,6 +473,9 @@ class KretaClient {
|
||||
);
|
||||
} else {
|
||||
logger.shout("Request to url: $url failed", ex.toString());
|
||||
if (ex is Exception) {
|
||||
logger.shout(ex);
|
||||
}
|
||||
}
|
||||
|
||||
rethrow;
|
||||
@@ -733,8 +805,10 @@ class KretaClient {
|
||||
}) async {
|
||||
if (from == null && to == null) {
|
||||
DateTime now = timeNow();
|
||||
/* you are taking too long °w°
|
||||
DateTime start = now.copyWith(month: 9, day: 1);
|
||||
from = now.isBefore(start) ? start.subtract(Duration(days: 365)) : start;
|
||||
from = now.isBefore(start) ? start.subtract(Duration(days: 365)) : start;*/
|
||||
from = now.subtract(Duration(days: 14));
|
||||
}
|
||||
return await _genericListedCachingGet(
|
||||
CacheId.getHomework,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:firka/api/client/kreta_client.dart';
|
||||
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:isar_community/isar.dart';
|
||||
import 'dart:io';
|
||||
|
||||
late final Logger logger;
|
||||
late final FlutterLocalNotificationsPlugin flnp;
|
||||
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
late AppInitialization initData;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:firka/api/consts.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -25,7 +28,9 @@ import 'package:firka/l10n/app_localizations_en.dart';
|
||||
import 'package:firka/l10n/app_localizations_hu.dart';
|
||||
import 'package:firka/core/swear_generator.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:isar_community/isar.dart';
|
||||
@@ -299,6 +304,49 @@ Future<AppInitialization> initializeApp() async {
|
||||
|
||||
await _initData(init);
|
||||
|
||||
initData = init;
|
||||
initDone = true;
|
||||
|
||||
flnp = FlutterLocalNotificationsPlugin();
|
||||
const DarwinInitializationSettings initializationSettingsDarwin =
|
||||
DarwinInitializationSettings(
|
||||
requestSoundPermission: true,
|
||||
requestBadgePermission: true,
|
||||
requestAlertPermission: false,
|
||||
);
|
||||
const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('ic_notification');
|
||||
const InitializationSettings initializationSettings = InitializationSettings(
|
||||
android: initializationSettingsAndroid,
|
||||
iOS: initializationSettingsDarwin,
|
||||
macOS: initializationSettingsDarwin,
|
||||
);
|
||||
await flnp.initialize(settings: initializationSettings);
|
||||
|
||||
Future<void> updateToken([String? fcm]) async {
|
||||
TokenModel? token = pickActiveToken(
|
||||
tokens: initData.tokens,
|
||||
settings: initData.settings,
|
||||
);
|
||||
|
||||
if (token == null) return;
|
||||
try {
|
||||
await initData.client.mutexCallback(() async {
|
||||
if (!await initData.client.refreshTokenProactively()) {
|
||||
throw TokenExpiredException();
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FirebaseMessaging.instance.onTokenRefresh.listen(
|
||||
(token) => unawaited(updateToken(token)),
|
||||
);
|
||||
|
||||
await updateToken();
|
||||
|
||||
return init;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ class TokenModel {
|
||||
String? idToken; // Unique identifier for the token if needed
|
||||
String? accessToken; // The main auth token
|
||||
String? refreshToken; // Token used to refresh the access token
|
||||
String? registrationId;
|
||||
String? fcmToken;
|
||||
DateTime? expiryDate;
|
||||
int? tokenVersion;
|
||||
int? updatedAtMs;
|
||||
|
||||
Submodule firka/lib/l10n updated: 25c4ab64a7...32bea9c6be
@@ -1,5 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
@@ -7,8 +10,34 @@ import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/app/initialization.dart';
|
||||
import 'package:firka/app/initialization_screen.dart';
|
||||
|
||||
Future<void> ertesites(String title, String message) async {
|
||||
logger.info("REMOTE Title: $title");
|
||||
logger.info("REMOTE Message: $message");
|
||||
const NotificationDetails notificationDetails = NotificationDetails(
|
||||
android: AndroidNotificationDetails(
|
||||
'teszt',
|
||||
'Értesítés',
|
||||
channelDescription: 'Értesítés a Krétától.',
|
||||
importance: Importance.max,
|
||||
ticker: 'ticker',
|
||||
),
|
||||
);
|
||||
await flnp.show(
|
||||
id: 0,
|
||||
title: title,
|
||||
body: message,
|
||||
notificationDetails: notificationDetails,
|
||||
payload: "szia",
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||
await ertesites(message.data["Title"], message.data["Message"]);
|
||||
}
|
||||
|
||||
void main() async {
|
||||
logger = Logger("Firka");
|
||||
|
||||
dio.options.connectTimeout = Duration(seconds: 5);
|
||||
dio.options.receiveTimeout = Duration(seconds: 3);
|
||||
dio.options.validateStatus = (status) => status != null && status < 500;
|
||||
@@ -28,6 +57,26 @@ void main() async {
|
||||
|
||||
await setupLogging();
|
||||
|
||||
await Firebase.initializeApp(
|
||||
name: defaultFirebaseAppName,
|
||||
options: FirebaseOptions(
|
||||
apiKey: "AIzaSyA_SnXigQkSvFuB5ECpgz8pZ1SjKzuKiFo",
|
||||
appId: "1:694136934013:android:2d6873f63e005250",
|
||||
androidClientId:
|
||||
"694136934013-6e2jmrbqume6lt92d2ceb5se6uru4uvm.apps.googleusercontent.com",
|
||||
projectId: "ellenorzo-v2",
|
||||
messagingSenderId: "694136934013",
|
||||
storageBucket: "ellenorzo-v2.appspot.com",
|
||||
databaseURL: "https://ellenorzo-v2.firebaseio.com",
|
||||
),
|
||||
);
|
||||
|
||||
FirebaseMessaging.instance.setAutoInitEnabled(true);
|
||||
|
||||
FirebaseMessaging.onBackgroundMessage(
|
||||
_firebaseMessagingBackgroundHandler,
|
||||
);
|
||||
|
||||
runApp(InitializationScreen());
|
||||
},
|
||||
(error, stackTrace) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:firka/ui/phone/pages/home/home_omissions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:firka/core/firka_bundle.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
@@ -177,6 +178,20 @@ GoRouter createAppRouter() {
|
||||
),
|
||||
],
|
||||
),
|
||||
StatefulShellBranch(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/omissions',
|
||||
pageBuilder: (context, state) => NoTransitionPage(
|
||||
key: state.pageKey,
|
||||
child: DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: HomeOmissionsScreen(initData),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
@@ -57,6 +57,11 @@ class ShellWithNavBar extends StatelessWidget {
|
||||
Majesticon.calendarSolid,
|
||||
Majesticon.calendarLine,
|
||||
),
|
||||
(
|
||||
initData.l10n.omissions,
|
||||
Majesticon.timerSolid,
|
||||
Majesticon.timerLine,
|
||||
),
|
||||
].indexed.map(
|
||||
(nav) => BottomNavIconWidget(
|
||||
() {
|
||||
|
||||
@@ -245,6 +245,119 @@ Future<void> showLessonBottomSheet(
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> showOmissionBottomSheet(
|
||||
BuildContext context,
|
||||
AppInitialization data,
|
||||
String description,
|
||||
List<Omission> omissions,
|
||||
) async {
|
||||
showFirkaBottomSheet(context, [
|
||||
Text(
|
||||
omissions.first.date.format(data.l10n, FormatMode.yyyymmdd),
|
||||
style: appStyle.fonts.H_18px.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
SizedBox(height: 2),
|
||||
Text(
|
||||
description,
|
||||
style: appStyle.fonts.B_16R.apply(color: appStyle.colors.textSecondary),
|
||||
),
|
||||
SizedBox(height: 2),
|
||||
LimitedBox(
|
||||
maxHeight: 336,
|
||||
child: ListView.builder(
|
||||
itemCount: omissions.length,
|
||||
itemBuilder: (b, i) {
|
||||
final o = omissions[i];
|
||||
return FirkaCard.single(
|
||||
height: 64,
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
padding: EdgeInsets.only(left: 14, right: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/icons/subtract.svg",
|
||||
color: appStyle.colors.a15p,
|
||||
width: 18,
|
||||
height: 18,
|
||||
),
|
||||
Text(
|
||||
o.lesson!.classNo?.toString() ?? "-",
|
||||
style: appStyle.fonts.B_14SB.apply(
|
||||
color: appStyle.colors.secondary,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
FilledCircle(
|
||||
diameter: 36,
|
||||
color: appStyle.colors.a15p,
|
||||
child: ClassIconWidget(
|
||||
uid: o.subject.uid,
|
||||
className: o.subject.name,
|
||||
category: o.subject.name,
|
||||
color: appStyle.colors.accent,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
o.subject.name,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
o.teacher,
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
o.lesson!.start.format(data.l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
o.lesson!.end.format(data.l10n, FormatMode.hmm),
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Future<void> showTestBottomSheet(
|
||||
BuildContext context,
|
||||
AppInitialization data,
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:firka/api/client/kreta_stream.dart';
|
||||
import 'package:firka/ui/phone/widgets/info_card.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson.dart';
|
||||
@@ -41,10 +43,12 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
|
||||
List<Lesson>? lessons;
|
||||
List<NoticeBoardItem>? noticeBoard;
|
||||
List<RemoteMessage> notifications = [];
|
||||
List<InfoBoardItem>? infoBoard;
|
||||
List<Test>? tests;
|
||||
List<Grade>? grades;
|
||||
List<Homework>? homework;
|
||||
List<Omission>? omissions;
|
||||
Student? student;
|
||||
Timer? timer;
|
||||
|
||||
@@ -66,6 +70,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
var testsFetched = 0;
|
||||
var gradesFetched = 0;
|
||||
var homeworkFetched = 0;
|
||||
var omissionFetched = 0;
|
||||
|
||||
widget.data.client
|
||||
.getTimeTableStream(
|
||||
@@ -139,6 +144,18 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
}
|
||||
});
|
||||
|
||||
widget.data.client.getOmissionsStream(cacheOnly: cacheOnly).forEach((
|
||||
omission,
|
||||
) {
|
||||
omissionFetched++;
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
this.omissions = omission.response;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
widget.data.client.getHomeworkStream(cacheOnly: cacheOnly).forEach((
|
||||
homework,
|
||||
) {
|
||||
@@ -161,7 +178,8 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
studentFetched < r ||
|
||||
testsFetched < r ||
|
||||
gradesFetched < r ||
|
||||
homeworkFetched < r) {
|
||||
homeworkFetched < r ||
|
||||
omissionFetched < r) {
|
||||
if (DateTime.now().difference(startTime) > maxWaitTime) {
|
||||
debugPrint('[HomeMain] Data fetch timed out after 30s');
|
||||
break;
|
||||
@@ -174,6 +192,10 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
FirebaseMessaging.onMessage.listen((event) {
|
||||
notifications.add(event);
|
||||
}, onError: (e) => logger.info(e));
|
||||
|
||||
(() async {
|
||||
await fetchData();
|
||||
})();
|
||||
@@ -198,8 +220,32 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
final gradeItems = grades ?? [];
|
||||
final testItems = tests ?? [];
|
||||
final homeworkItems = homework ?? [];
|
||||
final omissionItems = omissions?.groupList((o) => o.date).values ?? [];
|
||||
final noticeBoardWidgets = <(Widget, DateTime)>[];
|
||||
|
||||
for (final n in notifications) {
|
||||
noticeBoardWidgets.add((
|
||||
InfoCard.messageItem(
|
||||
InfoBoardItem(
|
||||
uid: "",
|
||||
title: "Értesítés",
|
||||
author: "Kréta",
|
||||
type: NameUidDesc(
|
||||
uid: "notificaiton",
|
||||
name: "notification",
|
||||
description: "notification",
|
||||
),
|
||||
contentHTML:
|
||||
"<code>${n.data}</code><code>${n.notification}<br/>${n.notification?.title}<br/>${n.notification?.body}<br/>${n.notification?.android}",
|
||||
contentText: "",
|
||||
date: now,
|
||||
createdAt: now,
|
||||
),
|
||||
),
|
||||
now,
|
||||
));
|
||||
}
|
||||
|
||||
for (final item in infoItems) {
|
||||
noticeBoardWidgets.add((InfoCard.messageItem(item), item.date));
|
||||
}
|
||||
@@ -216,6 +262,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
noticeBoardWidgets.add((InfoCard.homework(entry), entry.creationDate));
|
||||
}
|
||||
|
||||
for (final omission in omissionItems) {
|
||||
noticeBoardWidgets.add((
|
||||
InfoCard.omission(omission),
|
||||
omission.first.date,
|
||||
));
|
||||
}
|
||||
|
||||
noticeBoardWidgets.sort(
|
||||
(item1, item2) => item2.$2.difference(item1.$2).inMilliseconds,
|
||||
);
|
||||
|
||||
324
firka/lib/ui/phone/pages/home/home_omissions.dart
Normal file
324
firka/lib/ui/phone/pages/home/home_omissions.dart
Normal file
@@ -0,0 +1,324 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/ui/phone/widgets/info_card.dart';
|
||||
import 'package:firka/ui/phone/widgets/omission_bar.dart';
|
||||
import 'package:firka_common/firka_common.dart';
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:firka/ui/components/firka_card.dart';
|
||||
import 'package:firka/ui/components/grade_helpers.dart';
|
||||
import 'package:firka/ui/phone/widgets/grade_chart.dart';
|
||||
import 'package:firka/ui/phone/widgets/grade_summary_bar.dart';
|
||||
import 'package:firka/ui/shared/grade_small_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:firka/api/consts.dart';
|
||||
import 'package:firka/core/debug_helper.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||
import 'package:firka/core/settings.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
class HomeOmissionsScreen extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
|
||||
const HomeOmissionsScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _HomeOmissionsScreen();
|
||||
}
|
||||
|
||||
class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
|
||||
ApiResponse<List<Omission>>? omissions;
|
||||
|
||||
void _onRefreshRequested(BuildContext context) async {
|
||||
final cubit = context.read<HomeRefreshCubit>();
|
||||
omissions = await widget.data.client.getOmissions(forceCache: false);
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
cubit.onRefreshComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
(() async {
|
||||
omissions = await widget.data.client.getOmissions(forceCache: false);
|
||||
if (mounted) setState(() {});
|
||||
})();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<HomeRefreshCubit, HomeRefreshState>(
|
||||
listenWhen: (previous, current) =>
|
||||
current.refreshTrigger != previous.refreshTrigger,
|
||||
listener: (context, state) {
|
||||
_onRefreshRequested(context);
|
||||
},
|
||||
child: _buildContent(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
if (omissions == null) {
|
||||
return Center(child: DelayedSpinnerWidget());
|
||||
}
|
||||
|
||||
final omissionItems = omissions!.response ?? [];
|
||||
|
||||
final overallExcused = omissionItems
|
||||
.where((o) => o.state == OmissionState.excused)
|
||||
.length;
|
||||
|
||||
final overallUnexcused = omissionItems
|
||||
.where((o) => o.state == OmissionState.unexcused)
|
||||
.length;
|
||||
|
||||
final overallPending = omissionItems
|
||||
.where((o) => o.state == OmissionState.pending)
|
||||
.length;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 12.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.omissions,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Row(
|
||||
spacing: 10,
|
||||
children: [
|
||||
Expanded(
|
||||
child: FirkaCard.single(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"checkSolid",
|
||||
size: 12.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
Text(
|
||||
overallExcused.toString(),
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
initData.l10n.omission_state_excused,
|
||||
style: appStyle.fonts.B_16R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FirkaCard.single(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.timerSolid,
|
||||
size: 12.0,
|
||||
color: appStyle.colors.warningAccent,
|
||||
),
|
||||
Text(
|
||||
overallPending.toString(),
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
color: appStyle.colors.warningAccent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
initData.l10n.omission_state_pending,
|
||||
style: appStyle.fonts.B_16R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: FirkaCard.single(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.restrictedSolid,
|
||||
size: 12.0,
|
||||
color: appStyle.colors.errorAccent,
|
||||
),
|
||||
Text(
|
||||
overallUnexcused.toString(),
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
color: appStyle.colors.errorAccent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
initData.l10n.omission_state_unexcused,
|
||||
style: appStyle.fonts.B_16R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
OmissionBar(omissions: omissions!.response!),
|
||||
SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Text(
|
||||
initData.l10n.subjects,
|
||||
style: appStyle.fonts.B_16SB.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
...omissionItems
|
||||
.fold(
|
||||
LinkedHashMap<Subject, List<Omission>>(
|
||||
equals: (a, b) => a.uid == b.uid,
|
||||
hashCode: (a) => a.uid.hashCode,
|
||||
),
|
||||
(map, o) =>
|
||||
map
|
||||
..putIfAbsent(o.subject, () => <Omission>[]).add(o),
|
||||
)
|
||||
.entries
|
||||
.map((entry) {
|
||||
final excused = entry.value
|
||||
.where((o) => o.state == OmissionState.excused)
|
||||
.length;
|
||||
|
||||
final unexcused = entry.value
|
||||
.where((o) => o.state == OmissionState.unexcused)
|
||||
.length;
|
||||
|
||||
final pending = entry.value
|
||||
.where((o) => o.state == OmissionState.pending)
|
||||
.length;
|
||||
|
||||
return FirkaCard.single(
|
||||
height: 64,
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
spacing: 12,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
InfoCard.buildSubject(
|
||||
appStyle.colors.accent,
|
||||
entry.key,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 2,
|
||||
children: [
|
||||
Text(
|
||||
entry.key.name,
|
||||
style: appStyle.fonts.B_16SB.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"checkSolid",
|
||||
size: 12.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
Text(
|
||||
excused.toString(),
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.timerSolid,
|
||||
size: 12.0,
|
||||
color: appStyle.colors.warningAccent,
|
||||
),
|
||||
Text(
|
||||
pending.toString(),
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.restrictedLine,
|
||||
size: 12.0,
|
||||
color: appStyle.colors.errorAccent,
|
||||
),
|
||||
Text(
|
||||
unexcused.toString(),
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ class _HomeTimetableMonthlyScreen
|
||||
omission.subject.uid == omittedLesson.subject?.uid;
|
||||
});
|
||||
|
||||
if (omission?.state == "Igazolt") {
|
||||
if (omission?.state == OmissionState.excused) {
|
||||
body = Center(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
@@ -242,7 +242,7 @@ class _HomeTimetableMonthlyScreen
|
||||
break;
|
||||
}
|
||||
|
||||
if (omission?.lateForMin != null) {
|
||||
if (omission?.state == OmissionState.pending) {
|
||||
body = Center(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
|
||||
@@ -1,242 +1,297 @@
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/data/models/homework_cache_model.dart';
|
||||
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
||||
import 'package:firka/ui/components/firka_card.dart';
|
||||
import 'package:firka/ui/components/grade.dart';
|
||||
import 'package:firka/ui/components/grade_helpers.dart';
|
||||
import 'package:firka/ui/shared/class_icon.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
class InfoCard extends StatelessWidget {
|
||||
final void Function(BuildContext)? onTap;
|
||||
final Widget icon;
|
||||
final List<String> texts;
|
||||
final List<Widget> right;
|
||||
|
||||
final List<TextStyle> textSyles = [
|
||||
appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
|
||||
appStyle.fonts.B_14R.apply(color: appStyle.colors.textSecondary),
|
||||
];
|
||||
|
||||
InfoCard({
|
||||
required this.icon,
|
||||
required this.texts,
|
||||
this.right = const [],
|
||||
this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static Widget buildSubject(Color color, Subject subject) {
|
||||
return FilledCircle(
|
||||
diameter: 32,
|
||||
color: color.withAlpha(38),
|
||||
child: ClassIconWidget.subject(subject: subject, color: color, size: 20),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.test(Test test) {
|
||||
final color = appStyle.colors.accent;
|
||||
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: color.withAlpha(38),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
color: color,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
texts: [
|
||||
test.theme?.firstUpper() ?? test.method.description,
|
||||
test.subject.name.firstUpper(),
|
||||
],
|
||||
right: [buildSubject(color, test.subject)],
|
||||
onTap: (context) => showTestBottomSheet(context, initData, test),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.testDesc(Test test) {
|
||||
if (test.theme == null) {
|
||||
return InfoCard.test(test);
|
||||
}
|
||||
|
||||
final color = appStyle.colors.accent;
|
||||
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: color.withAlpha(38),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
color: color,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
texts: [test.theme!.firstUpper(), test.method.description.firstUpper()],
|
||||
right: [buildSubject(color, test.subject)],
|
||||
onTap: (context) => showTestBottomSheet(context, initData, test),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.messageItem(MessageItem item) {
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: appStyle.colors.accent,
|
||||
child: Text(
|
||||
item.author[0],
|
||||
style: appStyle.fonts.H_H2.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
),
|
||||
texts: [item.title, item.author],
|
||||
onTap: (context) => context.push('/message', extra: item),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.homework(Homework homework) {
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: appStyle.colors.accent.withAlpha(38),
|
||||
child: FutureBuilder<bool>(
|
||||
future: isHomeworkDone(initData.isar, homework.uid),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return SizedBox();
|
||||
}
|
||||
final done = snapshot.data!;
|
||||
return done
|
||||
? FirkaIconWidget(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"homeWithMark",
|
||||
color: appStyle.colors.accent,
|
||||
size: 24,
|
||||
)
|
||||
: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.homeSolid,
|
||||
color: appStyle.colors.accent,
|
||||
size: 24,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
texts: [initData.l10n.homework, homework.subjectName],
|
||||
right: [buildSubject(appStyle.colors.accent, homework.subject)],
|
||||
onTap: (context) => showHomeworkBottomSheet(context, initData, homework),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.gradeSubj(
|
||||
Grade grade, {
|
||||
void Function(BuildContext)? onTap,
|
||||
}) {
|
||||
String? value = grade.numericValue == null ? grade.strValue : null;
|
||||
return InfoCard(
|
||||
icon: GradeWidget(grade),
|
||||
texts: [
|
||||
(value ??
|
||||
grade.topic ??
|
||||
grade.mode?.description ??
|
||||
grade.type.description!)
|
||||
.firstUpper(),
|
||||
grade.subject.name.firstUpper(),
|
||||
],
|
||||
right: [
|
||||
buildSubject(
|
||||
grade.numericValue != null
|
||||
? getGradeColor(grade.numericValue!)
|
||||
: appStyle.colors.accent,
|
||||
grade.subject,
|
||||
),
|
||||
],
|
||||
onTap:
|
||||
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.gradeGhost(
|
||||
int gradeValue,
|
||||
int gradeWeigth, {
|
||||
void Function(BuildContext)? onTap,
|
||||
}) {
|
||||
return InfoCard(
|
||||
icon: GradeWidget.gradeValue(gradeValue, gradeWeight: gradeWeigth),
|
||||
texts: ["${initData.l10n.ghost_grade} ($gradeWeigth%)"],
|
||||
right: [],
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.gradeDesc(
|
||||
Grade grade, {
|
||||
void Function(BuildContext)? onTap,
|
||||
}) {
|
||||
List<String> texts = [
|
||||
(grade.mode?.description ?? grade.type.description!).firstUpper(),
|
||||
];
|
||||
|
||||
if (grade.topic != null) {
|
||||
texts = [grade.topic!.firstUpper(), ...texts];
|
||||
}
|
||||
|
||||
return InfoCard(
|
||||
icon: GradeWidget(grade),
|
||||
texts: texts,
|
||||
right: [buildSubject(appStyle.colors.accent, grade.subject)],
|
||||
onTap:
|
||||
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Text> children = [];
|
||||
int i = 0;
|
||||
for (var text in texts) {
|
||||
children.add(
|
||||
Text(text, style: textSyles[i], overflow: TextOverflow.ellipsis),
|
||||
);
|
||||
if (i < textSyles.length) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return GestureDetector(
|
||||
child: FirkaCard.single(
|
||||
height: 68,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
margin: EdgeInsets.all(0),
|
||||
child: Row(
|
||||
spacing: 12,
|
||||
children: [
|
||||
icon,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 2,
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
...right,
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (onTap == null) return;
|
||||
onTap!.call(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/data/models/homework_cache_model.dart';
|
||||
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
||||
import 'package:firka/ui/components/firka_card.dart';
|
||||
import 'package:firka/ui/components/grade.dart';
|
||||
import 'package:firka/ui/components/grade_helpers.dart';
|
||||
import 'package:firka/ui/shared/class_icon.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
class InfoCard extends StatelessWidget {
|
||||
final void Function(BuildContext)? onTap;
|
||||
final Widget icon;
|
||||
final List<String> texts;
|
||||
final List<Widget> right;
|
||||
|
||||
final List<TextStyle> textSyles = [
|
||||
appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
|
||||
appStyle.fonts.B_14R.apply(color: appStyle.colors.textSecondary),
|
||||
];
|
||||
|
||||
InfoCard({
|
||||
required this.icon,
|
||||
required this.texts,
|
||||
this.right = const [],
|
||||
this.onTap,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static Widget buildSubject(Color color, Subject subject) {
|
||||
return FilledCircle(
|
||||
diameter: 32,
|
||||
color: color.withAlpha(38),
|
||||
child: ClassIconWidget.subject(subject: subject, color: color, size: 20),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.test(Test test) {
|
||||
final color = appStyle.colors.accent;
|
||||
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: color.withAlpha(38),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
color: color,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
texts: [
|
||||
test.theme?.firstUpper() ?? test.method.description,
|
||||
test.subject.name.firstUpper(),
|
||||
],
|
||||
right: [buildSubject(color, test.subject)],
|
||||
onTap: (context) => showTestBottomSheet(context, initData, test),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.testDesc(Test test) {
|
||||
if (test.theme == null) {
|
||||
return InfoCard.test(test);
|
||||
}
|
||||
|
||||
final color = appStyle.colors.accent;
|
||||
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: color.withAlpha(38),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
color: color,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
texts: [test.theme!.firstUpper(), test.method.description.firstUpper()],
|
||||
right: [buildSubject(color, test.subject)],
|
||||
onTap: (context) => showTestBottomSheet(context, initData, test),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.messageItem(MessageItem item) {
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: appStyle.colors.accent,
|
||||
child: Text(
|
||||
item.author[0],
|
||||
style: appStyle.fonts.H_H2.apply(color: appStyle.colors.textPrimary),
|
||||
),
|
||||
),
|
||||
texts: [item.title, item.author],
|
||||
onTap: (context) => context.push('/message', extra: item),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.omission(List<Omission> omissions) {
|
||||
String title = "-";
|
||||
Color color = appStyle.colors.accent;
|
||||
FirkaIconType iconType = FirkaIconType.majesticons;
|
||||
Object iconData = "check";
|
||||
for (final state in [
|
||||
(
|
||||
OmissionState.pending,
|
||||
appStyle.colors.warningAccent,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.timerSolid,
|
||||
),
|
||||
(
|
||||
OmissionState.unexcused,
|
||||
appStyle.colors.errorAccent,
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.restrictedLine,
|
||||
),
|
||||
(
|
||||
OmissionState.excused,
|
||||
appStyle.colors.accent,
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"check",
|
||||
),
|
||||
]) {
|
||||
final count = omissions.where((o) => o.state == state.$1).length;
|
||||
|
||||
if (count == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
title = initData.l10n.omissions_count(state.$1.name, count);
|
||||
color = state.$2;
|
||||
iconType = state.$3;
|
||||
iconData = state.$4;
|
||||
break;
|
||||
}
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: color.withAlpha(38),
|
||||
child: FirkaIconWidget(iconType, iconData, color: color, size: 24),
|
||||
),
|
||||
texts: [
|
||||
title,
|
||||
DateFormat.MMMMd(
|
||||
initData.l10n.localeName,
|
||||
).format(omissions.first.date).firstUpper(),
|
||||
],
|
||||
onTap: (context) =>
|
||||
showOmissionBottomSheet(context, initData, title, omissions),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.homework(Homework homework) {
|
||||
return InfoCard(
|
||||
icon: FilledCircle(
|
||||
diameter: 36,
|
||||
color: appStyle.colors.accent.withAlpha(38),
|
||||
child: FutureBuilder<bool>(
|
||||
future: isHomeworkDone(initData.isar, homework.uid),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return SizedBox();
|
||||
}
|
||||
final done = snapshot.data!;
|
||||
return done
|
||||
? FirkaIconWidget(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"homeWithMark",
|
||||
color: appStyle.colors.accent,
|
||||
size: 24,
|
||||
)
|
||||
: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.homeSolid,
|
||||
color: appStyle.colors.accent,
|
||||
size: 24,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
texts: [initData.l10n.homework, homework.subjectName],
|
||||
right: [buildSubject(appStyle.colors.accent, homework.subject)],
|
||||
onTap: (context) => showHomeworkBottomSheet(context, initData, homework),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.gradeSubj(
|
||||
Grade grade, {
|
||||
void Function(BuildContext)? onTap,
|
||||
}) {
|
||||
String? value = grade.numericValue == null ? grade.strValue : null;
|
||||
return InfoCard(
|
||||
icon: GradeWidget(grade),
|
||||
texts: [
|
||||
(value ??
|
||||
grade.topic ??
|
||||
grade.mode?.description ??
|
||||
grade.type.description!)
|
||||
.firstUpper(),
|
||||
grade.subject.name.firstUpper(),
|
||||
],
|
||||
right: [
|
||||
buildSubject(
|
||||
grade.numericValue != null
|
||||
? getGradeColor(grade.numericValue!)
|
||||
: appStyle.colors.accent,
|
||||
grade.subject,
|
||||
),
|
||||
],
|
||||
onTap:
|
||||
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.gradeGhost(
|
||||
int gradeValue,
|
||||
int gradeWeigth, {
|
||||
void Function(BuildContext)? onTap,
|
||||
}) {
|
||||
return InfoCard(
|
||||
icon: GradeWidget.gradeValue(gradeValue, gradeWeight: gradeWeigth),
|
||||
texts: ["${initData.l10n.ghost_grade} ($gradeWeigth%)"],
|
||||
right: [],
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
factory InfoCard.gradeDesc(
|
||||
Grade grade, {
|
||||
void Function(BuildContext)? onTap,
|
||||
}) {
|
||||
List<String> texts = [
|
||||
(grade.mode?.description ?? grade.type.description!).firstUpper(),
|
||||
];
|
||||
|
||||
if (grade.topic != null) {
|
||||
texts = [grade.topic!.firstUpper(), ...texts];
|
||||
}
|
||||
|
||||
return InfoCard(
|
||||
icon: GradeWidget(grade),
|
||||
texts: texts,
|
||||
right: [buildSubject(appStyle.colors.accent, grade.subject)],
|
||||
onTap:
|
||||
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Text> children = [];
|
||||
int i = 0;
|
||||
for (var text in texts) {
|
||||
children.add(
|
||||
Text(text, style: textSyles[i], overflow: TextOverflow.ellipsis),
|
||||
);
|
||||
if (i < textSyles.length) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return GestureDetector(
|
||||
child: FirkaCard.single(
|
||||
height: 68,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
margin: EdgeInsets.all(0),
|
||||
child: Row(
|
||||
spacing: 12,
|
||||
children: [
|
||||
icon,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 2,
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
...right,
|
||||
],
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (onTap == null) return;
|
||||
onTap!.call(context);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,10 @@ class LessonWidget extends StatelessWidget {
|
||||
.group("settings")
|
||||
.subGroup("timetable_toast")
|
||||
.boolean("substitution");
|
||||
final showLessonNos =
|
||||
lesson.lessonNumber != null &&
|
||||
data.settings
|
||||
.group("settings")
|
||||
.subGroup("timetable_toast")
|
||||
.boolean("lesson_no");
|
||||
final showLessonNos = data.settings
|
||||
.group("settings")
|
||||
.subGroup("timetable_toast")
|
||||
.boolean("lesson_no");
|
||||
final isDismissed = lesson.type.name == "UresOra";
|
||||
|
||||
var accent = appStyle.colors.accent;
|
||||
@@ -115,7 +113,7 @@ class LessonWidget extends StatelessWidget {
|
||||
height: 18,
|
||||
),
|
||||
Text(
|
||||
lesson.lessonNumber!.toString(),
|
||||
lesson.lessonNumber?.toString() ?? "-",
|
||||
style: appStyle.fonts.B_14SB.apply(
|
||||
color: secondary,
|
||||
),
|
||||
|
||||
@@ -165,6 +165,8 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
|
||||
|
||||
await initializeApp();
|
||||
|
||||
await initData.client.updateFCMToken();
|
||||
|
||||
if (!mounted) return NavigationDecision.prevent;
|
||||
|
||||
if (mounted) {
|
||||
@@ -286,8 +288,8 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
|
||||
opacity: _isLoading
|
||||
? 1.0
|
||||
: _fadeAnimationController!.isAnimating
|
||||
? _fadeAnimation!.value
|
||||
: 0.0,
|
||||
? _fadeAnimation!.value
|
||||
: 0.0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: Container(
|
||||
color: appStyle.colors.background,
|
||||
@@ -332,7 +334,8 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
|
||||
text: _displayPath,
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
fontSize: 16,
|
||||
color: appStyle.colors.textTeritary ??
|
||||
color:
|
||||
appStyle.colors.textTeritary ??
|
||||
appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
|
||||
87
firka/lib/ui/phone/widgets/omission_bar.dart
Normal file
87
firka/lib/ui/phone/widgets/omission_bar.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/ui/components/firka_card.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:firka/ui/components/grade.dart';
|
||||
import 'package:firka/ui/components/grade_helpers.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
|
||||
class OmissionBar extends StatelessWidget {
|
||||
final List<Omission> omissions;
|
||||
|
||||
const OmissionBar({super.key, required this.omissions});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime start = now.copyWith(month: 9, day: 1);
|
||||
DateTime startOfTheYear = now.isBefore(start)
|
||||
? start.subtract(Duration(days: 365))
|
||||
: start;
|
||||
|
||||
Map<int, Color> dayToColor = omissions.fold(
|
||||
Map.identity(),
|
||||
(map, o) => map
|
||||
..putIfAbsent(
|
||||
o.date.difference(startOfTheYear).inDays,
|
||||
() => o.state == OmissionState.excused
|
||||
? appStyle.colors.accent
|
||||
: o.state == OmissionState.unexcused
|
||||
? appStyle.colors.errorAccent
|
||||
: appStyle.colors.warningAccent,
|
||||
),
|
||||
);
|
||||
|
||||
final bar = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Row(
|
||||
children: List.generate(now.difference(startOfTheYear).inDays, (i) {
|
||||
return Expanded(
|
||||
child: Container(
|
||||
height: 12,
|
||||
color: dayToColor[i] ?? appStyle.colors.a15p,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
return FirkaCard.single(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
bar,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat.MMMM(
|
||||
initData.l10n.localeName,
|
||||
).format(startOfTheYear).firstUpper(),
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
initData.l10n.now,
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
name: firka
|
||||
description: "Firka, Alternatív e-Kréta kliens."
|
||||
publish_to: 'none'
|
||||
publish_to: "none"
|
||||
|
||||
version: 1.1.2+2001
|
||||
|
||||
@@ -17,10 +17,11 @@ dependencies:
|
||||
|
||||
cupertino_icons: ^1.0.8
|
||||
flutter_launcher_icons: ^0.14.3
|
||||
flutter_local_notifications: ^22.0.0
|
||||
dio: ^5.8.0+1
|
||||
isar_community: 3.3.0
|
||||
isar_community_flutter_libs: 3.3.0
|
||||
build_runner: any
|
||||
isar_community: ^3.3.0
|
||||
isar_community_flutter_libs: ^3.3.0
|
||||
build_runner: ^2.15.0
|
||||
path_provider: ^2.1.0
|
||||
carousel_slider: ^5.0.0
|
||||
webview_flutter: ^4.7.0
|
||||
@@ -30,7 +31,7 @@ dependencies:
|
||||
permission_handler: ^12.0.1
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
intl: any
|
||||
intl: ^0.20.2
|
||||
image_picker: ^1.1.2
|
||||
image: ^4.5.4
|
||||
path: ^1.9.1
|
||||
@@ -59,20 +60,22 @@ dependencies:
|
||||
go_router: ^17.1.0
|
||||
flutter_bloc: ^9.0.0
|
||||
vibration: ^3.1.8
|
||||
firebase_messaging: ^16.2.0
|
||||
firebase_core: ^4.7.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^6.0.0
|
||||
yaml: ^3.1.2
|
||||
isar_community_generator: 3.3.0
|
||||
isar_community_generator: ^3.3.0
|
||||
android_notification_icons: ^0.0.1
|
||||
integration_test:
|
||||
sdk: flutter
|
||||
|
||||
android_notification_icons:
|
||||
image_path: 'assets/images/logos/dave_monochrome.png'
|
||||
icon_name: 'ic_notification'
|
||||
image_path: "assets/images/logos/dave_monochrome.png"
|
||||
icon_name: "ic_notification"
|
||||
|
||||
flutter:
|
||||
generate: true
|
||||
|
||||
@@ -4,21 +4,21 @@ import 'subject.dart';
|
||||
|
||||
class Omission extends UidObj {
|
||||
final Subject subject;
|
||||
final Class? c;
|
||||
final OmittedLesson? lesson;
|
||||
final DateTime date;
|
||||
final String teacher;
|
||||
final NameUidDesc? type;
|
||||
final NameUidDesc? mode;
|
||||
final int? lateForMin;
|
||||
final DateTime createdAt;
|
||||
final String state;
|
||||
final OmissionState state;
|
||||
final NameUidDesc? proofType;
|
||||
final UidObj? classGroup;
|
||||
|
||||
const Omission({
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
required this.c,
|
||||
required this.lesson,
|
||||
required this.date,
|
||||
required this.teacher,
|
||||
this.type,
|
||||
@@ -34,14 +34,14 @@ class Omission extends UidObj {
|
||||
return Omission(
|
||||
uid: json['Uid'],
|
||||
subject: Subject.fromJson(json['Tantargy']),
|
||||
c: json['Osztaly'] != null ? Class.fromJson(json['Osztaly']) : null,
|
||||
lesson: json['Ora'] != null ? OmittedLesson.fromJson(json['Ora']) : null,
|
||||
date: json.localDate('Datum')!,
|
||||
teacher: json['RogzitoTanarNeve'],
|
||||
type: json.nameUidDesc('Tipus'),
|
||||
mode: json.nameUidDesc('Mod'),
|
||||
lateForMin: json['KesesPercben'],
|
||||
createdAt: json.localDate('KeszitesDatuma')!,
|
||||
state: json['IgazolasAllapota'],
|
||||
state: OmissionState.fromString(json['IgazolasAllapota']),
|
||||
proofType: json.nameUidDesc('IgazolasTipusa'),
|
||||
classGroup: json.uid('OsztalyCsoport'),
|
||||
);
|
||||
@@ -52,7 +52,7 @@ class Omission extends UidObj {
|
||||
return 'Omission('
|
||||
'uid: "$uid", '
|
||||
'subject: $subject, '
|
||||
'c: $c, '
|
||||
'c: $lesson, '
|
||||
'date: $date, '
|
||||
'teacher: "$teacher", '
|
||||
'type: $type, '
|
||||
@@ -66,15 +66,39 @@ class Omission extends UidObj {
|
||||
}
|
||||
}
|
||||
|
||||
class Class {
|
||||
enum OmissionState {
|
||||
excused("Igazolt"),
|
||||
unexcused("Igazolatlan"),
|
||||
pending("Igazolando"),
|
||||
unknown("");
|
||||
|
||||
final String key;
|
||||
const OmissionState(this.key);
|
||||
|
||||
static fromString(String string) {
|
||||
for (final state in OmissionState.values) {
|
||||
if (state.key == string) {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
print("Unknown omission state: ${string}");
|
||||
return OmissionState.unknown;
|
||||
}
|
||||
}
|
||||
|
||||
class OmittedLesson {
|
||||
final DateTime start;
|
||||
final DateTime end;
|
||||
final int classNo;
|
||||
final int? classNo;
|
||||
|
||||
const Class({required this.start, required this.end, required this.classNo});
|
||||
const OmittedLesson({
|
||||
required this.start,
|
||||
required this.end,
|
||||
required this.classNo,
|
||||
});
|
||||
|
||||
factory Class.fromJson(Map<String, dynamic> json) {
|
||||
return Class(
|
||||
factory OmittedLesson.fromJson(Map<String, dynamic> json) {
|
||||
return OmittedLesson(
|
||||
start: json.localDate('KezdoDatum')!,
|
||||
end: json.localDate('VegDatum')!,
|
||||
classNo: json['Oraszam'],
|
||||
@@ -83,7 +107,7 @@ class Class {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Class('
|
||||
return 'OmittedLesson('
|
||||
'start: "$start", '
|
||||
'end: "$end", '
|
||||
'classNo: $classNo'
|
||||
|
||||
Reference in New Issue
Block a user