forked from firka/firka
Compare commits
16 Commits
feat/themi
...
5766eb6675
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5766eb6675 | ||
|
|
8fb5d5c89b | ||
|
|
f22ab629bc | ||
|
|
09ac4b7f61 | ||
|
|
5320625d83 | ||
|
|
eccdf90fd8 | ||
|
|
b4ccd52321 | ||
|
|
4658366fd4 | ||
|
|
aa77e25fe4 | ||
|
|
8984f8a915 | ||
|
|
4c28999d10 | ||
|
|
50274575f6 | ||
|
|
fb8fad142a | ||
|
|
2dccb59f7f | ||
|
|
7c9ade35f0 | ||
|
|
ca9e6c3efa |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -105,3 +105,4 @@ firka/debug-info/
|
||||
tool_logs/build/*.log
|
||||
tool_logs/d8dx_fix/*.log
|
||||
tool_logs/pub_fix/*.log
|
||||
secrets/upload_certificate.pem
|
||||
|
||||
5
firka/assets/images/surprise_grades/play_card_star.svg
Normal file
5
firka/assets/images/surprise_grades/play_card_star.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g id="tabler:play-card-star-filled">
|
||||
<path id="Vector" d="M14.1667 1.66667C14.8297 1.66667 15.4656 1.93006 15.9344 2.3989C16.4033 2.86774 16.6667 3.50363 16.6667 4.16667V15.8333C16.6667 16.4964 16.4033 17.1323 15.9344 17.6011C15.4656 18.0699 14.8297 18.3333 14.1667 18.3333H5.83333C5.17029 18.3333 4.53441 18.0699 4.06557 17.6011C3.59673 17.1323 3.33333 16.4964 3.33333 15.8333V4.16667C3.33333 3.50363 3.59673 2.86774 4.06557 2.3989C4.53441 1.93006 5.17029 1.66667 5.83333 1.66667H14.1667ZM14.175 15H14.1667C13.9543 15.0002 13.75 15.0816 13.5955 15.2274C13.4411 15.3732 13.3481 15.5725 13.3357 15.7845C13.3232 15.9965 13.3922 16.2053 13.5286 16.3682C13.6649 16.5311 13.8583 16.6357 14.0692 16.6608L14.175 16.6667C14.396 16.6667 14.608 16.5789 14.7643 16.4226C14.9205 16.2663 15.0083 16.0543 15.0083 15.8333C15.0083 15.6123 14.9205 15.4004 14.7643 15.2441C14.608 15.0878 14.396 15 14.175 15ZM10.025 7.08333L9.92917 7.0875C9.60917 7.12083 9.32583 7.315 9.18083 7.60667L8.75583 8.4625L7.8075 8.60083C7.455 8.65 7.1575 8.89833 7.04583 9.24083L7.01833 9.345C6.9866 9.50024 6.99456 9.66098 7.04146 9.81233C7.08837 9.96368 7.17271 10.1007 7.28667 10.2108L7.97 10.875L7.80833 11.8142C7.75 12.1742 7.8975 12.5283 8.18667 12.7375L8.27583 12.7942C8.41247 12.8713 8.56621 12.9131 8.7231 12.9157C8.87998 12.9183 9.03503 12.8817 9.17417 12.8092L10.0258 12.3625L10.875 12.8083C11.1892 12.975 11.575 12.9483 11.8667 12.7367L11.95 12.67C12.1842 12.4542 12.2967 12.1325 12.2417 11.8133L12.08 10.875L12.7658 10.2092C13.0242 9.9575 13.1158 9.5825 13.005 9.24167L12.97 9.15C12.9051 9.00436 12.8044 8.87758 12.6771 8.78153C12.5499 8.68548 12.4003 8.6233 12.2425 8.60083L11.2942 8.4625L10.8708 7.6075C10.793 7.44983 10.6727 7.31709 10.5233 7.22431C10.374 7.13152 10.2016 7.0824 10.0258 7.0825M5.84167 3.33333H5.83333C5.62093 3.33357 5.41664 3.4149 5.26219 3.56071C5.10775 3.70651 5.0148 3.90579 5.00236 4.11783C4.98991 4.32986 5.0589 4.53865 5.19522 4.70153C5.33155 4.8644 5.52492 4.96908 5.73583 4.99417L5.84167 5C6.06268 5 6.27464 4.9122 6.43092 4.75592C6.5872 4.59964 6.675 4.38768 6.675 4.16667C6.675 3.94565 6.5872 3.73369 6.43092 3.57741C6.27464 3.42113 6.06268 3.33333 5.84167 3.33333Z" fill="#A7DC22"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
3
firka/assets/images/surprise_grades/star_large.svg
Normal file
3
firka/assets/images/surprise_grades/star_large.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="Star 9" d="M10.5 0L11.047 7.18922C11.1594 8.66653 12.3335 9.84055 13.8108 9.95296L21 10.5L13.8108 11.047C12.3335 11.1594 11.1594 12.3335 11.047 13.8108L10.5 21L9.95296 13.8108C9.84055 12.3335 8.66653 11.1594 7.18923 11.047L0 10.5L7.18922 9.95296C8.66653 9.84055 9.84055 8.66653 9.95296 7.18923L10.5 0Z" fill="#A7DC22"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 503 B |
3
firka/assets/images/surprise_grades/star_medium.svg
Normal file
3
firka/assets/images/surprise_grades/star_medium.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="Star 11" d="M12.5 0L13.1885 9.0478C13.3009 10.5251 14.4749 11.6991 15.9522 11.8115L25 12.5L15.9522 13.1885C14.4749 13.3009 13.3009 14.4749 13.1885 15.9522L12.5 25L11.8115 15.9522C11.6991 14.4749 10.5251 13.3009 9.0478 13.1885L0 12.5L9.0478 11.8115C10.5251 11.6991 11.6991 10.5251 11.8115 9.0478L12.5 0Z" fill="#A7DC22"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 504 B |
3
firka/assets/images/surprise_grades/star_small.svg
Normal file
3
firka/assets/images/surprise_grades/star_small.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="9.87586" height="9.87586" viewBox="0 0 9.87586 9.87586" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path id="Star 10" d="M4.93793 0L5.15681 2.87656C5.23175 3.86143 6.01443 4.64411 6.9993 4.71905L9.87586 4.93793L6.9993 5.15681C6.01443 5.23175 5.23175 6.01443 5.15681 6.9993L4.93793 9.87586L4.71905 6.9993C4.64411 6.01443 3.86143 5.23175 2.87656 5.15681L0 4.93793L2.87656 4.71905C3.86143 4.64411 4.64411 3.86143 4.71905 2.87656L4.93793 0Z" fill="#A7DC22"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 549 B |
@@ -1,16 +1,16 @@
|
||||
icons:
|
||||
"flutter_launcher_icons.yaml": "c600507ca0df7cebd0f708124842512a14ed3d597b779176200d6ba25b1335b1"
|
||||
"pubspec.yaml": "d0f795bcffd597e260202b29476fc99caa3bb4aac5abd48a210cadb9f45c19e7"
|
||||
"pubspec.yaml": "dbb15aa3301f9f021134e6705847dfbc5149df751d698ba79e3b01da03e12353"
|
||||
"assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983"
|
||||
"assets/images/logos/monochrome_logo.png": "188d2b0a64c70323b09bcee721663d6698fb557066f20ddaec97bba6869c1c6c"
|
||||
"assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3"
|
||||
"assets/images/logos/colored_logo_only_mustache.png": "bad6220c11bdfb1dfe04e5173bd2ebedd3999689d4b3a68fc63dc520c96dd33b"
|
||||
l10n:
|
||||
"l10n.yml": "a57bc304cac4a2b0235593586f17f400a5165d67fc9aadeaa11893cfa36ee082"
|
||||
"lib/l10n/app_hu.arb": "e11b8fe4d4fd239584792971c341f1e329fb91f5f49fa6baa664c98b06fc5176"
|
||||
"lib/l10n/app_de.arb": "5114c70b506f290217161881336d6118c975d59f32347bbdc94a51c1a25293e7"
|
||||
"lib/l10n/app_en.arb": "a5417b2de058a67db40fa7bfb3526d800fd2f82349dfbc895cff8b298069e707"
|
||||
"lib/l10n/app_pl.arb": "36cad0796cf8bd20fe969d5fd8443430d25fa932028c0177917ecef6964a08dd"
|
||||
"lib/l10n/app_de.arb": "acaa77af7b19d9ea479bd876245d76b3079d05ce05f51db7a8300ea17dd68907"
|
||||
"lib/l10n/app_hu.arb": "63bfe9901b9fc233940de5bd1e9a714e4cbe91638861d0f2591df22e3bd8e91f"
|
||||
"lib/l10n/app_en.arb": "828c1536f650fb5240d511d32b2f89f8dca84576dfadc3626edb79fcd39887c9"
|
||||
"lib/l10n/app_pl.arb": "a8426455757e587c7635c3a62c650a4aae2a0cac1de1175e8ab7fb0d3b387537"
|
||||
isar:
|
||||
"lib/data/models/app_settings_model.dart": "5eb5af345f1347f104257f0999763650fe2673f9da1754bd12d3f756fe5c9723"
|
||||
"lib/data/models/token_model.dart": "8c957cd07e473827d78fd8fd4fb6c1336b636a69c25c93618e1e7f94b7cf0683"
|
||||
|
||||
@@ -21,6 +21,7 @@ import 'package:kreta_api/kreta_api.dart';
|
||||
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/bloc/toast_cubit.dart';
|
||||
import 'package:firka/core/dev/mock_backend.dart';
|
||||
import 'package:firka_common/data/models/token_model.dart';
|
||||
import 'package:firka/core/debug_helper.dart';
|
||||
import 'package:firka_common/data/util.dart';
|
||||
@@ -480,7 +481,7 @@ class KretaClient {
|
||||
};
|
||||
|
||||
return await dio.get(
|
||||
url,
|
||||
MockBackend.rewrite(url),
|
||||
options: Options(
|
||||
method: method,
|
||||
headers: headers,
|
||||
|
||||
34
firka/lib/api/login_finish.dart
Normal file
34
firka/lib/api/login_finish.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import "dart:io";
|
||||
|
||||
import "package:firka/app/app_state.dart";
|
||||
import "package:firka/app/initialization.dart";
|
||||
import "package:firka/services/watch_sync_helper.dart";
|
||||
import "package:firka_common/data/models/token_model.dart";
|
||||
import "package:kreta_api/kreta_api.dart";
|
||||
|
||||
Future<void> completeLogin(
|
||||
AppInitialization data,
|
||||
TokenGrantResponse resp,
|
||||
) async {
|
||||
var tokenModel = TokenModel.fromResp(resp);
|
||||
|
||||
await data.isar.writeTxn(() async {
|
||||
await data.isar.tokenModels.put(tokenModel);
|
||||
});
|
||||
|
||||
await data.settings.setSelectedAccountKey(tokenModel.key);
|
||||
await initializeApp();
|
||||
|
||||
if (Platform.isIOS) {
|
||||
final watchInstalled = await WatchSyncHelper.isWatchAppInstalled();
|
||||
if (watchInstalled) {
|
||||
try {
|
||||
await WatchSyncHelper.saveTokenToiCloud(tokenModel);
|
||||
} catch (_) {}
|
||||
|
||||
try {
|
||||
await WatchSyncHelper.sendTokenToWatch();
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
firka/lib/api/mock_login.dart
Normal file
38
firka/lib/api/mock_login.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import "package:dio/dio.dart";
|
||||
import "package:firka_common/core/consts.dart";
|
||||
|
||||
import "package:firka/app/app_state.dart";
|
||||
import "package:firka/core/dev/mock_backend.dart";
|
||||
import "package:kreta_api/kreta_api.dart";
|
||||
|
||||
Future<TokenGrantResponse> mockLogin(String username, String password) async {
|
||||
final headers = <String, String>{
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
"accept": "*/*",
|
||||
"user-agent": initData.userAgent,
|
||||
};
|
||||
|
||||
final formData = <String, String>{
|
||||
"grant_type": "password",
|
||||
"username": username,
|
||||
"password": password,
|
||||
"client_id": Constants.clientId,
|
||||
};
|
||||
|
||||
final response = await dio.post(
|
||||
MockBackend.rewrite(KretaLoginEndpoints.tokenGrantUrl),
|
||||
options: Options(headers: headers),
|
||||
data: formData,
|
||||
);
|
||||
|
||||
switch (response.statusCode) {
|
||||
case 200:
|
||||
return TokenGrantResponse.fromJson(response.data);
|
||||
case 401:
|
||||
throw Exception("Invalid credentials");
|
||||
default:
|
||||
throw Exception(
|
||||
"Failed to get access token, response code: ${response.statusCode}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:firka_common/core/consts.dart';
|
||||
import 'package:firka_common/data/models/token_model.dart';
|
||||
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/dev/mock_backend.dart';
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
|
||||
Future<TokenGrantResponse> getAccessToken(String code) async {
|
||||
@@ -23,7 +24,7 @@ Future<TokenGrantResponse> getAccessToken(String code) async {
|
||||
|
||||
try {
|
||||
final response = await dio.post(
|
||||
KretaLoginEndpoints.tokenGrantUrl,
|
||||
MockBackend.rewrite(KretaLoginEndpoints.tokenGrantUrl),
|
||||
options: Options(headers: headers),
|
||||
data: formData,
|
||||
);
|
||||
@@ -76,7 +77,7 @@ Future<TokenGrantResponse> extendToken(TokenModel model) async {
|
||||
}
|
||||
|
||||
final response = await dio.post(
|
||||
KretaLoginEndpoints.tokenGrantUrl,
|
||||
MockBackend.rewrite(KretaLoginEndpoints.tokenGrantUrl),
|
||||
options: Options(headers: headers),
|
||||
data: formData,
|
||||
);
|
||||
|
||||
@@ -195,6 +195,7 @@ Future<void> _initData(AppInitialization init) async {
|
||||
final token = init.settings.getSelectedToken();
|
||||
if (token == null) {
|
||||
logger.warning("[Init] No token available!");
|
||||
init.client = null;
|
||||
return;
|
||||
}
|
||||
logger.fine("Initializing kréta client as: ${token.username}");
|
||||
|
||||
22
firka/lib/core/dev/mock_backend.dart
Normal file
22
firka/lib/core/dev/mock_backend.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import "package:firka/core/settings/settings_repository.dart";
|
||||
import "package:firka/core/settings/settings_schema.dart";
|
||||
|
||||
class MockBackend {
|
||||
static String rewrite(String url) {
|
||||
if (!Settings.mockBackendEnabled.value) return url;
|
||||
|
||||
final mockBase = Settings.mockBackendUrl.value;
|
||||
if (mockBase.isEmpty) return url;
|
||||
|
||||
final mockUri = Uri.parse(mockBase);
|
||||
final uri = Uri.parse(url);
|
||||
|
||||
return uri
|
||||
.replace(
|
||||
scheme: mockUri.scheme,
|
||||
host: mockUri.host,
|
||||
port: mockUri.hasPort ? mockUri.port : null,
|
||||
)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
60
firka/lib/core/last_seen_helper.dart
Normal file
60
firka/lib/core/last_seen_helper.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
import "dart:convert";
|
||||
|
||||
import "package:firka/core/settings/settings_repository.dart";
|
||||
import "package:firka/core/settings/settings_schema.dart";
|
||||
import "package:firka_common/data/last_seen.dart";
|
||||
import "package:firka_common/data/models/grade_cache_model.dart";
|
||||
|
||||
class LastSeenHelper {
|
||||
static const grades = "grades";
|
||||
static const homework = "homework";
|
||||
static const tests = "tests";
|
||||
static const omissions = "omissions";
|
||||
static const messages = "messages";
|
||||
|
||||
static Map<String, dynamic> _read() {
|
||||
try {
|
||||
final decoded = jsonDecode(Settings.lastSeen.value);
|
||||
return decoded is Map<String, dynamic> ? decoded : {};
|
||||
} catch (_) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static LastSeen? get(int accountKey, String kind) {
|
||||
final account = _read()["$accountKey"];
|
||||
if (account is! Map) return null;
|
||||
|
||||
return LastSeen.parse(account[kind] as String?);
|
||||
}
|
||||
|
||||
static List<GradeCacheModel> openedGrades(
|
||||
int accountKey,
|
||||
List<GradeCacheModel> grades,
|
||||
) {
|
||||
if (!Settings.surpriseGrades.value) return grades;
|
||||
|
||||
final seen = get(accountKey, LastSeenHelper.grades);
|
||||
if (seen == null) return grades;
|
||||
|
||||
final hidden = LastSeen.newerThan(
|
||||
grades,
|
||||
seen,
|
||||
).map((g) => g.cacheKey).toSet();
|
||||
|
||||
return grades.where((g) => !hidden.contains(g.cacheKey)).toList();
|
||||
}
|
||||
|
||||
static Future<void> set(int accountKey, String kind, LastSeen seen) async {
|
||||
final all = _read();
|
||||
final account = all["$accountKey"];
|
||||
final entry = account is Map
|
||||
? Map<String, dynamic>.from(account)
|
||||
: <String, dynamic>{};
|
||||
|
||||
entry[kind] = seen.toText();
|
||||
all["$accountKey"] = entry;
|
||||
|
||||
await Settings.lastSeen.set(jsonEncode(all));
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
l10n.s_a,
|
||||
l10n.s_ag,
|
||||
[
|
||||
SettingsUiBackHeader(l10n.s_settings, always),
|
||||
SettingsUiHeader(l10n.s_ag, always),
|
||||
@@ -280,6 +280,8 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
], always),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_a_desc,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
@@ -289,6 +291,17 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
SettingsUiPersonalization(appIconPickerTree, always),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_c_desc,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.bellSolid,
|
||||
l10n.s_notifications,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
@@ -351,11 +364,85 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.lightningBoltSolid,
|
||||
l10n.s_extras,
|
||||
[SettingsUiBackHeader(l10n.s_settings, always)],
|
||||
never,
|
||||
[
|
||||
SettingsUiBackHeader(l10n.s_settings, always),
|
||||
SettingsUiHeader(l10n.s_extras, always),
|
||||
SettingsUiPadding(23, always),
|
||||
SettingsUiBoolean(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.questionCircleSolid,
|
||||
l10n.s_surprise_grades,
|
||||
SettingsRegistry.surpriseGrades,
|
||||
always,
|
||||
),
|
||||
SettingsUiBoolean(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.shootingStarSolid,
|
||||
l10n.s_seasonal_icons,
|
||||
SettingsRegistry.seasonalAppIcons,
|
||||
always,
|
||||
),
|
||||
SettingsUiBoolean(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.flower2Solid,
|
||||
l10n.s_uwu_mode,
|
||||
SettingsRegistry.uwuMode,
|
||||
always,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.calendarSolid,
|
||||
l10n.s_calendar_sync,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.bookmarkSolid,
|
||||
l10n.s_save_grades,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiPadding(20, always),
|
||||
SettingsUiHeaderSmall(l10n.s_welcome_msg, always),
|
||||
SettingsUiSubGroup(
|
||||
null,
|
||||
null,
|
||||
l10n.s_welcome_msg,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_extras_desc,
|
||||
),
|
||||
SettingsUiPadding(20, always),
|
||||
SettingsUiHeaderSmall(l10n.s_other, always),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.mapMarkerAreaSolid,
|
||||
l10n.s_sticker_map,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.qrCodeSolid,
|
||||
l10n.s_qr_reader,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiPadding(20, never),
|
||||
SettingsUiHeaderSmall(l10n.s_other, never),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"wrenchSolid",
|
||||
@@ -417,6 +504,15 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
],
|
||||
always,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.phoneSolid,
|
||||
l10n.s_feedback,
|
||||
const [],
|
||||
always,
|
||||
null,
|
||||
l10n.s_todo,
|
||||
),
|
||||
SettingsUiBoolean(
|
||||
null,
|
||||
null,
|
||||
|
||||
@@ -142,4 +142,43 @@ abstract class SettingsSchema {
|
||||
|
||||
@StringSetting(id: 1031, defaultValue: "firka")
|
||||
String get selectedGradeThemeId;
|
||||
|
||||
@BoolSetting(id: 1032, defaultValue: false)
|
||||
bool get mockBackendEnabled;
|
||||
|
||||
@StringSetting(id: 1033, defaultValue: "http://10.0.0.144:8090")
|
||||
String get mockBackendUrl;
|
||||
|
||||
@StringSetting(id: 1034, defaultValue: "{}")
|
||||
String get lastSeen;
|
||||
|
||||
@BoolSetting(id: 1035, defaultValue: true)
|
||||
bool get surpriseGrades;
|
||||
|
||||
@BoolSetting(id: 1036, defaultValue: true)
|
||||
bool get seasonalAppIcons;
|
||||
|
||||
@BoolSetting(id: 1037, defaultValue: false)
|
||||
bool get uwuMode;
|
||||
|
||||
@BoolSetting(id: 1038, defaultValue: true)
|
||||
bool get notifyAll;
|
||||
|
||||
@BoolSetting(id: 1039, defaultValue: true)
|
||||
bool get notifyGrades;
|
||||
|
||||
@BoolSetting(id: 1040, defaultValue: true)
|
||||
bool get notifyHomeworkTests;
|
||||
|
||||
@BoolSetting(id: 1041, defaultValue: true)
|
||||
bool get notifyAbsences;
|
||||
|
||||
@BoolSetting(id: 1042, defaultValue: true)
|
||||
bool get notifyLessons;
|
||||
|
||||
@BoolSetting(id: 1043, defaultValue: true)
|
||||
bool get notifyMessages;
|
||||
|
||||
@StringSetting(id: 1044, defaultValue: "[]")
|
||||
String get notifyMutedSubjects;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,22 @@ class SettingsRegistry {
|
||||
static const selectedThemeId = StringSetting(id: 1029, defaultValue: "builtin-firka-firka");
|
||||
static const selectedCoreThemeId = StringSetting(id: 1030, defaultValue: "firka");
|
||||
static const selectedGradeThemeId = StringSetting(id: 1031, defaultValue: "firka");
|
||||
static const mockBackendEnabled = BoolSetting(id: 1032, defaultValue: false);
|
||||
static const mockBackendUrl = StringSetting(id: 1033, defaultValue: "http://10.0.0.144:8090");
|
||||
static const lastSeen = StringSetting(id: 1034, defaultValue: "{}");
|
||||
static const surpriseGrades = BoolSetting(id: 1035, defaultValue: true);
|
||||
static const seasonalAppIcons = BoolSetting(id: 1036, defaultValue: true);
|
||||
static const uwuMode = BoolSetting(id: 1037, defaultValue: false);
|
||||
static const notifyAll = BoolSetting(id: 1038, defaultValue: true);
|
||||
static const notifyGrades = BoolSetting(id: 1039, defaultValue: true);
|
||||
static const notifyHomeworkTests = BoolSetting(id: 1040, defaultValue: true);
|
||||
static const notifyAbsences = BoolSetting(id: 1041, defaultValue: true);
|
||||
static const notifyLessons = BoolSetting(id: 1042, defaultValue: true);
|
||||
static const notifyMessages = BoolSetting(id: 1043, defaultValue: true);
|
||||
static const notifyMutedSubjects = StringSetting(id: 1044, defaultValue: "[]");
|
||||
|
||||
static const all = <Setting>[
|
||||
bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, liveActivityEnabled, liveActivityPrivacyEverDeclined, morningNotificationEnabled, morningNotificationTime, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId,
|
||||
bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, liveActivityEnabled, liveActivityPrivacyEverDeclined, morningNotificationEnabled, morningNotificationTime, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId, mockBackendEnabled, mockBackendUrl, lastSeen, surpriseGrades, seasonalAppIcons, uwuMode, notifyAll, notifyGrades, notifyHomeworkTests, notifyAbsences, notifyLessons, notifyMessages, notifyMutedSubjects,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -70,4 +83,17 @@ extension SettingsAccessors on SettingsRepository {
|
||||
SilentlySettable<String> get selectedThemeId => SilentlySettable(this, SettingsRegistry.selectedThemeId);
|
||||
SilentlySettable<String> get selectedCoreThemeId => SilentlySettable(this, SettingsRegistry.selectedCoreThemeId);
|
||||
SilentlySettable<String> get selectedGradeThemeId => SilentlySettable(this, SettingsRegistry.selectedGradeThemeId);
|
||||
SilentlySettable<bool> get mockBackendEnabled => SilentlySettable(this, SettingsRegistry.mockBackendEnabled);
|
||||
SilentlySettable<String> get mockBackendUrl => SilentlySettable(this, SettingsRegistry.mockBackendUrl);
|
||||
SilentlySettable<String> get lastSeen => SilentlySettable(this, SettingsRegistry.lastSeen);
|
||||
SilentlySettable<bool> get surpriseGrades => SilentlySettable(this, SettingsRegistry.surpriseGrades);
|
||||
SilentlySettable<bool> get seasonalAppIcons => SilentlySettable(this, SettingsRegistry.seasonalAppIcons);
|
||||
SilentlySettable<bool> get uwuMode => SilentlySettable(this, SettingsRegistry.uwuMode);
|
||||
SilentlySettable<bool> get notifyAll => SilentlySettable(this, SettingsRegistry.notifyAll);
|
||||
SilentlySettable<bool> get notifyGrades => SilentlySettable(this, SettingsRegistry.notifyGrades);
|
||||
SilentlySettable<bool> get notifyHomeworkTests => SilentlySettable(this, SettingsRegistry.notifyHomeworkTests);
|
||||
SilentlySettable<bool> get notifyAbsences => SilentlySettable(this, SettingsRegistry.notifyAbsences);
|
||||
SilentlySettable<bool> get notifyLessons => SilentlySettable(this, SettingsRegistry.notifyLessons);
|
||||
SilentlySettable<bool> get notifyMessages => SilentlySettable(this, SettingsRegistry.notifyMessages);
|
||||
SilentlySettable<String> get notifyMutedSubjects => SilentlySettable(this, SettingsRegistry.notifyMutedSubjects);
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ class SettingsUiSubGroup extends SettingsUiNode {
|
||||
final String title;
|
||||
final List<SettingsUiNode> children;
|
||||
final String? redirectTo;
|
||||
final String? subtitle;
|
||||
|
||||
const SettingsUiSubGroup(
|
||||
this.iconType,
|
||||
@@ -67,6 +68,7 @@ class SettingsUiSubGroup extends SettingsUiNode {
|
||||
this.children,
|
||||
bool Function() visible, [
|
||||
this.redirectTo,
|
||||
this.subtitle,
|
||||
]) : super(visible);
|
||||
}
|
||||
|
||||
@@ -158,3 +160,7 @@ class SettingsUiLogs extends SettingsUiNode {
|
||||
class SettingsUiLicensePage extends SettingsUiNode {
|
||||
const SettingsUiLicensePage(super.visible);
|
||||
}
|
||||
|
||||
class SettingsUiSubjectNotifications extends SettingsUiNode {
|
||||
const SettingsUiSubjectNotifications(super.visible);
|
||||
}
|
||||
|
||||
Submodule firka/lib/l10n updated: f4812ec3b3...f4ae8bbd36
@@ -12,6 +12,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/last_seen_helper.dart';
|
||||
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
|
||||
@@ -38,7 +39,10 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
final allGrades = widget.data.client!.cache.getGrades().findAllSync();
|
||||
final allGrades = LastSeenHelper.openedGrades(
|
||||
widget.data.settings.selectedAccountKey,
|
||||
widget.data.client!.cache.getGrades().findAllSync(),
|
||||
);
|
||||
|
||||
final subjectAverage = allGrades.getSubjectAverage();
|
||||
final roundedSubjectAverage = allGrades.getRoundedSubjectAverage();
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'package:isar_community/isar.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/last_seen_helper.dart';
|
||||
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
@@ -30,11 +31,14 @@ class HomeGradesSubjectScreen extends StatefulWidget {
|
||||
factory HomeGradesSubjectScreen.subject(SubjectCacheModel subject) {
|
||||
return HomeGradesSubjectScreen(
|
||||
subject,
|
||||
initData.client!.cache
|
||||
.getGrades()
|
||||
.subject((s) => s.cacheKeyEqualTo(subject.cacheKey))
|
||||
.sortByCreatedAtDesc()
|
||||
.findAllSync(),
|
||||
LastSeenHelper.openedGrades(
|
||||
initData.settings.selectedAccountKey,
|
||||
initData.client!.cache
|
||||
.getGrades()
|
||||
.subject((s) => s.cacheKeyEqualTo(subject.cacheKey))
|
||||
.sortByCreatedAtDesc()
|
||||
.findAllSync(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import 'package:firka_common/data/last_seen.dart';
|
||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||
import 'package:firka/core/last_seen_helper.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
import 'package:firka/ui/phone/screens/surprise_grades/surprise_grades_screen.dart';
|
||||
import 'package:firka/ui/phone/widgets/info_card.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson_slider.dart';
|
||||
import 'package:firka_common/data/util.dart';
|
||||
@@ -35,13 +41,69 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
await _seedLastSeen();
|
||||
if (mounted) setState(() => _fadeNewInserts = true);
|
||||
});
|
||||
}
|
||||
|
||||
List<GradeCacheModel> _newGrades() {
|
||||
if (!Settings.surpriseGrades.value) return const [];
|
||||
|
||||
final account = widget.data.settings.selectedAccountKey;
|
||||
final seen = LastSeenHelper.get(account, LastSeenHelper.grades);
|
||||
if (seen == null) return const [];
|
||||
|
||||
return LastSeen.newerThan(
|
||||
widget.data.client!.cache.getGrades().findAllSync(),
|
||||
seen,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _seedLastSeen() async {
|
||||
final account = widget.data.settings.selectedAccountKey;
|
||||
final existing = LastSeenHelper.get(account, LastSeenHelper.grades);
|
||||
if (existing != null) return;
|
||||
|
||||
final newest = LastSeen.newestOf(
|
||||
widget.data.client!.cache.getGrades().findAllSync(),
|
||||
);
|
||||
if (newest == null) return;
|
||||
|
||||
await LastSeenHelper.set(account, LastSeenHelper.grades, newest);
|
||||
}
|
||||
|
||||
void _openNewGrades(List<GradeCacheModel> grades) async {
|
||||
if (grades.isEmpty) return;
|
||||
|
||||
final revealed = <int>{};
|
||||
await Navigator.of(context, rootNavigator: true).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SurpriseGradesScreen(
|
||||
grades,
|
||||
widget.data.l10n,
|
||||
onRevealed: (g) => revealed.add(g.cacheKey),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final newest = revealed.length == grades.length
|
||||
? LastSeen.newestOf(grades)
|
||||
: null;
|
||||
if (newest != null) {
|
||||
await LastSeenHelper.set(
|
||||
widget.data.settings.selectedAccountKey,
|
||||
LastSeenHelper.grades,
|
||||
newest,
|
||||
);
|
||||
}
|
||||
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
void _onRefreshRequested(BuildContext context) async {
|
||||
final cubit = context.read<HomeRefreshCubit>();
|
||||
await _seedLastSeen();
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
cubit.onRefreshComplete();
|
||||
@@ -66,8 +128,12 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
Widget _buildContent(BuildContext context, ToastState toastState) {
|
||||
final now = timeNow();
|
||||
final student = widget.data.client!.cache.findStudentOrNull();
|
||||
final newGrades = _newGrades();
|
||||
final infoItems = widget.data.client!.cache.getMessages().findAllSync();
|
||||
final gradeItems = widget.data.client!.cache.getGrades().findAllSync();
|
||||
final gradeItems = LastSeenHelper.openedGrades(
|
||||
widget.data.settings.selectedAccountKey,
|
||||
widget.data.client!.cache.getGrades().findAllSync(),
|
||||
);
|
||||
final testItems = widget.data.client!.cache.getTests().findAllSync();
|
||||
final homeworkItems = widget.data.client!.cache
|
||||
.getHomeworks()
|
||||
@@ -154,8 +220,13 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
child: const Center(child: DelayedSpinnerWidget()),
|
||||
),
|
||||
_FadeInWhenLoaded(
|
||||
loaded: todayLesson.isNotEmpty,
|
||||
child: LessonSlider(todayLesson, testsTomorrow),
|
||||
loaded: todayLesson.isNotEmpty || newGrades.isNotEmpty,
|
||||
child: LessonSlider(
|
||||
todayLesson,
|
||||
testsTomorrow,
|
||||
newGrades: newGrades,
|
||||
onNewGradesTap: () => _openNewGrades(newGrades),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
...noticeBoardWidgets
|
||||
|
||||
@@ -20,11 +20,15 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import 'package:firka/core/debug_helper.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/ui/phone/screens/surprise_grades/surprise_grades_screen.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:home_widget/home_widget.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@@ -44,6 +48,7 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
Uint8List? profilePictureData;
|
||||
|
||||
bool useCache = true;
|
||||
late TextEditingController _mockBackendUrlController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -51,6 +56,15 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
|
||||
_picker = ImagePicker();
|
||||
profilePictureData = widget.data.profilePicture;
|
||||
_mockBackendUrlController = TextEditingController(
|
||||
text: Settings.mockBackendUrl.value,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_mockBackendUrlController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -99,6 +113,30 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Row(
|
||||
children: [
|
||||
Text('use mock backend'),
|
||||
Switch(
|
||||
value: Settings.mockBackendEnabled.value,
|
||||
onChanged: (bool value) {
|
||||
setState(() {
|
||||
Settings.mockBackendEnabled.set(value);
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: TextField(
|
||||
controller: _mockBackendUrlController,
|
||||
decoration: const InputDecoration(labelText: 'mock backend url'),
|
||||
onSubmitted: (value) {
|
||||
Settings.mockBackendUrl.set(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
profilePicture,
|
||||
ElevatedButton(
|
||||
@@ -217,6 +255,80 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
},
|
||||
child: const Text('getGrades()'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
final grades = widget.data.isar.gradeCacheModels
|
||||
.where()
|
||||
.findAllSync();
|
||||
|
||||
if (grades.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('no new grades uwu')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SurpriseGradesScreen(grades, widget.data.l10n),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('Epikus jegyszerzés'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
final grades = widget.data.isar.gradeCacheModels
|
||||
.where()
|
||||
.findAllSync();
|
||||
|
||||
if (grades.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('no new grades uwu')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SurpriseCardFaceDebugScreen(grades.first, widget.data.l10n),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('Epikus jegyszerzés (card face debug)'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final token = widget.data.settings.getSelectedToken();
|
||||
if (token == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('No token available to copy')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await Clipboard.setData(
|
||||
ClipboardData(text: token.accessToken),
|
||||
);
|
||||
if (!context.mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Access token copied')),
|
||||
);
|
||||
},
|
||||
child: const Text('Copy JWT'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SurpriseParticleDebugScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('Epikus jegyszerzés (particle debug)'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
var now = timeNow();
|
||||
|
||||
@@ -15,7 +15,11 @@ import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:sensors_plus/sensors_plus.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
import 'package:firka/api/login_finish.dart';
|
||||
import 'package:firka/api/mock_login.dart';
|
||||
import 'package:firka/core/bloc/theme_cubit.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/core/image_preloader.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
@@ -32,6 +36,11 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
||||
late LoginWebviewWidget _loginWebView;
|
||||
bool _preloadDone = false;
|
||||
|
||||
final _mockUsernameController = TextEditingController(text: "student");
|
||||
final _mockPasswordController = TextEditingController(text: "student");
|
||||
bool _mockLoginInProgress = false;
|
||||
String? _mockLoginError;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -40,6 +49,125 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
||||
_preloadImages();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_mockUsernameController.dispose();
|
||||
_mockPasswordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _showMockModeDialog() async {
|
||||
final wasEnabled = Settings.mockBackendEnabled.value;
|
||||
final urlController = TextEditingController(
|
||||
text: Settings.mockBackendUrl.value,
|
||||
);
|
||||
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return AlertDialog(
|
||||
backgroundColor: appStyle.colors.card,
|
||||
title: Text(
|
||||
wasEnabled ? 'Disable mock mode?' : 'Enable mock mode?',
|
||||
style: appStyle.fonts.H_16px.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
content: wasEnabled
|
||||
? Text(
|
||||
'Logging in will go back to the real e-Kréta service.',
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Logging in will talk to this mock kréta server instead of the real e-Kréta service. Use the mock API\'s IP, not localhost.',
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextField(
|
||||
controller: urlController,
|
||||
autofocus: true,
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'http://10.0.0.144:8090',
|
||||
hintStyle: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textTertiary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(
|
||||
'Cancel',
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.of(dialogContext).pop(false),
|
||||
),
|
||||
TextButton(
|
||||
child: Text(
|
||||
wasEnabled ? 'Disable' : 'Enable',
|
||||
style: appStyle.fonts.B_14R.apply(color: appStyle.colors.accent),
|
||||
),
|
||||
onPressed: () => Navigator.of(dialogContext).pop(true),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (confirmed != true) return;
|
||||
|
||||
if (!wasEnabled) {
|
||||
await Settings.mockBackendUrl.set(urlController.text.trim());
|
||||
}
|
||||
await Settings.mockBackendEnabled.set(!wasEnabled);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_mockLoginError = null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _submitMockLogin() async {
|
||||
setState(() {
|
||||
_mockLoginInProgress = true;
|
||||
_mockLoginError = null;
|
||||
});
|
||||
|
||||
try {
|
||||
final resp = await mockLogin(
|
||||
_mockUsernameController.text,
|
||||
_mockPasswordController.text,
|
||||
);
|
||||
await completeLogin(widget.data, resp);
|
||||
if (!mounted) return;
|
||||
appRouter?.go('/home');
|
||||
} catch (ex) {
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_mockLoginError = ex.toString();
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_mockLoginInProgress = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String _getPrivacyPolicyUrl() {
|
||||
return "https://firka.app/privacy";
|
||||
}
|
||||
@@ -87,6 +215,143 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildRealLoginButton() {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: false,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: _loginWebView,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shadows: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.textPrimary.withAlpha(13),
|
||||
blurRadius: 2,
|
||||
offset: const Offset(0, 1),
|
||||
spreadRadius: 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.data.l10n.loginBtn,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_16px.copyWith(
|
||||
color: appStyle.colors.textPrimaryLight,
|
||||
fontVariations: const [FontVariation("wght", 800)],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMockLoginField(
|
||||
TextEditingController controller,
|
||||
String hint, {
|
||||
bool obscure = false,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.card,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
obscureText: obscure,
|
||||
textInputAction: TextInputAction.next,
|
||||
cursorColor: appStyle.colors.accent,
|
||||
style: appStyle.fonts.B_16R.apply(color: appStyle.colors.textPrimary),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
hintStyle: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textTertiary,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMockLoginForm() {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'Mock mode, will connect to: ${Settings.mockBackendUrl.value.isEmpty ? "(not set, long-press the logo to disable then enable again and fill in the URL)" : Settings.mockBackendUrl.value}',
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_12R.copyWith(
|
||||
color: appStyle.colors.textTertiary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildMockLoginField(_mockUsernameController, 'Username'),
|
||||
const SizedBox(height: 8),
|
||||
_buildMockLoginField(
|
||||
_mockPasswordController,
|
||||
'Password',
|
||||
obscure: true,
|
||||
),
|
||||
if (_mockLoginError != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
_mockLoginError!,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_12R.copyWith(color: Colors.red),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
InkWell(
|
||||
onTap: _mockLoginInProgress ? null : _submitMockLogin,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: _mockLoginInProgress
|
||||
? const DelayedSpinnerWidget()
|
||||
: Text(
|
||||
widget.data.l10n.loginBtn,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_16px.copyWith(
|
||||
color: appStyle.colors.textPrimaryLight,
|
||||
fontVariations: const [FontVariation("wght", 800)],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_preloadDone) {
|
||||
@@ -176,33 +441,44 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
||||
const SizedBox(height: 16),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: paddingWidthHorizontal),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: ShapeDecoration(
|
||||
image: DecorationImage(
|
||||
image: PreloadedImageProvider(
|
||||
DefaultAssetBundle.of(context),
|
||||
'assets/images/logos/colored_logo.webp',
|
||||
child: GestureDetector(
|
||||
onLongPress: _showMockModeDialog,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 12,
|
||||
horizontal: 8,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 30,
|
||||
height: 30,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: ShapeDecoration(
|
||||
image: DecorationImage(
|
||||
image: PreloadedImageProvider(
|
||||
DefaultAssetBundle.of(context),
|
||||
'assets/images/logos/colored_logo.webp',
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Firka Napló',
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'Firka Napló',
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
@@ -459,61 +735,13 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
|
||||
right: 0,
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: paddingWidthHorizontal,
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: false,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: _loginWebView,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
decoration: ShapeDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
shadows: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.textPrimary.withAlpha(
|
||||
13,
|
||||
),
|
||||
blurRadius: 2,
|
||||
offset: const Offset(0, 1),
|
||||
spreadRadius: 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
widget.data.l10n.loginBtn,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_16px.copyWith(
|
||||
color: appStyle.colors.textPrimaryLight,
|
||||
fontVariations: const [
|
||||
FontVariation("wght", 800),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: paddingWidthHorizontal,
|
||||
),
|
||||
child: Settings.mockBackendEnabled.value
|
||||
? _buildMockLoginForm()
|
||||
: _buildRealLoginButton(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
GestureDetector(
|
||||
|
||||
@@ -229,6 +229,12 @@ class SettingsAccountPickerView extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await data.client!.cache.clearAccountData();
|
||||
} catch (e) {
|
||||
logger.warning('[Settings] Failed to clear cached data on logout: $e');
|
||||
}
|
||||
|
||||
await data.isar.writeTxn(() async {
|
||||
await data.isar.tokenModels.delete(active);
|
||||
});
|
||||
@@ -287,9 +293,10 @@ class SettingsAccountPickerView extends StatelessWidget {
|
||||
|
||||
await initializeApp();
|
||||
|
||||
if (!context.mounted) return;
|
||||
final nav = Navigator.of(context);
|
||||
if (nav.canPop()) nav.pop();
|
||||
if (context.mounted) {
|
||||
final nav = Navigator.of(context);
|
||||
if (nav.canPop()) nav.pop();
|
||||
}
|
||||
if (accounts.isEmpty) {
|
||||
appRouter?.go('/login');
|
||||
} else {
|
||||
|
||||
@@ -185,7 +185,7 @@ class SettingsAppIconPickerView extends StatelessWidget {
|
||||
if (group == data.l10n.s_ci_icon_g7 || group == data.l10n.s_ci_icon_g8) {
|
||||
pWidgets.add(SizedBox(height: 12));
|
||||
pWidgets.add(
|
||||
buildBoolRow(item.childProtection, settings, setStateOuter),
|
||||
buildBoolRow(context, item.childProtection, settings, setStateOuter),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
import "package:firka/core/settings/settings_repository.dart";
|
||||
import "package:firka/core/settings/settings_ui.dart";
|
||||
import "package:firka/ui/phone/screens/settings/settings_metrics.dart";
|
||||
import "package:firka/ui/phone/screens/settings/settings_toggle.dart";
|
||||
import "package:firka/ui/shared/firka_icon.dart";
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
import "package:firka_common/ui/components/firka_card.dart";
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
Widget buildBoolRow(
|
||||
BuildContext context,
|
||||
SettingsUiBoolean item,
|
||||
SettingsRepository settings,
|
||||
void Function(VoidCallback fn) setStateOuter,
|
||||
) {
|
||||
final value = settings.get(item.setting);
|
||||
final scale = settingsScale(context);
|
||||
|
||||
return FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -23,7 +28,7 @@ Widget buildBoolRow(
|
||||
item.iconData!,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
SizedBox(width: 12 * scale),
|
||||
],
|
||||
)
|
||||
: SizedBox(),
|
||||
@@ -33,20 +38,9 @@ Widget buildBoolRow(
|
||||
),
|
||||
],
|
||||
right: [
|
||||
Switch(
|
||||
SettingsToggle(
|
||||
value: value,
|
||||
thumbColor: WidgetStateProperty.fromMap({
|
||||
WidgetState.selected: appStyle.colors.buttonSecondaryFill,
|
||||
WidgetState.any: appStyle.colors.accent,
|
||||
}),
|
||||
trackColor: WidgetStateProperty.fromMap({
|
||||
WidgetState.selected: appStyle.colors.accent,
|
||||
WidgetState.any: appStyle.colors.a10p,
|
||||
}),
|
||||
trackOutlineColor: WidgetStateProperty.fromMap({
|
||||
WidgetState.selected: appStyle.colors.accent,
|
||||
WidgetState.any: appStyle.colors.a15p,
|
||||
}),
|
||||
scale: scale,
|
||||
onChanged: (v) async {
|
||||
await settings.set(item.setting, v);
|
||||
setStateOuter(() {});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import "package:flutter/widgets.dart";
|
||||
|
||||
const settingsDesignWidth = 376.0;
|
||||
const settingsItemHeight = 56.0;
|
||||
const settingsItemRounding = 16.0;
|
||||
|
||||
double settingsScale(BuildContext context) =>
|
||||
MediaQuery.sizeOf(context).width / settingsDesignWidth;
|
||||
@@ -24,6 +24,7 @@ import 'package:firka/core/state/firka_state.dart';
|
||||
import 'settings_account_picker.dart';
|
||||
import 'settings_app_icon_picker.dart';
|
||||
import 'settings_bool_row.dart';
|
||||
import 'settings_metrics.dart';
|
||||
import 'settings_license_page.dart';
|
||||
import 'settings_logs.dart';
|
||||
import 'settings_personalization_view.dart';
|
||||
@@ -77,6 +78,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
bool forceRender = false,
|
||||
}) {
|
||||
var widgets = List<Widget>.empty(growable: true);
|
||||
final scale = settingsScale(context);
|
||||
|
||||
for (var item in items) {
|
||||
if (!forceRender && !item.visible()) continue;
|
||||
@@ -93,34 +95,38 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
if (item is SettingsUiBackHeader) {
|
||||
widgets.add(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 0),
|
||||
child: GestureDetector(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 8, 16, 8),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-8, 0),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
Transform.translate(
|
||||
offset: const Offset(-8, 1),
|
||||
child: Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 13),
|
||||
SizedBox(height: 5),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -174,21 +180,42 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
);
|
||||
cardWidgets.add(SizedBox(width: 8));
|
||||
cardWidgets.add(SizedBox(width: 12 * scale));
|
||||
}
|
||||
|
||||
cardWidgets.add(
|
||||
Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
item.subtitle == null
|
||||
? Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 2,
|
||||
children: [
|
||||
Text(
|
||||
item.title,
|
||||
style: appStyle.fonts.B_16SB
|
||||
.apply(color: appStyle.colors.textPrimary)
|
||||
.copyWith(height: 1.1),
|
||||
),
|
||||
Text(
|
||||
item.subtitle!,
|
||||
style: appStyle.fonts.B_14R
|
||||
.apply(color: appStyle.colors.textSecondary)
|
||||
.copyWith(height: 1.1),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (item.children.isEmpty && item.redirectTo == null) return;
|
||||
if (item.redirectTo != null && item.redirectTo == "discord") {
|
||||
launchUrlString(
|
||||
"https://discord.com/invite/firka-1111649116020285532",
|
||||
@@ -204,6 +231,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
},
|
||||
child: item.redirectTo != null
|
||||
? FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: cardWidgets,
|
||||
right: [
|
||||
RotationTransition(
|
||||
@@ -217,7 +246,11 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
),
|
||||
],
|
||||
)
|
||||
: FirkaCard(left: cardWidgets),
|
||||
: FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: cardWidgets,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -231,7 +264,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -270,7 +304,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsUiBoolean) {
|
||||
widgets.add(buildBoolRow(item, settings, setState));
|
||||
widgets.add(buildBoolRow(context, item, settings, setState));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -282,7 +316,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
if (i == activeIndex) {
|
||||
widgets.add(
|
||||
FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
Text(
|
||||
k,
|
||||
@@ -320,7 +355,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: 52 + 12,
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
Text(
|
||||
k,
|
||||
@@ -388,6 +424,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -437,21 +475,16 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
child: Scaffold(
|
||||
backgroundColor: appStyle.colors.background,
|
||||
body: SafeArea(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
child: Stack(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsetsGeometry.all(20),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: body,
|
||||
),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(20, 20, 20, 40),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: body,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
63
firka/lib/ui/phone/screens/settings/settings_toggle.dart
Normal file
63
firka/lib/ui/phone/screens/settings/settings_toggle.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class SettingsToggle extends StatelessWidget {
|
||||
static const _designWidth = 40.0;
|
||||
static const _designHeight = 24.0;
|
||||
static const _designKnob = 20.0;
|
||||
|
||||
final bool value;
|
||||
final double scale;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
const SettingsToggle({
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
this.scale = 1,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final width = _designWidth * scale;
|
||||
final height = _designHeight * scale;
|
||||
final knob = _designKnob * scale;
|
||||
final inset = (height - knob) / 2;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onChanged(!value),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.easeOut,
|
||||
width: width,
|
||||
height: height,
|
||||
decoration: BoxDecoration(
|
||||
color: value ? appStyle.colors.accent : appStyle.colors.a15p,
|
||||
borderRadius: BorderRadius.circular(height / 2),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
AnimatedAlign(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
curve: Curves.easeOut,
|
||||
alignment: value ? Alignment.centerRight : Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: inset),
|
||||
child: Container(
|
||||
width: knob,
|
||||
height: knob,
|
||||
decoration: BoxDecoration(
|
||||
color: value
|
||||
? appStyle.colors.buttonSecondaryFill
|
||||
: appStyle.colors.accent,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
97
firka/lib/ui/phone/widgets/home_main_new_grades.dart
Normal file
97
firka/lib/ui/phone/widgets/home_main_new_grades.dart
Normal file
@@ -0,0 +1,97 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:firka/l10n/app_localizations.dart';
|
||||
import 'package:firka/ui/phone/screens/surprise_grades/surprise_grades_screen.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||
import 'package:firka_common/ui/components/firka_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
const _cardIcon = "assets/images/surprise_grades/play_card_star.svg";
|
||||
|
||||
class NewGradesWidget extends StatelessWidget {
|
||||
static const _designWidth = 336.0;
|
||||
static const _miniWidth = 90.117;
|
||||
static const _tilt = 15 * pi / 180;
|
||||
|
||||
static const _slots = [
|
||||
(172.04, 46.86, -_tilt, 1),
|
||||
(302.63, 20.32, _tilt, 2),
|
||||
(222.92, 9.0, 0.0, 0),
|
||||
];
|
||||
|
||||
final AppLocalizations l10n;
|
||||
final List<GradeCacheModel> grades;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const NewGradesWidget(this.l10n, this.grades, {this.onTap, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: FirkaCard.single(
|
||||
margin: EdgeInsets.only(bottom: 1),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final s = constraints.maxWidth / _designWidth;
|
||||
|
||||
return Stack(
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
for (final (left, top, angle, index) in _slots)
|
||||
if (index < grades.length)
|
||||
Positioned(
|
||||
left: left * s,
|
||||
top: top * s,
|
||||
child: Transform.rotate(
|
||||
angle: angle,
|
||||
child: SurpriseGradeMiniCard(
|
||||
grades[index],
|
||||
l10n,
|
||||
width: _miniWidth * s,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(left: 16 * s, top: 16 * s, child: _icon(s)),
|
||||
Positioned(
|
||||
left: 16 * s,
|
||||
top: 67 * s,
|
||||
child: Text(
|
||||
l10n.new_grades_card,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _icon(double s) {
|
||||
return Container(
|
||||
width: 32 * s,
|
||||
height: 32 * s,
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.a15p,
|
||||
borderRadius: BorderRadius.circular(16 * s),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: SvgPicture.asset(
|
||||
_cardIcon,
|
||||
width: 20 * s,
|
||||
height: 20 * s,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,242 +1,293 @@
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:firka_common/core/consts.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson_big.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka_common/core/debug_helper.dart';
|
||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||
import 'package:firka_common/ui/components/firka_card.dart';
|
||||
import 'package:firka_common/ui/theme/style.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
class _LessonSliderState extends State<LessonSlider> {
|
||||
DateTime now = timeNow();
|
||||
int? swipeBack;
|
||||
late Timer timer;
|
||||
int? activeLessonIndex;
|
||||
int? centeredPageIndex;
|
||||
CarouselSliderController controller = CarouselSliderController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
timer = Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
if (widget.lessons.isEmpty || !mounted) return;
|
||||
setState(() {
|
||||
if (swipeBack != null) swipeBack = swipeBack! - 1;
|
||||
now = timeNow();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
timer.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.lessons.isEmpty) {
|
||||
return SizedBox();
|
||||
}
|
||||
|
||||
LessonCacheModel? currentLesson;
|
||||
int tmpIndex;
|
||||
if (now.isBefore(widget.lessons.first.start)) {
|
||||
tmpIndex = 0;
|
||||
} else {
|
||||
(int, LessonCacheModel)? currentIndex = widget.lessons.indexed
|
||||
.firstWhereOrNull((e) => now.isBefore(e.$2.end));
|
||||
|
||||
tmpIndex = (currentIndex?.$1 ?? widget.lessons.length) + 1;
|
||||
if (currentIndex != null) {
|
||||
currentLesson = currentIndex.$2;
|
||||
}
|
||||
}
|
||||
|
||||
if (activeLessonIndex == null || tmpIndex != activeLessonIndex) {
|
||||
activeLessonIndex = tmpIndex;
|
||||
swipeBack = 0;
|
||||
}
|
||||
|
||||
centeredPageIndex ??= activeLessonIndex!;
|
||||
|
||||
if (controller.ready && swipeBack == 0) {
|
||||
controller.animateToPage(activeLessonIndex!);
|
||||
}
|
||||
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
spacing: 12,
|
||||
children: [
|
||||
OverflowBox(
|
||||
maxWidth: MediaQuery.widthOf(context),
|
||||
fit: OverflowBoxFit.deferToChild,
|
||||
child: CarouselSlider(
|
||||
items: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: StartingSoonWidget(initData.l10n, now, widget.lessons),
|
||||
),
|
||||
...widget.lessons.map(
|
||||
(entry) => Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: LessonBigWidget(
|
||||
initData,
|
||||
entry,
|
||||
active: currentLesson == entry,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: FirkaCard.single(
|
||||
padding: EdgeInsets.all(16),
|
||||
margin: EdgeInsets.only(bottom: 1),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
FilledCircle(
|
||||
diameter: 32,
|
||||
color: appStyle.colors.a15p,
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.moonSolid,
|
||||
size: 20,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
widget.tomorrowTestAmount == 0
|
||||
? initData.l10n.tt_no_classes_l2
|
||||
: initData.l10n.get_ready,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 28,
|
||||
padding: EdgeInsets.symmetric(horizontal: 6),
|
||||
decoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
color: appStyle.colors.background,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
size: 12,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
widget.tomorrowTestAmount == 0
|
||||
? initData.l10n.no_tests_tomorrow
|
||||
: initData.l10n.tests_tomorrow(
|
||||
widget.tomorrowTestAmount.toString(),
|
||||
),
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
carouselController: controller,
|
||||
options: CarouselOptions(
|
||||
initialPage: activeLessonIndex!,
|
||||
height: 106,
|
||||
viewportFraction: 346 / 376,
|
||||
enableInfiniteScroll: false,
|
||||
onPageChanged: (index, reason) {
|
||||
centeredPageIndex = index;
|
||||
if (index == activeLessonIndex) {
|
||||
swipeBack = null;
|
||||
} else if (reason == CarouselPageChangedReason.manual) {
|
||||
swipeBack = 5;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"sunSolid",
|
||||
color: centeredPageIndex == 0
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
size: centeredPageIndex == 0 ? 16 : 12,
|
||||
),
|
||||
...widget.lessons.indexed.map(
|
||||
(i) => FilledCircle(
|
||||
diameter: centeredPageIndex == i.$1 + 1 ? 10 : 8,
|
||||
color: centeredPageIndex == i.$1 + 1
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
child: SizedBox(),
|
||||
),
|
||||
),
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.moonSolid,
|
||||
color: centeredPageIndex == widget.lessons.length + 1
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
size: centeredPageIndex == widget.lessons.length + 1 ? 16 : 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LessonSlider extends StatefulWidget {
|
||||
final List<LessonCacheModel> lessons;
|
||||
final int tomorrowTestAmount;
|
||||
|
||||
LessonSlider(
|
||||
Iterable<LessonCacheModel> lessons,
|
||||
this.tomorrowTestAmount, {
|
||||
super.key,
|
||||
}) : lessons = lessons
|
||||
.where(((l) => l.type != TimetableConsts.event))
|
||||
.toList();
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _LessonSliderState();
|
||||
}
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:firka_common/core/consts.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/routing/chart_interaction_scope.dart';
|
||||
import 'package:firka/ui/phone/widgets/home_main_new_grades.dart';
|
||||
import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart';
|
||||
import 'package:firka/ui/phone/widgets/lesson_big.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka_common/core/debug_helper.dart';
|
||||
import 'package:firka_common/data/models/grade_cache_model.dart';
|
||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||
import 'package:firka_common/ui/components/firka_card.dart';
|
||||
import 'package:firka_common/ui/theme/style.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
class _LessonSliderState extends State<LessonSlider> {
|
||||
DateTime now = timeNow();
|
||||
int? swipeBack;
|
||||
late Timer timer;
|
||||
int? activeLessonIndex;
|
||||
int? centeredPageIndex;
|
||||
CarouselSliderController controller = CarouselSliderController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
timer = Timer.periodic(Duration(seconds: 1), (timer) async {
|
||||
if (widget.lessons.isEmpty || !mounted) return;
|
||||
setState(() {
|
||||
if (swipeBack != null) swipeBack = swipeBack! - 1;
|
||||
now = timeNow();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
timer.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasNewGrades = widget.newGrades.isNotEmpty;
|
||||
final hasLessons = widget.lessons.isNotEmpty;
|
||||
|
||||
if (!hasNewGrades && !hasLessons) {
|
||||
return SizedBox();
|
||||
}
|
||||
|
||||
final offset = hasNewGrades ? 1 : 0;
|
||||
|
||||
LessonCacheModel? currentLesson;
|
||||
int tmpIndex;
|
||||
if (!hasLessons) {
|
||||
tmpIndex = 0;
|
||||
} else if (now.isBefore(widget.lessons.first.start)) {
|
||||
tmpIndex = 0;
|
||||
} else {
|
||||
(int, LessonCacheModel)? currentIndex = widget.lessons.indexed
|
||||
.firstWhereOrNull((e) => now.isBefore(e.$2.end));
|
||||
|
||||
tmpIndex = (currentIndex?.$1 ?? widget.lessons.length) + 1;
|
||||
if (currentIndex != null) {
|
||||
currentLesson = currentIndex.$2;
|
||||
}
|
||||
}
|
||||
|
||||
if (activeLessonIndex == null || tmpIndex != activeLessonIndex) {
|
||||
activeLessonIndex = tmpIndex;
|
||||
swipeBack = 0;
|
||||
}
|
||||
|
||||
final initialPage = hasNewGrades ? 0 : activeLessonIndex!;
|
||||
centeredPageIndex ??= initialPage;
|
||||
|
||||
if (controller.ready && swipeBack == 0 && !hasNewGrades) {
|
||||
controller.animateToPage(activeLessonIndex!);
|
||||
}
|
||||
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
spacing: 12,
|
||||
children: [
|
||||
OverflowBox(
|
||||
maxWidth: MediaQuery.widthOf(context),
|
||||
fit: OverflowBoxFit.deferToChild,
|
||||
child: Listener(
|
||||
behavior: HitTestBehavior.deferToChild,
|
||||
onPointerDown: (_) =>
|
||||
ChartInteractionScope.of(context).value = true,
|
||||
onPointerUp: (_) => ChartInteractionScope.of(context).value = false,
|
||||
onPointerCancel: (_) =>
|
||||
ChartInteractionScope.of(context).value = false,
|
||||
child: CarouselSlider(
|
||||
items: [
|
||||
if (hasNewGrades)
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: NewGradesWidget(
|
||||
initData.l10n,
|
||||
widget.newGrades,
|
||||
onTap: widget.onNewGradesTap,
|
||||
),
|
||||
),
|
||||
if (hasLessons)
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: StartingSoonWidget(
|
||||
initData.l10n,
|
||||
now,
|
||||
widget.lessons,
|
||||
),
|
||||
),
|
||||
...widget.lessons.map(
|
||||
(entry) => Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: LessonBigWidget(
|
||||
initData,
|
||||
entry,
|
||||
active: currentLesson == entry,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasLessons)
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5),
|
||||
child: FirkaCard.single(
|
||||
padding: EdgeInsets.all(16),
|
||||
margin: EdgeInsets.only(bottom: 1),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
FilledCircle(
|
||||
diameter: 32,
|
||||
color: appStyle.colors.a15p,
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.moonSolid,
|
||||
size: 20,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
widget.tomorrowTestAmount == 0
|
||||
? initData.l10n.tt_no_classes_l2
|
||||
: initData.l10n.get_ready,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 28,
|
||||
padding: EdgeInsets.symmetric(horizontal: 6),
|
||||
decoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
color: appStyle.colors.background,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Solid,
|
||||
size: 12,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
widget.tomorrowTestAmount == 0
|
||||
? initData.l10n.no_tests_tomorrow
|
||||
: initData.l10n.tests_tomorrow(
|
||||
widget.tomorrowTestAmount.toString(),
|
||||
),
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
carouselController: controller,
|
||||
options: CarouselOptions(
|
||||
initialPage: initialPage,
|
||||
height: 106,
|
||||
viewportFraction: 346 / 376,
|
||||
enableInfiniteScroll: false,
|
||||
onPageChanged: (index, reason) {
|
||||
centeredPageIndex = index;
|
||||
if (index == activeLessonIndex! + offset) {
|
||||
swipeBack = null;
|
||||
} else if (reason == CarouselPageChangedReason.manual) {
|
||||
swipeBack = 5;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 16,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
if (hasNewGrades)
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.shootingStarSolid,
|
||||
color: centeredPageIndex == 0
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
size: centeredPageIndex == 0 ? 16 : 12,
|
||||
),
|
||||
if (hasLessons) ...[
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticonsLocal,
|
||||
"sunSolid",
|
||||
color: centeredPageIndex == offset
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
size: centeredPageIndex == offset ? 16 : 12,
|
||||
),
|
||||
...widget.lessons.indexed.map(
|
||||
(i) => FilledCircle(
|
||||
diameter: centeredPageIndex == i.$1 + 1 + offset ? 10 : 8,
|
||||
color: centeredPageIndex == i.$1 + 1 + offset
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
child: SizedBox(),
|
||||
),
|
||||
),
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.moonSolid,
|
||||
color: centeredPageIndex == widget.lessons.length + 1 + offset
|
||||
? appStyle.colors.accent
|
||||
: appStyle.colors.accent.withAlpha(128),
|
||||
size: centeredPageIndex == widget.lessons.length + 1 + offset
|
||||
? 16
|
||||
: 12,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LessonSlider extends StatefulWidget {
|
||||
final List<LessonCacheModel> lessons;
|
||||
final int tomorrowTestAmount;
|
||||
final List<GradeCacheModel> newGrades;
|
||||
final VoidCallback? onNewGradesTap;
|
||||
|
||||
LessonSlider(
|
||||
Iterable<LessonCacheModel> lessons,
|
||||
this.tomorrowTestAmount, {
|
||||
this.newGrades = const [],
|
||||
this.onNewGradesTap,
|
||||
super.key,
|
||||
}) : lessons = lessons
|
||||
.where(((l) => l.type != TimetableConsts.event))
|
||||
.toList();
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _LessonSliderState();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:firka_common/core/consts.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/app/initialization.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -11,9 +9,9 @@ import 'package:flutter_svg/svg.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import 'package:firka/services/watch_sync_helper.dart';
|
||||
import 'package:firka/api/login_finish.dart';
|
||||
import 'package:firka/api/token_grant.dart';
|
||||
import 'package:firka_common/data/models/token_model.dart';
|
||||
import 'package:firka/core/dev/mock_backend.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
|
||||
@@ -65,6 +63,8 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
|
||||
);
|
||||
}
|
||||
|
||||
loginUrl = MockBackend.rewrite(loginUrl);
|
||||
|
||||
final trimmed = loginUrl.replaceFirst(RegExp(r'^https?://'), '');
|
||||
final parts = trimmed.split('/');
|
||||
_displayHost = parts.isNotEmpty ? parts.first : trimmed;
|
||||
@@ -102,37 +102,11 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
|
||||
var code = uri.queryParameters["code"]!;
|
||||
|
||||
try {
|
||||
var isar = widget.data.isar;
|
||||
var resp = await getAccessToken(code);
|
||||
|
||||
logger.info("getAccessToken(): $resp");
|
||||
|
||||
var tokenModel = TokenModel.fromResp(resp);
|
||||
|
||||
await isar.writeTxn(() async {
|
||||
await isar.tokenModels.put(tokenModel);
|
||||
});
|
||||
|
||||
await widget.data.settings.setSelectedAccountKey(
|
||||
tokenModel.key,
|
||||
);
|
||||
await initializeApp();
|
||||
|
||||
if (Platform.isIOS) {
|
||||
final watchInstalled =
|
||||
await WatchSyncHelper.isWatchAppInstalled();
|
||||
if (watchInstalled) {
|
||||
try {
|
||||
await WatchSyncHelper.saveTokenToiCloud(tokenModel);
|
||||
} catch (_) {}
|
||||
|
||||
try {
|
||||
await WatchSyncHelper.sendTokenToWatch();
|
||||
} catch (_) {
|
||||
// Watch may be unavailable, ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
await completeLogin(widget.data, resp);
|
||||
|
||||
if (!mounted) return NavigationDecision.prevent;
|
||||
|
||||
|
||||
0
firka/lib/ui/phone/widgets/teacher_label.dart
Normal file
0
firka/lib/ui/phone/widgets/teacher_label.dart
Normal file
@@ -96,6 +96,7 @@ flutter:
|
||||
- assets/images/cactus_error_screen.png
|
||||
- assets/images/logos/dave_error.png
|
||||
- assets/icons/button/colorwheel.png
|
||||
- assets/images/surprise_grades/
|
||||
|
||||
fonts:
|
||||
- family: Montserrat
|
||||
@@ -132,4 +133,5 @@ flutter:
|
||||
style: normal
|
||||
|
||||
dependency_overrides:
|
||||
html: 0.15.6
|
||||
vector_math: ^2.2.0
|
||||
|
||||
@@ -9,6 +9,7 @@ const _lockFileName = 'codegen-lock.yaml';
|
||||
|
||||
void main() async {
|
||||
final root = _projectRoot();
|
||||
print(root);
|
||||
var ran = false;
|
||||
|
||||
if (_iconsOutOfDate(root)) {
|
||||
@@ -56,14 +57,15 @@ void main() async {
|
||||
ran = true;
|
||||
}
|
||||
|
||||
if (_isarOutOfDate(root) || _isarGeneratedFilesMissing(root)) {
|
||||
final inputs = _isarInputs(root);
|
||||
final hashes = _computeHashes(root, inputs);
|
||||
var common = p.join(p.dirname(root), "firka_common");
|
||||
if (_isarOutOfDate(common) || _isarGeneratedFilesMissing(common)) {
|
||||
final inputs = _isarInputs(common);
|
||||
final hashes = _computeHashes(common, inputs);
|
||||
stdout.writeln(
|
||||
'Isar generated dart files out of date or missing, running build_runner...',
|
||||
);
|
||||
await _run('dart', ['run', 'build_runner', 'build'], root);
|
||||
_updateLockWithHashes(root, 'isar', hashes);
|
||||
await _run('dart', ['run', 'build_runner', 'build'], common);
|
||||
_updateLockWithHashes(common, 'isar', hashes);
|
||||
ran = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,26 @@ class CacheManager {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> clearAccountData() async {
|
||||
await isarInit.writeTxn(() async {
|
||||
await getGrades().deleteAll();
|
||||
await getHomeworks().deleteAll();
|
||||
await getTests().deleteAll();
|
||||
await getOmissions().deleteAll();
|
||||
await getTimeTable().deleteAll();
|
||||
await getClassAverages().deleteAll();
|
||||
await getMessages().deleteAll();
|
||||
await isarInit.classGroupCacheModels
|
||||
.filter()
|
||||
.group(isCurrentClassGroup)
|
||||
.deleteAll();
|
||||
await isarInit.studentCacheModels
|
||||
.filter()
|
||||
.group(isCurrentStudent)
|
||||
.deleteAll();
|
||||
});
|
||||
}
|
||||
|
||||
void resolveTeachers() {
|
||||
Set<TeacherModel> teachers = HashSet<TeacherModel>(
|
||||
equals: (t, t2) =>
|
||||
|
||||
51
firka_common/lib/data/last_seen.dart
Normal file
51
firka_common/lib/data/last_seen.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:firka_common/data/models/generic_cache_model.dart';
|
||||
|
||||
class LastSeen {
|
||||
final DateTime createdAt;
|
||||
final int cacheKey;
|
||||
|
||||
const LastSeen(this.createdAt, this.cacheKey);
|
||||
|
||||
static LastSeen? parse(String? raw) {
|
||||
if (raw == null || raw.isEmpty) return null;
|
||||
|
||||
final parts = raw.split(":");
|
||||
if (parts.length != 2) return null;
|
||||
|
||||
final millis = int.tryParse(parts[0]);
|
||||
final key = int.tryParse(parts[1]);
|
||||
if (millis == null || key == null) return null;
|
||||
|
||||
return LastSeen(DateTime.fromMillisecondsSinceEpoch(millis), key);
|
||||
}
|
||||
|
||||
static LastSeen? newestOf(Iterable<GenericCacheModel> items) {
|
||||
LastSeen? newest;
|
||||
for (final item in items) {
|
||||
final seen = LastSeen(item.createdAt, item.cacheKey);
|
||||
if (newest == null || seen.isAfter(newest)) newest = seen;
|
||||
}
|
||||
return newest;
|
||||
}
|
||||
|
||||
static List<T> newerThan<T extends GenericCacheModel>(
|
||||
Iterable<T> items,
|
||||
LastSeen? seen,
|
||||
) {
|
||||
if (seen == null) return items.toList();
|
||||
|
||||
return items
|
||||
.where((i) => LastSeen(i.createdAt, i.cacheKey).isAfter(seen))
|
||||
.toList();
|
||||
}
|
||||
|
||||
bool isAfter(LastSeen other) {
|
||||
if (createdAt.isAfter(other.createdAt)) return true;
|
||||
if (createdAt.isAtSameMomentAs(other.createdAt)) {
|
||||
return cacheKey > other.cacheKey;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String toText() => "${createdAt.millisecondsSinceEpoch}:$cacheKey";
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class FirkaCard extends StatelessWidget {
|
||||
final Attach attached;
|
||||
final Color? color;
|
||||
final bool? isLightMode;
|
||||
final double? rounding;
|
||||
final Widget child;
|
||||
|
||||
factory FirkaCard({
|
||||
@@ -29,6 +30,7 @@ class FirkaCard extends StatelessWidget {
|
||||
double? height,
|
||||
double? width,
|
||||
bool? isLightMode,
|
||||
double? rounding,
|
||||
}) {
|
||||
final leftRow = Row(children: left);
|
||||
|
||||
@@ -50,6 +52,7 @@ class FirkaCard extends StatelessWidget {
|
||||
height: height,
|
||||
shadow: shadow,
|
||||
isLightMode: isLightMode,
|
||||
rounding: rounding,
|
||||
child: extra == null ? alignedRow : Column(children: [alignedRow, extra]),
|
||||
);
|
||||
}
|
||||
@@ -64,13 +67,14 @@ class FirkaCard extends StatelessWidget {
|
||||
this.height,
|
||||
this.width,
|
||||
this.isLightMode,
|
||||
this.rounding,
|
||||
required this.child,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final defaultRounding = 16.0;
|
||||
final defaultRounding = rounding ?? 16.0;
|
||||
final attachedRounding = 8.0;
|
||||
final isLight =
|
||||
isLightMode ?? Theme.of(context).brightness == Brightness.light;
|
||||
|
||||
Submodule firka_wear/lib/l10n updated: f4812ec3b3...9097326e88
@@ -53,7 +53,7 @@ class Grade extends UidObj {
|
||||
mode: json.nameUidDesc('Mod'),
|
||||
valueType: json.nameUidDesc('ErtekFajta')!,
|
||||
teacher: json['ErtekeloTanarNeve'],
|
||||
kind: json['Kind'],
|
||||
kind: json['Jelleg'],
|
||||
numericValue: json['SzamErtek'],
|
||||
strValue: json['SzovegesErtek'],
|
||||
weightPercentage: json['SulySzazalekErteke'],
|
||||
@@ -75,7 +75,7 @@ class Grade extends UidObj {
|
||||
'Mod': mode?.toJson(),
|
||||
'ErtekFajta': valueType.toJson(),
|
||||
'ErtekeloTanarNeve': teacher,
|
||||
'Kind': kind,
|
||||
'Jelleg': kind,
|
||||
'SzamErtek': numericValue,
|
||||
'SzovegesErtek': strValue,
|
||||
'SulySzazalekErteke': weightPercentage,
|
||||
|
||||
Reference in New Issue
Block a user