forked from firka/student-legacy
Livecardrework (#104)
This commit is contained in:
parent
708c411339
commit
3c431cbce1
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
|||||||
# See https://www.dartlang.org/guides/libraries/private-files
|
# See https://www.dartlang.org/guides/libraries/private-files
|
||||||
|
|
||||||
|
termek.txt
|
||||||
|
|
||||||
# Files and directories created by pub
|
# Files and directories created by pub
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.packages
|
.packages
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
- Újra dizájnolt jegy, stb. nézet
|
||||||
|
- Offline tárolt osztályátlagok
|
||||||
|
- Csengő késésének beállítása
|
||||||
|
- Óra végén a hátralévő idő másodperc pontos kijelzése
|
||||||
|
- Vissza gombra főoldalra ugrás
|
||||||
|
- Eddigi hiányzott órák százalékos kijelzése
|
||||||
|
- Hiányzások tantárgy szerinti rendezése
|
||||||
- Lapozás legyintéssel a tabok között
|
- Lapozás legyintéssel a tabok között
|
||||||
- Hiányzások jelzése az órarenben
|
- Hiányzások jelzése az órarenben
|
||||||
- Fordítás javítások
|
- Fordítás javítások
|
||||||
|
Binary file not shown.
@ -1,5 +0,0 @@
|
|||||||
<svg width="20" height="22" viewBox="0 0 20 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path
|
|
||||||
d="M1 8L10 1L19 8V19C19 19.5304 18.7893 20.0391 18.4142 20.4142C18.0391 20.7893 17.5304 21 17 21H3C2.46957 21 1.96086 20.7893 1.58579 20.4142C1.21071 20.0391 1 19.5304 1 19V8Z"
|
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 384 B |
@ -1,3 +0,0 @@
|
|||||||
<svg width="288" height="288" viewBox="0 0 288 288" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path d="M159.653 207.26C136.598 217.973 115.171 217.858 100.771 216.821C83.6064 215.583 69.7824 210.888 63.72 206.77C59.976 204.236 54.8928 205.215 52.3584 208.959C49.824 212.703 50.8032 217.786 54.5472 220.32C64.3104 226.93 81.5616 231.84 99.5904 233.136C102.643 233.367 105.998 233.496 109.613 233.496C125.309 233.496 145.238 231.999 166.55 222.092C170.64 220.176 172.426 215.324 170.51 211.22C168.61 207.13 163.742 205.344 159.653 207.26ZM250.574 195.135C251.352 124.057 258.667 -10.2371 122.616 0.620487C-11.7072 11.4348 23.904 153.332 21.9024 200.852C20.1312 225.994 11.7936 256.723 0 288H36.3024C40.0464 274.752 42.7824 261.634 43.9632 249.149C46.152 250.675 48.4992 252.144 51.0048 253.555C55.0656 255.96 58.5648 259.143 62.2656 262.512C70.9056 270.389 80.712 279.331 99.864 280.44C101.146 280.512 102.442 280.555 103.709 280.555C123.091 280.555 136.339 272.074 146.995 265.263C152.093 261.994 156.499 259.171 160.646 257.818C172.44 254.131 182.736 248.17 190.426 240.595C191.635 239.415 192.744 238.191 193.795 236.952C198.086 252.663 203.962 270.36 210.47 288H288C269.366 259.258 250.171 231.077 250.574 195.135ZM34.9056 156.471V156.457C33.5664 133.258 44.6688 113.761 59.688 112.882C74.7072 112.004 87.9696 130.105 89.3088 153.289C89.3088 153.303 89.3088 153.303 89.3088 153.303C89.3808 154.556 89.4096 155.794 89.4096 157.018C84.6576 158.213 80.352 159.956 76.5072 161.986C76.4928 161.813 76.4784 161.641 76.464 161.468V161.453C75.1824 148.292 68.1552 138.356 60.7536 139.249C53.3664 140.156 48.4128 151.561 49.7088 164.722C50.2704 170.468 51.912 175.594 54.216 179.482C53.64 179.929 52.0272 181.109 50.1696 182.477C48.7728 183.5 47.0592 184.738 45.0144 186.25C39.4272 178.906 35.5968 168.365 34.9056 156.471ZM187.099 213.797C186.566 226.051 170.525 237.586 155.722 242.208L155.635 242.237C149.472 244.239 143.986 247.752 138.168 251.467C128.405 257.717 118.296 264.183 103.709 264.183C102.744 264.183 101.765 264.154 100.8 264.096C87.4368 263.319 81.1872 257.631 73.2816 250.416C69.1056 246.615 64.7856 242.669 59.2272 239.415L59.0976 239.343C47.088 232.56 39.6288 224.136 39.1536 216.778C38.9232 213.135 40.5504 209.967 43.992 207.389C51.48 201.773 56.5056 198.101 59.8176 195.668C63.504 192.975 64.6272 192.168 65.448 191.376C66.0384 190.829 66.672 190.21 67.3632 189.533C74.232 182.852 85.7376 171.663 103.406 171.663C114.206 171.663 126.158 175.825 138.888 184.004C144.878 187.906 150.106 189.706 156.715 191.996C161.251 193.565 166.406 195.336 173.304 198.288L173.419 198.346C179.842 200.981 187.445 205.805 187.099 213.783V213.797ZM183.557 184.997C182.318 184.378 181.022 183.788 179.683 183.226C173.462 180.576 168.48 178.762 164.347 177.322C166.637 172.858 168.048 167.285 168.178 161.223C168.494 146.492 161.064 134.525 151.589 134.511C142.099 134.482 134.165 146.405 133.848 161.137C133.834 161.626 133.834 162.101 133.848 162.577C128.002 159.898 122.256 157.94 116.64 156.745C116.611 156.183 116.582 155.636 116.568 155.074V155.06C116.021 128.233 132.494 106.014 153.346 105.452C174.197 104.89 191.549 126.174 192.096 153.015V153.029C192.341 165.169 189.101 176.329 183.557 184.997Z" fill="black"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 3.2 KiB |
@ -24,7 +24,7 @@ class UserProvider with ChangeNotifier {
|
|||||||
void addUser(User user) {
|
void addUser(User user) {
|
||||||
_users[user.id] = user;
|
_users[user.id] = user;
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print("DEBUG: Added User: ${user.id} ${user.name}");
|
print("DEBUG: Added User: ${user.id}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:dynamic_color/dynamic_color.dart';
|
||||||
import 'package:filcnaplo/api/client.dart';
|
import 'package:filcnaplo/api/client.dart';
|
||||||
import 'package:filcnaplo/api/providers/news_provider.dart';
|
import 'package:filcnaplo/api/providers/news_provider.dart';
|
||||||
import 'package:filcnaplo/api/providers/database_provider.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
@ -18,6 +19,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:i18n_extension/i18n_widget.dart';
|
import 'package:i18n_extension/i18n_widget.dart';
|
||||||
|
import 'package:material_color_utilities/palettes/core_palette.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
// Providers
|
// Providers
|
||||||
@ -51,12 +53,14 @@ class App extends StatelessWidget {
|
|||||||
// Set high refresh mode #28
|
// Set high refresh mode #28
|
||||||
if (Platform.isAndroid) FlutterDisplayMode.setHighRefreshRate();
|
if (Platform.isAndroid) FlutterDisplayMode.setHighRefreshRate();
|
||||||
|
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
FilcAPI.getConfig(settings).then((Config? config) {
|
FilcAPI.getConfig(settings).then((Config? config) {
|
||||||
if (config != null) settings.update(context, database: database, config: config);
|
if (config != null) settings.update(context, database: database, config: config);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CorePalette? corePalette;
|
||||||
|
|
||||||
return I18n(
|
return I18n(
|
||||||
initialLocale: Locale(settings.language, settings.language.toUpperCase()),
|
initialLocale: Locale(settings.language, settings.language.toUpperCase()),
|
||||||
child: MultiProvider(
|
child: MultiProvider(
|
||||||
@ -84,45 +88,55 @@ class App extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
child: Consumer<ThemeModeObserver>(
|
child: Consumer<ThemeModeObserver>(
|
||||||
builder: (context, themeMode, child) {
|
builder: (context, themeMode, child) {
|
||||||
return MaterialApp(
|
return FutureBuilder<CorePalette?>(
|
||||||
builder: (context, child) {
|
future: DynamicColorPlugin.getCorePalette(),
|
||||||
// Limit font size scaling to 1.0
|
builder: (context, snapshot) {
|
||||||
double textScaleFactor = min(MediaQuery.of(context).textScaleFactor, 1.0);
|
corePalette = snapshot.data;
|
||||||
|
return MaterialApp(
|
||||||
|
builder: (context, child) {
|
||||||
|
// Limit font size scaling to 1.0
|
||||||
|
double textScaleFactor = min(MediaQuery.of(context).textScaleFactor, 1.0);
|
||||||
|
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor),
|
data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor),
|
||||||
child: child ?? Container(),
|
child: SafeArea(
|
||||||
);
|
top: false,
|
||||||
},
|
child: child ?? Container(),
|
||||||
title: "Filc Napló",
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
);
|
||||||
theme: AppTheme.lightTheme(context),
|
},
|
||||||
darkTheme: AppTheme.darkTheme(context),
|
title: "Filc Napló",
|
||||||
themeMode: themeMode.themeMode,
|
debugShowCheckedModeBanner: false,
|
||||||
localizationsDelegates: const [
|
theme: AppTheme.lightTheme(context, palette: corePalette),
|
||||||
GlobalMaterialLocalizations.delegate,
|
darkTheme: AppTheme.darkTheme(context, palette: corePalette),
|
||||||
GlobalWidgetsLocalizations.delegate,
|
themeMode: themeMode.themeMode,
|
||||||
GlobalCupertinoLocalizations.delegate,
|
localizationsDelegates: const [
|
||||||
],
|
GlobalMaterialLocalizations.delegate,
|
||||||
supportedLocales: const [
|
GlobalWidgetsLocalizations.delegate,
|
||||||
Locale('en', 'EN'),
|
GlobalCupertinoLocalizations.delegate,
|
||||||
Locale('hu', 'HU'),
|
],
|
||||||
Locale('de', 'DE'),
|
supportedLocales: const [
|
||||||
],
|
Locale('en', 'EN'),
|
||||||
localeListResolutionCallback: (locales, supported) {
|
Locale('hu', 'HU'),
|
||||||
Locale locale = const Locale('hu', 'HU');
|
Locale('de', 'DE'),
|
||||||
|
],
|
||||||
|
localeListResolutionCallback: (locales, supported) {
|
||||||
|
Locale locale = const Locale('hu', 'HU');
|
||||||
|
|
||||||
for (var loc in locales ?? []) {
|
for (var loc in locales ?? []) {
|
||||||
if (supported.contains(loc)) {
|
if (supported.contains(loc)) {
|
||||||
locale = loc;
|
locale = loc;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return locale;
|
return locale;
|
||||||
},
|
},
|
||||||
onGenerateRoute: (settings) => rootNavigator(settings),
|
onGenerateRoute: (settings) => rootNavigator(settings),
|
||||||
initialRoute: user.getUsers().isNotEmpty ? "navigation" : "login");
|
initialRoute: user.getUsers().isNotEmpty ? "navigation" : "login",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -7,6 +7,24 @@ import 'package:filcnaplo/models/settings.dart';
|
|||||||
import 'package:sqflite/sqflite.dart';
|
import 'package:sqflite/sqflite.dart';
|
||||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||||
|
|
||||||
|
const settingsDB = DatabaseStruct("settings", {
|
||||||
|
"language": String, "start_page": int, "rounding": int, "theme": int, "accent_color": int, "news": int, "news_state": int, "developer_mode": int,
|
||||||
|
"update_channel": int, "config": String, // general
|
||||||
|
"grade_color1": int, "grade_color2": int, "grade_color3": int, "grade_color4": int, "grade_color5": int, // grade colors
|
||||||
|
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
|
||||||
|
"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,
|
||||||
|
});
|
||||||
|
const usersDB = DatabaseStruct(
|
||||||
|
"users", {"id": String, "name": String, "username": String, "password": String, "institute_code": String, "student": String, "role": int});
|
||||||
|
const userDataDB = DatabaseStruct("user_data", {
|
||||||
|
"id": String, "grades": String, "timetable": String, "exams": String, "homework": String, "messages": String, "notes": String,
|
||||||
|
"events": String, "absences": String, "group_averages": String,
|
||||||
|
// "subject_lesson_count": String, // non kreta data
|
||||||
|
});
|
||||||
|
|
||||||
|
Future<void> createTable(Database db, DatabaseStruct struct) => db.execute("CREATE TABLE IF NOT EXISTS ${struct.table} ($struct)");
|
||||||
|
|
||||||
Future<Database> initDB() async {
|
Future<Database> initDB() async {
|
||||||
Database db;
|
Database db;
|
||||||
|
|
||||||
@ -17,13 +35,9 @@ Future<Database> initDB() async {
|
|||||||
db = await openDatabase("app.db");
|
db = await openDatabase("app.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create table Users
|
await createTable(db, settingsDB);
|
||||||
var usersDB = await createUsersTable(db);
|
await createTable(db, usersDB);
|
||||||
await db.execute("CREATE TABLE IF NOT EXISTS user_data ("
|
await createTable(db, userDataDB);
|
||||||
"id TEXT NOT NULL, grades TEXT, timetable TEXT, exams TEXT, homework TEXT, messages TEXT, notes TEXT, events TEXT, absences TEXT)");
|
|
||||||
|
|
||||||
// Create table Settings
|
|
||||||
var settingsDB = await createSettingsTable(db);
|
|
||||||
|
|
||||||
if ((await db.rawQuery("SELECT COUNT(*) FROM settings"))[0].values.first == 0) {
|
if ((await db.rawQuery("SELECT COUNT(*) FROM settings"))[0].values.first == 0) {
|
||||||
// Set default values for table Settings
|
// Set default values for table Settings
|
||||||
@ -32,8 +46,21 @@ Future<Database> initDB() async {
|
|||||||
|
|
||||||
// Migrate Databases
|
// Migrate Databases
|
||||||
try {
|
try {
|
||||||
await migrateDB(db, "settings", settingsDB.struct.keys, SettingsProvider.defaultSettings().toMap(), createSettingsTable);
|
await migrateDB(
|
||||||
await migrateDB(db, "users", usersDB.struct.keys, {"role": 0}, createUsersTable);
|
db,
|
||||||
|
struct: settingsDB,
|
||||||
|
defaultValues: SettingsProvider.defaultSettings().toMap(),
|
||||||
|
);
|
||||||
|
await migrateDB(
|
||||||
|
db,
|
||||||
|
struct: usersDB,
|
||||||
|
defaultValues: {"role": 0},
|
||||||
|
);
|
||||||
|
await migrateDB(db, struct: userDataDB, defaultValues: {
|
||||||
|
"grades": "[]", "timetable": "[]", "exams": "[]", "homework": "[]", "messages": "[]", "notes": "[]", "events": "[]", "absences": "[]",
|
||||||
|
"group_averages": "[]",
|
||||||
|
// "subject_lesson_count": "{}", // non kreta data
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("ERROR: migrateDB: $error");
|
print("ERROR: migrateDB: $error");
|
||||||
}
|
}
|
||||||
@ -41,44 +68,16 @@ Future<Database> initDB() async {
|
|||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<DatabaseStruct> createSettingsTable(Database db) async {
|
|
||||||
var settingsDB = DatabaseStruct({
|
|
||||||
"language": String, "start_page": int, "rounding": int, "theme": int, "accent_color": int, "news": int, "news_state": int, "developer_mode": int,
|
|
||||||
"update_channel": int, "config": String, // general
|
|
||||||
"grade_color1": int, "grade_color2": int, "grade_color3": int, "grade_color4": int, "grade_color5": int, // grade colors
|
|
||||||
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
|
|
||||||
"notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications
|
|
||||||
"x_filc_id": String, "graph_class_avg": int,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create table Settings
|
|
||||||
await db.execute("CREATE TABLE IF NOT EXISTS settings ($settingsDB)");
|
|
||||||
|
|
||||||
return settingsDB;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<DatabaseStruct> createUsersTable(Database db) async {
|
|
||||||
var usersDB = DatabaseStruct(
|
|
||||||
{"id": String, "name": String, "username": String, "password": String, "institute_code": String, "student": String, "role": int});
|
|
||||||
|
|
||||||
// Create table Users
|
|
||||||
await db.execute("CREATE TABLE IF NOT EXISTS users ($usersDB)");
|
|
||||||
|
|
||||||
return usersDB;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> migrateDB(
|
Future<void> migrateDB(
|
||||||
Database db,
|
Database db, {
|
||||||
String table,
|
required DatabaseStruct struct,
|
||||||
Iterable<String> keys,
|
required Map<String, Object?> defaultValues,
|
||||||
Map<String, Object?> defaultValues,
|
}) async {
|
||||||
Future<DatabaseStruct> Function(Database) create,
|
var originalRows = await db.query(struct.table);
|
||||||
) async {
|
|
||||||
var originalRows = await db.query(table);
|
|
||||||
|
|
||||||
if (originalRows.isEmpty) {
|
if (originalRows.isEmpty) {
|
||||||
await db.execute("drop table $table");
|
await db.execute("drop table ${struct.table}");
|
||||||
await create(db);
|
await createTable(db, struct);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,25 +85,28 @@ Future<void> migrateDB(
|
|||||||
|
|
||||||
// go through each row and add missing keys or delete non existing keys
|
// go through each row and add missing keys or delete non existing keys
|
||||||
await Future.forEach<Map<String, Object?>>(originalRows, (original) async {
|
await Future.forEach<Map<String, Object?>>(originalRows, (original) async {
|
||||||
bool migrationRequired = keys.any((key) => !original.containsKey(key) || original[key] == null);
|
bool migrationRequired = struct.struct.keys.any((key) => !original.containsKey(key) || original[key] == null) ||
|
||||||
|
original.keys.any((key) => !struct.struct.containsKey(key));
|
||||||
|
|
||||||
if (migrationRequired) {
|
if (migrationRequired) {
|
||||||
print("INFO: Migrating $table");
|
print("INFO: Migrating ${struct.table}");
|
||||||
var copy = Map<String, Object?>.from(original);
|
var copy = Map<String, Object?>.from(original);
|
||||||
|
|
||||||
// Fill missing columns
|
// Fill missing columns
|
||||||
for (var key in keys) {
|
for (var key in struct.struct.keys) {
|
||||||
if (!keys.contains(key)) {
|
|
||||||
print("DEBUG: dropping $key");
|
|
||||||
copy.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!original.containsKey(key) || original[key] == null) {
|
if (!original.containsKey(key) || original[key] == null) {
|
||||||
print("DEBUG: migrating $key");
|
print("DEBUG: migrating $key");
|
||||||
copy[key] = defaultValues[key];
|
copy[key] = defaultValues[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var key in original.keys) {
|
||||||
|
if (!struct.struct.keys.contains(key)) {
|
||||||
|
print("DEBUG: dropping $key");
|
||||||
|
copy.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
migrated.add(copy);
|
migrated.add(copy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -112,12 +114,12 @@ Future<void> migrateDB(
|
|||||||
// replace the old table with the migrated one
|
// replace the old table with the migrated one
|
||||||
if (migrated.isNotEmpty) {
|
if (migrated.isNotEmpty) {
|
||||||
// Delete table
|
// Delete table
|
||||||
await db.execute("drop table $table");
|
await db.execute("drop table ${struct.table}");
|
||||||
|
|
||||||
// Recreate table
|
// Recreate table
|
||||||
await create(db);
|
await createTable(db, struct);
|
||||||
await Future.forEach(migrated, (Map<String, Object?> copy) async {
|
await Future.forEach(migrated, (Map<String, Object?> copy) async {
|
||||||
await db.insert(table, copy);
|
await db.insert(struct.table, copy);
|
||||||
});
|
});
|
||||||
|
|
||||||
print("INFO: Database migrated");
|
print("INFO: Database migrated");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
||||||
import 'package:filcnaplo/models/user.dart';
|
import 'package:filcnaplo/models/user.dart';
|
||||||
import 'package:sqflite_common/sqlite_api.dart';
|
import 'package:sqflite_common/sqlite_api.dart';
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ import 'package:filcnaplo_kreta_api/models/message.dart';
|
|||||||
import 'package:filcnaplo_kreta_api/models/note.dart';
|
import 'package:filcnaplo_kreta_api/models/note.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/event.dart';
|
import 'package:filcnaplo_kreta_api/models/event.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/group_average.dart';
|
||||||
|
|
||||||
class DatabaseQuery {
|
class DatabaseQuery {
|
||||||
DatabaseQuery({required this.db});
|
DatabaseQuery({required this.db});
|
||||||
@ -106,9 +108,27 @@ class UserDatabaseQuery {
|
|||||||
Future<List<Absence>> getAbsences({required String userId}) async {
|
Future<List<Absence>> getAbsences({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? absebcesJson = userData.elementAt(0)["absences"] as String?;
|
String? absencesJson = userData.elementAt(0)["absences"] as String?;
|
||||||
if (absebcesJson == null) return [];
|
if (absencesJson == null) return [];
|
||||||
List<Absence> absebces = (jsonDecode(absebcesJson) as List).map((e) => Absence.fromJson(e)).toList();
|
List<Absence> absences = (jsonDecode(absencesJson) as List).map((e) => Absence.fromJson(e)).toList();
|
||||||
return absebces;
|
return absences;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<GroupAverage>> getGroupAverages({required String userId}) async {
|
||||||
|
List<Map> userData = await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||||
|
if (userData.isEmpty) return [];
|
||||||
|
String? groupAveragesJson = userData.elementAt(0)["group_averages"] as String?;
|
||||||
|
if (groupAveragesJson == null) return [];
|
||||||
|
List<GroupAverage> groupAverages = (jsonDecode(groupAveragesJson) as List).map((e) => GroupAverage.fromJson(e)).toList();
|
||||||
|
return groupAverages;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<SubjectLessonCount> getSubjectLessonCount({required String userId}) async {
|
||||||
|
List<Map> userData = await db.query("user_data", where: "id = ?", whereArgs: [userId]);
|
||||||
|
if (userData.isEmpty) return SubjectLessonCount.fromMap({});
|
||||||
|
String? lessonCountJson = userData.elementAt(0)["subject_lesson_count"] as String?;
|
||||||
|
if (lessonCountJson == null) return SubjectLessonCount.fromMap({});
|
||||||
|
SubjectLessonCount lessonCount = SubjectLessonCount.fromMap(jsonDecode(lessonCountJson) as Map);
|
||||||
|
return lessonCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:filcnaplo/models/subject_lesson_count.dart';
|
||||||
import 'package:sqflite_common/sqlite_api.dart';
|
import 'package:sqflite_common/sqlite_api.dart';
|
||||||
|
|
||||||
// Models
|
// Models
|
||||||
@ -12,6 +13,7 @@ import 'package:filcnaplo_kreta_api/models/message.dart';
|
|||||||
import 'package:filcnaplo_kreta_api/models/note.dart';
|
import 'package:filcnaplo_kreta_api/models/note.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/event.dart';
|
import 'package:filcnaplo_kreta_api/models/event.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/group_average.dart';
|
||||||
|
|
||||||
class DatabaseStore {
|
class DatabaseStore {
|
||||||
DatabaseStore({required this.db});
|
DatabaseStore({required this.db});
|
||||||
@ -43,43 +45,54 @@ class UserDatabaseStore {
|
|||||||
|
|
||||||
final Database db;
|
final Database db;
|
||||||
|
|
||||||
Future storeGrades(List<Grade> grades, {required String userId}) async {
|
Future<void> storeGrades(List<Grade> grades, {required String userId}) async {
|
||||||
String gradesJson = jsonEncode(grades.map((e) => e.json).toList());
|
String gradesJson = jsonEncode(grades.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"grades": gradesJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"grades": gradesJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeLessons(List<Lesson> lessons, {required String userId}) async {
|
Future<void> storeLessons(List<Lesson> lessons, {required String userId}) async {
|
||||||
String lessonsJson = jsonEncode(lessons.map((e) => e.json).toList());
|
String lessonsJson = jsonEncode(lessons.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"timetable": lessonsJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"timetable": lessonsJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeExams(List<Exam> exams, {required String userId}) async {
|
Future<void> storeExams(List<Exam> exams, {required String userId}) async {
|
||||||
String examsJson = jsonEncode(exams.map((e) => e.json).toList());
|
String examsJson = jsonEncode(exams.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"exams": examsJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"exams": examsJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeHomework(List<Homework> homework, {required String userId}) async {
|
Future<void> storeHomework(List<Homework> homework, {required String userId}) async {
|
||||||
String homeworkJson = jsonEncode(homework.map((e) => e.json).toList());
|
String homeworkJson = jsonEncode(homework.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"homework": homeworkJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"homework": homeworkJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeMessages(List<Message> messages, {required String userId}) async {
|
Future<void> storeMessages(List<Message> messages, {required String userId}) async {
|
||||||
String messagesJson = jsonEncode(messages.map((e) => e.json).toList());
|
String messagesJson = jsonEncode(messages.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"messages": messagesJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"messages": messagesJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeNotes(List<Note> notes, {required String userId}) async {
|
Future<void> storeNotes(List<Note> notes, {required String userId}) async {
|
||||||
String notesJson = jsonEncode(notes.map((e) => e.json).toList());
|
String notesJson = jsonEncode(notes.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"notes": notesJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"notes": notesJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeEvents(List<Event> events, {required String userId}) async {
|
Future<void> storeEvents(List<Event> events, {required String userId}) async {
|
||||||
String eventsJson = jsonEncode(events.map((e) => e.json).toList());
|
String eventsJson = jsonEncode(events.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"events": eventsJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"events": eventsJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeAbsences(List<Absence> absences, {required String userId}) async {
|
Future<void> storeAbsences(List<Absence> absences, {required String userId}) async {
|
||||||
String absencesJson = jsonEncode(absences.map((e) => e.json).toList());
|
String absencesJson = jsonEncode(absences.map((e) => e.json).toList());
|
||||||
await db.update("user_data", {"absences": absencesJson}, where: "id = ?", whereArgs: [userId]);
|
await db.update("user_data", {"absences": absencesJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> storeGroupAverages(List<GroupAverage> groupAverages, {required String userId}) async {
|
||||||
|
String groupAveragesJson = jsonEncode(groupAverages.map((e) => e.json).toList());
|
||||||
|
await db.update("user_data", {"group_averages": groupAveragesJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<void> storeSubjectLessonCount(SubjectLessonCount lessonCount, {required String userId}) async {
|
||||||
|
String lessonCountJson = jsonEncode(lessonCount.toMap());
|
||||||
|
await db.update("user_data", {"subject_lesson_count": lessonCountJson}, where: "id = ?", whereArgs: [userId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
class DatabaseStruct {
|
class DatabaseStruct {
|
||||||
|
final String table;
|
||||||
final Map<String, dynamic> struct;
|
final Map<String, dynamic> struct;
|
||||||
|
|
||||||
DatabaseStruct(this.struct);
|
const DatabaseStruct(this.table, this.struct);
|
||||||
|
|
||||||
String _toDBfield(String name, dynamic type) {
|
String _toDBfield(String name, dynamic type) {
|
||||||
String typeName = "";
|
String typeName = "";
|
||||||
|
@ -35,7 +35,7 @@ class SubjectIcon {
|
|||||||
if (RegExp("technika").hasMatch(name)) return Icons.build_outlined;
|
if (RegExp("technika").hasMatch(name)) return Icons.build_outlined;
|
||||||
if (RegExp("tanc").hasMatch(name)) return Icons.speaker_outlined;
|
if (RegExp("tanc").hasMatch(name)) return Icons.speaker_outlined;
|
||||||
if (RegExp("filozofia").hasMatch(name)) return Icons.psychology_outlined;
|
if (RegExp("filozofia").hasMatch(name)) return Icons.psychology_outlined;
|
||||||
if (RegExp("osztaly(fonoki|kozosseg)").hasMatch(name)) return Icons.groups_outlined;
|
if (RegExp("osztaly(fonoki|kozosseg)").hasMatch(name) || name == "ofo") return Icons.groups_outlined;
|
||||||
if (RegExp("gazdasag").hasMatch(name)) return Icons.account_balance_outlined;
|
if (RegExp("gazdasag").hasMatch(name)) return Icons.account_balance_outlined;
|
||||||
if (RegExp("szorgalom").hasMatch(name)) return Icons.verified_outlined;
|
if (RegExp("szorgalom").hasMatch(name)) return Icons.verified_outlined;
|
||||||
if (RegExp("magatartas").hasMatch(name)) return Icons.emoji_people_outlined;
|
if (RegExp("magatartas").hasMatch(name)) return Icons.emoji_people_outlined;
|
||||||
|
@ -32,7 +32,7 @@ extension UpdateHelper on Release {
|
|||||||
|
|
||||||
if (result.type != ResultType.done) {
|
if (result.type != ResultType.done) {
|
||||||
// ignore: avoid_print
|
// ignore: avoid_print
|
||||||
print("ERROR: installUpdate.openFile: " + result.message);
|
print("ERROR: installUpdate.openFile: ${result.message}");
|
||||||
throw result.message;
|
throw result.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
class FilcIcons {
|
class FilcIcons {
|
||||||
static const IconData home = FilcIconData(0x41);
|
FilcIcons._();
|
||||||
static const IconData linux = FilcIconData(0x42);
|
|
||||||
}
|
|
||||||
|
|
||||||
class FilcIconData extends IconData {
|
static const iconFontFamily = 'FilcIcons';
|
||||||
const FilcIconData(int codePoint) : super(codePoint, fontFamily: "FilcIcons");
|
|
||||||
|
/// home
|
||||||
|
static const IconData home = IconData(0x00, fontFamily: iconFontFamily);
|
||||||
|
|
||||||
|
/// linux
|
||||||
|
static const IconData linux = IconData(0x01, fontFamily: iconFontFamily);
|
||||||
|
|
||||||
|
/// upstairs
|
||||||
|
static const IconData upstairs = IconData(0x02, fontFamily: iconFontFamily);
|
||||||
|
|
||||||
|
/// downstairs
|
||||||
|
static const IconData downstairs = IconData(0x03, fontFamily: iconFontFamily);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ Widget errorBuilder(FlutterErrorDetails details) {
|
|||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
if (Navigator.of(context).canPop()) Navigator.pop(context);
|
if (Navigator.of(context).canPop()) Navigator.pop(context);
|
||||||
|
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (!errorShown && details.exceptionAsString() != lastException) {
|
if (!errorShown && details.exceptionAsString() != lastException) {
|
||||||
errorShown = true;
|
errorShown = true;
|
||||||
lastException = details.exceptionAsString();
|
lastException = details.exceptionAsString();
|
||||||
|
@ -127,7 +127,7 @@ class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const zero = Version(0, 0, 0);
|
static const zero = Version(0, 0, 0);
|
||||||
static const List<String> prereleases = ["dev", "pre", "alpha", "beta", "rc"];
|
static const List<String> prereleases = ["dev", "pre", "alpha", "beta", "rc", "nightly", "test"];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => toString().hashCode;
|
int get hashCode => toString().hashCode;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:filcnaplo/api/providers/database_provider.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
import 'package:filcnaplo/models/config.dart';
|
import 'package:filcnaplo/models/config.dart';
|
||||||
@ -8,7 +9,9 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
enum Pages { home, grades, timetable, messages, absences }
|
enum Pages { home, grades, timetable, messages, absences }
|
||||||
|
|
||||||
enum UpdateChannel { stable, beta, dev }
|
enum UpdateChannel { stable, beta, dev }
|
||||||
|
|
||||||
enum VibrationStrength { off, light, medium, strong }
|
enum VibrationStrength { off, light, medium, strong }
|
||||||
|
|
||||||
class SettingsProvider extends ChangeNotifier {
|
class SettingsProvider extends ChangeNotifier {
|
||||||
@ -47,6 +50,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
Config _config;
|
Config _config;
|
||||||
String _xFilcId;
|
String _xFilcId;
|
||||||
bool _graphClassAvg;
|
bool _graphClassAvg;
|
||||||
|
bool _goodStudent;
|
||||||
|
bool _presentationMode;
|
||||||
|
bool _bellDelayEnabled;
|
||||||
|
int _bellDelay;
|
||||||
|
|
||||||
SettingsProvider({
|
SettingsProvider({
|
||||||
required String language,
|
required String language,
|
||||||
@ -68,6 +75,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
required Config config,
|
required Config config,
|
||||||
required String xFilcId,
|
required String xFilcId,
|
||||||
required bool graphClassAvg,
|
required bool graphClassAvg,
|
||||||
|
required bool goodStudent,
|
||||||
|
required bool presentationMode,
|
||||||
|
required bool bellDelayEnabled,
|
||||||
|
required int bellDelay,
|
||||||
}) : _language = language,
|
}) : _language = language,
|
||||||
_startPage = startPage,
|
_startPage = startPage,
|
||||||
_rounding = rounding,
|
_rounding = rounding,
|
||||||
@ -86,9 +97,21 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
_updateChannel = updateChannel,
|
_updateChannel = updateChannel,
|
||||||
_config = config,
|
_config = config,
|
||||||
_xFilcId = xFilcId,
|
_xFilcId = xFilcId,
|
||||||
_graphClassAvg = graphClassAvg;
|
_graphClassAvg = graphClassAvg,
|
||||||
|
_goodStudent = goodStudent,
|
||||||
|
_presentationMode = presentationMode,
|
||||||
|
_bellDelayEnabled = bellDelayEnabled,
|
||||||
|
_bellDelay = bellDelay;
|
||||||
|
|
||||||
factory SettingsProvider.fromMap(Map map) {
|
factory SettingsProvider.fromMap(Map map) {
|
||||||
|
Map<String, Object?>? configMap;
|
||||||
|
|
||||||
|
try {
|
||||||
|
configMap = jsonDecode(map["config"] ?? "{}");
|
||||||
|
} catch (e) {
|
||||||
|
log("[ERROR] SettingsProvider.fromMap: $e");
|
||||||
|
}
|
||||||
|
|
||||||
return SettingsProvider(
|
return SettingsProvider(
|
||||||
language: map["language"],
|
language: map["language"],
|
||||||
startPage: Pages.values[map["start_page"]],
|
startPage: Pages.values[map["start_page"]],
|
||||||
@ -112,9 +135,13 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
abWeeks: map["ab_weeks"] == 1,
|
abWeeks: map["ab_weeks"] == 1,
|
||||||
swapABweeks: map["swap_ab_weeks"] == 1,
|
swapABweeks: map["swap_ab_weeks"] == 1,
|
||||||
updateChannel: UpdateChannel.values[map["update_channel"]],
|
updateChannel: UpdateChannel.values[map["update_channel"]],
|
||||||
config: Config.fromJson(jsonDecode(map["config"] ?? "{}")),
|
config: Config.fromJson(configMap ?? {}),
|
||||||
xFilcId: map["x_filc_id"],
|
xFilcId: map["x_filc_id"],
|
||||||
graphClassAvg: map["graph_class_avg"] == 1,
|
graphClassAvg: map["graph_class_avg"] == 1,
|
||||||
|
goodStudent: false,
|
||||||
|
presentationMode: map["presentation_mode"] == 1,
|
||||||
|
bellDelayEnabled: map["bell_delay_enabled"] == 1,
|
||||||
|
bellDelay: map["bell_delay"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +170,9 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
"config": jsonEncode(config.json),
|
"config": jsonEncode(config.json),
|
||||||
"x_filc_id": _xFilcId,
|
"x_filc_id": _xFilcId,
|
||||||
"graph_class_avg": _graphClassAvg ? 1 : 0,
|
"graph_class_avg": _graphClassAvg ? 1 : 0,
|
||||||
|
"presentation_mode": _presentationMode ? 1 : 0,
|
||||||
|
"bell_delay_enabled": _bellDelayEnabled ? 1 : 0,
|
||||||
|
"bell_delay": _bellDelay,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +203,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
config: Config.fromJson({}),
|
config: Config.fromJson({}),
|
||||||
xFilcId: const Uuid().v4(),
|
xFilcId: const Uuid().v4(),
|
||||||
graphClassAvg: false,
|
graphClassAvg: false,
|
||||||
|
goodStudent: false,
|
||||||
|
presentationMode: false,
|
||||||
|
bellDelayEnabled: false,
|
||||||
|
bellDelay: 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,10 +230,15 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
Config get config => _config;
|
Config get config => _config;
|
||||||
String get xFilcId => _xFilcId;
|
String get xFilcId => _xFilcId;
|
||||||
bool get graphClassAvg => _graphClassAvg;
|
bool get graphClassAvg => _graphClassAvg;
|
||||||
|
bool get goodStudent => _goodStudent;
|
||||||
|
bool get presentationMode => _presentationMode;
|
||||||
|
bool get bellDelayEnabled => _bellDelayEnabled;
|
||||||
|
int get bellDelay => _bellDelay;
|
||||||
|
|
||||||
Future<void> update(
|
Future<void> update(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
DatabaseProvider? database,
|
DatabaseProvider? database,
|
||||||
|
bool store = true,
|
||||||
String? language,
|
String? language,
|
||||||
Pages? startPage,
|
Pages? startPage,
|
||||||
int? rounding,
|
int? rounding,
|
||||||
@ -219,6 +258,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
Config? config,
|
Config? config,
|
||||||
String? xFilcId,
|
String? xFilcId,
|
||||||
bool? graphClassAvg,
|
bool? graphClassAvg,
|
||||||
|
bool? goodStudent,
|
||||||
|
bool? presentationMode,
|
||||||
|
bool? bellDelayEnabled,
|
||||||
|
int? bellDelay,
|
||||||
}) async {
|
}) async {
|
||||||
if (language != null && language != _language) _language = language;
|
if (language != null && language != _language) _language = language;
|
||||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||||
@ -241,9 +284,13 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
if (config != null && config != _config) _config = config;
|
if (config != null && config != _config) _config = config;
|
||||||
if (xFilcId != null && xFilcId != _xFilcId) _xFilcId = xFilcId;
|
if (xFilcId != null && xFilcId != _xFilcId) _xFilcId = xFilcId;
|
||||||
if (graphClassAvg != null && graphClassAvg != _graphClassAvg) _graphClassAvg = graphClassAvg;
|
if (graphClassAvg != null && graphClassAvg != _graphClassAvg) _graphClassAvg = graphClassAvg;
|
||||||
|
if (goodStudent != null) _goodStudent = goodStudent;
|
||||||
|
if (presentationMode != null && presentationMode != _presentationMode) _presentationMode = presentationMode;
|
||||||
|
if (bellDelay != null && bellDelay != _bellDelay) _bellDelay = bellDelay;
|
||||||
|
if (bellDelayEnabled != null && bellDelayEnabled != _bellDelayEnabled) _bellDelayEnabled = bellDelayEnabled;
|
||||||
|
|
||||||
database ??= Provider.of<DatabaseProvider>(context, listen: false);
|
database ??= Provider.of<DatabaseProvider>(context, listen: false);
|
||||||
await database.store.storeSettings(this);
|
if (store) await database.store.storeSettings(this);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
filcnaplo/lib/models/subject_lesson_count.dart
Normal file
31
filcnaplo/lib/models/subject_lesson_count.dart
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import 'package:filcnaplo_kreta_api/models/category.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/subject.dart';
|
||||||
|
|
||||||
|
enum SubjectLessonCountUpdateState { ready, updating }
|
||||||
|
|
||||||
|
class SubjectLessonCount {
|
||||||
|
DateTime lastUpdated;
|
||||||
|
Map<Subject, int> subjects;
|
||||||
|
SubjectLessonCountUpdateState state;
|
||||||
|
|
||||||
|
SubjectLessonCount({required this.lastUpdated, required this.subjects, this.state = SubjectLessonCountUpdateState.ready});
|
||||||
|
|
||||||
|
factory SubjectLessonCount.fromMap(Map json) {
|
||||||
|
return SubjectLessonCount(
|
||||||
|
lastUpdated: DateTime.fromMillisecondsSinceEpoch(json["last_updated"] ?? 0),
|
||||||
|
subjects: ((json["subjects"] as Map?) ?? {}).map(
|
||||||
|
(key, value) => MapEntry(
|
||||||
|
Subject(id: key, name: "", category: Category.fromJson({})),
|
||||||
|
value,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map toMap() {
|
||||||
|
return {
|
||||||
|
"last_updated": lastUpdated.millisecondsSinceEpoch,
|
||||||
|
"subjects": subjects.map((key, value) => MapEntry(key.id, value)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:filcnaplo/models/settings.dart';
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:material_color_utilities/material_color_utilities.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class AppTheme {
|
class AppTheme {
|
||||||
@ -8,56 +9,116 @@ class AppTheme {
|
|||||||
|
|
||||||
static const String _fontFamily = "Montserrat";
|
static const String _fontFamily = "Montserrat";
|
||||||
|
|
||||||
|
static Color? _paletteAccentLight(CorePalette? palette) => palette != null ? Color(palette.primary.get(70)) : null;
|
||||||
|
static Color? _paletteHighlightLight(CorePalette? palette) => palette != null ? Color(palette.neutral.get(100)) : null;
|
||||||
|
static Color? _paletteBackgroundLight(CorePalette? palette) => palette != null ? Color(palette.neutral.get(95)) : null;
|
||||||
|
|
||||||
|
static Color? _paletteAccentDark(CorePalette? palette) => palette != null ? Color(palette.primary.get(80)) : null;
|
||||||
|
static Color? _paletteBackgroundDark(CorePalette? palette) => palette != null ? Color(palette.neutralVariant.get(10)) : null;
|
||||||
|
static Color? _paletteHighlightDark(CorePalette? palette) => palette != null ? Color(palette.neutralVariant.get(20)) : null;
|
||||||
|
|
||||||
// Light Theme
|
// Light Theme
|
||||||
static ThemeData lightTheme(BuildContext context) {
|
static ThemeData lightTheme(BuildContext context, {CorePalette? palette}) {
|
||||||
var lightColors = LightAppColors();
|
var lightColors = LightAppColors();
|
||||||
Color accent = accentColorMap[Provider.of<SettingsProvider>(context, listen: false).accentColor] ?? const Color(0x00000000);
|
AccentColor accentColor = Provider.of<SettingsProvider>(context, listen: false).accentColor;
|
||||||
|
Color accent = accentColorMap[accentColor] ?? const Color(0x00000000);
|
||||||
|
|
||||||
|
if (accentColor == AccentColor.adaptive) {
|
||||||
|
if (palette != null) accent = _paletteAccentLight(palette)!;
|
||||||
|
} else {
|
||||||
|
palette = null;
|
||||||
|
}
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
|
brightness: Brightness.light,
|
||||||
|
fontFamily: _fontFamily,
|
||||||
|
scaffoldBackgroundColor: _paletteBackgroundLight(palette) ?? lightColors.background,
|
||||||
|
backgroundColor: _paletteHighlightLight(palette) ?? lightColors.highlight,
|
||||||
|
primaryColor: lightColors.filc,
|
||||||
|
dividerColor: const Color(0x00000000),
|
||||||
|
colorScheme: ColorScheme.fromSwatch(
|
||||||
|
accentColor: accent,
|
||||||
|
backgroundColor: _paletteBackgroundLight(palette) ?? lightColors.background,
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
fontFamily: _fontFamily,
|
cardColor: _paletteHighlightLight(palette) ?? lightColors.highlight,
|
||||||
scaffoldBackgroundColor: lightColors.background,
|
errorColor: lightColors.red,
|
||||||
backgroundColor: lightColors.highlight,
|
primaryColorDark: lightColors.filc,
|
||||||
primaryColor: lightColors.filc,
|
primarySwatch: Colors.teal,
|
||||||
dividerColor: const Color(0x00000000),
|
),
|
||||||
colorScheme: ColorScheme.fromSwatch(
|
shadowColor: lightColors.shadow,
|
||||||
accentColor: accent,
|
appBarTheme: AppBarTheme(backgroundColor: _paletteBackgroundLight(palette) ?? lightColors.background),
|
||||||
backgroundColor: lightColors.background,
|
indicatorColor: accent,
|
||||||
brightness: Brightness.light,
|
iconTheme: IconThemeData(color: lightColors.text.withOpacity(.75)),
|
||||||
cardColor: lightColors.highlight,
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
errorColor: lightColors.red,
|
indicatorColor: accent.withOpacity(accentColor == AccentColor.adaptive ? 0.4 : 0.8),
|
||||||
primaryColorDark: lightColors.filc,
|
iconTheme: MaterialStateProperty.all(IconThemeData(color: lightColors.text)),
|
||||||
primarySwatch: Colors.teal,
|
backgroundColor: _paletteHighlightLight(palette) ?? lightColors.highlight,
|
||||||
),
|
labelTextStyle: MaterialStateProperty.all(TextStyle(
|
||||||
shadowColor: lightColors.shadow,
|
fontSize: 13.0,
|
||||||
appBarTheme: AppBarTheme(backgroundColor: lightColors.background),
|
fontWeight: FontWeight.w500,
|
||||||
indicatorColor: accent,
|
color: lightColors.text.withOpacity(0.8),
|
||||||
iconTheme: IconThemeData(color: lightColors.text.withOpacity(.75)));
|
)),
|
||||||
|
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
|
||||||
|
height: 76.0,
|
||||||
|
),
|
||||||
|
sliderTheme: SliderThemeData(
|
||||||
|
inactiveTrackColor: accent.withOpacity(.3),
|
||||||
|
),
|
||||||
|
progressIndicatorTheme: ProgressIndicatorThemeData(color: accent),
|
||||||
|
expansionTileTheme: ExpansionTileThemeData(iconColor: accent),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dark Theme
|
// Dark Theme
|
||||||
static ThemeData darkTheme(BuildContext context) {
|
static ThemeData darkTheme(BuildContext context, {CorePalette? palette}) {
|
||||||
var darkColors = DarkAppColors();
|
var darkColors = DarkAppColors();
|
||||||
Color accent = accentColorMap[Provider.of<SettingsProvider>(context, listen: false).accentColor] ?? const Color(0x00000000);
|
AccentColor accentColor = Provider.of<SettingsProvider>(context, listen: false).accentColor;
|
||||||
|
Color accent = accentColorMap[accentColor] ?? const Color(0x00000000);
|
||||||
|
|
||||||
|
if (accentColor == AccentColor.adaptive) {
|
||||||
|
if (palette != null) accent = _paletteAccentDark(palette)!;
|
||||||
|
} else {
|
||||||
|
palette = null;
|
||||||
|
}
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
fontFamily: _fontFamily,
|
||||||
|
scaffoldBackgroundColor: _paletteBackgroundDark(palette) ?? darkColors.background,
|
||||||
|
backgroundColor: _paletteHighlightDark(palette) ?? darkColors.highlight,
|
||||||
|
primaryColor: darkColors.filc,
|
||||||
|
dividerColor: const Color(0x00000000),
|
||||||
|
colorScheme: ColorScheme.fromSwatch(
|
||||||
|
accentColor: accent,
|
||||||
|
backgroundColor: _paletteBackgroundDark(palette) ?? darkColors.background,
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
fontFamily: _fontFamily,
|
cardColor: _paletteHighlightDark(palette) ?? darkColors.highlight,
|
||||||
scaffoldBackgroundColor: darkColors.background,
|
errorColor: darkColors.red,
|
||||||
backgroundColor: darkColors.highlight,
|
primaryColorDark: darkColors.filc,
|
||||||
primaryColor: darkColors.filc,
|
primarySwatch: Colors.teal,
|
||||||
dividerColor: const Color(0x00000000),
|
),
|
||||||
colorScheme: ColorScheme.fromSwatch(
|
shadowColor: darkColors.shadow,
|
||||||
accentColor: accent,
|
appBarTheme: AppBarTheme(backgroundColor: _paletteBackgroundDark(palette) ?? darkColors.background),
|
||||||
backgroundColor: darkColors.background,
|
indicatorColor: accent,
|
||||||
brightness: Brightness.dark,
|
iconTheme: IconThemeData(color: darkColors.text.withOpacity(.75)),
|
||||||
cardColor: darkColors.highlight,
|
navigationBarTheme: NavigationBarThemeData(
|
||||||
errorColor: darkColors.red,
|
indicatorColor: accent.withOpacity(accentColor == AccentColor.adaptive ? 0.4 : 0.8),
|
||||||
primaryColorDark: darkColors.filc,
|
iconTheme: MaterialStateProperty.all(IconThemeData(color: darkColors.text)),
|
||||||
primarySwatch: Colors.teal,
|
backgroundColor: _paletteHighlightDark(palette) ?? darkColors.highlight,
|
||||||
),
|
labelTextStyle: MaterialStateProperty.all(TextStyle(
|
||||||
shadowColor: darkColors.shadow,
|
fontSize: 13.0,
|
||||||
appBarTheme: AppBarTheme(backgroundColor: darkColors.background),
|
fontWeight: FontWeight.w500,
|
||||||
indicatorColor: accent,
|
color: darkColors.text.withOpacity(0.8),
|
||||||
iconTheme: IconThemeData(color: darkColors.text.withOpacity(.75)));
|
)),
|
||||||
|
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
|
||||||
|
height: 76.0,
|
||||||
|
),
|
||||||
|
sliderTheme: SliderThemeData(
|
||||||
|
inactiveTrackColor: accent.withOpacity(.3),
|
||||||
|
),
|
||||||
|
progressIndicatorTheme: ProgressIndicatorThemeData(color: accent),
|
||||||
|
expansionTileTheme: ExpansionTileThemeData(iconColor: accent),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,18 +128,19 @@ class AppColors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AccentColor { filc, blue, green, lime, yellow, orange, red, pink, purple }
|
enum AccentColor { filc, blue, green, lime, yellow, orange, red, pink, purple, adaptive }
|
||||||
|
|
||||||
Map<AccentColor, Color> accentColorMap = {
|
Map<AccentColor, Color> accentColorMap = {
|
||||||
AccentColor.filc: const Color(0xff20AC9B),
|
AccentColor.filc: const Color(0xff20AC9B),
|
||||||
AccentColor.blue: Colors.blue.shade300,
|
AccentColor.blue: Colors.blue.shade300,
|
||||||
AccentColor.green: Colors.green.shade300,
|
AccentColor.green: Colors.green.shade400,
|
||||||
AccentColor.lime: Colors.lime.shade300,
|
AccentColor.lime: Colors.lightGreen.shade400,
|
||||||
AccentColor.yellow: Colors.yellow.shade300,
|
AccentColor.yellow: Colors.orange.shade300,
|
||||||
AccentColor.orange: Colors.deepOrange.shade300,
|
AccentColor.orange: Colors.deepOrange.shade300,
|
||||||
AccentColor.red: Colors.red.shade300,
|
AccentColor.red: Colors.red.shade300,
|
||||||
AccentColor.pink: Colors.pink.shade300,
|
AccentColor.pink: Colors.pink.shade300,
|
||||||
AccentColor.purple: Colors.purple.shade300,
|
AccentColor.purple: Colors.purple.shade300,
|
||||||
|
AccentColor.adaptive: const Color(0xff20AC9B),
|
||||||
};
|
};
|
||||||
|
|
||||||
abstract class ThemeAppColors {
|
abstract class ThemeAppColors {
|
||||||
|
37
filcnaplo/lib/utils/reverse_search.dart
Normal file
37
filcnaplo/lib/utils/reverse_search.dart
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:filcnaplo_kreta_api/models/absence.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/lesson.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/models/week.dart';
|
||||||
|
import 'package:filcnaplo_kreta_api/providers/timetable_provider.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ReverseSearch {
|
||||||
|
static Future<Lesson?> getLessonByAbsence(Absence absence, BuildContext context) async {
|
||||||
|
final timetableProvider = Provider.of<TimetableProvider>(context, listen: false);
|
||||||
|
|
||||||
|
List<Lesson> lessons = [];
|
||||||
|
try {
|
||||||
|
await timetableProvider.fetch(week: Week.fromDate(absence.date), db: false);
|
||||||
|
} catch (e) {
|
||||||
|
log("[ERROR] getLessonByAbsence: $e");
|
||||||
|
}
|
||||||
|
lessons = timetableProvider.lessons;
|
||||||
|
|
||||||
|
// Find absence lesson in timetable
|
||||||
|
Lesson lesson = lessons.firstWhere(
|
||||||
|
(l) => _sameDate(l.date, absence.date) && l.subject.id == absence.subject.id && l.lessonIndex == absence.lessonIndex.toString(),
|
||||||
|
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);
|
||||||
|
}
|
@ -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.2.3+148
|
version: 3.3.0-beta.6+162
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.16.0-80.1.beta <3.0.0"
|
sdk: ">=2.16.0-80.1.beta <3.0.0"
|
||||||
@ -32,17 +32,19 @@ dependencies:
|
|||||||
html: ^0.15.0
|
html: ^0.15.0
|
||||||
open_file: ^3.2.1
|
open_file: ^3.2.1
|
||||||
path_provider: ^2.0.2
|
path_provider: ^2.0.2
|
||||||
permission_handler: ^8.3.0
|
permission_handler: ^9.2.0
|
||||||
share_plus: ^3.0.4
|
share_plus: ^4.0.4
|
||||||
connectivity_plus: ^2.0.2
|
connectivity_plus: ^2.0.2
|
||||||
flutter_displaymode: ^0.3.2
|
flutter_displaymode: ^0.4.0
|
||||||
quick_actions: ^0.6.0
|
quick_actions: ^0.6.0
|
||||||
implicitly_animated_reorderable_list: ^0.4.2
|
implicitly_animated_reorderable_list: ^0.4.2
|
||||||
|
dynamic_color: ^1.2.2
|
||||||
|
material_color_utilities: ^0.1.3
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^1.0.0
|
flutter_lints: ^2.0.1
|
||||||
# flutter_launcher_icons: ^0.9.0
|
# flutter_launcher_icons: ^0.9.0
|
||||||
# flutter_native_splash: ^1.2.0
|
# flutter_native_splash: ^1.2.0
|
||||||
sqflite_common_ffi: ^2.0.0+3
|
sqflite_common_ffi: ^2.0.0+3
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 132581180c76fd10960abe49f073629e772cfc66
|
Subproject commit 85e956539e717d8806ec74389e47bad3c9371160
|
@ -1 +1 @@
|
|||||||
Subproject commit bee4c6cdd9561cfff62303fcc7c7a1abe81c3cf5
|
Subproject commit c7dc6d7d1f5e52387ab4ecf61581893fe929dc2e
|
Loading…
x
Reference in New Issue
Block a user