Merge branch 'refilc:dev' into dev
This commit is contained in:
@@ -7,23 +7,33 @@ import 'package:provider/provider.dart';
|
||||
|
||||
class SelfNoteProvider with ChangeNotifier {
|
||||
late List<SelfNote> _notes;
|
||||
late List<TodoItem> _todoItems;
|
||||
late BuildContext _context;
|
||||
|
||||
List<SelfNote> get notes => _notes;
|
||||
List<TodoItem> get todos => _todoItems;
|
||||
|
||||
SelfNoteProvider({
|
||||
List<SelfNote> initialNotes = const [],
|
||||
List<TodoItem> initialTodoItems = const [],
|
||||
required BuildContext context,
|
||||
}) {
|
||||
_notes = List.castFrom(initialNotes);
|
||||
_todoItems = List.castFrom(initialTodoItems);
|
||||
_context = context;
|
||||
|
||||
if (_notes.isEmpty) restore();
|
||||
if (_todoItems.isEmpty) restoreTodo();
|
||||
}
|
||||
|
||||
// restore self notes from db
|
||||
Future<void> restore() async {
|
||||
String? userId = Provider.of<UserProvider>(_context, listen: false).id;
|
||||
|
||||
// await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
// .userStore
|
||||
// .storeSelfNotes([], userId: userId!);
|
||||
|
||||
// load self notes from db
|
||||
if (userId != null) {
|
||||
var dbNotes = await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
@@ -34,6 +44,24 @@ class SelfNoteProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
// restore todo items from db
|
||||
Future<void> restoreTodo() async {
|
||||
String? userId = Provider.of<UserProvider>(_context, listen: false).id;
|
||||
|
||||
// await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
// .userStore
|
||||
// .storeSelfNotes([], userId: userId!);
|
||||
|
||||
// load self notes from db
|
||||
if (userId != null) {
|
||||
var dbTodo = await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
.userQuery
|
||||
.getTodoItems(userId: userId);
|
||||
_todoItems = dbTodo;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
// fetches fresh data from api (not needed, cuz no api for that)
|
||||
// Future<void> fetch() async {
|
||||
// }
|
||||
@@ -50,4 +78,17 @@ class SelfNoteProvider with ChangeNotifier {
|
||||
_notes = notes;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// store todo items in db
|
||||
Future<void> storeTodo(List<TodoItem> todos) async {
|
||||
User? user = Provider.of<UserProvider>(_context, listen: false).user;
|
||||
if (user == null) throw "Cannot store Self Notes for User null";
|
||||
String userId = user.id;
|
||||
|
||||
await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||
.userStore
|
||||
.storeSelfTodoItems(todos, userId: userId);
|
||||
_todoItems = todos;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
"nav_shadow": int,
|
||||
"new_colors": int,
|
||||
"uwu_mode": int,
|
||||
// quick settings
|
||||
"q_timetable_lesson_num": int, "q_timetable_sub_tiles": int,
|
||||
"q_subjects_sub_tiles": int,
|
||||
});
|
||||
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
||||
// YOU'VE BEEN WARNED!!!
|
||||
@@ -81,7 +84,7 @@ const userDataDB = DatabaseStruct("user_data", {
|
||||
"goal_befores": String,
|
||||
"goal_pin_dates": String,
|
||||
// todo and notes
|
||||
"todo_items": String, "self_notes": String,
|
||||
"todo_items": String, "self_notes": String, "self_todo": String,
|
||||
// v5 shit
|
||||
"roundings": String,
|
||||
"grade_rarities": String,
|
||||
@@ -149,7 +152,7 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
"goal_befores": "{}",
|
||||
"goal_pin_dates": "{}",
|
||||
// todo and notes
|
||||
"todo_items": "{}", "self_notes": "[]",
|
||||
"todo_items": "{}", "self_notes": "[]", "self_todo": "[]",
|
||||
// v5 shit
|
||||
"roundings": "{}",
|
||||
"grade_rarities": "{}",
|
||||
|
||||
@@ -317,6 +317,18 @@ class UserDatabaseQuery {
|
||||
return selfNotes;
|
||||
}
|
||||
|
||||
Future<List<TodoItem>> getTodoItems({required String userId}) async {
|
||||
List<Map> userData =
|
||||
await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||
if (userData.isEmpty) return [];
|
||||
String? todoItemsJson = userData.elementAt(0)["self_todo"] as String?;
|
||||
if (todoItemsJson == null) return [];
|
||||
List<TodoItem> todoItems = (jsonDecode(todoItemsJson) as List)
|
||||
.map((e) => TodoItem.fromJson(e))
|
||||
.toList();
|
||||
return todoItems;
|
||||
}
|
||||
|
||||
// v5
|
||||
Future<Map<String, String>> getRoundings({required String userId}) async {
|
||||
List<Map> userData =
|
||||
|
||||
@@ -196,6 +196,13 @@ class UserDatabaseStore {
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future<void> storeSelfTodoItems(List<TodoItem> todoItems,
|
||||
{required String userId}) async {
|
||||
String todoItemsJson = jsonEncode(todoItems.map((e) => e.json).toList());
|
||||
await db.update("user_data", {"self_todo": todoItemsJson},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
// v5
|
||||
Future<void> storeRoundings(Map<String, String> roundings,
|
||||
{required String userId}) async {
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
enum NoteType { text, image }
|
||||
|
||||
class SelfNote {
|
||||
String id;
|
||||
String? title;
|
||||
String content;
|
||||
NoteType noteType;
|
||||
|
||||
Map? json;
|
||||
|
||||
SelfNote({
|
||||
required this.id,
|
||||
this.title,
|
||||
required this.content,
|
||||
required this.noteType,
|
||||
this.json,
|
||||
});
|
||||
|
||||
@@ -16,6 +21,7 @@ class SelfNote {
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
content: json['content'],
|
||||
noteType: json['note_type'] == 'image' ? NoteType.image : NoteType.text,
|
||||
json: json,
|
||||
);
|
||||
}
|
||||
@@ -24,5 +30,40 @@ class SelfNote {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'content': content,
|
||||
'note_type': noteType == NoteType.image ? 'image' : 'text',
|
||||
};
|
||||
}
|
||||
|
||||
class TodoItem {
|
||||
String id;
|
||||
String title;
|
||||
String content;
|
||||
bool done;
|
||||
|
||||
Map? json;
|
||||
|
||||
TodoItem({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.content,
|
||||
required this.done,
|
||||
this.json,
|
||||
});
|
||||
|
||||
factory TodoItem.fromJson(Map json) {
|
||||
return TodoItem(
|
||||
id: json['id'],
|
||||
title: json['title'],
|
||||
content: json['content'],
|
||||
done: json['done'],
|
||||
json: json,
|
||||
);
|
||||
}
|
||||
|
||||
get toJson => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'content': content,
|
||||
'done': done,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -105,6 +105,10 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool _navShadow;
|
||||
bool _newColors;
|
||||
bool _uwuMode;
|
||||
// quick settings
|
||||
bool _qTimetableLessonNum;
|
||||
bool _qTimetableSubTiles;
|
||||
bool _qSubjectsSubTiles;
|
||||
|
||||
SettingsProvider({
|
||||
DatabaseProvider? database,
|
||||
@@ -172,6 +176,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
required bool navShadow,
|
||||
required bool newColors,
|
||||
required bool uwuMode,
|
||||
required bool qTimetableLessonNum,
|
||||
required bool qTimetableSubTiles,
|
||||
required bool qSubjectsSubTiles,
|
||||
}) : _database = database,
|
||||
_language = language,
|
||||
_startPage = startPage,
|
||||
@@ -236,7 +243,10 @@ class SettingsProvider extends ChangeNotifier {
|
||||
_calendarId = calendarId,
|
||||
_navShadow = navShadow,
|
||||
_newColors = newColors,
|
||||
_uwuMode = uwuMode;
|
||||
_uwuMode = uwuMode,
|
||||
_qTimetableLessonNum = qTimetableLessonNum,
|
||||
_qTimetableSubTiles = qTimetableSubTiles,
|
||||
_qSubjectsSubTiles = qSubjectsSubTiles;
|
||||
|
||||
factory SettingsProvider.fromMap(Map map,
|
||||
{required DatabaseProvider database}) {
|
||||
@@ -321,6 +331,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
navShadow: map['nav_shadow'] == 1,
|
||||
newColors: map['new_colors'] == 1,
|
||||
uwuMode: map['uwu_mode'] == 1,
|
||||
qTimetableLessonNum: map['q_timetable_lesson_num'] == 1,
|
||||
qTimetableSubTiles: map['q_timetable_sub_tiles'] == 1,
|
||||
qSubjectsSubTiles: map['q_subjects_sub_tiles'] == 1,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -393,6 +406,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
"nav_shadow": _navShadow ? 1 : 0,
|
||||
"new_colors": _newColors ? 1 : 0,
|
||||
"uwu_mode": _uwuMode ? 1 : 0,
|
||||
"q_timetable_lesson_num": _qTimetableLessonNum ? 1 : 0,
|
||||
"q_timetable_sub_tiles": _qTimetableSubTiles ? 1 : 0,
|
||||
"q_subjects_sub_tiles": _qSubjectsSubTiles ? 1 : 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -469,6 +485,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
navShadow: true,
|
||||
newColors: true,
|
||||
uwuMode: false,
|
||||
qTimetableLessonNum: true,
|
||||
qTimetableSubTiles: true,
|
||||
qSubjectsSubTiles: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -536,6 +555,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool get navShadow => _navShadow;
|
||||
bool get newColors => _newColors;
|
||||
bool get uwuMode => _uwuMode;
|
||||
bool get qTimetableLessonNum => _qTimetableLessonNum;
|
||||
bool get qTimetableSubTiles => _qTimetableSubTiles;
|
||||
bool get qSubjectsSubTiles => _qSubjectsSubTiles;
|
||||
|
||||
Future<void> update({
|
||||
bool store = true,
|
||||
@@ -599,6 +621,9 @@ class SettingsProvider extends ChangeNotifier {
|
||||
bool? navShadow,
|
||||
bool? newColors,
|
||||
bool? uwuMode,
|
||||
bool? qTimetableLessonNum,
|
||||
bool? qTimetableSubTiles,
|
||||
bool? qSubjectsSubTiles,
|
||||
}) async {
|
||||
if (language != null && language != _language) _language = language;
|
||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||
@@ -669,7 +694,7 @@ class SettingsProvider extends ChangeNotifier {
|
||||
if (bellDelay != null && bellDelay != _bellDelay) _bellDelay = bellDelay;
|
||||
if (bellDelayEnabled != null && bellDelayEnabled != _bellDelayEnabled) {
|
||||
_bellDelayEnabled = bellDelayEnabled;
|
||||
if(Platform.isIOS){
|
||||
if (Platform.isIOS) {
|
||||
LiveCardProvider.hasActivitySettingsChanged = true;
|
||||
}
|
||||
}
|
||||
@@ -781,6 +806,17 @@ class SettingsProvider extends ChangeNotifier {
|
||||
if (uwuMode != null && uwuMode != _uwuMode) {
|
||||
_uwuMode = uwuMode;
|
||||
}
|
||||
if (qTimetableLessonNum != null &&
|
||||
qTimetableLessonNum != _qTimetableLessonNum) {
|
||||
_qTimetableLessonNum = qTimetableLessonNum;
|
||||
}
|
||||
if (qTimetableSubTiles != null &&
|
||||
qTimetableSubTiles != _qTimetableSubTiles) {
|
||||
_qTimetableSubTiles = qTimetableSubTiles;
|
||||
}
|
||||
if (qSubjectsSubTiles != null && qSubjectsSubTiles != _qSubjectsSubTiles) {
|
||||
_qSubjectsSubTiles = qSubjectsSubTiles;
|
||||
}
|
||||
// store or not
|
||||
if (store) await _database?.store.storeSettings(this);
|
||||
notifyListeners();
|
||||
|
||||
@@ -31,3 +31,66 @@ Map<AccentColor, Color> accentColorMap = {
|
||||
AccentColor.adaptive: const Color(0xFF3D7BF4),
|
||||
AccentColor.custom: const Color(0xFF3D7BF4),
|
||||
};
|
||||
|
||||
// new v5 things
|
||||
Map<AccentColor, Color> lightPrimary = {
|
||||
AccentColor.filc: const Color(0xFF050B15),
|
||||
};
|
||||
Map<AccentColor, Color> lightSecondary = {
|
||||
AccentColor.filc: const Color(0xFF3F444F),
|
||||
};
|
||||
Map<AccentColor, Color> lightTeritary = {
|
||||
AccentColor.filc: const Color(0xFF1C469A),
|
||||
};
|
||||
Map<AccentColor, Color> lightIcon = {
|
||||
AccentColor.filc: const Color(0xFF0A2456),
|
||||
};
|
||||
Map<AccentColor, Color> lightAccent = {
|
||||
AccentColor.filc: const Color(0xFF487DE6),
|
||||
};
|
||||
Map<AccentColor, Color> lightBgDarkened = {
|
||||
AccentColor.filc: const Color(0xFFB9C8E5),
|
||||
};
|
||||
Map<AccentColor, Color> lightBtnSecStrk = {
|
||||
AccentColor.filc: const Color(0xFFCEDBF5),
|
||||
};
|
||||
Map<AccentColor, Color> lightBg = {
|
||||
AccentColor.filc: const Color(0xFFDAE4F7),
|
||||
};
|
||||
Map<AccentColor, Color> lightCard = {
|
||||
AccentColor.filc: const Color(0xFFEDF3FF),
|
||||
};
|
||||
Map<AccentColor, Color> lightBtnSec = {
|
||||
AccentColor.filc: const Color(0xFFFBFCFF),
|
||||
};
|
||||
|
||||
Map<AccentColor, Color> darkPrimary = {
|
||||
AccentColor.filc: const Color(0xFFEBF1FD),
|
||||
};
|
||||
Map<AccentColor, Color> darkSecondary = {
|
||||
AccentColor.filc: const Color(0xFFCFD8E9),
|
||||
};
|
||||
Map<AccentColor, Color> darkTeritary = {
|
||||
AccentColor.filc: const Color(0xFFAEC8FC),
|
||||
};
|
||||
Map<AccentColor, Color> darkIcon = {
|
||||
AccentColor.filc: const Color(0xFFBAD1FF),
|
||||
};
|
||||
Map<AccentColor, Color> darkAccent = {
|
||||
AccentColor.filc: const Color(0xFF487DE6),
|
||||
};
|
||||
Map<AccentColor, Color> darkBgDarkened = {
|
||||
AccentColor.filc: const Color(0xFF010205),
|
||||
};
|
||||
Map<AccentColor, Color> darkBtnSecStrk = {
|
||||
AccentColor.filc: const Color(0xFF1C2230),
|
||||
};
|
||||
Map<AccentColor, Color> darkBg = {
|
||||
AccentColor.filc: const Color(0xFF070A0E),
|
||||
};
|
||||
Map<AccentColor, Color> darkCard = {
|
||||
AccentColor.filc: const Color(0xFF0F131B),
|
||||
};
|
||||
Map<AccentColor, Color> darkBtnSec = {
|
||||
AccentColor.filc: const Color(0xFF131822),
|
||||
};
|
||||
|
||||
73
refilc/lib/theme/colors/new_colors.dart
Normal file
73
refilc/lib/theme/colors/new_colors.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class NewColors extends ThemeExtension<NewColors> {
|
||||
const NewColors({
|
||||
required this.accent,
|
||||
required this.primary,
|
||||
required this.secondary,
|
||||
required this.teritary,
|
||||
required this.icon,
|
||||
required this.darkenBg,
|
||||
required this.btnSecStrk,
|
||||
required this.background,
|
||||
required this.card,
|
||||
required this.btnSec,
|
||||
});
|
||||
|
||||
final Color? accent;
|
||||
final Color? primary;
|
||||
final Color? secondary;
|
||||
final Color? teritary;
|
||||
final Color? icon;
|
||||
final Color? darkenBg;
|
||||
final Color? btnSecStrk;
|
||||
final Color? background;
|
||||
final Color? card;
|
||||
final Color? btnSec;
|
||||
|
||||
@override
|
||||
NewColors copyWith({
|
||||
Color? accent,
|
||||
Color? primary,
|
||||
Color? secondary,
|
||||
Color? teritary,
|
||||
Color? icon,
|
||||
Color? darkenBg,
|
||||
Color? btnSecStrk,
|
||||
Color? background,
|
||||
Color? card,
|
||||
Color? btnSec,
|
||||
}) {
|
||||
return NewColors(
|
||||
accent: accent ?? this.accent,
|
||||
primary: primary ?? this.primary,
|
||||
secondary: secondary ?? this.secondary,
|
||||
teritary: teritary ?? this.teritary,
|
||||
icon: icon ?? this.icon,
|
||||
darkenBg: darkenBg ?? this.darkenBg,
|
||||
btnSecStrk: btnSecStrk ?? this.btnSecStrk,
|
||||
background: background ?? this.background,
|
||||
card: card ?? this.card,
|
||||
btnSec: btnSec ?? this.btnSec,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
NewColors lerp(NewColors? other, double t) {
|
||||
if (other is! NewColors) {
|
||||
return this;
|
||||
}
|
||||
return NewColors(
|
||||
accent: Color.lerp(accent, other.accent, t),
|
||||
primary: Color.lerp(primary, other.primary, t),
|
||||
secondary: Color.lerp(secondary, other.secondary, t),
|
||||
teritary: Color.lerp(teritary, other.teritary, t),
|
||||
icon: Color.lerp(icon, other.icon, t),
|
||||
darkenBg: Color.lerp(darkenBg, other.darkenBg, t),
|
||||
btnSecStrk: Color.lerp(btnSecStrk, other.btnSecStrk, t),
|
||||
background: Color.lerp(background, other.background, t),
|
||||
card: Color.lerp(card, other.card, t),
|
||||
btnSec: Color.lerp(btnSec, other.btnSec, t),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,20 @@ class AppTheme {
|
||||
amount: 0.4); // white mode: same tertiary as secondary
|
||||
|
||||
return ThemeData(
|
||||
// extensions: [
|
||||
// NewColors(
|
||||
// accent: lightAccent[accentColor]!,
|
||||
// primary: lightPrimary[accentColor]!,
|
||||
// secondary: lightSecondary[accentColor]!,
|
||||
// teritary: lightTeritary[accentColor]!,
|
||||
// icon: lightIcon[accentColor]!,
|
||||
// darkenBg: lightBgDarkened[accentColor]!,
|
||||
// btnSecStrk: lightBtnSecStrk[accentColor]!,
|
||||
// background: lightBg[accentColor]!,
|
||||
// card: lightCard[accentColor]!,
|
||||
// btnSec: lightBtnSec[accentColor]!,
|
||||
// ),
|
||||
// ],
|
||||
brightness: Brightness.light,
|
||||
useMaterial3: true,
|
||||
fontFamily: _defaultFontFamily,
|
||||
@@ -198,6 +212,20 @@ class AppTheme {
|
||||
amount: 0.1); // dark mode: tertiary is way darker than secondary
|
||||
|
||||
return ThemeData(
|
||||
// extensions: [
|
||||
// NewColors(
|
||||
// accent: darkAccent[accentColor]!,
|
||||
// primary: darkPrimary[accentColor]!,
|
||||
// secondary: darkSecondary[accentColor]!,
|
||||
// teritary: darkTeritary[accentColor]!,
|
||||
// icon: darkIcon[accentColor]!,
|
||||
// darkenBg: darkBgDarkened[accentColor]!,
|
||||
// btnSecStrk: darkBtnSecStrk[accentColor]!,
|
||||
// background: darkBg[accentColor]!,
|
||||
// card: darkCard[accentColor]!,
|
||||
// btnSec: darkBtnSec[accentColor]!,
|
||||
// ),
|
||||
// ],
|
||||
brightness: Brightness.dark,
|
||||
useMaterial3: true,
|
||||
fontFamily: _defaultFontFamily,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:refilc_kreta_api/models/absence.dart';
|
||||
import 'package:refilc_kreta_api/models/exam.dart';
|
||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||
import 'package:refilc_kreta_api/models/subject.dart';
|
||||
import 'package:refilc_kreta_api/models/week.dart';
|
||||
import 'package:refilc_kreta_api/providers/grade_provider.dart';
|
||||
import 'package:refilc_kreta_api/providers/timetable_provider.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -38,7 +41,54 @@ class ReverseSearch {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Lesson?> getLessonByExam(
|
||||
Exam exam, BuildContext context) async {
|
||||
final timetableProvider =
|
||||
Provider.of<TimetableProvider>(context, listen: false);
|
||||
|
||||
List<Lesson> lessons = [];
|
||||
final week = Week.fromDate(exam.writeDate);
|
||||
try {
|
||||
await timetableProvider.fetch(week: week);
|
||||
} catch (e) {
|
||||
log("[ERROR] getLessonByAbsence: $e");
|
||||
}
|
||||
lessons = timetableProvider.getWeek(week) ?? [];
|
||||
|
||||
// Find absence lesson in timetable
|
||||
Lesson lesson = lessons.firstWhere(
|
||||
(l) =>
|
||||
_sameDate(l.date, exam.writeDate) && l.subject.id == exam.subject.id,
|
||||
orElse: () => Lesson.fromJson({'isEmpty': true}),
|
||||
);
|
||||
|
||||
if (lesson.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
return lesson;
|
||||
}
|
||||
}
|
||||
|
||||
// difference.inDays is not reliable
|
||||
static bool _sameDate(DateTime a, DateTime b) =>
|
||||
(a.year == b.year && a.month == b.month && a.day == b.day);
|
||||
|
||||
static Future<GradeSubject?> getSubjectByLesson(
|
||||
Lesson lesson, BuildContext context) async {
|
||||
final gradeProvider = Provider.of<GradeProvider>(context, listen: false);
|
||||
|
||||
try {
|
||||
await gradeProvider.fetch();
|
||||
} catch (e) {
|
||||
log("[ERROR] getSubjectByLesson: $e");
|
||||
}
|
||||
|
||||
try {
|
||||
return gradeProvider.grades.map((e) => e.subject).firstWhere(
|
||||
(s) => s.id == lesson.subject.id,
|
||||
);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user