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