diff --git a/firka/lib/app/initialization_screen.dart b/firka/lib/app/initialization_screen.dart index 2407a26c..7fd8b1ec 100644 --- a/firka/lib/app/initialization_screen.dart +++ b/firka/lib/app/initialization_screen.dart @@ -15,7 +15,7 @@ import 'package:firka/core/bloc/settings_cubit.dart'; import 'package:firka/core/bloc/theme_cubit.dart'; import 'package:firka/core/firka_bundle.dart'; import 'package:firka/routing/app_router.dart'; -import 'package:firka/services/watch_sync_helper.dart'; +import 'package:firka/services/wear_sync_helper.dart'; import 'package:firka/ui/theme/style.dart'; import 'package:firka/ui/phone/pages/extras/main_wear_pair.dart'; import 'package:firka/l10n/app_localizations.dart'; diff --git a/firka/lib/core/settings/settings_effects.dart b/firka/lib/core/settings/settings_effects.dart index cdc791d5..6fc9b70f 100644 --- a/firka/lib/core/settings/settings_effects.dart +++ b/firka/lib/core/settings/settings_effects.dart @@ -7,7 +7,7 @@ import "package:firka/app/initialization.dart"; import "package:firka/services/fcm_service.dart"; import "package:firka/services/notification_delivery_service.dart"; import "package:firka/services/progress_notification_service.dart"; -import "package:firka/services/watch_sync_helper.dart"; +import "package:firka/services/wear_sync_helper.dart"; import "package:firka/ui/phone/screens/themes/builtin_theme_id.dart"; import "package:firka_common/ui/theme/core_theme.dart"; diff --git a/firka/lib/l10n b/firka/lib/l10n index e01d6c09..4756fdfd 160000 --- a/firka/lib/l10n +++ b/firka/lib/l10n @@ -1 +1 @@ -Subproject commit e01d6c090dd3b4928c0eb609111fb3f11e3e4bf8 +Subproject commit 4756fdfddcf423f3d45f2edc73cc0e0fd619fbd4 diff --git a/firka/lib/services/watch_sync_helper.dart b/firka/lib/services/watch_sync_helper.dart deleted file mode 100644 index fde6ee26..00000000 --- a/firka/lib/services/watch_sync_helper.dart +++ /dev/null @@ -1,114 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; - -import 'package:flutter/services.dart'; -import 'package:watch_connectivity/watch_connectivity.dart'; - -import 'package:firka/app/app_state.dart'; -import 'package:firka/services/wear_sync_cache.dart'; -import 'package:firka/api/client/kreta_client.dart'; - -/// Helper class for Wear OS sync (Android). -class WatchSyncHelper { - static const _wearSyncChannel = MethodChannel('app.firka/wear_sync'); - static WatchConnectivity? _androidWatchConnectivity; - static WatchConnectivity get _watchConnectivityAndroid { - _androidWatchConnectivity ??= WatchConnectivity(); - return _androidWatchConnectivity!; - } - - /// Callback for Watch pairing message events (Android Wear OS pairing flow). - /// Set by initialization_screen.dart to handle "ping" messages for Watch pairing. - static void Function(Map message)? onWatchMessage; - - /// Send a fire-and-forget message to Watch via watch_connectivity (Android). - /// The payload is sent as a JSON string for reliable transport. - static Future sendMessageToWatch(Map message) async { - if (!Platform.isAndroid) return; - await _watchConnectivityAndroid.sendMessage({ - 'data': jsonEncode(message), - }); - } - - /// Starts the Wear sync foreground service (Android only). Call after writing initial cache. - /// [appDirPath] is the application documents directory path (for the background isolate). - static Future startWearSyncService( - String cachePath, - String appDirPath, - ) async { - if (!Platform.isAndroid) return; - await _wearSyncChannel.invokeMethod( - 'startWearSyncService', - {'cachePath': cachePath, 'appDirPath': appDirPath}, - ); - } - - /// Builds fresh sync payload, writes cache, and starts the Wear sync service (Android only). - /// Use when enabling Wear OS support or on app launch when support is already enabled. - static Future startWearSyncServiceWithFreshCache( - KretaClient client, - String appDirPath, - ) async { - if (!Platform.isAndroid) return; - final payload = await buildWearSyncPayload(client); - if (payload == null) return; - final path = await getWearSyncCachePath(); - await writeWearSyncCache(path, payload); - await startWearSyncService(path, appDirPath); - } - - /// Sets the method call handler for getLocalizedString (Android). Call once when initData is ready. - static void setWearSyncMethodCallHandler() { - if (!Platform.isAndroid) return; - _wearSyncChannel.setMethodCallHandler((MethodCall call) async { - if (call.method == 'getLocalizedString') { - final key = call.arguments as String?; - return getLocalizedString(key); - } - return null; - }); - } - - /// Returns the localized string for [key] from l10n. Used by Kotlin for notification title/text. - static String? getLocalizedString(String? key) { - if (key == null || !initDone) return null; - switch (key) { - case 'wearSyncNotificationTitle': - return initData.l10n.wearSyncNotificationTitle; - case 'wearSyncNotificationText': - return initData.l10n.wearSyncNotificationText; - default: - return null; - } - } - - /// Stops the Wear sync foreground service (Android only). - static Future stopWearSyncService() async { - if (!Platform.isAndroid) return; - await _wearSyncChannel.invokeMethod('stopWearSyncService'); - } - - /// Runs sync in foreground: fetches timetable + grades, writes cache, sends sync_data to watch. - /// Used when app is in foreground and watch sends request_sync (Android) or equivalent. - static Future runWearSyncInForeground(KretaClient client) async { - final payload = await buildWearSyncPayload(client); - if (payload == null) return; - final path = await getWearSyncCachePath(); - await writeWearSyncCache(path, payload); - await sendMessageToWatch({'id': 'sync_data', ...payload}); - } - - /// Stream of messages from the watch (Android: watch_connectivity). Use for request_sync etc. - static Stream> get watchMessageStream { - if (!Platform.isAndroid) return const Stream.empty(); - return _watchConnectivityAndroid.messageStream.map((m) { - final map = Map.from(m); - final data = map['data']; - if (data is String) { - return jsonDecode(data) as Map; - } - return map; - }); - } -} diff --git a/firka/lib/services/wear_sync_cache.dart b/firka/lib/services/wear_sync_cache.dart index bcdc5aa2..2ea7ddca 100644 --- a/firka/lib/services/wear_sync_cache.dart +++ b/firka/lib/services/wear_sync_cache.dart @@ -5,7 +5,6 @@ import 'package:path_provider/path_provider.dart' show getApplicationDocumentsDirectory; import 'package:firka/api/client/kreta_client.dart'; -import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; /// File name for the Wear OS sync cache written by the phone (Dart isolate or main). @@ -28,15 +27,15 @@ const String wearSyncCacheFileName = 'wear_sync_cache.json'; /// Builds the sync payload (same shape as init_data / sync_data): timetable (2 weeks), grades, lastSyncAt. Future?> buildWearSyncPayload(KretaClient client) async { final (start, end) = getWearSyncTimetableRange(); - await client.getLessons(start, end); - await client.getGrades(); + final lessons = await client.getLessons(start, end); + final grades = await client.getGrades(); final now = timeNow(); - final timetable = ([]).map((l) => l.toJson()).toList(); - final grades = ([]).map((g) => g.toJson()).toList(); + final timetable = lessons.map((l) => l.toJson()).toList(); + final gradesJson = grades.map((g) => g.toJson()).toList(); return { 'lastSyncAt': now.toUtc().toIso8601String(), 'timetable': timetable, - 'grades': grades, + 'grades': gradesJson, }; } diff --git a/firka/lib/services/wear_sync_helper.dart b/firka/lib/services/wear_sync_helper.dart index b8580535..fde6ee26 100644 --- a/firka/lib/services/wear_sync_helper.dart +++ b/firka/lib/services/wear_sync_helper.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -5,30 +6,33 @@ import 'package:flutter/services.dart'; import 'package:watch_connectivity/watch_connectivity.dart'; import 'package:firka/app/app_state.dart'; -import 'package:firka/api/client/kreta_client.dart'; import 'package:firka/services/wear_sync_cache.dart'; +import 'package:firka/api/client/kreta_client.dart'; -/// Helper for Wear OS ↔ phone communication (Android only). -/// Handles sync service, watch_connectivity messages, and sending data to the watch. -class WearSyncHelper { - WearSyncHelper._(); - +/// Helper class for Wear OS sync (Android). +class WatchSyncHelper { static const _wearSyncChannel = MethodChannel('app.firka/wear_sync'); - static WatchConnectivity? _watchConnectivity; - static WatchConnectivity get _watchConnectivityInstance { - _watchConnectivity ??= WatchConnectivity(); - return _watchConnectivity!; + static WatchConnectivity? _androidWatchConnectivity; + static WatchConnectivity get _watchConnectivityAndroid { + _androidWatchConnectivity ??= WatchConnectivity(); + return _androidWatchConnectivity!; } - /// Sends a fire-and-forget message to the Wear OS watch (payload sent as JSON string). + /// Callback for Watch pairing message events (Android Wear OS pairing flow). + /// Set by initialization_screen.dart to handle "ping" messages for Watch pairing. + static void Function(Map message)? onWatchMessage; + + /// Send a fire-and-forget message to Watch via watch_connectivity (Android). + /// The payload is sent as a JSON string for reliable transport. static Future sendMessageToWatch(Map message) async { if (!Platform.isAndroid) return; - await _watchConnectivityInstance.sendMessage({ + await _watchConnectivityAndroid.sendMessage({ 'data': jsonEncode(message), }); } - /// Starts the Wear sync foreground service (Android only). + /// Starts the Wear sync foreground service (Android only). Call after writing initial cache. + /// [appDirPath] is the application documents directory path (for the background isolate). static Future startWearSyncService( String cachePath, String appDirPath, @@ -41,6 +45,7 @@ class WearSyncHelper { } /// Builds fresh sync payload, writes cache, and starts the Wear sync service (Android only). + /// Use when enabling Wear OS support or on app launch when support is already enabled. static Future startWearSyncServiceWithFreshCache( KretaClient client, String appDirPath, @@ -85,8 +90,8 @@ class WearSyncHelper { } /// Runs sync in foreground: fetches timetable + grades, writes cache, sends sync_data to watch. + /// Used when app is in foreground and watch sends request_sync (Android) or equivalent. static Future runWearSyncInForeground(KretaClient client) async { - if (!Platform.isAndroid) return; final payload = await buildWearSyncPayload(client); if (payload == null) return; final path = await getWearSyncCachePath(); @@ -94,10 +99,10 @@ class WearSyncHelper { await sendMessageToWatch({'id': 'sync_data', ...payload}); } - /// Stream of messages from the Wear OS watch. Empty when not on Android. + /// Stream of messages from the watch (Android: watch_connectivity). Use for request_sync etc. static Stream> get watchMessageStream { if (!Platform.isAndroid) return const Stream.empty(); - return _watchConnectivityInstance.messageStream.map((m) { + return _watchConnectivityAndroid.messageStream.map((m) { final map = Map.from(m); final data = map['data']; if (data is String) { diff --git a/firka/lib/ui/phone/pages/extras/main_wear_pair.dart b/firka/lib/ui/phone/pages/extras/main_wear_pair.dart index fbd12251..fe98521b 100644 --- a/firka/lib/ui/phone/pages/extras/main_wear_pair.dart +++ b/firka/lib/ui/phone/pages/extras/main_wear_pair.dart @@ -1,5 +1,5 @@ import 'package:firka/app/app_state.dart'; -import 'package:firka/services/watch_sync_helper.dart'; +import 'package:firka/services/wear_sync_helper.dart'; import 'package:firka/services/wear_sync_cache.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; diff --git a/firka_common/lib/data/models/grade_cache_model.dart b/firka_common/lib/data/models/grade_cache_model.dart index 1b66c065..68394c7a 100644 --- a/firka_common/lib/data/models/grade_cache_model.dart +++ b/firka_common/lib/data/models/grade_cache_model.dart @@ -10,6 +10,8 @@ part 'grade_cache_model.g.dart'; @collection class GradeCacheModel extends GenericCacheModel { + GradeCacheModel(); + String? mode; String? topic; late String type; @@ -49,4 +51,32 @@ class GradeCacheModel extends GenericCacheModel { }); } } + + /// Plain-field JSON representation (no Isar links) for cross-process sync, e.g. Wear OS. + Map toJson() { + return { + 'mode': mode, + 'topic': topic, + 'type': type, + 'valueType': valueType, + 'writtenAt': writtenAt.toIso8601String(), + 'numericValue': numericValue, + 'weightPercentage': weightPercentage, + 'textValue': textValue, + 'teacherName': teacherName, + }; + } + + factory GradeCacheModel.fromJson(Map json) { + return GradeCacheModel() + ..mode = json['mode'] as String? + ..topic = json['topic'] as String? + ..type = json['type'] as String + ..valueType = json['valueType'] as String + ..writtenAt = DateTime.parse(json['writtenAt'] as String) + ..numericValue = json['numericValue'] as int? + ..weightPercentage = json['weightPercentage'] as int? + ..textValue = json['textValue'] as String + ..teacherName = json['teacherName'] as String; + } } diff --git a/firka_common/lib/data/models/lesson_cache_model.dart b/firka_common/lib/data/models/lesson_cache_model.dart index 8edf49ca..face46fd 100644 --- a/firka_common/lib/data/models/lesson_cache_model.dart +++ b/firka_common/lib/data/models/lesson_cache_model.dart @@ -15,6 +15,8 @@ part 'lesson_cache_model.g.dart'; @collection class LessonCacheModel extends GenericCacheModel { + LessonCacheModel(); + String? uid; @Index() late DateTime start; @@ -91,6 +93,40 @@ class LessonCacheModel extends GenericCacheModel { bool isEvent() { return type == TimetableConsts.event; } + + /// Plain-field JSON representation (no Isar links) for cross-process sync, e.g. Wear OS. + Map toJson() { + return { + 'uid': uid, + 'start': start.toIso8601String(), + 'end': end.toIso8601String(), + 'dailyNth': dailyNth, + 'yearlyNth': yearlyNth, + 'name': name, + 'topic': topic, + 'roomName': roomName, + 'state': state, + 'type': type, + 'teacher': teacher, + 'substituteTeacher': substituteTeacher, + }; + } + + factory LessonCacheModel.fromJson(Map json) { + return LessonCacheModel() + ..uid = json['uid'] as String? + ..start = DateTime.parse(json['start'] as String) + ..end = DateTime.parse(json['end'] as String) + ..dailyNth = json['dailyNth'] as int? + ..yearlyNth = json['yearlyNth'] as int? + ..name = json['name'] as String + ..topic = json['topic'] as String? + ..roomName = json['roomName'] as String? + ..state = json['state'] as String + ..type = json['type'] as String + ..teacher = json['teacher'] as String? + ..substituteTeacher = json['substituteTeacher'] as String?; + } } typedef AfterQBFilter = QueryBuilder; diff --git a/firka_wear/analysis_options.yaml b/firka_wear/analysis_options.yaml index 0d290213..5671d4c5 100644 --- a/firka_wear/analysis_options.yaml +++ b/firka_wear/analysis_options.yaml @@ -7,6 +7,10 @@ # The following line activates a set of recommended lints for Flutter apps, # packages, and plugins designed to encourage good coding practices. +analyzer: + exclude: + - build/** + - android/** include: package:flutter_lints/flutter.yaml linter: diff --git a/firka_wear/lib/core/extensions.dart b/firka_wear/lib/core/extensions.dart index 179e003f..b417da60 100644 --- a/firka_wear/lib/core/extensions.dart +++ b/firka_wear/lib/core/extensions.dart @@ -4,7 +4,7 @@ import 'package:intl/intl.dart'; import 'package:firka_wear/core/debug_helper.dart'; import 'package:firka_wear/l10n/app_localizations.dart'; import 'package:firka_common/core/extensions.dart'; -import 'package:kreta_api/kreta_api.dart'; +import 'package:firka_common/data/models/lesson_cache_model.dart'; export 'package:firka_common/core/extensions.dart'; @@ -166,24 +166,24 @@ extension DateGrouper on Iterable { } } -extension LessonExtension on List { - int getLessonNo(Lesson lesson) { - return lesson.lessonNumber ?? indexOf(lesson); +extension LessonExtension on List { + int getLessonNo(LessonCacheModel lesson) { + return lesson.dailyNth ?? indexOf(lesson); } - Lesson? getCurrentLesson(DateTime now) { + LessonCacheModel? getCurrentLesson(DateTime now) { return firstWhereOrNull( (lesson) => now.isAfter(lesson.start) && now.isBefore(lesson.end), ); } - Lesson? getPrevLesson(DateTime now) { + LessonCacheModel? getPrevLesson(DateTime now) { return firstWhereOrNull( (lesson) => lesson.end.isBefore(now.add(Duration(milliseconds: 1))), ); } - Lesson? getNextLesson(DateTime now) { + LessonCacheModel? getNextLesson(DateTime now) { return firstWhereOrNull( (lesson) => lesson.start.isAfter(now.add(Duration(milliseconds: 1))), ); diff --git a/firka_wear/lib/services/wear_sync_store.dart b/firka_wear/lib/services/wear_sync_store.dart index 9ba53d49..453c8953 100644 --- a/firka_wear/lib/services/wear_sync_store.dart +++ b/firka_wear/lib/services/wear_sync_store.dart @@ -3,7 +3,8 @@ import 'dart:math'; import 'package:isar_community/isar.dart'; -import 'package:kreta_api/kreta_api.dart'; +import 'package:firka_common/data/models/lesson_cache_model.dart'; +import 'package:firka_common/data/models/grade_cache_model.dart'; import 'package:firka_wear/data/models/generic_cache_model.dart'; import 'package:firka_wear/data/models/token_model.dart'; @@ -15,12 +16,12 @@ class WearSyncStore { final Isar isar; - List _timetable = []; - List _grades = []; + List _timetable = []; + List _grades = []; DateTime? _lastSyncAt; - List get timetable => List.unmodifiable(_timetable); - List get grades => List.unmodifiable(_grades); + List get timetable => List.unmodifiable(_timetable); + List get grades => List.unmodifiable(_grades); DateTime? get lastSyncAt => _lastSyncAt; /// True if we have no data or data is older than 1 hour. @@ -64,7 +65,9 @@ class WearSyncStore { if (timetableCache?.cacheData != null) { final raw = jsonDecode(timetableCache!.cacheData!) as List; _timetable = raw - .map((e) => Lesson.fromJson(Map.from(e as Map))) + .map( + (e) => LessonCacheModel.fromJson(Map.from(e as Map)), + ) .toList(); } @@ -73,7 +76,9 @@ class WearSyncStore { if (gradesCache?.cacheData != null) { final raw = jsonDecode(gradesCache!.cacheData!) as List; _grades = raw - .map((e) => Grade.fromJson(Map.from(e as Map))) + .map( + (e) => GradeCacheModel.fromJson(Map.from(e as Map)), + ) .toList(); } } catch (_) {} @@ -81,8 +86,8 @@ class WearSyncStore { Future save({ required DateTime? lastSyncAt, - required List timetable, - required List grades, + required List timetable, + required List grades, }) async { final studentIdNorm = await _getStudentIdNorm(); if (studentIdNorm == null) return; @@ -124,7 +129,7 @@ class WearSyncStore { } /// Returns lessons that fall on [date] (compare by calendar day via lesson start). - List getLessonsForDate(DateTime date) { + List getLessonsForDate(DateTime date) { final y = date.year; final m = date.month; final d = date.day; diff --git a/firka_wear/lib/ui/wear/screens/home/home_screen.dart b/firka_wear/lib/ui/wear/screens/home/home_screen.dart index ffd37f3f..33debad9 100644 --- a/firka_wear/lib/ui/wear/screens/home/home_screen.dart +++ b/firka_wear/lib/ui/wear/screens/home/home_screen.dart @@ -3,12 +3,13 @@ import 'dart:convert'; import 'dart:math'; import 'package:firka_common/data/models/subject_cache_model.dart'; +import 'package:firka_common/data/models/lesson_cache_model.dart'; +import 'package:firka_common/data/models/grade_cache_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_arc_text/flutter_arc_text.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:kreta_api/kreta_api.dart'; import 'package:watch_connectivity/watch_connectivity.dart'; import 'package:wearable_rotary/wearable_rotary.dart'; import 'package:wear_plus/wear_plus.dart'; @@ -38,7 +39,7 @@ class _WearHomeScreenState extends State { WearAppInitialization get data => widget.data; int? currentLessonNo; - List today = List.empty(growable: true); + List today = List.empty(growable: true); String apiError = ""; DateTime now = timeNow(); Timer? timer; @@ -113,11 +114,15 @@ class _WearHomeScreenState extends State { : null; final rawTimetable = msg['timetable'] as List? ?? []; final timetable = rawTimetable - .map((e) => Lesson.fromJson(Map.from(e as Map))) + .map( + (e) => LessonCacheModel.fromJson(Map.from(e as Map)), + ) .toList(); final rawGrades = msg['grades'] as List? ?? []; final grades = rawGrades - .map((e) => Grade.fromJson(Map.from(e as Map))) + .map( + (e) => GradeCacheModel.fromJson(Map.from(e as Map)), + ) .toList(); await data.syncStore.save( lastSyncAt: lastSyncAt, @@ -222,9 +227,9 @@ class _WearHomeScreenState extends State { } currentLessonNo = null; if (now.isAfter(today.first.start) && now.isBefore(today.last.end)) { - Lesson? currentLesson = today.getCurrentLesson(now); - Lesson? lastLesson = today.getPrevLesson(now); - Lesson? nextLesson = today.getNextLesson(now); + LessonCacheModel? currentLesson = today.getCurrentLesson(now); + LessonCacheModel? lastLesson = today.getPrevLesson(now); + LessonCacheModel? nextLesson = today.getNextLesson(now); if (currentLesson != null) { currentLessonNo = today.getLessonNo(currentLesson); diff --git a/firka_wear/lib/ui/wear/screens/home/home_screen_body.dart b/firka_wear/lib/ui/wear/screens/home/home_screen_body.dart index 3d69db00..d3e82049 100644 --- a/firka_wear/lib/ui/wear/screens/home/home_screen_body.dart +++ b/firka_wear/lib/ui/wear/screens/home/home_screen_body.dart @@ -27,7 +27,7 @@ class _HomeScreenBodyPage extends StatelessWidget { } class _LessonCardPage extends StatelessWidget { - final Lesson? lesson; + final LessonCacheModel? lesson; final double viewportHeight; const _LessonCardPage({ diff --git a/firka_wear/lib/ui/wear/screens/login/login_screen.dart b/firka_wear/lib/ui/wear/screens/login/login_screen.dart index dbd88c4d..74cba26b 100644 --- a/firka_wear/lib/ui/wear/screens/login/login_screen.dart +++ b/firka_wear/lib/ui/wear/screens/login/login_screen.dart @@ -3,7 +3,8 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:kreta_api/kreta_api.dart'; +import 'package:firka_common/data/models/lesson_cache_model.dart'; +import 'package:firka_common/data/models/grade_cache_model.dart'; import 'package:watch_connectivity/watch_connectivity.dart'; import 'package:wear_plus/wear_plus.dart'; @@ -79,13 +80,17 @@ class _WearLoginScreen extends State { final rawTimetable = msg["timetable"] as List? ?? []; final timetable = rawTimetable .map( - (e) => Lesson.fromJson(Map.from(e as Map)), + (e) => LessonCacheModel.fromJson( + Map.from(e as Map), + ), ) .toList(); final rawGrades = msg["grades"] as List? ?? []; final grades = rawGrades .map( - (e) => Grade.fromJson(Map.from(e as Map)), + (e) => GradeCacheModel.fromJson( + Map.from(e as Map), + ), ) .toList(); await initData.syncStore.save( diff --git a/firka_wear/lib/ui/wear/widgets/lesson_card_small.dart b/firka_wear/lib/ui/wear/widgets/lesson_card_small.dart index 62ff7a9a..dab1dfb2 100644 --- a/firka_wear/lib/ui/wear/widgets/lesson_card_small.dart +++ b/firka_wear/lib/ui/wear/widgets/lesson_card_small.dart @@ -1,6 +1,6 @@ import 'package:firka_common/data/models/subject_cache_model.dart'; +import 'package:firka_common/data/models/lesson_cache_model.dart'; import 'package:flutter/material.dart'; -import 'package:kreta_api/kreta_api.dart'; import 'package:firka_wear/ui/components/firka_shadow.dart'; import 'package:firka_wear/ui/shared/class_icon.dart'; @@ -27,16 +27,16 @@ class LessonCardSmall extends StatelessWidget { }); factory LessonCardSmall.fromLesson( - Lesson lesson, { + LessonCacheModel lesson, { VoidCallback? onTap, Color? iconColor, bool shadow = true, Key? key, }) { return LessonCardSmall( - uid: lesson.uid, + uid: lesson.uid ?? lesson.name, subjectName: lesson.name, - category: lesson.subject?.name ?? '', + category: '', roomName: lesson.roomName, onTap: onTap, iconColor: iconColor,