lot of things done, like custom lesson things
This commit is contained in:
@@ -86,6 +86,7 @@ const userDataDB = DatabaseStruct("user_data", {
|
||||
"roundings": String,
|
||||
"grade_rarities": String,
|
||||
"linked_accounts": String,
|
||||
"custom_lesson_desc": String,
|
||||
});
|
||||
|
||||
Future<void> createTable(Database db, DatabaseStruct struct) =>
|
||||
@@ -153,6 +154,7 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
"roundings": "{}",
|
||||
"grade_rarities": "{}",
|
||||
"linked_accounts": "[]",
|
||||
"custom_lesson_desc": "{}",
|
||||
});
|
||||
} catch (error) {
|
||||
print("ERROR: migrateDB: $error");
|
||||
|
||||
@@ -214,11 +214,13 @@ class UserDatabaseQuery {
|
||||
return lessonCount;
|
||||
}
|
||||
|
||||
Future<DateTime> lastSeen({required String userId, required LastSeenCategory category}) async {
|
||||
Future<DateTime> lastSeen(
|
||||
{required String userId, required LastSeenCategory category}) async {
|
||||
List<Map> userData =
|
||||
await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||
if (userData.isEmpty) return DateTime(0);
|
||||
int? lastSeenDate = userData.elementAt(0)["last_seen_${category.name}"] as int?;
|
||||
int? lastSeenDate =
|
||||
userData.elementAt(0)["last_seen_${category.name}"] as int?;
|
||||
if (lastSeenDate == null) return DateTime(0);
|
||||
DateTime lastSeen = DateTime.fromMillisecondsSinceEpoch(lastSeenDate);
|
||||
return lastSeen;
|
||||
@@ -348,4 +350,15 @@ class UserDatabaseQuery {
|
||||
.toList();
|
||||
return accounts;
|
||||
}
|
||||
|
||||
Future<Map<String, String>> getCustomLessonDescriptions(
|
||||
{required String userId}) async {
|
||||
List<Map> userData =
|
||||
await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||
if (userData.isEmpty) return {};
|
||||
String? descJson = userData.elementAt(0)["custom_lesson_desc"] as String?;
|
||||
if (descJson == null) return {};
|
||||
return (jsonDecode(descJson) as Map)
|
||||
.map((key, value) => MapEntry(key.toString(), value.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,6 @@ class UserDatabaseStore {
|
||||
await db.update("user_data", {"last_seen_${category.name}": lastSeenDate},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
|
||||
// renamed things
|
||||
Future<void> storeRenamedSubjects(Map<String, String> subjects,
|
||||
@@ -218,4 +217,11 @@ class UserDatabaseStore {
|
||||
await db.update("user_data", {"linked_accounts": accountsJson},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
|
||||
Future<void> storeCustomLessonDescriptions(Map<String, String> descs,
|
||||
{required String userId}) async {
|
||||
String descJson = jsonEncode(descs);
|
||||
await db.update("user_data", {"custom_lesson_desc": descJson},
|
||||
where: "id = ?", whereArgs: [userId]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,11 @@ class AppTheme {
|
||||
? settings.customHighlightColor
|
||||
: _paletteHighlightLight(palette)) ??
|
||||
lightColors.highlight;
|
||||
Color textColor = (accentColor == AccentColor.custom
|
||||
? settings.customTextColor
|
||||
: _paletteTextLight(palette)) ??
|
||||
lightColors.text;
|
||||
// Color textColor = (accentColor == AccentColor.custom
|
||||
// ? settings.customTextColor
|
||||
// : _paletteTextLight(palette)) ??
|
||||
// lightColors.text;
|
||||
Color textColor = lightColors.text;
|
||||
|
||||
Color newSecondary = (accentColor == AccentColor.adaptive ||
|
||||
accentColor == AccentColor.custom ||
|
||||
@@ -174,10 +175,11 @@ class AppTheme {
|
||||
? settings.customHighlightColor
|
||||
: _paletteHighlightDark(palette)) ??
|
||||
darkColors.highlight;
|
||||
Color textColor = (accentColor == AccentColor.custom
|
||||
? settings.customTextColor
|
||||
: _paletteTextDark(palette)) ??
|
||||
darkColors.text;
|
||||
// Color textColor = (accentColor == AccentColor.custom
|
||||
// ? settings.customTextColor
|
||||
// : _paletteTextDark(palette)) ??
|
||||
// darkColors.text;
|
||||
Color textColor = darkColors.text;
|
||||
|
||||
Color newSecondary = (accentColor == AccentColor.adaptive ||
|
||||
accentColor == AccentColor.custom ||
|
||||
|
||||
Reference in New Issue
Block a user