filcnaplo
This commit is contained in:
parent
b22e6da194
commit
6dc0168ec4
@ -20,7 +20,7 @@ class FilcAPI {
|
|||||||
static const config = "https://api.filcnaplo.hu/config";
|
static const config = "https://api.filcnaplo.hu/config";
|
||||||
static const reportApi = "https://api.filcnaplo.hu/report";
|
static const reportApi = "https://api.filcnaplo.hu/report";
|
||||||
static const premiumApi = "https://api.filcnaplo.hu/premium/activate";
|
static const premiumApi = "https://api.filcnaplo.hu/premium/activate";
|
||||||
static const premiumScopesApi = "https://api.filcnaplo.hu/premium/scopes";
|
// static const premiumScopesApi = "https://api.filcnaplo.hu/premium/scopes";
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
static const repo = "filc/naplo";
|
static const repo = "filc/naplo";
|
||||||
|
@ -38,7 +38,6 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
_settings = settings {
|
_settings = settings {
|
||||||
_liveActivitiesPlugin.init(appGroupId: "group.filcnaplo.livecard");
|
_liveActivitiesPlugin.init(appGroupId: "group.filcnaplo.livecard");
|
||||||
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
|
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
|
||||||
timetable.restore().then((_) => update());
|
|
||||||
_delay = settings.bellDelayEnabled ? Duration(seconds: settings.bellDelay) : Duration.zero;
|
_delay = settings.bellDelayEnabled ? Duration(seconds: settings.bellDelay) : Duration.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,5 +195,5 @@ class LiveCardProvider extends ChangeNotifier {
|
|||||||
|
|
||||||
bool _sameDate(DateTime a, DateTime b) => (a.year == b.year && a.month == b.month && a.day == b.day);
|
bool _sameDate(DateTime a, DateTime b) => (a.year == b.year && a.month == b.month && a.day == b.day);
|
||||||
|
|
||||||
List<Lesson> _today(TimetableProvider p) => p.lessons.where((l) => _sameDate(l.date, _now())).toList();
|
List<Lesson> _today(TimetableProvider p) => (p.getWeek(Week.current()) ?? []).where((l) => _sameDate(l.date, _now())).toList();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ const settingsDB = DatabaseStruct("settings", {
|
|||||||
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
|
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
|
||||||
"notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications
|
"notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications
|
||||||
"x_filc_id": String, "graph_class_avg": int, "presentation_mode": int, "bell_delay": int, "bell_delay_enabled": int,
|
"x_filc_id": String, "graph_class_avg": int, "presentation_mode": int, "bell_delay": int, "bell_delay_enabled": int,
|
||||||
"grade_opening_fun": int, "icon_pack": String, "premium_scopes": String, "premium_token": String, "last_account_id": String, "renamed_subjects_enabled": int,
|
"grade_opening_fun": int, "icon_pack": String, "premium_scopes": String, "premium_token": String, "premium_login": String,
|
||||||
|
"last_account_id": String, "renamed_subjects_enabled": int,
|
||||||
});
|
});
|
||||||
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
||||||
// YOU'VE BEEN WARNED!!!
|
// YOU'VE BEEN WARNED!!!
|
||||||
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
import 'package:filcnaplo/api/providers/database_provider.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
||||||
import 'package:filcnaplo/models/user.dart';
|
import 'package:filcnaplo/models/user.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||||
// ignore: depend_on_referenced_packages
|
// ignore: depend_on_referenced_packages
|
||||||
import 'package:sqflite_common/sqlite_api.dart';
|
import 'package:sqflite_common/sqlite_api.dart';
|
||||||
|
|
||||||
@ -61,12 +62,15 @@ class UserDatabaseQuery {
|
|||||||
return grades;
|
return grades;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Lesson>> getLessons({required String userId}) async {
|
Future<Map<Week, List<Lesson>>> getLessons({required String userId}) async {
|
||||||
List<Map> userData = await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
List<Map> userData = await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||||
if (userData.isEmpty) return [];
|
if (userData.isEmpty) return {};
|
||||||
String? lessonsJson = userData.elementAt(0)["timetable"] as String?;
|
String? lessonsJson = userData.elementAt(0)["timetable"] as String?;
|
||||||
if (lessonsJson == null) return [];
|
if (lessonsJson == null) return {};
|
||||||
List<Lesson> lessons = (jsonDecode(lessonsJson) as List).map((e) => Lesson.fromJson(e)).toList();
|
if (jsonDecode(lessonsJson) is List) return {};
|
||||||
|
Map<Week, List<Lesson>> lessons = (jsonDecode(lessonsJson) as Map).cast<String, List>().map((key, value) {
|
||||||
|
return MapEntry(Week.fromId(int.parse(key)), value.cast<Map<String, Object?>>().map((e) => Lesson.fromJson(e)).toList());
|
||||||
|
}).cast();
|
||||||
return lessons;
|
return lessons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||||
// ignore: depend_on_referenced_packages
|
// ignore: depend_on_referenced_packages
|
||||||
import 'package:sqflite_common/sqlite_api.dart';
|
import 'package:sqflite_common/sqlite_api.dart';
|
||||||
|
|
||||||
@ -51,8 +53,11 @@ class UserDatabaseStore {
|
|||||||
await db.update("user_data", {"grades": gradesJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"grades": gradesJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> storeLessons(List<Lesson> lessons, {required String userId}) async {
|
Future<void> storeLessons(Map<Week, List<Lesson>?> lessons, {required String userId}) async {
|
||||||
String lessonsJson = jsonEncode(lessons.map((e) => e.json).toList());
|
final map = lessons.map<String, List<Map<String, Object?>>>(
|
||||||
|
(k, v) => MapEntry(k.id.toString(), v!.where((e) => e.json != null).map((e) => e.json!).toList().cast()),
|
||||||
|
);
|
||||||
|
String lessonsJson = jsonEncode(map);
|
||||||
await db.update("user_data", {"timetable": lessonsJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"timetable": lessonsJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,10 @@ import 'package:filcnaplo/models/release.dart';
|
|||||||
import 'package:open_file/open_file.dart';
|
import 'package:open_file/open_file.dart';
|
||||||
|
|
||||||
enum UpdateState { none, preparing, downloading, installing }
|
enum UpdateState { none, preparing, downloading, installing }
|
||||||
|
|
||||||
typedef UpdateCallback = Function(double progress, UpdateState state);
|
typedef UpdateCallback = Function(double progress, UpdateState state);
|
||||||
|
|
||||||
|
// ignore: todo
|
||||||
// TODO: cleanup old apk files
|
// TODO: cleanup old apk files
|
||||||
|
|
||||||
extension UpdateHelper on Release {
|
extension UpdateHelper on Release {
|
||||||
|
@ -64,6 +64,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
Color _customHighlightColor;
|
Color _customHighlightColor;
|
||||||
List<String> _premiumScopes;
|
List<String> _premiumScopes;
|
||||||
String _premiumAccessToken;
|
String _premiumAccessToken;
|
||||||
|
String _premiumLogin;
|
||||||
String _lastAccountId;
|
String _lastAccountId;
|
||||||
bool _renamedSubjectsEnabled;
|
bool _renamedSubjectsEnabled;
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
required Color customHighlightColor,
|
required Color customHighlightColor,
|
||||||
required List<String> premiumScopes,
|
required List<String> premiumScopes,
|
||||||
required String premiumAccessToken,
|
required String premiumAccessToken,
|
||||||
|
required String premiumLogin,
|
||||||
required String lastAccountId,
|
required String lastAccountId,
|
||||||
required bool renameSubjectsEnabled,
|
required bool renameSubjectsEnabled,
|
||||||
}) : _database = database,
|
}) : _database = database,
|
||||||
@ -132,6 +134,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
_customHighlightColor = customHighlightColor,
|
_customHighlightColor = customHighlightColor,
|
||||||
_premiumScopes = premiumScopes,
|
_premiumScopes = premiumScopes,
|
||||||
_premiumAccessToken = premiumAccessToken,
|
_premiumAccessToken = premiumAccessToken,
|
||||||
|
_premiumLogin = premiumLogin,
|
||||||
_lastAccountId = lastAccountId,
|
_lastAccountId = lastAccountId,
|
||||||
_renamedSubjectsEnabled = renameSubjectsEnabled;
|
_renamedSubjectsEnabled = renameSubjectsEnabled;
|
||||||
|
|
||||||
@ -182,6 +185,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
customHighlightColor: Color(map["custom_highlight_color"]),
|
customHighlightColor: Color(map["custom_highlight_color"]),
|
||||||
premiumScopes: jsonDecode(map["premium_scopes"]).cast<String>(),
|
premiumScopes: jsonDecode(map["premium_scopes"]).cast<String>(),
|
||||||
premiumAccessToken: map["premium_token"],
|
premiumAccessToken: map["premium_token"],
|
||||||
|
premiumLogin: map["premium_login"],
|
||||||
lastAccountId: map["last_account_id"],
|
lastAccountId: map["last_account_id"],
|
||||||
renameSubjectsEnabled: map["renamed_subjects_enabled"] == 1,
|
renameSubjectsEnabled: map["renamed_subjects_enabled"] == 1,
|
||||||
);
|
);
|
||||||
@ -222,6 +226,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
"custom_highlight_color": _customHighlightColor.value,
|
"custom_highlight_color": _customHighlightColor.value,
|
||||||
"premium_scopes": jsonEncode(_premiumScopes),
|
"premium_scopes": jsonEncode(_premiumScopes),
|
||||||
"premium_token": _premiumAccessToken,
|
"premium_token": _premiumAccessToken,
|
||||||
|
"premium_login": _premiumLogin,
|
||||||
"last_account_id": _lastAccountId,
|
"last_account_id": _lastAccountId,
|
||||||
"renamed_subjects_enabled": _renamedSubjectsEnabled ? 1 : 0
|
"renamed_subjects_enabled": _renamedSubjectsEnabled ? 1 : 0
|
||||||
};
|
};
|
||||||
@ -266,6 +271,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
customHighlightColor: const Color(0xff222222),
|
customHighlightColor: const Color(0xff222222),
|
||||||
premiumScopes: [],
|
premiumScopes: [],
|
||||||
premiumAccessToken: "",
|
premiumAccessToken: "",
|
||||||
|
premiumLogin: "",
|
||||||
lastAccountId: "",
|
lastAccountId: "",
|
||||||
renameSubjectsEnabled: false,
|
renameSubjectsEnabled: false,
|
||||||
);
|
);
|
||||||
@ -302,6 +308,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
Color? get customHighlightColor => _customHighlightColor;
|
Color? get customHighlightColor => _customHighlightColor;
|
||||||
List<String> get premiumScopes => _premiumScopes;
|
List<String> get premiumScopes => _premiumScopes;
|
||||||
String get premiumAccessToken => _premiumAccessToken;
|
String get premiumAccessToken => _premiumAccessToken;
|
||||||
|
String get premiumLogin => _premiumLogin;
|
||||||
String get lastAccountId => _lastAccountId;
|
String get lastAccountId => _lastAccountId;
|
||||||
bool get renamedSubjectsEnabled => _renamedSubjectsEnabled;
|
bool get renamedSubjectsEnabled => _renamedSubjectsEnabled;
|
||||||
|
|
||||||
@ -337,6 +344,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
Color? customHighlightColor,
|
Color? customHighlightColor,
|
||||||
List<String>? premiumScopes,
|
List<String>? premiumScopes,
|
||||||
String? premiumAccessToken,
|
String? premiumAccessToken,
|
||||||
|
String? premiumLogin,
|
||||||
String? lastAccountId,
|
String? lastAccountId,
|
||||||
bool? renamedSubjectsEnabled,
|
bool? renamedSubjectsEnabled,
|
||||||
}) async {
|
}) async {
|
||||||
@ -372,6 +380,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
if (customHighlightColor != null && customHighlightColor != _customHighlightColor) _customHighlightColor = customHighlightColor;
|
if (customHighlightColor != null && customHighlightColor != _customHighlightColor) _customHighlightColor = customHighlightColor;
|
||||||
if (premiumScopes != null && premiumScopes != _premiumScopes) _premiumScopes = premiumScopes;
|
if (premiumScopes != null && premiumScopes != _premiumScopes) _premiumScopes = premiumScopes;
|
||||||
if (premiumAccessToken != null && premiumAccessToken != _premiumAccessToken) _premiumAccessToken = premiumAccessToken;
|
if (premiumAccessToken != null && premiumAccessToken != _premiumAccessToken) _premiumAccessToken = premiumAccessToken;
|
||||||
|
if (premiumLogin != null && premiumLogin != _premiumLogin) _premiumLogin = premiumLogin;
|
||||||
if (lastAccountId != null && lastAccountId != _lastAccountId) _lastAccountId = lastAccountId;
|
if (lastAccountId != null && lastAccountId != _lastAccountId) _lastAccountId = lastAccountId;
|
||||||
if (renamedSubjectsEnabled != null && renamedSubjectsEnabled != _renamedSubjectsEnabled) _renamedSubjectsEnabled = renamedSubjectsEnabled;
|
if (renamedSubjectsEnabled != null && renamedSubjectsEnabled != _renamedSubjectsEnabled) _renamedSubjectsEnabled = renamedSubjectsEnabled;
|
||||||
|
|
||||||
|
@ -9,9 +9,9 @@ class Supporter {
|
|||||||
|
|
||||||
const Supporter({required this.avatar, required this.name, this.comment = "", this.price = 0, this.type = DonationType.once});
|
const Supporter({required this.avatar, required this.name, this.comment = "", this.price = 0, this.type = DonationType.once});
|
||||||
|
|
||||||
factory Supporter.fromJson(Map json) {
|
factory Supporter.fromJson(Map json, {String? avatarPattern}) {
|
||||||
return Supporter(
|
return Supporter(
|
||||||
avatar: json["avatar"] ?? "",
|
avatar: json["avatar"] ?? avatarPattern != null ? avatarPattern!.replaceFirst("\$", json["name"]) : "",
|
||||||
name: json["name"] ?? "Unknown",
|
name: json["name"] ?? "Unknown",
|
||||||
comment: json["comment"] ?? "",
|
comment: json["comment"] ?? "",
|
||||||
price: json["price"].toInt() ?? 0,
|
price: json["price"].toInt() ?? 0,
|
||||||
@ -40,7 +40,10 @@ class Supporters {
|
|||||||
progress: json["percentage"].toDouble() ?? 100.0,
|
progress: json["percentage"].toDouble() ?? 100.0,
|
||||||
max: json["target"].toDouble() ?? 1.0,
|
max: json["target"].toDouble() ?? 1.0,
|
||||||
description: json["description"] ?? "",
|
description: json["description"] ?? "",
|
||||||
github: json["sponsors"]["github"].map((e) => Supporter.fromJson(e)).cast<Supporter>().toList(),
|
github: json["sponsors"]["github"]
|
||||||
|
.map((e) => Supporter.fromJson(e, avatarPattern: "https://github.com/\$.png?size=200"))
|
||||||
|
.cast<Supporter>()
|
||||||
|
.toList(),
|
||||||
patreon: json["sponsors"]["patreon"].map((e) => Supporter.fromJson(e)).cast<Supporter>().toList(),
|
patreon: json["sponsors"]["patreon"].map((e) => Supporter.fromJson(e)).cast<Supporter>().toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import 'package:filcnaplo/ui/filter/widgets/events.dart' as event_filter;
|
|||||||
import 'package:filcnaplo/ui/filter/widgets/lessons.dart' as lesson_filter;
|
import 'package:filcnaplo/ui/filter/widgets/lessons.dart' as lesson_filter;
|
||||||
import 'package:filcnaplo/ui/filter/widgets/update.dart' as update_filter;
|
import 'package:filcnaplo/ui/filter/widgets/update.dart' as update_filter;
|
||||||
import 'package:filcnaplo/ui/filter/widgets/missed_exams.dart' as missed_exam_filter;
|
import 'package:filcnaplo/ui/filter/widgets/missed_exams.dart' as missed_exam_filter;
|
||||||
|
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/event_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/event_provider.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/exam_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/exam_provider.dart';
|
||||||
@ -117,7 +118,7 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData, {bool absencesN
|
|||||||
|
|
||||||
// Changed Lessons
|
// Changed Lessons
|
||||||
case FilterType.lessons:
|
case FilterType.lessons:
|
||||||
items = lesson_filter.getWidgets(timetableProvider.lessons);
|
items = lesson_filter.getWidgets(timetableProvider.getWeek(Week.current()) ?? []);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Updates
|
// Updates
|
||||||
@ -127,7 +128,7 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData, {bool absencesN
|
|||||||
|
|
||||||
// Missed Exams
|
// Missed Exams
|
||||||
case FilterType.missedExams:
|
case FilterType.missedExams:
|
||||||
items = missed_exam_filter.getWidgets(timetableProvider.lessons);
|
items = missed_exam_filter.getWidgets(timetableProvider.getWeek(Week.current()) ?? []);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
|
@ -12,12 +12,13 @@ class ReverseSearch {
|
|||||||
final timetableProvider = Provider.of<TimetableProvider>(context, listen: false);
|
final timetableProvider = Provider.of<TimetableProvider>(context, listen: false);
|
||||||
|
|
||||||
List<Lesson> lessons = [];
|
List<Lesson> lessons = [];
|
||||||
|
final week = Week.fromDate(absence.date);
|
||||||
try {
|
try {
|
||||||
await timetableProvider.fetch(week: Week.fromDate(absence.date), db: false);
|
await timetableProvider.fetch(week: week);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("[ERROR] getLessonByAbsence: $e");
|
log("[ERROR] getLessonByAbsence: $e");
|
||||||
}
|
}
|
||||||
lessons = timetableProvider.lessons;
|
lessons = timetableProvider.getWeek(week) ?? [];
|
||||||
|
|
||||||
// Find absence lesson in timetable
|
// Find absence lesson in timetable
|
||||||
Lesson lesson = lessons.firstWhere(
|
Lesson lesson = lessons.firstWhere(
|
||||||
|
@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez"
|
|||||||
homepage: https://filcnaplo.hu
|
homepage: https://filcnaplo.hu
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
|
|
||||||
version: 3.5.0-beta.3+179
|
version: 3.5.0-beta.4+181
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
@ -65,6 +65,7 @@ dependencies:
|
|||||||
flutter_svg: ^1.1.6
|
flutter_svg: ^1.1.6
|
||||||
image_picker: ^0.8.6
|
image_picker: ^0.8.6
|
||||||
image_crop: ^0.4.1
|
image_crop: ^0.4.1
|
||||||
|
animations: ^2.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^2.0.1
|
flutter_lints: ^2.0.1
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2942cba9ee001cf968dd5475121519928eb0e83f
|
Subproject commit bfd448792ab26d103bfd67d128652cc4261b021a
|
@ -1 +1 @@
|
|||||||
Subproject commit f4c669a1ec2a8f49f97aacdfafa154650d62558d
|
Subproject commit e6e67fdce0ec798b8bec045a9978d7b0bf5ff362
|
@ -1 +1 @@
|
|||||||
Subproject commit ebcb60b416c57412a8339827a8cf57ff8df518fc
|
Subproject commit 9f1bcbdcf451018113d239d3c0444fe29d1b005a
|
@ -1 +1 @@
|
|||||||
Subproject commit d814295464ae9bbdaf9e3566b73430a7f84958d9
|
Subproject commit f06c4c03fcd8aec5c83ff2d322d2185123cc2d23
|
Loading…
x
Reference in New Issue
Block a user