forked from firka/firka
fix: address all issues found by flutter analyze
This commit is contained in:
@@ -1,12 +1,8 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka/core/settings.dart';
|
|
||||||
import 'package:firka_common/core/consts.dart';
|
|
||||||
import 'package:firka_common/data/cache_manager.dart';
|
import 'package:firka_common/data/cache_manager.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
import 'package:firka_common/data/database.dart';
|
||||||
import 'package:firka_common/data/models/class_average_cache_model.dart';
|
import 'package:firka_common/data/models/class_average_cache_model.dart';
|
||||||
@@ -207,7 +203,7 @@ class KretaClient {
|
|||||||
String? leaseOperationId;
|
String? leaseOperationId;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Platform.isIOS && studentIdNorm != null) {
|
if (Platform.isIOS) {
|
||||||
final watchInstalled = await WatchSyncHelper.isWatchAppInstalled();
|
final watchInstalled = await WatchSyncHelper.isWatchAppInstalled();
|
||||||
if (watchInstalled) {
|
if (watchInstalled) {
|
||||||
final leaseReady = await WatchSyncHelper.waitForWatchRefreshLease(
|
final leaseReady = await WatchSyncHelper.waitForWatchRefreshLease(
|
||||||
@@ -228,7 +224,7 @@ class KretaClient {
|
|||||||
final extended = await extendToken(sourceToken);
|
final extended = await extendToken(sourceToken);
|
||||||
return TokenModel.fromResp(extended);
|
return TokenModel.fromResp(extended);
|
||||||
} finally {
|
} finally {
|
||||||
if (Platform.isIOS && studentIdNorm != null && leaseOperationId != null) {
|
if (Platform.isIOS && leaseOperationId != null) {
|
||||||
await WatchSyncHelper.releaseIPhoneRefreshLease(
|
await WatchSyncHelper.releaseIPhoneRefreshLease(
|
||||||
studentIdNorm: studentIdNorm,
|
studentIdNorm: studentIdNorm,
|
||||||
operationId: leaseOperationId,
|
operationId: leaseOperationId,
|
||||||
@@ -239,11 +235,6 @@ class KretaClient {
|
|||||||
|
|
||||||
Future<void> _syncTokenToAppleTargets(TokenModel token) async {
|
Future<void> _syncTokenToAppleTargets(TokenModel token) async {
|
||||||
if (!Platform.isIOS) return;
|
if (!Platform.isIOS) return;
|
||||||
if (token.accessToken == null ||
|
|
||||||
token.refreshToken == null ||
|
|
||||||
token.expiryDate == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final watchInstalled = await WatchSyncHelper.isWatchAppInstalled();
|
final watchInstalled = await WatchSyncHelper.isWatchAppInstalled();
|
||||||
if (!watchInstalled) {
|
if (!watchInstalled) {
|
||||||
@@ -269,8 +260,7 @@ class KretaClient {
|
|||||||
Future<bool> recoverToken() async {
|
Future<bool> recoverToken() async {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
final localExpiry = cache.token.expiryDate;
|
final localExpiry = cache.token.expiryDate;
|
||||||
if (localExpiry != null &&
|
if (localExpiry.isAfter(now.add(const Duration(seconds: 60)))) {
|
||||||
localExpiry.isAfter(now.add(const Duration(seconds: 60)))) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,10 +321,9 @@ class KretaClient {
|
|||||||
iCloudHasToken = true;
|
iCloudHasToken = true;
|
||||||
|
|
||||||
final recoveredExpiry = cache.token.expiryDate;
|
final recoveredExpiry = cache.token.expiryDate;
|
||||||
if (recoveredExpiry != null &&
|
if (recoveredExpiry.isAfter(
|
||||||
recoveredExpiry.isAfter(
|
timeNow().add(const Duration(seconds: 60)),
|
||||||
timeNow().add(const Duration(seconds: 60)),
|
)) {
|
||||||
)) {
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"[Recovery] Step 2 SUCCESS on attempt ${attempt + 1}: usable iCloud token applied without immediate refresh",
|
"[Recovery] Step 2 SUCCESS on attempt ${attempt + 1}: usable iCloud token applied without immediate refresh",
|
||||||
);
|
);
|
||||||
@@ -380,8 +369,7 @@ class KretaClient {
|
|||||||
final now = timeNow();
|
final now = timeNow();
|
||||||
final fiveMinutesFromNow = now.add(const Duration(minutes: 5));
|
final fiveMinutesFromNow = now.add(const Duration(minutes: 5));
|
||||||
|
|
||||||
if (cache.token.expiryDate == null ||
|
if (cache.token.expiryDate.isBefore(fiveMinutesFromNow)) {
|
||||||
cache.token.expiryDate!.isBefore(fiveMinutesFromNow)) {
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"[Proactive] Token expired or expiring soon, starting recovery...",
|
"[Proactive] Token expired or expiring soon, starting recovery...",
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ class LiveActivityBackendClient {
|
|||||||
'roomName': lesson.roomName,
|
'roomName': lesson.roomName,
|
||||||
'isSubstitution': lesson.substituteTeacher != null,
|
'isSubstitution': lesson.substituteTeacher != null,
|
||||||
'substituteTeacher': lesson.substituteTeacher,
|
'substituteTeacher': lesson.substituteTeacher,
|
||||||
'isCancelled':
|
'isCancelled': lesson.state.name.toLowerCase().contains('elmarad'),
|
||||||
lesson.state.name?.toLowerCase().contains('elmarad') ?? false,
|
|
||||||
'lastModified': validLastModified.toIso8601String(),
|
'lastModified': validLastModified.toIso8601String(),
|
||||||
};
|
};
|
||||||
}).toList();
|
}).toList();
|
||||||
@@ -141,8 +140,7 @@ class LiveActivityBackendClient {
|
|||||||
'roomName': lesson.roomName,
|
'roomName': lesson.roomName,
|
||||||
'isSubstitution': lesson.substituteTeacher != null,
|
'isSubstitution': lesson.substituteTeacher != null,
|
||||||
'substituteTeacher': lesson.substituteTeacher,
|
'substituteTeacher': lesson.substituteTeacher,
|
||||||
'isCancelled':
|
'isCancelled': lesson.state.name.toLowerCase().contains('elmarad'),
|
||||||
lesson.state.name?.toLowerCase().contains('elmarad') ?? false,
|
|
||||||
'lastModified': validLastModified.toIso8601String(),
|
'lastModified': validLastModified.toIso8601String(),
|
||||||
};
|
};
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'package:firka_common/core/consts.dart';
|
|||||||
import 'package:firka_common/data/models/token_model.dart';
|
import 'package:firka_common/data/models/token_model.dart';
|
||||||
|
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
|
||||||
Future<TokenGrantResponse> getAccessToken(String code) async {
|
Future<TokenGrantResponse> getAccessToken(String code) async {
|
||||||
@@ -58,8 +57,8 @@ Future<TokenGrantResponse> extendToken(TokenModel model) async {
|
|||||||
};
|
};
|
||||||
|
|
||||||
final formData = <String, String>{
|
final formData = <String, String>{
|
||||||
"institute_code": model.iss!,
|
"institute_code": model.iss,
|
||||||
"refresh_token": model.refreshToken!,
|
"refresh_token": model.refreshToken,
|
||||||
"grant_type": "refresh_token",
|
"grant_type": "refresh_token",
|
||||||
"client_id": Constants.clientId,
|
"client_id": Constants.clientId,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:firka_common/core/consts.dart';
|
import 'package:firka_common/core/consts.dart';
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:firka/api/client/kreta_client.dart';
|
import 'package:firka/api/client/kreta_client.dart';
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ import 'dart:io';
|
|||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
import 'package:firka_common/data/database.dart';
|
import 'package:firka_common/data/database.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/api/client/kreta_client.dart';
|
import 'package:firka/api/client/kreta_client.dart';
|
||||||
import 'package:firka_common/data/models/app_settings_model.dart';
|
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
import 'package:firka_common/data/models/token_model.dart';
|
||||||
import 'package:firka/services/live_activity_service.dart';
|
import 'package:firka/services/live_activity_service.dart';
|
||||||
import 'package:firka/core/settings/settings_effects.dart';
|
import 'package:firka/core/settings/settings_effects.dart';
|
||||||
@@ -128,7 +126,7 @@ Future<void> _initData(AppInitialization init) async {
|
|||||||
"[Init] System locale changed in auto mode: $previousLocale -> $nextLocale",
|
"[Init] System locale changed in auto mode: $previousLocale -> $nextLocale",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
init.themeCubit?.refresh();
|
init.themeCubit.refresh();
|
||||||
}());
|
}());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -161,8 +159,8 @@ Future<void> _initData(AppInitialization init) async {
|
|||||||
|
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
final expiryDate = token.expiryDate;
|
final expiryDate = token.expiryDate;
|
||||||
if (expiryDate != null && expiryDate.isAfter(DateTime.now())) {
|
if (expiryDate.isAfter(DateTime.now())) {
|
||||||
init.toastCubit?.clear();
|
init.toastCubit.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
unawaited(() async {
|
unawaited(() async {
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:firka/api/client/kreta_client.dart';
|
|
||||||
import 'package:firka/core/extensions.dart';
|
|
||||||
import 'package:firka_common/core/debug_helper.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
@@ -46,7 +43,6 @@ class _InitializationScreenState extends State<InitializationScreen> {
|
|||||||
colorScheme: ColorScheme.fromSeed(
|
colorScheme: ColorScheme.fromSeed(
|
||||||
seedColor: style.colors.accent,
|
seedColor: style.colors.accent,
|
||||||
brightness: style.isLight ? Brightness.light : Brightness.dark,
|
brightness: style.isLight ? Brightness.light : Brightness.dark,
|
||||||
background: style.colors.background,
|
|
||||||
surface: style.colors.card,
|
surface: style.colors.card,
|
||||||
),
|
),
|
||||||
useMaterial3: false,
|
useMaterial3: false,
|
||||||
@@ -178,11 +174,11 @@ class _InitializationScreenState extends State<InitializationScreen> {
|
|||||||
appRouter = _router;
|
appRouter = _router;
|
||||||
}
|
}
|
||||||
|
|
||||||
final themeCubit = initData.themeCubit!;
|
final themeCubit = initData.themeCubit;
|
||||||
final settingsCubit = initData.settingsCubit!;
|
final settingsCubit = initData.settingsCubit;
|
||||||
final profilePictureCubit = initData.profilePictureCubit!;
|
final profilePictureCubit = initData.profilePictureCubit;
|
||||||
final reauthCubit = initData.toastCubit!;
|
final reauthCubit = initData.toastCubit;
|
||||||
final homeRefreshCubit = initData.homeRefreshCubit!;
|
final homeRefreshCubit = initData.homeRefreshCubit;
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider<ThemeCubit>.value(value: themeCubit),
|
BlocProvider<ThemeCubit>.value(value: themeCubit),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:firka/app/app_state.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class FirkaBundle extends CachingAssetBundle {
|
class FirkaBundle extends CachingAssetBundle {
|
||||||
|
|||||||
@@ -21,5 +21,5 @@ Future<void> pickProfilePicture(
|
|||||||
await File(p.join(dataDir.path, "profile.webp")).writeAsBytes(bytes);
|
await File(p.join(dataDir.path, "profile.webp")).writeAsBytes(bytes);
|
||||||
|
|
||||||
data.profilePicture = bytes;
|
data.profilePicture = bytes;
|
||||||
data.profilePictureCubit?.notifyChanged();
|
data.profilePictureCubit.notifyChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class SettingsUiButton extends SettingsUiNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SettingsUiAppIconPreview extends SettingsUiNode {
|
class SettingsUiAppIconPreview extends SettingsUiNode {
|
||||||
const SettingsUiAppIconPreview(bool Function() visible) : super(visible);
|
const SettingsUiAppIconPreview(super.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingsUiAppIconPicker extends SettingsUiNode {
|
class SettingsUiAppIconPicker extends SettingsUiNode {
|
||||||
@@ -139,13 +139,13 @@ class SettingsUiAppIconPicker extends SettingsUiNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SettingsUiKretaAccountPicker extends SettingsUiNode {
|
class SettingsUiKretaAccountPicker extends SettingsUiNode {
|
||||||
const SettingsUiKretaAccountPicker(bool Function() visible) : super(visible);
|
const SettingsUiKretaAccountPicker(super.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingsUiLogs extends SettingsUiNode {
|
class SettingsUiLogs extends SettingsUiNode {
|
||||||
const SettingsUiLogs(bool Function() visible) : super(visible);
|
const SettingsUiLogs(super.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SettingsUiLicensePage extends SettingsUiNode {
|
class SettingsUiLicensePage extends SettingsUiNode {
|
||||||
const SettingsUiLicensePage(bool Function() visible) : super(visible);
|
const SettingsUiLicensePage(super.visible);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,8 +152,7 @@ class IOSWidgetHelper {
|
|||||||
},
|
},
|
||||||
'theme': lesson.theme,
|
'theme': lesson.theme,
|
||||||
'roomName': lesson.roomName,
|
'roomName': lesson.roomName,
|
||||||
'isCancelled':
|
'isCancelled': lesson.state.name.toLowerCase().contains('elmarad'),
|
||||||
lesson.state.name?.toLowerCase().contains('elmarad') ?? false,
|
|
||||||
'isSubstitution': lesson.substituteTeacher != null,
|
'isSubstitution': lesson.substituteTeacher != null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:firka/api/client/kreta_client.dart';
|
import 'package:firka/api/client/kreta_client.dart';
|
||||||
import 'package:firka/data/ios_widget_helper.dart';
|
import 'package:firka/data/ios_widget_helper.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
import 'package:firka/core/debug_helper.dart';
|
import 'package:firka/core/debug_helper.dart';
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
import 'package:firka/core/settings/settings_repository.dart';
|
||||||
@@ -103,8 +101,6 @@ class WidgetCacheHelper {
|
|||||||
KretaClient client,
|
KretaClient client,
|
||||||
) async {
|
) async {
|
||||||
final dataDir = await getApplicationDocumentsDirectory();
|
final dataDir = await getApplicationDocumentsDirectory();
|
||||||
final dayStart = DateTime(date.year, date.month, date.day);
|
|
||||||
final dayEnd = dayStart.add(Duration(hours: 23, minutes: 59));
|
|
||||||
|
|
||||||
final json = toJson(style, []);
|
final json = toJson(style, []);
|
||||||
json['displayDate'] =
|
json['displayDate'] =
|
||||||
@@ -160,11 +156,11 @@ class WidgetCacheHelper {
|
|||||||
final todayMidnight = DateTime(now.year, now.month, now.day);
|
final todayMidnight = DateTime(now.year, now.month, now.day);
|
||||||
final tomorrowMidnight = todayMidnight.add(Duration(days: 1));
|
final tomorrowMidnight = todayMidnight.add(Duration(days: 1));
|
||||||
|
|
||||||
final todayResponse = await client.getLessons(
|
await client.getLessons(
|
||||||
todayMidnight,
|
todayMidnight,
|
||||||
todayMidnight.add(Duration(hours: 23, minutes: 59)),
|
todayMidnight.add(Duration(hours: 23, minutes: 59)),
|
||||||
);
|
);
|
||||||
final tomorrowResponse = await client.getLessons(
|
await client.getLessons(
|
||||||
tomorrowMidnight,
|
tomorrowMidnight,
|
||||||
tomorrowMidnight.add(Duration(hours: 23, minutes: 59)),
|
tomorrowMidnight.add(Duration(hours: 23, minutes: 59)),
|
||||||
);
|
);
|
||||||
@@ -181,7 +177,7 @@ class WidgetCacheHelper {
|
|||||||
if (tomorrowLessons.isEmpty) {
|
if (tomorrowLessons.isEmpty) {
|
||||||
for (int i = 2; i <= 7; i++) {
|
for (int i = 2; i <= 7; i++) {
|
||||||
final dayMidnight = todayMidnight.add(Duration(days: i));
|
final dayMidnight = todayMidnight.add(Duration(days: i));
|
||||||
final dayResponse = await client.getLessons(
|
await client.getLessons(
|
||||||
dayMidnight,
|
dayMidnight,
|
||||||
dayMidnight.add(Duration(hours: 23, minutes: 59)),
|
dayMidnight.add(Duration(hours: 23, minutes: 59)),
|
||||||
);
|
);
|
||||||
@@ -201,7 +197,7 @@ class WidgetCacheHelper {
|
|||||||
final grades = [];
|
final grades = [];
|
||||||
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'iOS widget refresh: ${grades.length} grades fetched (cached: ${gradesResponse})',
|
'iOS widget refresh: ${grades.length} grades fetched (cached: $gradesResponse)',
|
||||||
);
|
);
|
||||||
|
|
||||||
final Map<String, double> subjectAverages = {};
|
final Map<String, double> subjectAverages = {};
|
||||||
|
|||||||
@@ -242,8 +242,7 @@ class LiveActivityManager {
|
|||||||
'nextRoomName': isBeforeSchool ? null : nextLesson?.roomName,
|
'nextRoomName': isBeforeSchool ? null : nextLesson?.roomName,
|
||||||
'nextStartTime': nextStartTimeForActivity?.toUtc().toIso8601String(),
|
'nextStartTime': nextStartTimeForActivity?.toUtc().toIso8601String(),
|
||||||
'isSubstitution': currentLesson.substituteTeacher != null,
|
'isSubstitution': currentLesson.substituteTeacher != null,
|
||||||
'isCancelled':
|
'isCancelled': currentLesson.state.name.toLowerCase().contains('elmarad'),
|
||||||
currentLesson.state.name?.toLowerCase().contains('elmarad') ?? false,
|
|
||||||
'substituteTeacher': currentLesson.substituteTeacher,
|
'substituteTeacher': currentLesson.substituteTeacher,
|
||||||
'currentTime': now.toUtc().toIso8601String(),
|
'currentTime': now.toUtc().toIso8601String(),
|
||||||
'mode': mode,
|
'mode': mode,
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ class LiveActivityService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
initData.themeCubit?.refresh();
|
initData.themeCubit.refresh();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_logger.warning('Error syncing global settings: $e');
|
_logger.warning('Error syncing global settings: $e');
|
||||||
}
|
}
|
||||||
@@ -422,37 +422,23 @@ class LiveActivityService {
|
|||||||
_logger.info(
|
_logger.info(
|
||||||
'Background fetch: attempting to fetch fresh data from KRÉTA API',
|
'Background fetch: attempting to fetch fresh data from KRÉTA API',
|
||||||
);
|
);
|
||||||
final timetableResponse = await client.getLessons(
|
await client.getLessons(startOfWeek, endOfWeek);
|
||||||
startOfWeek,
|
|
||||||
endOfWeek,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
allLessons = <Lesson>[];
|
||||||
allLessons = <Lesson>[];
|
_logger.info(
|
||||||
_logger.info(
|
'Background fetch: successfully fetched ${allLessons.length} lessons from KRÉTA API',
|
||||||
'Background fetch: successfully fetched ${allLessons.length} lessons from KRÉTA API',
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw Exception('KRÉTA API returned null response');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
'Background fetch: KRÉTA API failed ($e), falling back to cache',
|
'Background fetch: KRÉTA API failed ($e), falling back to cache',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
final cachedResponse = await client.getLessons(
|
await client.getLessons(startOfWeek, endOfWeek);
|
||||||
startOfWeek,
|
|
||||||
endOfWeek,
|
allLessons = <Lesson>[];
|
||||||
|
_logger.info(
|
||||||
|
'Background fetch: successfully loaded ${allLessons.length} lessons from cache',
|
||||||
);
|
);
|
||||||
if (true) {
|
|
||||||
allLessons = <Lesson>[];
|
|
||||||
_logger.info(
|
|
||||||
'Background fetch: successfully loaded ${allLessons.length} lessons from cache',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
_logger.severe('Background fetch: both API and cache failed');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (cacheError) {
|
} catch (cacheError) {
|
||||||
_logger.severe(
|
_logger.severe(
|
||||||
'Background fetch: cache fallback also failed: $cacheError',
|
'Background fetch: cache fallback also failed: $cacheError',
|
||||||
@@ -480,10 +466,7 @@ class LiveActivityService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final candidateDayEnd = candidateDay.add(const Duration(days: 1));
|
final candidateDayEnd = candidateDay.add(const Duration(days: 1));
|
||||||
final response = await client.getLessons(
|
await client.getLessons(candidateDay, candidateDayEnd);
|
||||||
candidateDay,
|
|
||||||
candidateDayEnd,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
final schoolLessons = [].where((lesson) {
|
final schoolLessons = [].where((lesson) {
|
||||||
@@ -668,9 +651,9 @@ class LiveActivityService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final studentResp = await effectiveClient.getStudent();
|
await effectiveClient.getStudent();
|
||||||
final activeToken = initData.client!.cache.token;
|
final activeToken = initData.client!.cache.token;
|
||||||
final studentName = null ?? activeToken?.username ?? "Student";
|
final studentName = activeToken.username;
|
||||||
|
|
||||||
await onUserLogin(
|
await onUserLogin(
|
||||||
client: effectiveClient,
|
client: effectiveClient,
|
||||||
@@ -838,37 +821,23 @@ class LiveActivityService {
|
|||||||
_logger.info(
|
_logger.info(
|
||||||
'onUserLogin: Attempting to fetch fresh timetable from KRÉTA API',
|
'onUserLogin: Attempting to fetch fresh timetable from KRÉTA API',
|
||||||
);
|
);
|
||||||
final timetableResponse = await client.getLessons(
|
await client.getLessons(startOfWeek, endOfWeek);
|
||||||
startOfWeek,
|
|
||||||
endOfWeek,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
allLessons = <Lesson>[];
|
||||||
allLessons = <Lesson>[];
|
_logger.info(
|
||||||
_logger.info(
|
'onUserLogin: Successfully fetched ${allLessons.length} lessons from KRÉTA API',
|
||||||
'onUserLogin: Successfully fetched ${allLessons.length} lessons from KRÉTA API',
|
);
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw Exception('KRÉTA API returned null response');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
'onUserLogin: KRÉTA API failed ($e), falling back to cache',
|
'onUserLogin: KRÉTA API failed ($e), falling back to cache',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
final cachedResponse = await client.getLessons(
|
await client.getLessons(startOfWeek, endOfWeek);
|
||||||
startOfWeek,
|
|
||||||
endOfWeek,
|
allLessons = <Lesson>[];
|
||||||
|
_logger.info(
|
||||||
|
'onUserLogin: Successfully loaded ${allLessons.length} lessons from cache',
|
||||||
);
|
);
|
||||||
if (true) {
|
|
||||||
allLessons = <Lesson>[];
|
|
||||||
_logger.info(
|
|
||||||
'onUserLogin: Successfully loaded ${allLessons.length} lessons from cache',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
_logger.severe('onUserLogin: Both API and cache failed');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (cacheError) {
|
} catch (cacheError) {
|
||||||
_logger.severe(
|
_logger.severe(
|
||||||
'onUserLogin: Cache fallback also failed: $cacheError',
|
'onUserLogin: Cache fallback also failed: $cacheError',
|
||||||
@@ -891,10 +860,7 @@ class LiveActivityService {
|
|||||||
|
|
||||||
List<Lesson> nextWeekBreakEvents = [];
|
List<Lesson> nextWeekBreakEvents = [];
|
||||||
try {
|
try {
|
||||||
final nextWeekResponse = await client.getLessons(
|
await client.getLessons(nextWeekStart, nextWeekEnd);
|
||||||
nextWeekStart,
|
|
||||||
nextWeekEnd,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
nextWeekBreakEvents = <Lesson>[].where((lesson) {
|
nextWeekBreakEvents = <Lesson>[].where((lesson) {
|
||||||
@@ -995,10 +961,7 @@ class LiveActivityService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final candidateDayEnd = candidateDay.add(const Duration(days: 1));
|
final candidateDayEnd = candidateDay.add(const Duration(days: 1));
|
||||||
final response = await client.getLessons(
|
await client.getLessons(candidateDay, candidateDayEnd);
|
||||||
candidateDay,
|
|
||||||
candidateDayEnd,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
final schoolLessons = [].where((lesson) {
|
final schoolLessons = [].where((lesson) {
|
||||||
@@ -1173,33 +1136,17 @@ class LiveActivityService {
|
|||||||
List<Lesson> allLessons = [];
|
List<Lesson> allLessons = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final timetableResponse = await client.getLessons(
|
await client.getLessons(startOfWeek, endOfWeek);
|
||||||
startOfWeek,
|
|
||||||
endOfWeek,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
allLessons = List<Lesson>.from([]);
|
||||||
allLessons = List<Lesson>.from([]);
|
|
||||||
} else {
|
|
||||||
throw Exception('KRÉTA API returned null response');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
'checkAndUpdateTimetable: KRÉTA API failed ($e), falling back to cache',
|
'checkAndUpdateTimetable: KRÉTA API failed ($e), falling back to cache',
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
final cachedResponse = await client.getLessons(
|
await client.getLessons(startOfWeek, endOfWeek);
|
||||||
startOfWeek,
|
|
||||||
endOfWeek,
|
allLessons = <Lesson>[];
|
||||||
);
|
|
||||||
if (true) {
|
|
||||||
allLessons = <Lesson>[];
|
|
||||||
} else {
|
|
||||||
_logger.severe(
|
|
||||||
'checkAndUpdateTimetable: Both API and cache failed',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (cacheError) {
|
} catch (cacheError) {
|
||||||
_logger.severe(
|
_logger.severe(
|
||||||
'checkAndUpdateTimetable: Cache fallback also failed: $cacheError',
|
'checkAndUpdateTimetable: Cache fallback also failed: $cacheError',
|
||||||
@@ -1217,10 +1164,7 @@ class LiveActivityService {
|
|||||||
|
|
||||||
List<Lesson> nextWeekBreakEvents = [];
|
List<Lesson> nextWeekBreakEvents = [];
|
||||||
try {
|
try {
|
||||||
final nextWeekResponse = await client.getLessons(
|
await client.getLessons(nextWeekStart, nextWeekEnd);
|
||||||
nextWeekStart,
|
|
||||||
nextWeekEnd,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
nextWeekBreakEvents = <Lesson>[].where((lesson) {
|
nextWeekBreakEvents = <Lesson>[].where((lesson) {
|
||||||
@@ -1317,10 +1261,7 @@ class LiveActivityService {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final candidateDayEnd = candidateDay.add(const Duration(days: 1));
|
final candidateDayEnd = candidateDay.add(const Duration(days: 1));
|
||||||
final response = await client.getLessons(
|
await client.getLessons(candidateDay, candidateDayEnd);
|
||||||
candidateDay,
|
|
||||||
candidateDayEnd,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
final schoolLessons = [].where((lesson) {
|
final schoolLessons = [].where((lesson) {
|
||||||
@@ -1838,8 +1779,7 @@ class LiveActivityService {
|
|||||||
final settingsStore = initData.settings;
|
final settingsStore = initData.settings;
|
||||||
|
|
||||||
final studentResp = await client.getStudent();
|
final studentResp = await client.getStudent();
|
||||||
final studentName =
|
final studentName = studentResp.name;
|
||||||
studentResp.name ?? client.cache.token.username ?? 'Student';
|
|
||||||
|
|
||||||
await checkAndUpdateTimetable(
|
await checkAndUpdateTimetable(
|
||||||
client: client,
|
client: client,
|
||||||
@@ -1943,7 +1883,7 @@ class LiveActivityService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await client.getLessons(weekStart, weekEnd);
|
await client.getLessons(weekStart, weekEnd);
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
final breakEvents = [].where((lesson) {
|
final breakEvents = [].where((lesson) {
|
||||||
@@ -1971,13 +1911,13 @@ class LiveActivityService {
|
|||||||
breakEvents.sort((a, b) => a.start.compareTo(b.start));
|
breakEvents.sort((a, b) => a.start.compareTo(b.start));
|
||||||
lastBreakDay = breakEvents.last;
|
lastBreakDay = breakEvents.last;
|
||||||
_logger.info(
|
_logger.info(
|
||||||
'[GlobalBreakSearcher] Found ${breakEvents.length} break event(s) in week ${weeksSearched + 1}, last: ${lastBreakDay} on ${lastBreakDay}',
|
'[GlobalBreakSearcher] Found ${breakEvents.length} break event(s) in week ${weeksSearched + 1}, last: $lastBreakDay on $lastBreakDay',
|
||||||
);
|
);
|
||||||
} else if (schoolLessons.isNotEmpty) {
|
} else if (schoolLessons.isNotEmpty) {
|
||||||
schoolLessons.sort((a, b) => a.start.compareTo(b.start));
|
schoolLessons.sort((a, b) => a.start.compareTo(b.start));
|
||||||
firstSchoolDayAfterBreak = schoolLessons.first;
|
firstSchoolDayAfterBreak = schoolLessons.first;
|
||||||
_logger.info(
|
_logger.info(
|
||||||
'[GlobalBreakSearcher] Found first school day after break: ${firstSchoolDayAfterBreak} on ${firstSchoolDayAfterBreak}',
|
'[GlobalBreakSearcher] Found first school day after break: $firstSchoolDayAfterBreak on $firstSchoolDayAfterBreak',
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -1985,10 +1925,6 @@ class LiveActivityService {
|
|||||||
'[GlobalBreakSearcher] Week ${weeksSearched + 1} is empty, continuing search...',
|
'[GlobalBreakSearcher] Week ${weeksSearched + 1} is empty, continuing search...',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_logger.info(
|
|
||||||
'[GlobalBreakSearcher] Week ${weeksSearched + 1} returned no data, continuing search...',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final isTokenError =
|
final isTokenError =
|
||||||
@@ -2007,7 +1943,7 @@ class LiveActivityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final cachedResponse = await client.getLessons(weekStart, weekEnd);
|
await client.getLessons(weekStart, weekEnd);
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
final weekLessons = [];
|
final weekLessons = [];
|
||||||
@@ -2040,20 +1976,16 @@ class LiveActivityService {
|
|||||||
breakEvents.sort((a, b) => a.start.compareTo(b.start));
|
breakEvents.sort((a, b) => a.start.compareTo(b.start));
|
||||||
lastBreakDay = breakEvents.last;
|
lastBreakDay = breakEvents.last;
|
||||||
_logger.info(
|
_logger.info(
|
||||||
'[GlobalBreakSearcher] Found ${breakEvents.length} break event(s) in cached week ${weeksSearched + 1}, last: ${lastBreakDay} on ${lastBreakDay}',
|
'[GlobalBreakSearcher] Found ${breakEvents.length} break event(s) in cached week ${weeksSearched + 1}, last: $lastBreakDay on $lastBreakDay',
|
||||||
);
|
);
|
||||||
} else if (schoolLessons.isNotEmpty) {
|
} else if (schoolLessons.isNotEmpty) {
|
||||||
schoolLessons.sort((a, b) => a.start.compareTo(b.start));
|
schoolLessons.sort((a, b) => a.start.compareTo(b.start));
|
||||||
firstSchoolDayAfterBreak = schoolLessons.first;
|
firstSchoolDayAfterBreak = schoolLessons.first;
|
||||||
_logger.info(
|
_logger.info(
|
||||||
'[GlobalBreakSearcher] Found first school day after break in cache: ${firstSchoolDayAfterBreak} on ${firstSchoolDayAfterBreak}',
|
'[GlobalBreakSearcher] Found first school day after break in cache: $firstSchoolDayAfterBreak on $firstSchoolDayAfterBreak',
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_logger.info(
|
|
||||||
'[GlobalBreakSearcher] No cache available for week ${weeksSearched + 1}',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (cacheError) {
|
} catch (cacheError) {
|
||||||
_logger.warning(
|
_logger.warning(
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ class WatchSyncHelper {
|
|||||||
required TokenModel currentToken,
|
required TokenModel currentToken,
|
||||||
}) {
|
}) {
|
||||||
final currentExpiry = currentToken.expiryDate;
|
final currentExpiry = currentToken.expiryDate;
|
||||||
if (currentExpiry == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final incomingVersion =
|
final incomingVersion =
|
||||||
incomingTokenVersion ??
|
incomingTokenVersion ??
|
||||||
@@ -160,7 +157,6 @@ class WatchSyncHelper {
|
|||||||
|
|
||||||
final currentRefresh = currentToken.refreshToken;
|
final currentRefresh = currentToken.refreshToken;
|
||||||
if (incomingRefreshToken != null &&
|
if (incomingRefreshToken != null &&
|
||||||
currentRefresh != null &&
|
|
||||||
incomingRefreshToken != currentRefresh) {
|
incomingRefreshToken != currentRefresh) {
|
||||||
if (incomingIdToken != null && incomingIdToken != currentToken.idToken) {
|
if (incomingIdToken != null && incomingIdToken != currentToken.idToken) {
|
||||||
return true;
|
return true;
|
||||||
@@ -195,7 +191,7 @@ class WatchSyncHelper {
|
|||||||
'idToken': token.idToken,
|
'idToken': token.idToken,
|
||||||
'accessToken': token.accessToken,
|
'accessToken': token.accessToken,
|
||||||
'refreshToken': token.refreshToken,
|
'refreshToken': token.refreshToken,
|
||||||
'expiryDate': token.expiryDate!.millisecondsSinceEpoch,
|
'expiryDate': token.expiryDate.millisecondsSinceEpoch,
|
||||||
'tokenVersion': tokenVersion,
|
'tokenVersion': tokenVersion,
|
||||||
'updatedAtMs': updatedAtMs,
|
'updatedAtMs': updatedAtMs,
|
||||||
};
|
};
|
||||||
@@ -412,7 +408,7 @@ class WatchSyncHelper {
|
|||||||
await isar.tokenModels.clear();
|
await isar.tokenModels.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (initDone) initData.toastCubit?.clear();
|
if (initDone) initData.toastCubit.clear();
|
||||||
|
|
||||||
await prefs.setBool(_iosFreshInstallHandledKey, true);
|
await prefs.setBool(_iosFreshInstallHandledKey, true);
|
||||||
return true;
|
return true;
|
||||||
@@ -493,9 +489,9 @@ class WatchSyncHelper {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final token = initData.client!.cache.token;
|
final token = initData.client!.cache.token;
|
||||||
final expiryDate = token?.expiryDate;
|
final expiryDate = token.expiryDate;
|
||||||
if (expiryDate != null && expiryDate.isAfter(DateTime.now())) {
|
if (expiryDate.isAfter(DateTime.now())) {
|
||||||
if (initDone) initData.toastCubit?.clear();
|
if (initDone) initData.toastCubit.clear();
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[WatchSync] Cleared reauth flag after iCloud notification (token is valid)',
|
'[WatchSync] Cleared reauth flag after iCloud notification (token is valid)',
|
||||||
);
|
);
|
||||||
@@ -513,17 +509,6 @@ class WatchSyncHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final token = initData.client!.cache.token;
|
final token = initData.client!.cache.token;
|
||||||
if (token == null) {
|
|
||||||
debugPrint('[WatchSync] No active token available');
|
|
||||||
return {'error': 'no_token'};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token.accessToken == null ||
|
|
||||||
token.refreshToken == null ||
|
|
||||||
token.expiryDate == null) {
|
|
||||||
debugPrint('[WatchSync] Token incomplete');
|
|
||||||
return {'error': 'token_incomplete'};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initData.client!.needsReauth) {
|
if (initData.client!.needsReauth) {
|
||||||
debugPrint('[WatchSync] iPhone needs reauth');
|
debugPrint('[WatchSync] iPhone needs reauth');
|
||||||
@@ -699,12 +684,8 @@ class WatchSyncHelper {
|
|||||||
final watchIdToken = tokenData['idToken'] as String?;
|
final watchIdToken = tokenData['idToken'] as String?;
|
||||||
final watchRefreshToken = tokenData['refreshToken'] as String?;
|
final watchRefreshToken = tokenData['refreshToken'] as String?;
|
||||||
|
|
||||||
final isForActiveAccount =
|
final isForActiveAccount = watchStudentIdNorm == expectedStudentIdNorm;
|
||||||
expectedStudentIdNorm == null ||
|
if (isForActiveAccount && currentToken.key == watchStudentIdNorm) {
|
||||||
watchStudentIdNorm == expectedStudentIdNorm;
|
|
||||||
if (isForActiveAccount &&
|
|
||||||
currentToken != null &&
|
|
||||||
currentToken.key == watchStudentIdNorm) {
|
|
||||||
if (!_isIncomingTokenNewerThanCurrent(
|
if (!_isIncomingTokenNewerThanCurrent(
|
||||||
incomingExpiry: watchExpiryDate,
|
incomingExpiry: watchExpiryDate,
|
||||||
incomingIdToken: watchIdToken,
|
incomingIdToken: watchIdToken,
|
||||||
@@ -742,7 +723,7 @@ class WatchSyncHelper {
|
|||||||
|
|
||||||
if (isForActiveAccount) {
|
if (isForActiveAccount) {
|
||||||
initData.client!.cache.token = newToken;
|
initData.client!.cache.token = newToken;
|
||||||
if (initDone) initData.toastCubit?.clear();
|
if (initDone) initData.toastCubit.clear();
|
||||||
} else {
|
} else {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[WatchSync] Stored token for inactive account ($watchStudentIdNorm), active is $expectedStudentIdNorm',
|
'[WatchSync] Stored token for inactive account ($watchStudentIdNorm), active is $expectedStudentIdNorm',
|
||||||
@@ -768,13 +749,6 @@ class WatchSyncHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.accessToken == null ||
|
|
||||||
token.refreshToken == null ||
|
|
||||||
token.expiryDate == null) {
|
|
||||||
debugPrint('[WatchSync] Token incomplete, not sending to Watch');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final accessExpired = !_isAccessTokenUsable(
|
final accessExpired = !_isAccessTokenUsable(
|
||||||
token.expiryDate,
|
token.expiryDate,
|
||||||
skew: const Duration(),
|
skew: const Duration(),
|
||||||
@@ -870,8 +844,7 @@ class WatchSyncHelper {
|
|||||||
final expectedStudentIdNorm = initData.client!.cache.token.key;
|
final expectedStudentIdNorm = initData.client!.cache.token.key;
|
||||||
|
|
||||||
final iCloudStudentIdNorm = tokenData['studentIdNorm'] as int?;
|
final iCloudStudentIdNorm = tokenData['studentIdNorm'] as int?;
|
||||||
if (expectedStudentIdNorm != null &&
|
if (iCloudStudentIdNorm != expectedStudentIdNorm) {
|
||||||
iCloudStudentIdNorm != expectedStudentIdNorm) {
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[WatchSync] iCloud token belongs to different account ($iCloudStudentIdNorm), active is $expectedStudentIdNorm - ignoring',
|
'[WatchSync] iCloud token belongs to different account ($iCloudStudentIdNorm), active is $expectedStudentIdNorm - ignoring',
|
||||||
);
|
);
|
||||||
@@ -903,17 +876,15 @@ class WatchSyncHelper {
|
|||||||
final iCloudRefreshToken = tokenData['refreshToken'] as String?;
|
final iCloudRefreshToken = tokenData['refreshToken'] as String?;
|
||||||
|
|
||||||
final currentToken = initData.client!.cache.token;
|
final currentToken = initData.client!.cache.token;
|
||||||
final localExpiry = currentToken?.expiryDate;
|
final localExpiry = currentToken.expiryDate;
|
||||||
final shouldAccept = currentToken == null
|
final shouldAccept = _isIncomingTokenNewerThanCurrent(
|
||||||
? true
|
incomingExpiry: iCloudExpiryDate,
|
||||||
: _isIncomingTokenNewerThanCurrent(
|
incomingIdToken: iCloudIdToken,
|
||||||
incomingExpiry: iCloudExpiryDate,
|
incomingRefreshToken: iCloudRefreshToken,
|
||||||
incomingIdToken: iCloudIdToken,
|
incomingTokenVersion: iCloudTokenVersion,
|
||||||
incomingRefreshToken: iCloudRefreshToken,
|
incomingUpdatedAtMs: iCloudUpdatedAtMs,
|
||||||
incomingTokenVersion: iCloudTokenVersion,
|
currentToken: currentToken,
|
||||||
incomingUpdatedAtMs: iCloudUpdatedAtMs,
|
);
|
||||||
currentToken: currentToken,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (shouldAccept) {
|
if (shouldAccept) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
@@ -937,18 +908,14 @@ class WatchSyncHelper {
|
|||||||
await effectiveIsar.tokenModels.put(newToken);
|
await effectiveIsar.tokenModels.put(newToken);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (effectiveClient != null &&
|
if (effectiveClient != null && newToken.key == expectedStudentIdNorm) {
|
||||||
(expectedStudentIdNorm == null ||
|
|
||||||
newToken.key == expectedStudentIdNorm)) {
|
|
||||||
effectiveClient.cache.token = newToken;
|
effectiveClient.cache.token = newToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
final shouldClearReauth =
|
final shouldClearReauth =
|
||||||
!iCloudAccessExpired &&
|
!iCloudAccessExpired && newToken.key == expectedStudentIdNorm;
|
||||||
(expectedStudentIdNorm == null ||
|
|
||||||
newToken.key == expectedStudentIdNorm);
|
|
||||||
if (shouldClearReauth) {
|
if (shouldClearReauth) {
|
||||||
if (initDone) initData.toastCubit?.clear();
|
if (initDone) initData.toastCubit.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
@@ -974,13 +941,6 @@ class WatchSyncHelper {
|
|||||||
}) async {
|
}) async {
|
||||||
if (!Platform.isIOS) return;
|
if (!Platform.isIOS) return;
|
||||||
|
|
||||||
if (token.accessToken == null ||
|
|
||||||
token.refreshToken == null ||
|
|
||||||
token.expiryDate == null) {
|
|
||||||
debugPrint('[WatchSync] Token incomplete, not saving to iCloud');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final watchInstalled = await isWatchAppInstalled();
|
final watchInstalled = await isWatchAppInstalled();
|
||||||
if (!watchInstalled) {
|
if (!watchInstalled) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
@@ -1019,11 +979,7 @@ class WatchSyncHelper {
|
|||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
debugPrint('[WatchSync] No response from Watch');
|
debugPrint('[WatchSync] No response from Watch');
|
||||||
if (currentToken != null &&
|
if (!initData.client!.needsReauth) {
|
||||||
currentToken.accessToken != null &&
|
|
||||||
currentToken.refreshToken != null &&
|
|
||||||
currentToken.expiryDate != null &&
|
|
||||||
!initData.client!.needsReauth) {
|
|
||||||
debugPrint('[WatchSync] Sending iPhone token to Watch (no response)');
|
debugPrint('[WatchSync] Sending iPhone token to Watch (no response)');
|
||||||
await _sendTokenToWatchInternal(
|
await _sendTokenToWatchInternal(
|
||||||
currentToken,
|
currentToken,
|
||||||
@@ -1036,11 +992,7 @@ class WatchSyncHelper {
|
|||||||
final tokenData = result as Map<dynamic, dynamic>;
|
final tokenData = result as Map<dynamic, dynamic>;
|
||||||
if (tokenData.containsKey('error')) {
|
if (tokenData.containsKey('error')) {
|
||||||
debugPrint('[WatchSync] Watch returned error: ${tokenData['error']}');
|
debugPrint('[WatchSync] Watch returned error: ${tokenData['error']}');
|
||||||
if (currentToken != null &&
|
if (!initData.client!.needsReauth) {
|
||||||
currentToken.accessToken != null &&
|
|
||||||
currentToken.refreshToken != null &&
|
|
||||||
currentToken.expiryDate != null &&
|
|
||||||
!initData.client!.needsReauth) {
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[WatchSync] Sending iPhone token to Watch (Watch has no token)',
|
'[WatchSync] Sending iPhone token to Watch (Watch has no token)',
|
||||||
);
|
);
|
||||||
@@ -1064,16 +1016,11 @@ class WatchSyncHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expectedStudentIdNorm != null &&
|
if (watchStudentIdNorm != expectedStudentIdNorm) {
|
||||||
watchStudentIdNorm != expectedStudentIdNorm) {
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'[WatchSync] Watch token belongs to different account ($watchStudentIdNorm), active is $expectedStudentIdNorm - keeping active account',
|
'[WatchSync] Watch token belongs to different account ($watchStudentIdNorm), active is $expectedStudentIdNorm - keeping active account',
|
||||||
);
|
);
|
||||||
if (currentToken != null &&
|
if (!(initData.client!.needsReauth)) {
|
||||||
currentToken.accessToken != null &&
|
|
||||||
currentToken.refreshToken != null &&
|
|
||||||
currentToken.expiryDate != null &&
|
|
||||||
!(initData.client!.needsReauth)) {
|
|
||||||
await _sendTokenToWatchInternal(
|
await _sendTokenToWatchInternal(
|
||||||
currentToken,
|
currentToken,
|
||||||
allowExpiredAccessToken: true,
|
allowExpiredAccessToken: true,
|
||||||
@@ -1087,11 +1034,7 @@ class WatchSyncHelper {
|
|||||||
debugPrint(
|
debugPrint(
|
||||||
'[WatchSync] Watch provided expired token, ignoring and keeping iPhone token',
|
'[WatchSync] Watch provided expired token, ignoring and keeping iPhone token',
|
||||||
);
|
);
|
||||||
if (currentToken != null &&
|
if (_isAccessTokenUsable(
|
||||||
currentToken.accessToken != null &&
|
|
||||||
currentToken.refreshToken != null &&
|
|
||||||
currentToken.expiryDate != null &&
|
|
||||||
_isAccessTokenUsable(
|
|
||||||
currentToken.expiryDate,
|
currentToken.expiryDate,
|
||||||
skew: const Duration(),
|
skew: const Duration(),
|
||||||
) &&
|
) &&
|
||||||
@@ -1107,16 +1050,14 @@ class WatchSyncHelper {
|
|||||||
final watchUpdatedAtMs = _asInt(tokenData['updatedAtMs']);
|
final watchUpdatedAtMs = _asInt(tokenData['updatedAtMs']);
|
||||||
final watchIdToken = tokenData['idToken'] as String?;
|
final watchIdToken = tokenData['idToken'] as String?;
|
||||||
final watchRefreshToken = tokenData['refreshToken'] as String?;
|
final watchRefreshToken = tokenData['refreshToken'] as String?;
|
||||||
final shouldAccept = currentToken == null
|
final shouldAccept = _isIncomingTokenNewerThanCurrent(
|
||||||
? true
|
incomingExpiry: watchExpiryDate,
|
||||||
: _isIncomingTokenNewerThanCurrent(
|
incomingIdToken: watchIdToken,
|
||||||
incomingExpiry: watchExpiryDate,
|
incomingRefreshToken: watchRefreshToken,
|
||||||
incomingIdToken: watchIdToken,
|
incomingTokenVersion: watchTokenVersion,
|
||||||
incomingRefreshToken: watchRefreshToken,
|
incomingUpdatedAtMs: watchUpdatedAtMs,
|
||||||
incomingTokenVersion: watchTokenVersion,
|
currentToken: currentToken,
|
||||||
incomingUpdatedAtMs: watchUpdatedAtMs,
|
);
|
||||||
currentToken: currentToken,
|
|
||||||
);
|
|
||||||
if (shouldAccept) {
|
if (shouldAccept) {
|
||||||
debugPrint('[WatchSync] Watch has newer token, updating iPhone');
|
debugPrint('[WatchSync] Watch has newer token, updating iPhone');
|
||||||
final newToken = TokenModel.fromValues(
|
final newToken = TokenModel.fromValues(
|
||||||
@@ -1138,9 +1079,8 @@ class WatchSyncHelper {
|
|||||||
|
|
||||||
initData.client!.cache.token = newToken;
|
initData.client!.cache.token = newToken;
|
||||||
|
|
||||||
if (expectedStudentIdNorm == null ||
|
if (newToken.key == expectedStudentIdNorm) {
|
||||||
newToken.key == expectedStudentIdNorm) {
|
if (initDone) initData.toastCubit.clear();
|
||||||
if (initDone) initData.toastCubit?.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ import 'package:isar_community/isar.dart';
|
|||||||
import 'package:watch_connectivity/watch_connectivity.dart';
|
import 'package:watch_connectivity/watch_connectivity.dart';
|
||||||
|
|
||||||
import 'package:firka/api/client/kreta_client.dart';
|
import 'package:firka/api/client/kreta_client.dart';
|
||||||
import 'package:firka/core/bloc/toast_cubit.dart';
|
|
||||||
import 'package:firka_common/data/models/app_settings_model.dart';
|
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/homework_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
import 'package:firka_common/data/models/token_model.dart';
|
||||||
import 'package:firka/services/wear_sync_cache.dart';
|
import 'package:firka/services/wear_sync_cache.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ const String wearSyncCacheFileName = 'wear_sync_cache.json';
|
|||||||
/// Builds the sync payload (same shape as init_data / sync_data): timetable (2 weeks), grades, lastSyncAt.
|
/// Builds the sync payload (same shape as init_data / sync_data): timetable (2 weeks), grades, lastSyncAt.
|
||||||
Future<Map<String, dynamic>?> buildWearSyncPayload(KretaClient client) async {
|
Future<Map<String, dynamic>?> buildWearSyncPayload(KretaClient client) async {
|
||||||
final (start, end) = getWearSyncTimetableRange();
|
final (start, end) = getWearSyncTimetableRange();
|
||||||
final timetableResp = await client.getLessons(start, end);
|
await client.getLessons(start, end);
|
||||||
final gradesResp = await client.getGrades();
|
await client.getGrades();
|
||||||
final now = timeNow();
|
final now = timeNow();
|
||||||
final timetable = (<Lesson>[]).map((l) => l.toJson()).toList();
|
final timetable = (<Lesson>[]).map((l) => l.toJson()).toList();
|
||||||
final grades = (<Grade>[]).map((g) => g.toJson()).toList();
|
final grades = (<Grade>[]).map((g) => g.toJson()).toList();
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import 'package:firka_common/data/util.dart';
|
|||||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||||
import 'package:firka_common/ui/shared/grade_small_card.dart';
|
import 'package:firka_common/ui/shared/grade_small_card.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka_common/data/models/homework_cache_model.dart';
|
import 'package:firka_common/data/models/homework_cache_model.dart';
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
import 'package:firka/core/settings/settings_repository.dart';
|
||||||
@@ -30,7 +29,6 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:firka/ui/shared/class_icon.dart';
|
import 'package:firka/ui/shared/class_icon.dart';
|
||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
import 'package:firka_common/ui/components/firka_card.dart';
|
||||||
import 'package:firka_common/ui/components/grade.dart';
|
import 'package:firka_common/ui/components/grade.dart';
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
|
||||||
|
|
||||||
Future<void> showFirkaBottomSheet(
|
Future<void> showFirkaBottomSheet(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
@@ -726,7 +724,7 @@ class _GradeCalculatorSheetContentState
|
|||||||
min: 0,
|
min: 0,
|
||||||
max: (_snapPoints.length - 1).toDouble(),
|
max: (_snapPoints.length - 1).toDouble(),
|
||||||
divisions: _snapPoints.length - 1,
|
divisions: _snapPoints.length - 1,
|
||||||
label: '${weightPercent}%',
|
label: '$weightPercent%',
|
||||||
onChanged: (v) => setState(() => weightIndex = v.round()),
|
onChanged: (v) => setState(() => weightIndex = v.round()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -197,4 +197,4 @@ class _CopyButtonState extends State<_CopyButton> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import 'package:firka/core/bloc/theme_cubit.dart';
|
|||||||
import 'package:firka/core/settings.dart';
|
import 'package:firka/core/settings.dart';
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
import 'package:firka/core/settings/settings_repository.dart';
|
||||||
import 'package:firka/core/settings/settings_schema.dart';
|
import 'package:firka/core/settings/settings_schema.dart';
|
||||||
import 'package:firka_common/data/models/app_settings_model.dart';
|
|
||||||
import 'package:firka_common/ui/components/firka_shadow.dart';
|
import 'package:firka_common/ui/components/firka_shadow.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
import 'package:firka/ui/shared/firka_icon.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:firka/core/settings.dart';
|
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
import 'package:firka/ui/phone/widgets/login_webview.dart';
|
import 'package:firka/ui/phone/widgets/login_webview.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void showReauthBottomSheet(
|
void showReauthBottomSheet(
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class _WearPairSheetContentState extends State<_WearPairSheetContent> {
|
|||||||
'idToken': m.idToken,
|
'idToken': m.idToken,
|
||||||
'accessToken': m.accessToken,
|
'accessToken': m.accessToken,
|
||||||
'refreshToken': m.refreshToken,
|
'refreshToken': m.refreshToken,
|
||||||
'expiryDate': m.expiryDate!.millisecondsSinceEpoch,
|
'expiryDate': m.expiryDate.millisecondsSinceEpoch,
|
||||||
},
|
},
|
||||||
'lastSyncAt': widget.payload['lastSyncAt'],
|
'lastSyncAt': widget.payload['lastSyncAt'],
|
||||||
'timetable': widget.payload['timetable'],
|
'timetable': widget.payload['timetable'],
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
import 'dart:collection';
|
|
||||||
|
|
||||||
import 'package:firka/core/extensions.dart';
|
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
|
||||||
import 'package:firka_common/data/models/class_average_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
import 'package:firka_common/ui/components/firka_card.dart';
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
import 'package:firka_common/core/grade_helper.dart';
|
||||||
import 'package:firka/ui/phone/widgets/grade_chart.dart';
|
import 'package:firka/ui/phone/widgets/grade_chart.dart';
|
||||||
@@ -18,13 +10,10 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import 'package:firka/core/debug_helper.dart';
|
|
||||||
import 'package:firka/core/state/firka_state.dart';
|
import 'package:firka/core/state/firka_state.dart';
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/core/bloc/home_refresh_cubit.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/theme/style.dart';
|
||||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
|
||||||
|
|
||||||
class HomeGradesScreen extends StatefulWidget {
|
class HomeGradesScreen extends StatefulWidget {
|
||||||
final AppInitialization data;
|
final AppInitialization data;
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import 'package:firka/ui/phone/widgets/grade_summary_bar.dart';
|
import 'package:firka/ui/phone/widgets/grade_summary_bar.dart';
|
||||||
import 'package:firka/ui/phone/widgets/info_card.dart';
|
import 'package:firka/ui/phone/widgets/info_card.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/teacher_model.dart';
|
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:collection';
|
|
||||||
|
|
||||||
import 'package:carousel_slider/carousel_slider.dart';
|
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/homework_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/message_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/omission_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/student_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/test_cache_model.dart';
|
|
||||||
import 'package:firka/ui/phone/widgets/info_card.dart';
|
import 'package:firka/ui/phone/widgets/info_card.dart';
|
||||||
import 'package:firka/ui/phone/widgets/lesson.dart';
|
|
||||||
import 'package:firka/ui/phone/widgets/lesson_slider.dart';
|
import 'package:firka/ui/phone/widgets/lesson_slider.dart';
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart';
|
|
||||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
|
||||||
|
|
||||||
import 'package:firka/core/debug_helper.dart';
|
import 'package:firka/core/debug_helper.dart';
|
||||||
import 'package:firka/core/state/firka_state.dart';
|
import 'package:firka/core/state/firka_state.dart';
|
||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
|
||||||
import '../../widgets/home_main_welcome.dart';
|
import '../../widgets/home_main_welcome.dart';
|
||||||
import '../../widgets/lesson_big.dart';
|
|
||||||
|
|
||||||
class HomeMainScreen extends StatefulWidget {
|
class HomeMainScreen extends StatefulWidget {
|
||||||
final AppInitialization data;
|
final AppInitialization data;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
|||||||
tempTargetIndex = oldIndex < targetIndex ? oldIndex + 1 : oldIndex - 1;
|
tempTargetIndex = oldIndex < targetIndex ? oldIndex + 1 : oldIndex - 1;
|
||||||
|
|
||||||
// Create a new order where target day is next to current day
|
// Create a new order where target day is next to current day
|
||||||
List<DateTime> reorderedDates = List.from(_animationDates!);
|
List<DateTime> reorderedDates = List.from(_animationDates);
|
||||||
final targetDate = reorderedDates.removeAt(targetIndex);
|
final targetDate = reorderedDates.removeAt(targetIndex);
|
||||||
reorderedDates.insert(tempTargetIndex, targetDate);
|
reorderedDates.insert(tempTargetIndex, targetDate);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import 'package:firka/ui/phone/screens/settings/settings_screen.dart';
|
import 'package:firka/ui/phone/screens/settings/settings_screen.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/omission_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/test_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
@@ -9,11 +7,9 @@ import 'package:firka/core/debug_helper.dart';
|
|||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka/core/settings.dart';
|
import 'package:firka/core/settings.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
import 'package:transparent_pointer/transparent_pointer.dart';
|
import 'package:transparent_pointer/transparent_pointer.dart';
|
||||||
|
|
||||||
@@ -87,7 +83,7 @@ class _HomeTimetableMonthlyScreen
|
|||||||
// column-major -> row-major
|
// column-major -> row-major
|
||||||
for (var week = 0; week < 7; week++) {
|
for (var week = 0; week < 7; week++) {
|
||||||
for (var day = 0; day < 7; day++) {
|
for (var day = 0; day < 7; day++) {
|
||||||
final d = dates![week * 7 + day];
|
final d = dates[week * 7 + day];
|
||||||
|
|
||||||
bool outOfRange =
|
bool outOfRange =
|
||||||
d.isBefore(currentMonthStart) || d.isAfter(currentMonthEnd);
|
d.isBefore(currentMonthStart) || d.isAfter(currentMonthEnd);
|
||||||
@@ -339,12 +335,12 @@ class _HomeTimetableMonthlyScreen
|
|||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
now = DateTime(now!.year, now!.month - 1);
|
now = DateTime(now.year, now.month - 1);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
now!
|
now
|
||||||
.format(widget.data.l10n, FormatMode.yyyymmmm)
|
.format(widget.data.l10n, FormatMode.yyyymmmm)
|
||||||
.toLowerCase(),
|
.toLowerCase(),
|
||||||
style: appStyle.fonts.B_16R.apply(
|
style: appStyle.fonts.B_16R.apply(
|
||||||
@@ -360,7 +356,7 @@ class _HomeTimetableMonthlyScreen
|
|||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
now = DateTime(now!.year, now!.month + 1);
|
now = DateTime(now.year, now.month + 1);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:firka_common/data/models/class_average_cache_model.dart';
|
import 'package:firka_common/data/models/class_average_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/homework_cache_model.dart';
|
import 'package:firka_common/data/models/homework_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
@@ -23,7 +22,6 @@ import 'package:image_picker/image_picker.dart';
|
|||||||
import 'package:firka/core/debug_helper.dart';
|
import 'package:firka/core/debug_helper.dart';
|
||||||
import 'package:firka/core/state/firka_state.dart';
|
import 'package:firka/core/state/firka_state.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
import 'package:firka/ui/shared/firka_icon.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:home_widget/home_widget.dart';
|
import 'package:home_widget/home_widget.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:firka_common/data/models/app_settings_model.dart';
|
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
import 'package:firka/core/settings/settings_repository.dart';
|
||||||
import 'package:firka/core/settings/settings_schema.dart';
|
import 'package:firka/core/settings/settings_schema.dart';
|
||||||
import 'package:firka/ui/components/firka_button.dart';
|
import 'package:firka/ui/components/firka_button.dart';
|
||||||
|
|||||||
@@ -1,32 +1,23 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:firka/core/bloc/toast_cubit.dart';
|
import 'package:firka/core/bloc/toast_cubit.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka/core/extensions.dart';
|
|
||||||
import 'package:firka/core/firka_bundle.dart';
|
import 'package:firka/core/firka_bundle.dart';
|
||||||
import 'package:firka/services/live_activity_service.dart';
|
import 'package:firka/services/live_activity_service.dart';
|
||||||
import 'package:firka/core/settings.dart';
|
import 'package:firka/core/settings.dart';
|
||||||
import 'package:firka/core/settings/settings_repository.dart';
|
import 'package:firka/core/settings/settings_repository.dart';
|
||||||
import 'package:firka/core/settings/settings_schema.dart';
|
import 'package:firka/core/settings/settings_schema.dart';
|
||||||
import 'package:firka/services/watch_sync_helper.dart';
|
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
import 'package:firka/ui/phone/pages/extras/firka_toast.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:home_widget/home_widget.dart';
|
import 'package:home_widget/home_widget.dart';
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
|
||||||
|
|
||||||
import 'package:firka/core/debug_helper.dart';
|
|
||||||
import 'package:firka/core/bloc/profile_picture_cubit.dart';
|
import 'package:firka/core/bloc/profile_picture_cubit.dart';
|
||||||
import 'package:firka/core/bloc/settings_cubit.dart';
|
import 'package:firka/core/bloc/settings_cubit.dart';
|
||||||
import 'package:firka/core/state/firka_state.dart';
|
import 'package:firka/core/state/firka_state.dart';
|
||||||
import 'package:firka/core/image_preloader.dart';
|
import 'package:firka/core/image_preloader.dart';
|
||||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
import 'package:firka/ui/shared/delayed_spinner.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
|
||||||
import '../../pages/extras/main_error.dart';
|
|
||||||
|
|
||||||
bool _fetching = false;
|
bool _fetching = false;
|
||||||
bool _prefetched = false;
|
bool _prefetched = false;
|
||||||
@@ -44,7 +35,6 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
|||||||
with WidgetsBindingObserver {
|
with WidgetsBindingObserver {
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
bool _preloadDone = false;
|
bool _preloadDone = false;
|
||||||
bool _didRunSecondaryICloudRecovery = false;
|
|
||||||
bool _didRunLiveActivityLogin = false;
|
bool _didRunLiveActivityLogin = false;
|
||||||
bool _hasCompletedFirstPrefetch = false;
|
bool _hasCompletedFirstPrefetch = false;
|
||||||
|
|
||||||
@@ -130,7 +120,7 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
|||||||
if (!_didRunLiveActivityLogin) {
|
if (!_didRunLiveActivityLogin) {
|
||||||
_didRunLiveActivityLogin = true;
|
_didRunLiveActivityLogin = true;
|
||||||
final token = initData.client!.cache.token;
|
final token = initData.client!.cache.token;
|
||||||
final studentName = token?.username ?? "Student";
|
final studentName = token.username;
|
||||||
LiveActivityService.onUserLogin(
|
LiveActivityService.onUserLogin(
|
||||||
client: initData.client!,
|
client: initData.client!,
|
||||||
studentName: studentName,
|
studentName: studentName,
|
||||||
@@ -255,7 +245,6 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
|||||||
if (state == AppLifecycleState.resumed && !_disposed) {
|
if (state == AppLifecycleState.resumed && !_disposed) {
|
||||||
logger.info('[Home] App resumed to foreground, re-running prefetch');
|
logger.info('[Home] App resumed to foreground, re-running prefetch');
|
||||||
_prefetched = false;
|
_prefetched = false;
|
||||||
_didRunSecondaryICloudRecovery = false;
|
|
||||||
prefetch();
|
prefetch();
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
|
||||||
@@ -273,7 +262,7 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
|||||||
Future.delayed(const Duration(milliseconds: 500), () async {
|
Future.delayed(const Duration(milliseconds: 500), () async {
|
||||||
if (_disposed || _didRunLiveActivityLogin) return;
|
if (_disposed || _didRunLiveActivityLogin) return;
|
||||||
_didRunLiveActivityLogin = true;
|
_didRunLiveActivityLogin = true;
|
||||||
final studentName = initData.client!.cache.token.username ?? 'Student';
|
final studentName = initData.client!.cache.token.username;
|
||||||
LiveActivityService.onUserLogin(
|
LiveActivityService.onUserLogin(
|
||||||
client: initData.client!,
|
client: initData.client!,
|
||||||
studentName: studentName,
|
studentName: studentName,
|
||||||
@@ -288,7 +277,7 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
|||||||
void _refreshLiveActivityOnResume() async {
|
void _refreshLiveActivityOnResume() async {
|
||||||
if (!_hasCompletedFirstPrefetch) return;
|
if (!_hasCompletedFirstPrefetch) return;
|
||||||
try {
|
try {
|
||||||
final studentName = initData.client!.cache.token.username ?? "Student";
|
final studentName = initData.client!.cache.token.username;
|
||||||
await LiveActivityService.checkAndUpdateTimetable(
|
await LiveActivityService.checkAndUpdateTimetable(
|
||||||
client: initData.client!,
|
client: initData.client!,
|
||||||
studentName: studentName,
|
studentName: studentName,
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ import 'package:firka/core/image_preloader.dart';
|
|||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
import 'package:firka/ui/shared/delayed_spinner.dart';
|
||||||
|
|
||||||
const String _privacyUrlHungarian = 'https://firka.app/privacy-policy';
|
|
||||||
const String _privacyUrlOther = 'https://firka.app/privacy-policy';
|
|
||||||
|
|
||||||
class LoginScreen extends StatefulWidget {
|
class LoginScreen extends StatefulWidget {
|
||||||
final AppInitialization data;
|
final AppInitialization data;
|
||||||
const LoginScreen(this.data, {super.key});
|
const LoginScreen(this.data, {super.key});
|
||||||
@@ -44,7 +41,7 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _getPrivacyPolicyUrl() {
|
String _getPrivacyPolicyUrl() {
|
||||||
return "https://firka.app/privacy";
|
return "https://firka.app/privacy";
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showPrivacyPolicyWebview() async {
|
Future<void> _showPrivacyPolicyWebview() async {
|
||||||
@@ -58,10 +55,7 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.sizeOf(context).height,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
child: DomainBrowserWebviewWidget(
|
child: DomainBrowserWebviewWidget(data: widget.data, url: url),
|
||||||
data: widget.data,
|
|
||||||
url: url,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -295,7 +289,8 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
|||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 8),
|
horizontal: 8,
|
||||||
|
),
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (ctx, constraints) =>
|
builder: (ctx, constraints) =>
|
||||||
_FloatingCardsSlide(
|
_FloatingCardsSlide(
|
||||||
@@ -661,7 +656,7 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
|
|||||||
double _sceneWidth = 0;
|
double _sceneWidth = 0;
|
||||||
double _sceneHeight = 0;
|
double _sceneHeight = 0;
|
||||||
|
|
||||||
//we needed a cooldown, so that again, the phone doesn't turn into a bomb | EDIT: actually this was fixed by the minimum speed, so we don't need it anymore
|
//we needed a cooldown, so that again, the phone doesn't turn into a bomb | EDIT: actually this was fixed by the minimum speed, so we don't need it anymore
|
||||||
// DateTime? _lastVibration;
|
// DateTime? _lastVibration;
|
||||||
|
|
||||||
Offset _clampVel(Offset v) => Offset(
|
Offset _clampVel(Offset v) => Offset(
|
||||||
@@ -673,7 +668,7 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
|
|||||||
// final now = DateTime.now();
|
// final now = DateTime.now();
|
||||||
// if (_lastVibration != null &&
|
// if (_lastVibration != null &&
|
||||||
// now.difference(_lastVibration!).inMilliseconds < 2) //first used 50 but it wasn't good enough, so now it's 2
|
// now.difference(_lastVibration!).inMilliseconds < 2) //first used 50 but it wasn't good enough, so now it's 2
|
||||||
// return;
|
// return;
|
||||||
// _lastVibration = now;
|
// _lastVibration = now;
|
||||||
Vibration.vibrate(duration: 20);
|
Vibration.vibrate(duration: 20);
|
||||||
}
|
}
|
||||||
@@ -896,7 +891,7 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
|
|||||||
child: Stack(
|
child: Stack(
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
children: [
|
children: [
|
||||||
//background rectangle
|
//background rectangle
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
@@ -904,7 +899,7 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: appStyle.colors.buttonSecondaryFill, //button color xdddd
|
color: appStyle.colors.buttonSecondaryFill, //button color xdddd
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: Radius.circular(32),
|
topLeft: Radius.circular(32),
|
||||||
topRight: Radius.circular(32),
|
topRight: Radius.circular(32),
|
||||||
@@ -952,7 +947,7 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withOpacity(0.55),
|
color: Colors.black.withValues(alpha: 0.55),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
width: math.min(260, _sceneWidth - 24),
|
width: math.min(260, _sceneWidth - 24),
|
||||||
@@ -973,10 +968,14 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
|
|||||||
'accel: (${accel.x.toStringAsFixed(2)}, ${accel.y.toStringAsFixed(2)}, ${accel.z.toStringAsFixed(2)})',
|
'accel: (${accel.x.toStringAsFixed(2)}, ${accel.y.toStringAsFixed(2)}, ${accel.z.toStringAsFixed(2)})',
|
||||||
),
|
),
|
||||||
Text('baseline set: ${_baseline != null}'),
|
Text('baseline set: ${_baseline != null}'),
|
||||||
Text('scene: ${_sceneWidth.toStringAsFixed(0)} x ${_sceneHeight.toStringAsFixed(0)}'),
|
Text(
|
||||||
|
'scene: ${_sceneWidth.toStringAsFixed(0)} x ${_sceneHeight.toStringAsFixed(0)}',
|
||||||
|
),
|
||||||
Text('center: ${formatOffset(center)}'),
|
Text('center: ${formatOffset(center)}'),
|
||||||
Text('card[0] pos: ${formatOffset(firstPos)}'),
|
Text('card[0] pos: ${formatOffset(firstPos)}'),
|
||||||
Text('card[0] vel: ${formatOffset(firstVel)} | |v|=${speed.toStringAsFixed(2)}'),
|
Text(
|
||||||
|
'card[0] vel: ${formatOffset(firstVel)} | |v|=${speed.toStringAsFixed(2)}',
|
||||||
|
),
|
||||||
Text('cards: ${_cards.length}'),
|
Text('cards: ${_cards.length}'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class SettingsAccountPickerView extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _accountRow(BuildContext context, TokenModel token) {
|
Widget _accountRow(BuildContext context, TokenModel token) {
|
||||||
final jwt = JWT.decode(token.idToken!);
|
final jwt = JWT.decode(token.idToken);
|
||||||
final payload = jwt.payload as Map<String, dynamic>;
|
final payload = jwt.payload as Map<String, dynamic>;
|
||||||
String studentRole = payload["role"];
|
String studentRole = payload["role"];
|
||||||
if (studentRole == "Tanulo") {
|
if (studentRole == "Tanulo") {
|
||||||
@@ -150,14 +150,12 @@ class SettingsAccountPickerView extends StatelessWidget {
|
|||||||
'[Settings] Failed to clear shared language state on account switch: $e',
|
'[Settings] Failed to clear shared language state on account switch: $e',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (previousAccountId != null) {
|
try {
|
||||||
try {
|
await WatchSyncHelper.clearRefreshLeaseForAccount(previousAccountId);
|
||||||
await WatchSyncHelper.clearRefreshLeaseForAccount(previousAccountId);
|
} catch (e) {
|
||||||
} catch (e) {
|
logger.warning(
|
||||||
logger.warning(
|
'[Settings] Failed to clear refresh lease on account switch: $e',
|
||||||
'[Settings] Failed to clear refresh lease on account switch: $e',
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka/l10n/app_localizations.dart';
|
import 'package:firka/l10n/app_localizations.dart';
|
||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
|
|||||||
@@ -18,11 +18,7 @@ class DomainBrowserWebviewWidget extends StatefulWidget {
|
|||||||
final AppInitialization? data;
|
final AppInitialization? data;
|
||||||
final String? url;
|
final String? url;
|
||||||
|
|
||||||
const DomainBrowserWebviewWidget({
|
const DomainBrowserWebviewWidget({super.key, this.data, this.url});
|
||||||
super.key,
|
|
||||||
this.data,
|
|
||||||
this.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DomainBrowserWebviewWidget> createState() =>
|
State<DomainBrowserWebviewWidget> createState() =>
|
||||||
@@ -51,8 +47,10 @@ class _DomainBrowserWebviewWidgetState
|
|||||||
end: 0.0,
|
end: 0.0,
|
||||||
).animate(_fadeAnimationController!);
|
).animate(_fadeAnimationController!);
|
||||||
|
|
||||||
assert(widget.data != null && widget.url != null,
|
assert(
|
||||||
'DomainBrowserWebviewWidget requires non-null data and url');
|
widget.data != null && widget.url != null,
|
||||||
|
'DomainBrowserWebviewWidget requires non-null data and url',
|
||||||
|
);
|
||||||
|
|
||||||
_webViewController = WebViewController()
|
_webViewController = WebViewController()
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
@@ -93,10 +91,12 @@ class _DomainBrowserWebviewWidgetState
|
|||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
final data = widget.data!;
|
|
||||||
final mediaQuery = MediaQuery.of(context);
|
final mediaQuery = MediaQuery.of(context);
|
||||||
final safePadding = mediaQuery.padding;
|
final safePadding = mediaQuery.padding;
|
||||||
final displayUrl = (widget.url ?? '').replaceFirst(RegExp(r'^https?://'), '');
|
final displayUrl = (widget.url ?? '').replaceFirst(
|
||||||
|
RegExp(r'^https?://'),
|
||||||
|
'',
|
||||||
|
);
|
||||||
final displayParts = displayUrl.split('/');
|
final displayParts = displayUrl.split('/');
|
||||||
final host = displayParts.isNotEmpty ? displayParts.first : displayUrl;
|
final host = displayParts.isNotEmpty ? displayParts.first : displayUrl;
|
||||||
final path = displayParts.length > 1
|
final path = displayParts.length > 1
|
||||||
@@ -158,7 +158,7 @@ class _DomainBrowserWebviewWidgetState
|
|||||||
color: appStyle.colors.accent,
|
color: appStyle.colors.accent,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -186,8 +186,8 @@ class _DomainBrowserWebviewWidgetState
|
|||||||
opacity: _isLoading
|
opacity: _isLoading
|
||||||
? 1.0
|
? 1.0
|
||||||
: _fadeAnimationController!.isAnimating
|
: _fadeAnimationController!.isAnimating
|
||||||
? _fadeAnimation!.value
|
? _fadeAnimation!.value
|
||||||
: 0.0,
|
: 0.0,
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: appStyle.colors.background,
|
color: appStyle.colors.background,
|
||||||
@@ -232,7 +232,8 @@ class _DomainBrowserWebviewWidgetState
|
|||||||
text: path,
|
text: path,
|
||||||
style: appStyle.fonts.B_14R.copyWith(
|
style: appStyle.fonts.B_14R.copyWith(
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
color: appStyle.colors.textTeritary ??
|
color:
|
||||||
|
appStyle.colors.textTeritary ??
|
||||||
appStyle.colors.textSecondary,
|
appStyle.colors.textSecondary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
import 'package:firka_common/ui/components/firka_card.dart';
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
import 'package:firka_common/core/grade_helper.dart';
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka_common/ui/components/grade.dart';
|
import 'package:firka_common/ui/components/grade.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
import 'package:firka/ui/shared/firka_icon.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:firka/ui/shared/firka_icon.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka/ui/theme/style.dart';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
|
|
||||||
class WelcomeWidget extends StatefulWidget {
|
class WelcomeWidget extends StatefulWidget {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
import 'package:firka_common/core/grade_helper.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/homework_cache_model.dart';
|
import 'package:firka_common/data/models/homework_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/message_cache_model.dart';
|
import 'package:firka_common/data/models/message_cache_model.dart';
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
||||||
import 'package:firka/ui/shared/class_icon.dart';
|
import 'package:firka/ui/shared/class_icon.dart';
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
import 'package:firka/ui/shared/firka_icon.dart';
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:firka/core/debug_helper.dart';
|
import 'package:firka/core/debug_helper.dart';
|
||||||
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
||||||
import 'package:firka/ui/shared/class_icon.dart';
|
import 'package:firka/ui/shared/class_icon.dart';
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import 'package:firka_common/ui/components/firka_card.dart';
|
|||||||
import 'package:firka_common/ui/theme/style.dart';
|
import 'package:firka_common/ui/theme/style.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||||
|
|
||||||
class _LessonSliderState extends State<LessonSlider> {
|
class _LessonSliderState extends State<LessonSlider> {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:firka_common/core/consts.dart';
|
import 'package:firka_common/core/consts.dart';
|
||||||
import 'package:firka/services/live_activity_service.dart';
|
|
||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/app/initialization.dart';
|
import 'package:firka/app/initialization.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firka/app/app_state.dart';
|
import 'package:firka/app/app_state.dart';
|
||||||
import 'package:firka/core/extensions.dart';
|
import 'package:firka/core/extensions.dart';
|
||||||
import 'package:firka_common/core/debug_helper.dart';
|
import 'package:firka_common/core/debug_helper.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
import 'package:firka_common/ui/components/firka_card.dart';
|
||||||
import 'package:firka_common/data/models/omission_cache_model.dart';
|
import 'package:firka_common/data/models/omission_cache_model.dart';
|
||||||
@@ -9,13 +8,8 @@ import 'package:firka_common/data/util.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
import 'package:firka_common/ui/components/grade.dart';
|
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
|
||||||
import 'package:firka/ui/shared/firka_icon.dart';
|
|
||||||
import 'package:flutter/material.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';
|
import 'package:firka/ui/theme/style.dart';
|
||||||
|
|
||||||
class OmissionBar extends StatelessWidget {
|
class OmissionBar extends StatelessWidget {
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ void main() async {
|
|||||||
|
|
||||||
if (_iconsOutOfDate(root)) {
|
if (_iconsOutOfDate(root)) {
|
||||||
final inputs = _iconsInputs(root);
|
final inputs = _iconsInputs(root);
|
||||||
final manifestFile = File(p.join(root, 'android/app/src/main/AndroidManifest.xml'));
|
final manifestFile = File(
|
||||||
|
p.join(root, 'android/app/src/main/AndroidManifest.xml'),
|
||||||
|
);
|
||||||
String? manifestBackup;
|
String? manifestBackup;
|
||||||
if (manifestFile.existsSync()) {
|
if (manifestFile.existsSync()) {
|
||||||
manifestBackup = manifestFile.readAsStringSync();
|
manifestBackup = manifestFile.readAsStringSync();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firka_common/data/database.dart';
|
import 'package:firka_common/data/database.dart';
|
||||||
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
import 'package:firka_common/data/models/class_group_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
|
|
||||||
part 'teacher_model.g.dart';
|
part 'teacher_model.g.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/util.dart';
|
import 'package:firka_common/data/util.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
|
||||||
import 'package:firka_common/data/models/student_cache_model.dart';
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import 'dart:math';
|
|||||||
import 'package:firka_common/data/cache_manager.dart';
|
import 'package:firka_common/data/cache_manager.dart';
|
||||||
import 'package:firka_common/data/database.dart';
|
import 'package:firka_common/data/database.dart';
|
||||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||||
import 'package:firka_common/data/models/token_model.dart';
|
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
|||||||
@@ -50,9 +50,7 @@ class FirkaCard extends StatelessWidget {
|
|||||||
height: height,
|
height: height,
|
||||||
shadow: shadow,
|
shadow: shadow,
|
||||||
isLightMode: isLightMode,
|
isLightMode: isLightMode,
|
||||||
child: extra == null
|
child: extra == null ? alignedRow : Column(children: [alignedRow, extra]),
|
||||||
? alignedRow
|
|
||||||
: Column(children: [alignedRow, extra!]),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:firka_common/core/grade_helper.dart';
|
import 'package:firka_common/core/grade_helper.dart';
|
||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
|
|
||||||
import 'package:firka_common/ui/theme/style.dart';
|
import 'package:firka_common/ui/theme/style.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:firka_common/core/icon_helper.dart';
|
import 'package:firka_common/core/icon_helper.dart';
|
||||||
import 'package:firka_common/ui/shared/firka_icon.dart';
|
import 'package:firka_common/ui/shared/firka_icon.dart';
|
||||||
|
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
|
|
||||||
class ClassIconWidget extends StatelessWidget {
|
class ClassIconWidget extends StatelessWidget {
|
||||||
final SubjectCacheModel subject;
|
final SubjectCacheModel subject;
|
||||||
final Color color;
|
final Color color;
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:firka_common/ui/theme/style.dart';
|
import 'package:firka_common/ui/theme/style.dart';
|
||||||
|
|
||||||
import '../../firka_common.dart';
|
|
||||||
|
|
||||||
class CounterDigitWidget extends StatelessWidget {
|
class CounterDigitWidget extends StatelessWidget {
|
||||||
final String c;
|
final String c;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
|
||||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
|
||||||
|
|
||||||
import 'package:firka_common/ui/components/firka_card.dart';
|
import 'package:firka_common/ui/components/firka_card.dart';
|
||||||
import 'package:firka_common/core/grade_helper.dart';
|
import 'package:firka_common/core/grade_helper.dart';
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ class SettingsSchemaBuilder implements Builder {
|
|||||||
.whereType<ClassDeclaration>()
|
.whereType<ClassDeclaration>()
|
||||||
.firstWhere((c) => c.name.lexeme == "SettingsSchema");
|
.firstWhere((c) => c.name.lexeme == "SettingsSchema");
|
||||||
|
|
||||||
final entries = <(String name, String dartType, String annotationClass, String args)>[];
|
final entries =
|
||||||
|
<(String name, String dartType, String annotationClass, String args)>[];
|
||||||
for (final member in schemaClass.members) {
|
for (final member in schemaClass.members) {
|
||||||
if (member is! MethodDeclaration || !member.isGetter) continue;
|
if (member is! MethodDeclaration || !member.isGetter) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_arc_text/flutter_arc_text.dart';
|
import 'package:flutter_arc_text/flutter_arc_text.dart';
|
||||||
@@ -336,10 +337,8 @@ class _WearHomeScreenState extends State<WearHomeScreen> {
|
|||||||
child: ClassIconWidget(
|
child: ClassIconWidget(
|
||||||
color: wearStyle.colors.accent,
|
color: wearStyle.colors.accent,
|
||||||
size: 16,
|
size: 16,
|
||||||
uid: currentLesson.uid,
|
subject: SubjectCacheModel()..name = currentLesson.name,
|
||||||
className: currentLesson.name,
|
),
|
||||||
category: currentLesson.subject?.name ?? '',
|
|
||||||
).build(context),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Center(
|
Center(
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:kreta_api/kreta_api.dart';
|
import 'package:kreta_api/kreta_api.dart';
|
||||||
|
|
||||||
@@ -58,9 +59,7 @@ class LessonCardSmall extends StatelessWidget {
|
|||||||
height: 24,
|
height: 24,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: ClassIconWidget(
|
child: ClassIconWidget(
|
||||||
uid: uid,
|
subject: SubjectCacheModel()..name = subjectName,
|
||||||
className: subjectName,
|
|
||||||
category: category,
|
|
||||||
color: iconColor ?? wearStyle.colors.accent,
|
color: iconColor ?? wearStyle.colors.accent,
|
||||||
size: 16,
|
size: 16,
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user