forked from firka/firka
Compare commits
36 Commits
backup/ios
...
5766eb6675
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5766eb6675 | ||
|
|
8fb5d5c89b | ||
|
|
f22ab629bc | ||
|
|
09ac4b7f61 | ||
|
|
5320625d83 | ||
|
|
eccdf90fd8 | ||
|
|
b4ccd52321 | ||
|
|
4658366fd4 | ||
|
|
aa77e25fe4 | ||
|
|
8984f8a915 | ||
|
|
4c28999d10 | ||
|
|
50274575f6 | ||
|
|
fb8fad142a | ||
|
|
2dccb59f7f | ||
|
|
7c9ade35f0 | ||
|
|
ca9e6c3efa | ||
| a4af924653 | |||
| 8bc52aadcb | |||
| 6101513a43 | |||
| 16e7ca49ca | |||
| dd05320346 | |||
| 1f9512d03a | |||
| d36992c7bc | |||
| fd57184f99 | |||
| fa31c0d7a3 | |||
| 47e9047873 | |||
| 7319878cb8 | |||
| 3dc902b4cf | |||
| 71e1250932 | |||
| 39651c2ab7 | |||
| bffd1d66d9 | |||
| 3480fb2ac0 | |||
| f5a16da72d | |||
| 04a441cd08 | |||
| 80856d1e8d | |||
| 9a74bd5178 |
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
|
||||
|
||||
BIN
firka/assets/fonts/FiraCode-VariableFont_wght.ttf
Normal file
BIN
firka/assets/fonts/FiraCode-VariableFont_wght.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/JustMeAgainDownHere.ttf
Normal file
BIN
firka/assets/fonts/JustMeAgainDownHere.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/Monoton-Regular.ttf
Normal file
BIN
firka/assets/fonts/Monoton-Regular.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/PirataOne-Regular.ttf
Normal file
BIN
firka/assets/fonts/PirataOne-Regular.ttf
Normal file
Binary file not shown.
BIN
firka/assets/fonts/Vollkorn-VariableFont_wght.ttf
Normal file
BIN
firka/assets/fonts/Vollkorn-VariableFont_wght.ttf
Normal file
Binary file not shown.
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,15 +1,16 @@
|
||||
icons:
|
||||
"flutter_launcher_icons.yaml": "c600507ca0df7cebd0f708124842512a14ed3d597b779176200d6ba25b1335b1"
|
||||
"pubspec.yaml": "a6ae0bd67a2b6226bec2dfd55437b3db2b7ca4a03f315c1a0a8c2f4b505c7c87"
|
||||
"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_de.arb": "c6a12eaadf03b012a6a377b3efa4e606bd985355e76e6351956a017f4cfdadc1"
|
||||
"lib/l10n/app_hu.arb": "a63aace8d129dbc054c4996dd9ef7d54aad96888241ce1310518b10a9a7b561d"
|
||||
"lib/l10n/app_en.arb": "b2d72778fedb46155f41eb210906ed8ffba8b12744a2800b039951e0a2a88133"
|
||||
"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';
|
||||
@@ -79,7 +80,11 @@ class KretaClient {
|
||||
return lessons;
|
||||
}
|
||||
|
||||
Future<void> renewTimetable({bool wholeYear = false}) async {
|
||||
Future<void> renewTimetable({
|
||||
bool wholeYear = false,
|
||||
DateTime? skipFrom,
|
||||
DateTime? skipTo,
|
||||
}) async {
|
||||
DateTime now = timeNow();
|
||||
DateTime firstDayOfSchool = now.getFirstSchoolDay();
|
||||
DateTime firstDayOfNextYear = firstDayOfSchool.copyWith(
|
||||
@@ -129,12 +134,20 @@ class KretaClient {
|
||||
int waitAfter = 5;
|
||||
while (date.isBefore(to)) {
|
||||
DateTime tmpTo = date.add(Duration(days: 14));
|
||||
requests.add(getLessons(date, tmpTo));
|
||||
final alreadyFetched =
|
||||
skipFrom != null &&
|
||||
skipTo != null &&
|
||||
!date.isBefore(skipFrom) &&
|
||||
!tmpTo.isAfter(skipTo);
|
||||
if (!alreadyFetched) {
|
||||
requests.add(getLessons(date, tmpTo));
|
||||
i++;
|
||||
}
|
||||
date = tmpTo;
|
||||
|
||||
i++;
|
||||
if (waitAfter == i) {
|
||||
await Future.wait(requests);
|
||||
requests = [];
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
@@ -164,13 +177,16 @@ class KretaClient {
|
||||
if (reInit) {
|
||||
await init();
|
||||
}
|
||||
final currentFrom = timeNow().getMonday();
|
||||
final currentTo = currentFrom.add(const Duration(days: 14));
|
||||
await Future.wait([
|
||||
getTests(),
|
||||
getHomework(),
|
||||
renewMessages(),
|
||||
getGrades(),
|
||||
getLessons(currentFrom, currentTo),
|
||||
]);
|
||||
await renewTimetable();
|
||||
await renewTimetable(skipFrom: currentFrom, skipTo: currentTo);
|
||||
|
||||
// manual link
|
||||
await getOmissions();
|
||||
@@ -184,6 +200,49 @@ class KretaClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Runs [action] without the fetching toast. Sets the error toast on failure.
|
||||
Future<void> pullRefresh(Future Function() action) async {
|
||||
try {
|
||||
await action();
|
||||
} catch (e) {
|
||||
if (!isTokenExpired(e)) {
|
||||
_toastCubit.setActiveToast(.error, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Refetches everything shown on the home feed (not the full school-year cache).
|
||||
Future<void> refreshHomeFeed() async {
|
||||
await pullRefresh(() async {
|
||||
final weekFrom = timeNow().getMonday();
|
||||
final weekTo = weekFrom.add(const Duration(days: 7));
|
||||
await Future.wait([
|
||||
getStudent(),
|
||||
getTests(),
|
||||
getHomework(),
|
||||
renewMessages(),
|
||||
getGrades(),
|
||||
getLessons(weekFrom, weekTo),
|
||||
]);
|
||||
// manual link
|
||||
await getOmissions();
|
||||
cache.resolveTeachers();
|
||||
});
|
||||
}
|
||||
|
||||
/// Fetches lessons in 14-day chunks so [from]..[to] stays under the API range limit.
|
||||
Future<void> getLessonsCovering(DateTime from, DateTime to) async {
|
||||
DateTime date = from;
|
||||
final requests = <Future>[];
|
||||
while (date.isBefore(to)) {
|
||||
final tmpTo = date.add(const Duration(days: 14));
|
||||
final end = tmpTo.isAfter(to) ? to : tmpTo;
|
||||
requests.add(getLessons(date, end));
|
||||
date = tmpTo;
|
||||
}
|
||||
await Future.wait(requests);
|
||||
}
|
||||
|
||||
Future<void> _setReauthFlag() async {
|
||||
if (Platform.isIOS) {
|
||||
try {
|
||||
@@ -422,7 +481,7 @@ class KretaClient {
|
||||
};
|
||||
|
||||
return await dio.get(
|
||||
url,
|
||||
MockBackend.rewrite(url),
|
||||
options: Options(
|
||||
method: method,
|
||||
headers: headers,
|
||||
@@ -556,6 +615,7 @@ class KretaClient {
|
||||
isarInit.writeTxnSync(() {
|
||||
isarInit.collection<C>().putAllSync(caches);
|
||||
});
|
||||
initData.homeRefreshCubit.requestRefresh();
|
||||
return caches;
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
);
|
||||
|
||||
@@ -12,11 +12,13 @@ import 'package:firka/services/live_activity_service.dart';
|
||||
import 'package:firka/core/settings/settings_effects.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
import 'package:firka/core/settings/title_font.dart';
|
||||
import 'package:firka/services/watch_sync_helper.dart';
|
||||
import 'package:firka/l10n/app_localizations_de.dart';
|
||||
import 'package:firka/l10n/app_localizations_en.dart';
|
||||
import 'package:firka/l10n/app_localizations_hu.dart';
|
||||
import 'package:firka/core/swear_generator.dart';
|
||||
import 'package:firka/ui/phone/screens/themes/builtin_theme_id.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
@@ -80,28 +82,71 @@ void initTheme(AppInitialization data) {
|
||||
final brightness =
|
||||
SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
|
||||
final titleFont = Settings.titleFont.value;
|
||||
final titleWeight = Settings.titleWeight.value;
|
||||
final fonts = buildAppFonts(
|
||||
headingFamily: titleFont.fontFamily,
|
||||
headingWeight: titleWeight,
|
||||
supportsWeight: titleFont.supportsWeight,
|
||||
);
|
||||
|
||||
appHeadingTextCase = switch (Settings.titleCapitalization.value) {
|
||||
TitleCapitalization.lower => HeadingTextCase.lower,
|
||||
TitleCapitalization.upper => HeadingTextCase.upper,
|
||||
TitleCapitalization.normal => HeadingTextCase.normal,
|
||||
};
|
||||
|
||||
FirkaStyle baseStyle;
|
||||
final coreId = Settings.selectedCoreThemeId.value;
|
||||
final gradeId = Settings.selectedGradeThemeId.value;
|
||||
switch (Settings.themeBrightness.value) {
|
||||
case ThemeBrightness.light:
|
||||
appStyle = lightStyle;
|
||||
baseStyle = styleFor(
|
||||
coreId: coreId,
|
||||
gradeId: gradeId,
|
||||
isLight: true,
|
||||
fonts: fonts,
|
||||
);
|
||||
themeCubit.setLightMode(true);
|
||||
break;
|
||||
case ThemeBrightness.dark:
|
||||
appStyle = darkStyle;
|
||||
baseStyle = styleFor(
|
||||
coreId: coreId,
|
||||
gradeId: gradeId,
|
||||
isLight: false,
|
||||
fonts: fonts,
|
||||
);
|
||||
themeCubit.setLightMode(false);
|
||||
break;
|
||||
case ThemeBrightness.auto:
|
||||
if (brightness == Brightness.dark) {
|
||||
appStyle = darkStyle;
|
||||
baseStyle = styleFor(
|
||||
coreId: coreId,
|
||||
gradeId: gradeId,
|
||||
isLight: false,
|
||||
fonts: fonts,
|
||||
);
|
||||
themeCubit.setLightMode(false);
|
||||
} else {
|
||||
appStyle = lightStyle;
|
||||
baseStyle = styleFor(
|
||||
coreId: coreId,
|
||||
gradeId: gradeId,
|
||||
isLight: true,
|
||||
fonts: fonts,
|
||||
);
|
||||
themeCubit.setLightMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appStyle = baseStyle;
|
||||
}
|
||||
Future<void> _initData(AppInitialization init) async {
|
||||
await init.settings.loadAll();
|
||||
final selectedThemeId = Settings.selectedThemeId.value;
|
||||
final normalized = normalizeSelectedThemeId(selectedThemeId);
|
||||
if (normalized != selectedThemeId) {
|
||||
await Settings.selectedThemeId.set(normalized);
|
||||
}
|
||||
await initLang(init);
|
||||
initTheme(init);
|
||||
|
||||
@@ -150,12 +195,28 @@ 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}");
|
||||
init.client = KretaClient(token);
|
||||
await init.client!.init();
|
||||
init.client!.renewCache(reInit: false);
|
||||
|
||||
// Don't block first paint on the network: render whatever is already
|
||||
// cached, then stream in student/timetable/grades/etc. as they arrive.
|
||||
unawaited(() async {
|
||||
try {
|
||||
await init.client!.init();
|
||||
} catch (e) {
|
||||
logger.warning("[Init] Failed to initialize KretaClient: $e");
|
||||
if (!isTokenExpired(e)) {
|
||||
init.toastCubit.setActiveToast(.error, e);
|
||||
}
|
||||
}
|
||||
init.homeRefreshCubit.requestRefresh();
|
||||
|
||||
await init.client!.renewCache(reInit: false);
|
||||
init.homeRefreshCubit.requestRefresh();
|
||||
}());
|
||||
|
||||
if (Platform.isIOS) {
|
||||
final expiryDate = token.expiryDate;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -317,4 +317,16 @@ extension StringExtension on String {
|
||||
"${string[0]}.",
|
||||
).shortenName(index - string.length + 2 + 1);
|
||||
}
|
||||
|
||||
/// Removes CSS font-feature-settings. flutter_html passes values like
|
||||
/// `normal` into FontFeature, which requires a 4-character OpenType tag.
|
||||
String withoutFontFeatureSettings() {
|
||||
return replaceAll(
|
||||
RegExp(
|
||||
r'''font-feature-settings\s*:\s*[^;}"']+;?''',
|
||||
caseSensitive: false,
|
||||
),
|
||||
"",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -131,6 +131,68 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
never,
|
||||
);
|
||||
|
||||
final appIconPickerTree = <SettingsUiNode>[
|
||||
SettingsUiHeader(l10n.s_ci_icon_header, always),
|
||||
SettingsUiHeader(l10n.s_ci_warning_header, isDebug),
|
||||
// s_ci_icon_subtitle is intentionally unrendered: the original renderer
|
||||
// never had a case for SettingsSubtitle either, so this was already dead.
|
||||
SettingsUiPadding(24, always),
|
||||
SettingsUiAppIconPreview(always),
|
||||
SettingsUiPadding(24, always),
|
||||
childProtection,
|
||||
SettingsUiAppIconPicker(
|
||||
{
|
||||
l10n.s_ci_icon_g1: const ["original", "proto", "pride"],
|
||||
l10n.s_ci_icon_g2: const ["pixel", "galaxy", "cactus"],
|
||||
l10n.s_ci_icon_g3: const ["old", "refilc", "filc", "szivacs"],
|
||||
l10n.s_ci_icon_g4: const [
|
||||
"modern",
|
||||
"cc",
|
||||
"paper",
|
||||
"filco",
|
||||
"o1g",
|
||||
"pear",
|
||||
"half_firka_2",
|
||||
"nuke",
|
||||
"refulc",
|
||||
],
|
||||
l10n.s_ci_icon_g5: const [
|
||||
"kreta",
|
||||
"cc",
|
||||
"repont",
|
||||
"void_icon",
|
||||
"pixelized",
|
||||
"mkkp",
|
||||
"fidesz",
|
||||
"tisza",
|
||||
],
|
||||
l10n.s_ci_icon_g6: const ["xmas1", "xmas2", "xmas3"],
|
||||
l10n.s_ci_icon_g7: const [
|
||||
"lgbtq",
|
||||
"lgbtqp",
|
||||
"trans",
|
||||
"enby",
|
||||
"ace",
|
||||
"gay",
|
||||
"lesb",
|
||||
"bi",
|
||||
],
|
||||
l10n.s_ci_icon_g8: const [
|
||||
"lgbtq_f",
|
||||
"lgbtqp_f",
|
||||
"trans_f",
|
||||
"enby_f",
|
||||
"ace_f",
|
||||
"gay_f",
|
||||
"lesb_f",
|
||||
"bi_f",
|
||||
],
|
||||
},
|
||||
childProtection,
|
||||
always,
|
||||
),
|
||||
];
|
||||
|
||||
return SettingsUiGroup([
|
||||
SettingsUiBackHeader(l10n.s_a, always),
|
||||
SettingsUiHeader(l10n.s_settings, always),
|
||||
@@ -138,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),
|
||||
@@ -218,87 +280,28 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
|
||||
], always),
|
||||
],
|
||||
always,
|
||||
null,
|
||||
l10n.s_a_desc,
|
||||
),
|
||||
SettingsUiSubGroup(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.flower2Solid,
|
||||
l10n.s_c,
|
||||
[
|
||||
SettingsUiBackHeader(l10n.s_settings, always),
|
||||
SettingsUiHeader(l10n.s_customization, always),
|
||||
SettingsUiHeaderSmall(l10n.s_c_icon_header, always),
|
||||
SettingsUiPadding(16, always),
|
||||
SettingsUiAppIconPreview(always),
|
||||
SettingsUiSubGroup(null, null, l10n.s_c_replace_icon, [
|
||||
SettingsUiHeader(l10n.s_ci_icon_header, always),
|
||||
SettingsUiHeader(l10n.s_ci_warning_header, isDebug),
|
||||
// s_ci_icon_subtitle is intentionally unrendered: the original renderer
|
||||
// never had a case for SettingsSubtitle either, so this was already dead.
|
||||
SettingsUiPadding(24, always),
|
||||
SettingsUiAppIconPreview(always),
|
||||
SettingsUiPadding(24, always),
|
||||
childProtection,
|
||||
SettingsUiAppIconPicker(
|
||||
{
|
||||
l10n.s_ci_icon_g1: const ["original", "proto", "pride"],
|
||||
l10n.s_ci_icon_g2: const ["pixel", "galaxy", "cactus"],
|
||||
l10n.s_ci_icon_g3: const ["old", "refilc", "filc", "szivacs"],
|
||||
l10n.s_ci_icon_g4: const [
|
||||
"modern",
|
||||
"cc",
|
||||
"paper",
|
||||
"filco",
|
||||
"o1g",
|
||||
"pear",
|
||||
"half_firka_2",
|
||||
"nuke",
|
||||
"refulc",
|
||||
],
|
||||
l10n.s_ci_icon_g5: const [
|
||||
"kreta",
|
||||
"cc",
|
||||
"repont",
|
||||
"void_icon",
|
||||
"pixelized",
|
||||
"mkkp",
|
||||
"fidesz",
|
||||
"tisza",
|
||||
],
|
||||
l10n.s_ci_icon_g6: const ["xmas1", "xmas2", "xmas3"],
|
||||
l10n.s_ci_icon_g7: const [
|
||||
"lgbtq",
|
||||
"lgbtqp",
|
||||
"trans",
|
||||
"enby",
|
||||
"ace",
|
||||
"gay",
|
||||
"lesb",
|
||||
"bi",
|
||||
],
|
||||
l10n.s_ci_icon_g8: const [
|
||||
"lgbtq_f",
|
||||
"lgbtqp_f",
|
||||
"trans_f",
|
||||
"enby_f",
|
||||
"ace_f",
|
||||
"gay_f",
|
||||
"lesb_f",
|
||||
"bi_f",
|
||||
],
|
||||
},
|
||||
childProtection,
|
||||
always,
|
||||
),
|
||||
], isAndroid),
|
||||
SettingsUiPadding(16, always),
|
||||
SettingsUiHeaderSmall(l10n.s_c_theme_header, always),
|
||||
SettingsUiEnum(SettingsRegistry.themeBrightness, [
|
||||
l10n.s_c_theme_auto,
|
||||
l10n.s_c_theme_light,
|
||||
l10n.s_c_theme_dark,
|
||||
], always),
|
||||
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,
|
||||
@@ -361,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",
|
||||
@@ -427,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,
|
||||
|
||||
@@ -23,9 +23,20 @@ void registerSettingsEffects(
|
||||
|
||||
repo.onChange(SettingsRegistry.themeBrightness, (_) async {
|
||||
initTheme(initData);
|
||||
initData.themeCubit.refresh();
|
||||
initData.homeRefreshCubit.requestRefresh();
|
||||
});
|
||||
|
||||
Future<void> refreshTitleStyle(_) async {
|
||||
initTheme(initData);
|
||||
initData.themeCubit.refresh();
|
||||
initData.homeRefreshCubit.requestRefresh();
|
||||
}
|
||||
|
||||
repo.onChange(SettingsRegistry.titleFont, refreshTitleStyle);
|
||||
repo.onChange(SettingsRegistry.titleWeight, refreshTitleStyle);
|
||||
repo.onChange(SettingsRegistry.titleCapitalization, refreshTitleStyle);
|
||||
|
||||
repo.onChange(SettingsRegistry.wearOsSupport, (enabled) async {
|
||||
if (!Platform.isAndroid) return;
|
||||
if (enabled && initDone) {
|
||||
|
||||
@@ -7,6 +7,18 @@ enum AppLanguage { auto, hu, en, de }
|
||||
|
||||
enum ThemeBrightness { auto, light, dark }
|
||||
|
||||
enum TitleFont {
|
||||
montserrat,
|
||||
monoton,
|
||||
pirataOne,
|
||||
justMeAgainDownHere,
|
||||
figtree,
|
||||
firaCode,
|
||||
vollkorn,
|
||||
}
|
||||
|
||||
enum TitleCapitalization { lower, normal, upper }
|
||||
|
||||
abstract class SettingsSchema {
|
||||
@DoubleSetting(id: 1001, defaultValue: 0, min: 0, max: 120)
|
||||
double get bellDelay;
|
||||
@@ -96,4 +108,77 @@ abstract class SettingsSchema {
|
||||
|
||||
@BoolSetting(id: 1024, defaultValue: false)
|
||||
bool get wearOsSupport;
|
||||
|
||||
// 1025 is reserved for the selected Kréta account outside SettingsRegistry.
|
||||
@EnumSetting(
|
||||
id: 1026,
|
||||
defaultValue: TitleFont.montserrat,
|
||||
values: TitleFont.values,
|
||||
)
|
||||
TitleFont get titleFont;
|
||||
|
||||
@DoubleSetting(
|
||||
id: 1027,
|
||||
defaultValue: 700,
|
||||
min: 100,
|
||||
max: 900,
|
||||
precision: 0,
|
||||
step: 100,
|
||||
)
|
||||
double get titleWeight;
|
||||
|
||||
@EnumSetting(
|
||||
id: 1028,
|
||||
defaultValue: TitleCapitalization.normal,
|
||||
values: TitleCapitalization.values,
|
||||
)
|
||||
TitleCapitalization get titleCapitalization;
|
||||
|
||||
@StringSetting(id: 1029, defaultValue: "builtin-firka-firka")
|
||||
String get selectedThemeId;
|
||||
|
||||
@StringSetting(id: 1030, defaultValue: "firka")
|
||||
String get selectedCoreThemeId;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@@ -3,47 +3,14 @@
|
||||
part of "settings_schema.dart";
|
||||
|
||||
class SettingsRegistry {
|
||||
static const bellDelay = DoubleSetting(
|
||||
id: 1001,
|
||||
defaultValue: 0,
|
||||
min: 0,
|
||||
max: 120,
|
||||
);
|
||||
static const rounding1 = DoubleSetting(
|
||||
id: 1002,
|
||||
defaultValue: 0.5,
|
||||
min: 0.1,
|
||||
max: 0.99,
|
||||
precision: 2,
|
||||
);
|
||||
static const rounding2 = DoubleSetting(
|
||||
id: 1003,
|
||||
defaultValue: 0.5,
|
||||
min: 0.1,
|
||||
max: 0.99,
|
||||
precision: 2,
|
||||
);
|
||||
static const rounding3 = DoubleSetting(
|
||||
id: 1004,
|
||||
defaultValue: 0.5,
|
||||
min: 0.1,
|
||||
max: 0.99,
|
||||
precision: 2,
|
||||
);
|
||||
static const rounding4 = DoubleSetting(
|
||||
id: 1005,
|
||||
defaultValue: 0.5,
|
||||
min: 0.1,
|
||||
max: 0.99,
|
||||
precision: 2,
|
||||
);
|
||||
static const bellDelay = DoubleSetting(id: 1001, defaultValue: 0, min: 0, max: 120);
|
||||
static const rounding1 = DoubleSetting(id: 1002, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2);
|
||||
static const rounding2 = DoubleSetting(id: 1003, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2);
|
||||
static const rounding3 = DoubleSetting(id: 1004, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2);
|
||||
static const rounding4 = DoubleSetting(id: 1005, defaultValue: 0.5, min: 0.1, max: 0.99, precision: 2);
|
||||
static const classAvgOnGraph = BoolSetting(id: 1006, defaultValue: true);
|
||||
static const leftHandedMode = BoolSetting(id: 1007, defaultValue: false);
|
||||
static const language = EnumSetting(
|
||||
id: 1008,
|
||||
defaultValue: AppLanguage.auto,
|
||||
values: AppLanguage.values,
|
||||
);
|
||||
static const language = EnumSetting(id: 1008, defaultValue: AppLanguage.auto, values: AppLanguage.values);
|
||||
static const appIcon = StringSetting(id: 0, defaultValue: "original");
|
||||
static const childProtection = BoolSetting(id: 1010, defaultValue: true);
|
||||
static const betaWarning = BoolSetting(id: 1011, defaultValue: false);
|
||||
@@ -51,111 +18,82 @@ class SettingsRegistry {
|
||||
static const ttToastTestsAndHw = BoolSetting(id: 1013, defaultValue: true);
|
||||
static const ttToastBreaks = BoolSetting(id: 1014, defaultValue: true);
|
||||
static const statsForNerds = BoolSetting(id: 1015, defaultValue: false);
|
||||
static const developerOptsEnabled = BoolSetting(
|
||||
id: 1016,
|
||||
defaultValue: false,
|
||||
);
|
||||
static const themeBrightness = EnumSetting(
|
||||
id: 1017,
|
||||
defaultValue: ThemeBrightness.auto,
|
||||
values: ThemeBrightness.values,
|
||||
);
|
||||
static const developerOptsEnabled = BoolSetting(id: 1016, defaultValue: false);
|
||||
static const themeBrightness = EnumSetting(id: 1017, defaultValue: ThemeBrightness.auto, values: ThemeBrightness.values);
|
||||
static const ttToastSubstitution = BoolSetting(id: 1018, defaultValue: true);
|
||||
static const liveActivityEnabled = BoolSetting(id: 1019, defaultValue: false);
|
||||
static const liveActivityPrivacyEverDeclined = BoolSetting(
|
||||
id: 1020,
|
||||
defaultValue: false,
|
||||
);
|
||||
static const morningNotificationEnabled = BoolSetting(
|
||||
id: 1021,
|
||||
defaultValue: true,
|
||||
);
|
||||
static const morningNotificationTime = DoubleSetting(
|
||||
id: 1022,
|
||||
defaultValue: 120,
|
||||
min: 30,
|
||||
max: 240,
|
||||
precision: 0,
|
||||
step: 15,
|
||||
);
|
||||
static const liveActivityPrivacyEverDeclined = BoolSetting(id: 1020, defaultValue: false);
|
||||
static const morningNotificationEnabled = BoolSetting(id: 1021, defaultValue: true);
|
||||
static const morningNotificationTime = DoubleSetting(id: 1022, defaultValue: 120, min: 30, max: 240, precision: 0, step: 15);
|
||||
static const ttToastABTimetable = BoolSetting(id: 1023, defaultValue: true);
|
||||
static const wearOsSupport = BoolSetting(id: 1024, defaultValue: false);
|
||||
static const titleFont = EnumSetting(id: 1026, defaultValue: TitleFont.montserrat, values: TitleFont.values);
|
||||
static const titleWeight = DoubleSetting(id: 1027, defaultValue: 700, min: 100, max: 900, precision: 0, step: 100);
|
||||
static const titleCapitalization = EnumSetting(id: 1028, defaultValue: TitleCapitalization.normal, values: TitleCapitalization.values);
|
||||
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,
|
||||
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,
|
||||
];
|
||||
}
|
||||
|
||||
extension SettingsAccessors on SettingsRepository {
|
||||
SilentlySettable<double> get bellDelay =>
|
||||
SilentlySettable(this, SettingsRegistry.bellDelay);
|
||||
SilentlySettable<double> get rounding1 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding1);
|
||||
SilentlySettable<double> get rounding2 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding2);
|
||||
SilentlySettable<double> get rounding3 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding3);
|
||||
SilentlySettable<double> get rounding4 =>
|
||||
SilentlySettable(this, SettingsRegistry.rounding4);
|
||||
SilentlySettable<bool> get classAvgOnGraph =>
|
||||
SilentlySettable(this, SettingsRegistry.classAvgOnGraph);
|
||||
SilentlySettable<bool> get leftHandedMode =>
|
||||
SilentlySettable(this, SettingsRegistry.leftHandedMode);
|
||||
SilentlySettable<AppLanguage> get language =>
|
||||
SilentlySettable(this, SettingsRegistry.language);
|
||||
SilentlySettable<String> get appIcon =>
|
||||
SilentlySettable(this, SettingsRegistry.appIcon);
|
||||
SilentlySettable<bool> get childProtection =>
|
||||
SilentlySettable(this, SettingsRegistry.childProtection);
|
||||
SilentlySettable<bool> get betaWarning =>
|
||||
SilentlySettable(this, SettingsRegistry.betaWarning);
|
||||
SilentlySettable<bool> get ttToastLessonNo =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastLessonNo);
|
||||
SilentlySettable<bool> get ttToastTestsAndHw =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastTestsAndHw);
|
||||
SilentlySettable<bool> get ttToastBreaks =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastBreaks);
|
||||
SilentlySettable<bool> get statsForNerds =>
|
||||
SilentlySettable(this, SettingsRegistry.statsForNerds);
|
||||
SilentlySettable<bool> get developerOptsEnabled =>
|
||||
SilentlySettable(this, SettingsRegistry.developerOptsEnabled);
|
||||
SilentlySettable<ThemeBrightness> get themeBrightness =>
|
||||
SilentlySettable(this, SettingsRegistry.themeBrightness);
|
||||
SilentlySettable<bool> get ttToastSubstitution =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastSubstitution);
|
||||
SilentlySettable<bool> get liveActivityEnabled =>
|
||||
SilentlySettable(this, SettingsRegistry.liveActivityEnabled);
|
||||
SilentlySettable<bool> get liveActivityPrivacyEverDeclined =>
|
||||
SilentlySettable(this, SettingsRegistry.liveActivityPrivacyEverDeclined);
|
||||
SilentlySettable<bool> get morningNotificationEnabled =>
|
||||
SilentlySettable(this, SettingsRegistry.morningNotificationEnabled);
|
||||
SilentlySettable<double> get morningNotificationTime =>
|
||||
SilentlySettable(this, SettingsRegistry.morningNotificationTime);
|
||||
SilentlySettable<bool> get ttToastABTimetable =>
|
||||
SilentlySettable(this, SettingsRegistry.ttToastABTimetable);
|
||||
SilentlySettable<bool> get wearOsSupport =>
|
||||
SilentlySettable(this, SettingsRegistry.wearOsSupport);
|
||||
SilentlySettable<double> get bellDelay => SilentlySettable(this, SettingsRegistry.bellDelay);
|
||||
SilentlySettable<double> get rounding1 => SilentlySettable(this, SettingsRegistry.rounding1);
|
||||
SilentlySettable<double> get rounding2 => SilentlySettable(this, SettingsRegistry.rounding2);
|
||||
SilentlySettable<double> get rounding3 => SilentlySettable(this, SettingsRegistry.rounding3);
|
||||
SilentlySettable<double> get rounding4 => SilentlySettable(this, SettingsRegistry.rounding4);
|
||||
SilentlySettable<bool> get classAvgOnGraph => SilentlySettable(this, SettingsRegistry.classAvgOnGraph);
|
||||
SilentlySettable<bool> get leftHandedMode => SilentlySettable(this, SettingsRegistry.leftHandedMode);
|
||||
SilentlySettable<AppLanguage> get language => SilentlySettable(this, SettingsRegistry.language);
|
||||
SilentlySettable<String> get appIcon => SilentlySettable(this, SettingsRegistry.appIcon);
|
||||
SilentlySettable<bool> get childProtection => SilentlySettable(this, SettingsRegistry.childProtection);
|
||||
SilentlySettable<bool> get betaWarning => SilentlySettable(this, SettingsRegistry.betaWarning);
|
||||
SilentlySettable<bool> get ttToastLessonNo => SilentlySettable(this, SettingsRegistry.ttToastLessonNo);
|
||||
SilentlySettable<bool> get ttToastTestsAndHw => SilentlySettable(this, SettingsRegistry.ttToastTestsAndHw);
|
||||
SilentlySettable<bool> get ttToastBreaks => SilentlySettable(this, SettingsRegistry.ttToastBreaks);
|
||||
SilentlySettable<bool> get statsForNerds => SilentlySettable(this, SettingsRegistry.statsForNerds);
|
||||
SilentlySettable<bool> get developerOptsEnabled => SilentlySettable(this, SettingsRegistry.developerOptsEnabled);
|
||||
SilentlySettable<ThemeBrightness> get themeBrightness => SilentlySettable(this, SettingsRegistry.themeBrightness);
|
||||
SilentlySettable<bool> get ttToastSubstitution => SilentlySettable(this, SettingsRegistry.ttToastSubstitution);
|
||||
SilentlySettable<bool> get liveActivityEnabled => SilentlySettable(this, SettingsRegistry.liveActivityEnabled);
|
||||
SilentlySettable<bool> get liveActivityPrivacyEverDeclined => SilentlySettable(this, SettingsRegistry.liveActivityPrivacyEverDeclined);
|
||||
SilentlySettable<bool> get morningNotificationEnabled => SilentlySettable(this, SettingsRegistry.morningNotificationEnabled);
|
||||
SilentlySettable<double> get morningNotificationTime => SilentlySettable(this, SettingsRegistry.morningNotificationTime);
|
||||
SilentlySettable<bool> get ttToastABTimetable => SilentlySettable(this, SettingsRegistry.ttToastABTimetable);
|
||||
SilentlySettable<bool> get wearOsSupport => SilentlySettable(this, SettingsRegistry.wearOsSupport);
|
||||
SilentlySettable<TitleFont> get titleFont => SilentlySettable(this, SettingsRegistry.titleFont);
|
||||
SilentlySettable<double> get titleWeight => SilentlySettable(this, SettingsRegistry.titleWeight);
|
||||
SilentlySettable<TitleCapitalization> get titleCapitalization => SilentlySettable(this, SettingsRegistry.titleCapitalization);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -127,6 +129,15 @@ class SettingsUiAppIconPreview extends SettingsUiNode {
|
||||
const SettingsUiAppIconPreview(super.visible);
|
||||
}
|
||||
|
||||
class SettingsUiPersonalization extends SettingsUiNode {
|
||||
final List<SettingsUiNode> appIconPickerChildren;
|
||||
|
||||
const SettingsUiPersonalization(
|
||||
this.appIconPickerChildren,
|
||||
bool Function() visible,
|
||||
) : super(visible);
|
||||
}
|
||||
|
||||
class SettingsUiAppIconPicker extends SettingsUiNode {
|
||||
final Map<String, List<String>> iconGroups;
|
||||
final SettingsUiBoolean childProtection;
|
||||
@@ -149,3 +160,7 @@ class SettingsUiLogs extends SettingsUiNode {
|
||||
class SettingsUiLicensePage extends SettingsUiNode {
|
||||
const SettingsUiLicensePage(super.visible);
|
||||
}
|
||||
|
||||
class SettingsUiSubjectNotifications extends SettingsUiNode {
|
||||
const SettingsUiSubjectNotifications(super.visible);
|
||||
}
|
||||
|
||||
25
firka/lib/core/settings/title_font.dart
Normal file
25
firka/lib/core/settings/title_font.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import "package:firka/core/settings/settings_schema.dart";
|
||||
|
||||
extension TitleFontInfo on TitleFont {
|
||||
String get fontFamily => switch (this) {
|
||||
TitleFont.montserrat => "Montserrat",
|
||||
TitleFont.monoton => "Monoton",
|
||||
TitleFont.pirataOne => "Pirata One",
|
||||
TitleFont.justMeAgainDownHere => "Just Me Again Down Here",
|
||||
TitleFont.figtree => "Figtree",
|
||||
TitleFont.firaCode => "Fira Code",
|
||||
TitleFont.vollkorn => "Vollkorn",
|
||||
};
|
||||
|
||||
String get displayName => fontFamily;
|
||||
|
||||
bool get supportsWeight => switch (this) {
|
||||
TitleFont.montserrat ||
|
||||
TitleFont.figtree ||
|
||||
TitleFont.firaCode ||
|
||||
TitleFont.vollkorn => true,
|
||||
TitleFont.monoton ||
|
||||
TitleFont.pirataOne ||
|
||||
TitleFont.justMeAgainDownHere => false,
|
||||
};
|
||||
}
|
||||
31
firka/lib/core/snowflake.dart
Normal file
31
firka/lib/core/snowflake.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import "dart:math";
|
||||
|
||||
/// Local Twitter-style snowflake IDs (64-bit, decimal string).
|
||||
class Snowflake {
|
||||
static const int _epochMs = 1704067200000; // 2024-01-01 UTC
|
||||
static final int _workerId = Random().nextInt(1 << 10);
|
||||
static int _sequence = 0;
|
||||
static int _lastTimestamp = -1;
|
||||
|
||||
static String nextId() {
|
||||
var ts = DateTime.now().millisecondsSinceEpoch;
|
||||
if (ts < _lastTimestamp) {
|
||||
ts = _lastTimestamp;
|
||||
}
|
||||
|
||||
if (ts == _lastTimestamp) {
|
||||
_sequence = (_sequence + 1) & 0xFFF;
|
||||
if (_sequence == 0) {
|
||||
while (ts <= _lastTimestamp) {
|
||||
ts = DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_sequence = 0;
|
||||
}
|
||||
|
||||
_lastTimestamp = ts;
|
||||
final id = ((ts - _epochMs) << 22) | (_workerId << 12) | _sequence;
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
Submodule firka/lib/l10n updated: 2715ee8b5d...f4ae8bbd36
@@ -1,4 +1,5 @@
|
||||
import 'package:firka/ui/phone/pages/home/home_omissions.dart';
|
||||
import 'package:firka_common/data/models/message_cache_model.dart';
|
||||
import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:firka/core/firka_bundle.dart';
|
||||
@@ -19,13 +20,14 @@ import 'package:firka/ui/phone/screens/login/login_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/message/message_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/home/home_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/settings/settings_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/themes/theme_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/themes/themes_screen.dart';
|
||||
import 'package:firka/ui/phone/screens/themes/user_theme.dart';
|
||||
import 'package:firka/routing/chart_interaction_scope.dart';
|
||||
import 'package:firka/routing/shell_with_nav_bar.dart';
|
||||
import 'package:firka/routing/swipable_navigator_container.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
|
||||
GoRouter createAppRouter() {
|
||||
final subjectRoute = GoRoute(
|
||||
path: 'subject',
|
||||
@@ -96,10 +98,27 @@ GoRouter createAppRouter() {
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/themes',
|
||||
builder: (context, state) => DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: ThemesScreen(initData, key: state.pageKey),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/theme',
|
||||
builder: (context, state) {
|
||||
final args = state.extra as ThemeScreenArgs;
|
||||
return DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: ThemeScreen(initData, args, key: state.pageKey),
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
path: '/message',
|
||||
builder: (context, state) {
|
||||
final info = state.extra as MessageItem?;
|
||||
final info = state.extra as MessageCacheModel?;
|
||||
if (info == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
@@ -172,9 +191,12 @@ GoRouter createAppRouter() {
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'monthly',
|
||||
builder: (context, state) => DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: HomeTimetableMonthlyScreen(initData),
|
||||
pageBuilder: (context, state) => _viewSwitchPage(
|
||||
key: state.pageKey,
|
||||
child: DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: HomeTimetableMonthlyScreen(initData),
|
||||
),
|
||||
),
|
||||
),
|
||||
subjectRoute,
|
||||
@@ -239,3 +261,33 @@ String? _redirect(BuildContext context, GoRouterState state) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
CustomTransitionPage<void> _viewSwitchPage({
|
||||
required LocalKey key,
|
||||
required Widget child,
|
||||
}) {
|
||||
return CustomTransitionPage<void>(
|
||||
key: key,
|
||||
opaque: false,
|
||||
transitionDuration: const Duration(milliseconds: 300),
|
||||
reverseTransitionDuration: const Duration(milliseconds: 250),
|
||||
child: child,
|
||||
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
||||
final curved = CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: Curves.easeOut,
|
||||
reverseCurve: Curves.easeIn,
|
||||
);
|
||||
return FadeTransition(
|
||||
opacity: curved,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.04),
|
||||
end: Offset.zero,
|
||||
).animate(curved),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class ShellWithNavBar extends StatelessWidget {
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(55, 16, 55, 12),
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
|
||||
@@ -52,28 +52,30 @@ Future<void> showFirkaBottomSheet(
|
||||
color: appStyle.colors.background,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
heightFactor: 0,
|
||||
alignment: Alignment.topCenter,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 18),
|
||||
width: 40,
|
||||
height: 4,
|
||||
foregroundDecoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusGeometry.circular(2),
|
||||
child: SelectionArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
heightFactor: 0,
|
||||
alignment: Alignment.topCenter,
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 18),
|
||||
width: 40,
|
||||
height: 4,
|
||||
foregroundDecoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadiusGeometry.circular(2),
|
||||
),
|
||||
color: appStyle.colors.shadowColor,
|
||||
),
|
||||
color: appStyle.colors.shadowColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
...children,
|
||||
],
|
||||
SizedBox(height: 40),
|
||||
...children,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -516,7 +518,7 @@ Future<void> showHomeworkBottomSheet(
|
||||
margin: EdgeInsets.all(0),
|
||||
padding: EdgeInsets.all(12),
|
||||
child: Html(
|
||||
data: homework.description,
|
||||
data: homework.description.withoutFontFeatureSettings(),
|
||||
style: {
|
||||
"*": Style.fromTextStyle(
|
||||
appStyle.fonts.B_16R.apply(color: appStyle.colors.textPrimary),
|
||||
|
||||
42
firka/lib/ui/components/firka_icon_button.dart
Normal file
42
firka/lib/ui/components/firka_icon_button.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
|
||||
class FirkaIconButton extends StatelessWidget {
|
||||
final Widget child;
|
||||
final VoidCallback? onTap;
|
||||
final Color? color;
|
||||
|
||||
const FirkaIconButton({
|
||||
required this.child,
|
||||
this.onTap,
|
||||
this.color,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final button = Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
padding: const EdgeInsets.all(6),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
color: color ?? appStyle.colors.buttonSecondaryFill,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.shadowColor,
|
||||
offset: const Offset(0, 1),
|
||||
blurRadius: appStyle.colors.shadowBlur.toDouble(),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
|
||||
if (onTap == null) return button;
|
||||
|
||||
return GestureDetector(onTap: onTap, child: button);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/bloc/theme_cubit.dart';
|
||||
import 'package:firka/core/settings.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
import 'package:firka_common/ui/components/firka_shadow.dart';
|
||||
import 'package:firka_common/ui/components/firka_card.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
Widget _extrasActionTile({
|
||||
required double width,
|
||||
required VoidCallback onTap,
|
||||
required Widget icon,
|
||||
required String label,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: FirkaCard.single(
|
||||
width: width,
|
||||
height: 60,
|
||||
margin: EdgeInsets.zero,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Row(
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
label,
|
||||
textAlign: TextAlign.right,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showExtrasBottomSheet(BuildContext context, AppInitialization data) {
|
||||
Widget Function(double) debugBtn = (_) => const SizedBox();
|
||||
@@ -18,49 +49,20 @@ void showExtrasBottomSheet(BuildContext context, AppInitialization data) {
|
||||
logger.finest("showExtrasBottomSheet() developer mode: ${isDeveloper()}");
|
||||
|
||||
if (isDeveloper()) {
|
||||
debugBtn = (double itemWidth) => GestureDetector(
|
||||
debugBtn = (double itemWidth) => _extrasActionTile(
|
||||
// Fejlesztői menü
|
||||
width: itemWidth,
|
||||
onTap: () {
|
||||
context.pop();
|
||||
context.push('/debug');
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
width: itemWidth,
|
||||
child: FirkaShadow(
|
||||
shadow: true,
|
||||
child: Card(
|
||||
color: appStyle.colors.card,
|
||||
shadowColor: context.watch<ThemeCubit>().state.isLightMode
|
||||
? null
|
||||
: Colors.transparent,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0),
|
||||
child: Row(
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.bug2Solid,
|
||||
size: 22.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
data.l10n.debug_screen,
|
||||
textAlign: TextAlign.right,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
icon: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.bug2Solid,
|
||||
size: 22.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
label: data.l10n.debug_screen,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,12 +115,13 @@ void showExtrasBottomSheet(BuildContext context, AppInitialization data) {
|
||||
builder: (context, constraints) {
|
||||
final itemWidth = (constraints.maxWidth - 8) / 2;
|
||||
return Wrap(
|
||||
spacing: 2,
|
||||
runSpacing: 2,
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
debugBtn(itemWidth),
|
||||
GestureDetector(
|
||||
_extrasActionTile(
|
||||
// Fiókod
|
||||
width: itemWidth,
|
||||
onTap: () {
|
||||
context.pop();
|
||||
context.push(
|
||||
@@ -128,105 +131,28 @@ void showExtrasBottomSheet(BuildContext context, AppInitialization data) {
|
||||
).children,
|
||||
);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
width: itemWidth,
|
||||
child: FirkaShadow(
|
||||
shadow: true,
|
||||
child: Card(
|
||||
color: appStyle.colors.card,
|
||||
shadowColor:
|
||||
context
|
||||
.watch<ThemeCubit>()
|
||||
.state
|
||||
.isLightMode
|
||||
? null
|
||||
: Colors.transparent,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.userSolid,
|
||||
size: 22.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
data.l10n.s_your_account,
|
||||
textAlign: TextAlign.right,
|
||||
style: appStyle.fonts.B_16R
|
||||
.apply(
|
||||
color: appStyle
|
||||
.colors
|
||||
.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
icon: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.userSolid,
|
||||
size: 22.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
label: data.l10n.s_your_account,
|
||||
),
|
||||
GestureDetector(
|
||||
_extrasActionTile(
|
||||
// Beállítás
|
||||
width: itemWidth,
|
||||
onTap: () {
|
||||
context.pop();
|
||||
context.push('/settings');
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
width: itemWidth,
|
||||
child: FirkaShadow(
|
||||
shadow: true,
|
||||
child: Card(
|
||||
color: appStyle.colors.card,
|
||||
shadowColor:
|
||||
context
|
||||
.watch<ThemeCubit>()
|
||||
.state
|
||||
.isLightMode
|
||||
? null
|
||||
: Colors.transparent,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 22.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
data.l10n.settings_screen,
|
||||
textAlign: TextAlign.right,
|
||||
style: appStyle.fonts.B_16R
|
||||
.apply(
|
||||
color: appStyle
|
||||
.colors
|
||||
.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
icon: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 22.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
label: data.l10n.settings_screen,
|
||||
),
|
||||
// Ide jön a többi gomb majd
|
||||
],
|
||||
|
||||
@@ -43,6 +43,9 @@ class FirkaToastWidget extends StatefulWidget {
|
||||
factory FirkaToastWidget.error(BuildContext context, Object e) {
|
||||
return FirkaToastWidget(
|
||||
backgroundColor: appStyle.colors.errorCard,
|
||||
onDismiss: () {
|
||||
initData.toastCubit.clear();
|
||||
},
|
||||
children: [
|
||||
Text(
|
||||
initData.l10n.api_error,
|
||||
|
||||
@@ -31,7 +31,9 @@ void showErrorBottomSheet(BuildContext context, String err) {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(child: Text(err, style: appStyle.fonts.B_16R)),
|
||||
child: SelectionArea(
|
||||
child: Center(child: Text(err, style: appStyle.fonts.B_16R)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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();
|
||||
@@ -80,7 +84,7 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.subjects,
|
||||
headingText(widget.data.l10n.subjects),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
@@ -93,8 +97,13 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
|
||||
GradeSummaryBar(grades: allGrades, l10n: widget.data.l10n),
|
||||
SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => widget.data.client!.pullRefresh(
|
||||
() => widget.data.client!.getGrades(),
|
||||
),
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.your_subjects,
|
||||
style: appStyle.fonts.H_14px.apply(
|
||||
@@ -241,6 +250,7 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:firka_common/data/util.dart';
|
||||
import 'package:firka_common/ui/components/filled_circle.dart';
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/ui/components/common_bottom_sheets.dart';
|
||||
import 'package:firka/ui/components/firka_icon_button.dart';
|
||||
import 'package:firka/ui/phone/widgets/grade_chart.dart';
|
||||
import 'package:firka/ui/shared/class_icon.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
@@ -17,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';
|
||||
@@ -29,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(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -232,19 +237,7 @@ class _HomeGradesSubjectScreen extends FirkaState<HomeGradesSubjectScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
child: Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.menuSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {
|
||||
showSubjectBottomSheetSettings(
|
||||
context,
|
||||
@@ -255,6 +248,12 @@ class _HomeGradesSubjectScreen extends FirkaState<HomeGradesSubjectScreen> {
|
||||
},
|
||||
);
|
||||
},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.menuSolid,
|
||||
size: 20.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
@@ -13,6 +17,8 @@ import 'package:firka/core/debug_helper.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/bloc/home_refresh_cubit.dart';
|
||||
import 'package:firka/core/bloc/toast_cubit.dart';
|
||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import '../../widgets/home_main_welcome.dart';
|
||||
|
||||
@@ -28,8 +34,76 @@ class HomeMainScreen extends StatefulWidget {
|
||||
class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
_HomeMainScreen();
|
||||
|
||||
// After the first frame, newly inserted notice groups fade in.
|
||||
// Groups present on the initial paint (warm cache) stay instant.
|
||||
bool _fadeNewInserts = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
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();
|
||||
@@ -44,14 +118,22 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
listener: (context, state) {
|
||||
_onRefreshRequested(context);
|
||||
},
|
||||
child: _buildContent(context),
|
||||
child: BlocBuilder<ToastCubit, ToastState>(
|
||||
buildWhen: (previous, current) => previous.type != current.type,
|
||||
builder: (context, toastState) => _buildContent(context, toastState),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
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()
|
||||
@@ -103,45 +185,71 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
)
|
||||
.length;
|
||||
|
||||
final bodyEmpty = todayLesson.isEmpty && noticeBoardWidgets.isEmpty;
|
||||
final showInnerSpinner =
|
||||
toastState.type == ActiveToastType.fetching && bodyEmpty;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => Future.value(),
|
||||
onRefresh: () => widget.data.client!.refreshHomeFeed(),
|
||||
notificationPredicate: (ScrollNotification notification) {
|
||||
return notification.depth == 0;
|
||||
},
|
||||
triggerMode: RefreshIndicatorTriggerMode.onEdge,
|
||||
displacement: 0,
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
SizedBox(height: 24),
|
||||
WelcomeWidget(
|
||||
widget.data.l10n,
|
||||
now,
|
||||
widget.data.client!.cache.findStudent(),
|
||||
todayLesson,
|
||||
_FadeInWhenLoaded(
|
||||
loaded: student != null,
|
||||
child: student != null
|
||||
? WelcomeWidget(
|
||||
widget.data.l10n,
|
||||
now,
|
||||
student,
|
||||
todayLesson,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
SizedBox(height: 48),
|
||||
LessonSlider(todayLesson, testsTomorrow),
|
||||
if (showInnerSpinner)
|
||||
SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height * 0.35,
|
||||
child: const Center(child: DelayedSpinnerWidget()),
|
||||
),
|
||||
_FadeInWhenLoaded(
|
||||
loaded: todayLesson.isNotEmpty || newGrades.isNotEmpty,
|
||||
child: LessonSlider(
|
||||
todayLesson,
|
||||
testsTomorrow,
|
||||
newGrades: newGrades,
|
||||
onNewGradesTap: () => _openNewGrades(newGrades),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
...noticeBoardWidgets
|
||||
.groupList((e) => e.$2)
|
||||
.entries
|
||||
.map(
|
||||
(e) => Column(
|
||||
spacing: 10,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
e.key.format(widget.data.l10n, FormatMode.main),
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
(e) => _FadeInOnInsert(
|
||||
key: ValueKey(e.key),
|
||||
animate: _fadeNewInserts,
|
||||
child: Column(
|
||||
spacing: 10,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
e.key.format(widget.data.l10n, FormatMode.main),
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
...e.value.map((v) => v.$1),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
...e.value.map((v) => v.$1),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -150,3 +258,92 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Fades in when [loaded] flips from false to true. First paint with data is instant.
|
||||
class _FadeInWhenLoaded extends StatelessWidget {
|
||||
const _FadeInWhenLoaded({
|
||||
required this.loaded,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final bool loaded;
|
||||
final Widget child;
|
||||
|
||||
static const _duration = Duration(milliseconds: 300);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedSwitcher(
|
||||
duration: _duration,
|
||||
switchInCurve: Curves.easeOut,
|
||||
transitionBuilder: (child, animation) => FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.04),
|
||||
end: Offset.zero,
|
||||
).animate(animation),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
child: loaded
|
||||
? KeyedSubtree(key: const ValueKey("content"), child: child)
|
||||
: const SizedBox.shrink(key: ValueKey("empty")),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Fades newly inserted list sections. Skips animation when [animate] is false (warm cache).
|
||||
class _FadeInOnInsert extends StatefulWidget {
|
||||
const _FadeInOnInsert({
|
||||
super.key,
|
||||
required this.animate,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final bool animate;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<_FadeInOnInsert> createState() => _FadeInOnInsertState();
|
||||
}
|
||||
|
||||
class _FadeInOnInsertState extends State<_FadeInOnInsert>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _opacity;
|
||||
late final Animation<Offset> _slide;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
value: widget.animate ? 0 : 1,
|
||||
);
|
||||
final curved = CurvedAnimation(parent: _controller, curve: Curves.easeOut);
|
||||
_opacity = curved;
|
||||
_slide = Tween<Offset>(
|
||||
begin: const Offset(0, 0.04),
|
||||
end: Offset.zero,
|
||||
).animate(curved);
|
||||
if (widget.animate) {
|
||||
_controller.forward();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FadeTransition(
|
||||
opacity: _opacity,
|
||||
child: SlideTransition(position: _slide, child: widget.child),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.omissions,
|
||||
headingText(widget.data.l10n.omissions),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
@@ -177,10 +177,15 @@ class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
|
||||
OmissionBar(),
|
||||
SizedBox(height: 20),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Text(
|
||||
initData.l10n.subjects,
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => widget.data.client!.pullRefresh(
|
||||
() => widget.data.client!.getOmissions(),
|
||||
),
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
children: [
|
||||
Text(
|
||||
initData.l10n.subjects,
|
||||
style: appStyle.fonts.B_16SB.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
@@ -293,6 +298,7 @@ class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:firka/ui/phone/widgets/bottom_tt_icon.dart';
|
||||
import 'package:firka/ui/phone/widgets/tt_day.dart';
|
||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||
@@ -12,6 +9,7 @@ import 'package:firka/core/settings.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka/ui/components/firka_icon_button.dart';
|
||||
import 'package:firka/ui/phone/screens/settings/settings_screen.dart';
|
||||
import 'package:firka/ui/phone/widgets/bubble_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -19,7 +17,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
import 'package:transparent_pointer/transparent_pointer.dart';
|
||||
|
||||
import 'package:firka_common/core/consts.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
@@ -39,22 +36,26 @@ class HomeTimetableScreen extends StatefulWidget {
|
||||
|
||||
class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
with TickerProviderStateMixin {
|
||||
// Original dates list for display
|
||||
LinkedHashMap<DateTime, List<LessonCacheModel>> dates =
|
||||
LinkedHashMap.identity();
|
||||
static const int _originIndex = 100000;
|
||||
|
||||
// Dates list for carousel animation
|
||||
List<DateTime> _animationDates = [];
|
||||
late DateTime currentMonday;
|
||||
int active = 0;
|
||||
final CarouselSliderController _controller = CarouselSliderController();
|
||||
final Map<DateTime, List<LessonCacheModel>> _lessonsCache = {};
|
||||
final Map<int, DateTime> _indexToDate = {};
|
||||
|
||||
AnimationController? _cardAnimationController;
|
||||
Animation<Offset>? _cardOffsetAnimation;
|
||||
bool _showAnimatedCard = false;
|
||||
final PageController _pageController = PageController(
|
||||
initialPage: _originIndex,
|
||||
);
|
||||
final GlobalKey _pageViewKey = GlobalKey();
|
||||
|
||||
// Flag to track if we're using temporary order
|
||||
bool _isTemporaryOrder = false;
|
||||
int _activePageIndex = _originIndex;
|
||||
late DateTime _currentTabWeekMonday;
|
||||
late List<DateTime> _tabDays;
|
||||
|
||||
bool animating = false;
|
||||
int? _programmaticTargetIndex;
|
||||
|
||||
late final AnimationController _weekSlideController;
|
||||
Widget? _outgoingWeek;
|
||||
int _weekSlideDir = 0;
|
||||
|
||||
_HomeTimetableScreen();
|
||||
|
||||
@@ -62,109 +63,269 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_cardAnimationController = AnimationController(
|
||||
duration: Duration(milliseconds: 300),
|
||||
_weekSlideController = AnimationController(
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
updateWeek(timeNow());
|
||||
}
|
||||
|
||||
bool animating = false;
|
||||
|
||||
void _handleNavTap(int oldIndex, int targetIndex) async {
|
||||
if (animating) return;
|
||||
HapticFeedback.mediumImpact();
|
||||
|
||||
final original = _animationDates;
|
||||
|
||||
// If the target is not adjacent, create temporary order
|
||||
int tempTargetIndex = targetIndex;
|
||||
if ((targetIndex - oldIndex).abs() > 1) {
|
||||
// Determine the temporary target position next to the current position
|
||||
tempTargetIndex = oldIndex < targetIndex ? oldIndex + 1 : oldIndex - 1;
|
||||
|
||||
// Create a new order where target day is next to current day
|
||||
List<DateTime> reorderedDates = List.from(_animationDates);
|
||||
final targetDate = reorderedDates.removeAt(targetIndex);
|
||||
reorderedDates.insert(tempTargetIndex, targetDate);
|
||||
|
||||
setState(() {
|
||||
_animationDates = reorderedDates;
|
||||
_isTemporaryOrder = true;
|
||||
});
|
||||
}
|
||||
|
||||
active = -1;
|
||||
|
||||
const double cardWidth = 40.0;
|
||||
const double spacing = 16.0;
|
||||
final double totalCardWidth = cardWidth + spacing;
|
||||
|
||||
final double start = oldIndex * totalCardWidth;
|
||||
final double end = targetIndex * totalCardWidth;
|
||||
|
||||
_cardAnimationController!.reset();
|
||||
_cardOffsetAnimation =
|
||||
Tween<Offset>(begin: Offset(start, 0), end: Offset(end, 0)).animate(
|
||||
CurvedAnimation(
|
||||
parent: _cardAnimationController!,
|
||||
curve: Curves.easeInOut,
|
||||
),
|
||||
);
|
||||
|
||||
setState(() {
|
||||
_showAnimatedCard = true;
|
||||
});
|
||||
|
||||
_cardAnimationController!.forward();
|
||||
|
||||
animating = true;
|
||||
await _controller.animateToPage(
|
||||
tempTargetIndex,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
value: 1,
|
||||
);
|
||||
|
||||
// After animation, restore the original order if necessary
|
||||
if (_isTemporaryOrder) {
|
||||
setState(() {
|
||||
_animationDates = original; // Restore from original dates
|
||||
_isTemporaryOrder = false;
|
||||
});
|
||||
|
||||
// Jump to the correct position without animation
|
||||
_controller.jumpToPage(targetIndex);
|
||||
var today = timeNow().getMidnight();
|
||||
var anchor = today;
|
||||
while (!_isDayVisible(anchor)) {
|
||||
anchor = anchor.add(Duration(days: 1));
|
||||
}
|
||||
_indexToDate[_originIndex] = anchor;
|
||||
|
||||
animating = false;
|
||||
setState(() {
|
||||
active = targetIndex;
|
||||
_showAnimatedCard = false;
|
||||
});
|
||||
|
||||
_cardAnimationController!.reset();
|
||||
_currentTabWeekMonday = _activeWeekMonday;
|
||||
_tabDays = _visibleDaysOfWeek(_currentTabWeekMonday);
|
||||
}
|
||||
|
||||
void updateWeek(DateTime monday) {
|
||||
currentMonday = monday.getMonday().getMidnight();
|
||||
@override
|
||||
void dispose() {
|
||||
_weekSlideController.dispose();
|
||||
_pageController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
dates.clear();
|
||||
for (int i = 0; i < 7; i++) {
|
||||
final day = currentMonday.add(Duration(days: i));
|
||||
DateTime get _activeDay => _dateForIndex(_activePageIndex);
|
||||
|
||||
dates[day] = widget.data.client!.cache
|
||||
DateTime get _activeWeekMonday => _activeDay.getMonday().getMidnight();
|
||||
|
||||
List<LessonCacheModel> _lessonsFor(DateTime day) {
|
||||
return _lessonsCache.putIfAbsent(
|
||||
day,
|
||||
() => widget.data.client!.cache
|
||||
.getTimeTable()
|
||||
.on(day)
|
||||
.sortByStart()
|
||||
.findAllSync();
|
||||
.findAllSync(),
|
||||
);
|
||||
}
|
||||
|
||||
if (day.weekday > 5 &&
|
||||
dates[day]!.every((l) => l.type == TimetableConsts.event)) {
|
||||
dates.remove(day);
|
||||
bool _isDayVisible(DateTime day) {
|
||||
if (day.weekday <= 5) return true;
|
||||
return _lessonsFor(day).any((l) => l.type != TimetableConsts.event);
|
||||
}
|
||||
|
||||
List<DateTime> _visibleDaysOfWeek(DateTime monday) {
|
||||
return [
|
||||
for (int i = 0; i < 7; i++)
|
||||
if (_isDayVisible(monday.add(Duration(days: i))))
|
||||
monday.add(Duration(days: i)),
|
||||
];
|
||||
}
|
||||
|
||||
DateTime _dateForIndex(int index) {
|
||||
final cached = _indexToDate[index];
|
||||
if (cached != null) return cached;
|
||||
|
||||
var nearest = _indexToDate.keys.reduce(
|
||||
(a, b) => (a - index).abs() < (b - index).abs() ? a : b,
|
||||
);
|
||||
var date = _indexToDate[nearest]!;
|
||||
final dir = index > nearest ? 1 : -1;
|
||||
var i = nearest;
|
||||
while (i != index) {
|
||||
date = date.add(Duration(days: dir));
|
||||
if (_isDayVisible(date)) i += dir;
|
||||
}
|
||||
|
||||
_indexToDate[index] = date;
|
||||
return date;
|
||||
}
|
||||
|
||||
int _indexForDate(DateTime day) {
|
||||
day = day.getMidnight();
|
||||
|
||||
var nearest = _indexToDate.entries.reduce(
|
||||
(a, b) =>
|
||||
(a.value.difference(day)).abs() < (b.value.difference(day)).abs()
|
||||
? a
|
||||
: b,
|
||||
);
|
||||
var index = nearest.key;
|
||||
var date = nearest.value;
|
||||
final dir = day.isAfter(date) ? 1 : -1;
|
||||
while (!date.isAtSameMomentAs(day)) {
|
||||
date = date.add(Duration(days: dir));
|
||||
if (_isDayVisible(date)) index += dir;
|
||||
}
|
||||
|
||||
_indexToDate[index] = date;
|
||||
return index;
|
||||
}
|
||||
|
||||
Widget _dayPageFor(DateTime day) {
|
||||
bool isEvent(LessonCacheModel model) {
|
||||
return model.type == TimetableConsts.event;
|
||||
}
|
||||
|
||||
final lessons = List<LessonCacheModel>.from(_lessonsFor(day))
|
||||
..removeWhere(isEvent);
|
||||
final events = List<LessonCacheModel>.from(_lessonsFor(day))
|
||||
..retainWhere(isEvent);
|
||||
return TimeTableDayWidget(
|
||||
lessons,
|
||||
events,
|
||||
onRefresh: () => widget.data.client!.pullRefresh(
|
||||
() => widget.data.client!.getLessonsCovering(
|
||||
_currentTabWeekMonday,
|
||||
_currentTabWeekMonday.add(const Duration(days: 7)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _weekTabBar(List<DateTime> days, DateTime activeDay) {
|
||||
final tabs = <Widget>[];
|
||||
for (final day in days) {
|
||||
Widget ttWidget = BottomTimeTableNavIconWidget(
|
||||
widget.data.l10n,
|
||||
() {
|
||||
_goToDay(day);
|
||||
},
|
||||
day.isAtSameMomentAs(activeDay),
|
||||
day,
|
||||
);
|
||||
|
||||
if (_lessonsFor(day).any((l) => l.test.loadAndGet() != null)) {
|
||||
tabs.add(
|
||||
Stack(
|
||||
children: [
|
||||
ttWidget,
|
||||
Transform.translate(offset: Offset(34, -9), child: BubbleTest()),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
tabs.add(ttWidget);
|
||||
}
|
||||
}
|
||||
_animationDates = List.from(dates.keys);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(bottom: 2),
|
||||
decoration: ShapeDecoration(
|
||||
color: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)),
|
||||
shadows: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.background,
|
||||
blurRadius: 36,
|
||||
offset: Offset(0, -27),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(child: Wrap(spacing: 16, children: tabs)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _weekPanel({
|
||||
required Widget dayChild,
|
||||
required List<DateTime> tabDays,
|
||||
required DateTime activeDay,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(child: dayChild),
|
||||
_weekTabBar(tabDays, activeDay),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _shiftWeek(int weeks) {
|
||||
final targetMonday = _currentTabWeekMonday.add(Duration(days: 7 * weeks));
|
||||
final offset = _activeDay.difference(_currentTabWeekMonday).inDays;
|
||||
var target = targetMonday.add(Duration(days: offset));
|
||||
if (!_isDayVisible(target)) {
|
||||
target = _visibleDaysOfWeek(targetMonday).first;
|
||||
}
|
||||
_goToDay(target, animate: false);
|
||||
}
|
||||
|
||||
void _goToDay(DateTime day, {bool animate = true}) async {
|
||||
if (animating) return;
|
||||
|
||||
final targetIndex = _indexForDate(day);
|
||||
if (targetIndex == _activePageIndex) return;
|
||||
|
||||
HapticFeedback.mediumImpact();
|
||||
_programmaticTargetIndex = targetIndex;
|
||||
|
||||
final weekChanged = !day.getMonday().getMidnight().isAtSameMomentAs(
|
||||
_currentTabWeekMonday,
|
||||
);
|
||||
|
||||
if (!animate) {
|
||||
if (weekChanged) {
|
||||
await _slideToWeek(targetIndex, day);
|
||||
} else {
|
||||
animating = true;
|
||||
_pageController.jumpToPage(targetIndex);
|
||||
animating = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
animating = true;
|
||||
try {
|
||||
await _pageController.animateToPage(
|
||||
targetIndex,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
} finally {
|
||||
animating = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _slideToWeek(int targetIndex, DateTime day) async {
|
||||
_visibleDaysOfWeek(day.getMonday().getMidnight());
|
||||
|
||||
_outgoingWeek = _weekPanel(
|
||||
dayChild: _dayPageFor(_activeDay),
|
||||
tabDays: List<DateTime>.from(_tabDays),
|
||||
activeDay: _activeDay,
|
||||
);
|
||||
_weekSlideDir = targetIndex > _activePageIndex ? 1 : -1;
|
||||
_weekSlideController.value = 0;
|
||||
|
||||
animating = true;
|
||||
_pageController.jumpToPage(targetIndex);
|
||||
if (mounted) setState(() {});
|
||||
|
||||
try {
|
||||
await _weekSlideController.forward();
|
||||
} finally {
|
||||
if (mounted) {
|
||||
_outgoingWeek = null;
|
||||
animating = false;
|
||||
setState(() {});
|
||||
} else {
|
||||
animating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onPageChanged(int index) {
|
||||
if (!mounted) return;
|
||||
|
||||
final programmatic = _programmaticTargetIndex != null;
|
||||
if (programmatic && (index == _programmaticTargetIndex || !animating)) {
|
||||
_programmaticTargetIndex = null;
|
||||
}
|
||||
if (!programmatic) {
|
||||
HapticFeedback.mediumImpact();
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_activePageIndex = index;
|
||||
final weekMonday = _activeWeekMonday;
|
||||
if (!weekMonday.isAtSameMomentAs(_currentTabWeekMonday)) {
|
||||
_currentTabWeekMonday = weekMonday;
|
||||
_tabDays = _visibleDaysOfWeek(weekMonday);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -177,6 +338,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
listenWhen: (previous, current) =>
|
||||
current.refreshTrigger != previous.refreshTrigger,
|
||||
listener: (context, state) {
|
||||
_lessonsCache.clear();
|
||||
setState(() {});
|
||||
},
|
||||
child: _buildContent(context),
|
||||
@@ -185,77 +347,58 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
List<Widget> ttWidgets = [];
|
||||
List<Widget> ttDays = [];
|
||||
final showABTimetable = Settings.ttToastABTimetable.value;
|
||||
// Build navigation icons using original dates
|
||||
var i = 0;
|
||||
for (MapEntry<DateTime, List<LessonCacheModel>> e in dates.entries) {
|
||||
var realIndex = i;
|
||||
Widget ttWidget = BottomTimeTableNavIconWidget(
|
||||
widget.data.l10n,
|
||||
() {
|
||||
_handleNavTap(active, realIndex);
|
||||
},
|
||||
active == i,
|
||||
e.key,
|
||||
);
|
||||
|
||||
if (e.value.any((l) => l.test.loadAndGet() != null)) {
|
||||
ttWidgets.add(
|
||||
Stack(
|
||||
children: [
|
||||
ttWidget,
|
||||
Transform.translate(offset: Offset(34, -9), child: BubbleTest()),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ttWidgets.add(ttWidget);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
bool isEvent(LessonCacheModel model) {
|
||||
return model.type == TimetableConsts.event;
|
||||
}
|
||||
|
||||
// Build carousel pages using animation dates
|
||||
for (DateTime date in _animationDates) {
|
||||
final lessons = List<LessonCacheModel>.from(dates[date]!)
|
||||
..removeWhere(isEvent);
|
||||
final events = List<LessonCacheModel>.from(dates[date]!)
|
||||
..retainWhere(isEvent);
|
||||
ttDays.add(TimeTableDayWidget(lessons, events));
|
||||
}
|
||||
|
||||
Widget ttAnimatedCard = BottomTimeTableNavIconWidget(
|
||||
widget.data.l10n,
|
||||
() => {},
|
||||
false,
|
||||
null,
|
||||
);
|
||||
|
||||
if (_cardOffsetAnimation != null && _showAnimatedCard) {
|
||||
ttAnimatedCard = AnimatedBuilder(
|
||||
animation: _cardOffsetAnimation!,
|
||||
builder: (context, child) {
|
||||
return Transform.translate(
|
||||
offset: _cardOffsetAnimation!.value,
|
||||
child: BottomTimeTableNavIconWidget(
|
||||
widget.data.l10n,
|
||||
() => {},
|
||||
true,
|
||||
null,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ClipRect(
|
||||
child: AnimatedBuilder(
|
||||
animation: _weekSlideController,
|
||||
builder: (context, child) {
|
||||
final sliding = _outgoingWeek != null;
|
||||
final t = sliding
|
||||
? Curves.easeInOut.transform(_weekSlideController.value)
|
||||
: 1.0;
|
||||
final dx = _weekSlideDir * MediaQuery.sizeOf(context).width;
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: Offset((1 - t) * dx, 0),
|
||||
child: IgnorePointer(ignoring: sliding, child: child),
|
||||
),
|
||||
if (_outgoingWeek != null)
|
||||
IgnorePointer(
|
||||
child: Transform.translate(
|
||||
offset: Offset(-t * dx, 0),
|
||||
child: _outgoingWeek,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
child: _weekPanel(
|
||||
dayChild: PageView.builder(
|
||||
key: _pageViewKey,
|
||||
controller: _pageController,
|
||||
onPageChanged: _onPageChanged,
|
||||
itemBuilder: (context, index) {
|
||||
return _dayPageFor(_dateForIndex(index));
|
||||
},
|
||||
),
|
||||
tabDays: _tabDays,
|
||||
activeDay: _activeDay,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
@@ -269,58 +412,37 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.timetable,
|
||||
headingText(widget.data.l10n.timetable),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.tableSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {
|
||||
context.push('/timetable/monthly');
|
||||
},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.tableSolid,
|
||||
size: 20.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
/* TODO: 1.1.0
|
||||
|
||||
Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.plusLine,
|
||||
size: 32.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
FirkaIconButton(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.plusLine,
|
||||
size: 20.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
*/
|
||||
GestureDetector(
|
||||
child: Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {
|
||||
showSettingsSheet(
|
||||
context,
|
||||
@@ -329,6 +451,12 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
timetableToastTree(widget.data.l10n),
|
||||
);
|
||||
},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 20.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -351,11 +479,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
updateWeek(
|
||||
currentMonday.subtract(Duration(days: 7)),
|
||||
);
|
||||
});
|
||||
_shiftWeek(-1);
|
||||
},
|
||||
),
|
||||
GestureDetector(
|
||||
@@ -363,7 +487,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
currentMonday.format(
|
||||
_currentTabWeekMonday.format(
|
||||
widget.data.l10n,
|
||||
FormatMode.yyyymmddwedd,
|
||||
),
|
||||
@@ -379,7 +503,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
),
|
||||
),
|
||||
Text(
|
||||
currentMonday.isAWeek()
|
||||
_currentTabWeekMonday.isAWeek()
|
||||
? widget.data.l10n.a_week
|
||||
: widget.data.l10n.b_week,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
@@ -390,10 +514,11 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
updateWeek(timeNow());
|
||||
_controller.jumpToPage(active);
|
||||
});
|
||||
var today = timeNow().getMidnight();
|
||||
while (!_isDayVisible(today)) {
|
||||
today = today.add(Duration(days: 1));
|
||||
}
|
||||
_goToDay(today, animate: false);
|
||||
},
|
||||
),
|
||||
GestureDetector(
|
||||
@@ -409,9 +534,7 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
updateWeek(currentMonday.add(Duration(days: 7)));
|
||||
});
|
||||
_shiftWeek(1);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -422,59 +545,6 @@ class _HomeTimetableScreen extends FirkaState<HomeTimetableScreen>
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TransparentPointer(
|
||||
child: CarouselSlider(
|
||||
items: ttDays,
|
||||
carouselController: _controller,
|
||||
options: CarouselOptions(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
viewportFraction: 1,
|
||||
enableInfiniteScroll: false,
|
||||
initialPage: active,
|
||||
onPageChanged: (i, _) {
|
||||
if (animating || !mounted) return;
|
||||
|
||||
HapticFeedback.mediumImpact();
|
||||
|
||||
setState(() {
|
||||
active = i;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(bottom: 2),
|
||||
decoration: ShapeDecoration(
|
||||
color: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
shadows: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.background,
|
||||
blurRadius: 36,
|
||||
offset: Offset(0, -27),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Stack(
|
||||
children: [
|
||||
ttAnimatedCard,
|
||||
Wrap(spacing: 16, children: ttWidgets),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:firka/ui/components/firka_icon_button.dart';
|
||||
import 'package:firka/ui/phone/screens/settings/settings_screen.dart';
|
||||
import 'package:firka_common/data/models/lesson_cache_model.dart';
|
||||
import 'package:firka_common/data/util.dart';
|
||||
@@ -254,56 +255,35 @@ class _HomeTimetableMonthlyScreen
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.data.l10n.timetable,
|
||||
headingText(widget.data.l10n.timetable),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.tableSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {
|
||||
context.pop();
|
||||
},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.tableSolid,
|
||||
size: 20.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
// Nincs elkészítve jelenleg: Dolgozat stb hozzáadása(?)
|
||||
// Card(
|
||||
// color: appStyle.colors.buttonSecondaryFill,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(4),
|
||||
// child: FirkaIconWidget(
|
||||
// FirkaIconType.majesticons,
|
||||
// Majesticon.plusLine,
|
||||
// size: 32.0,
|
||||
// color: appStyle.colors.accent,
|
||||
// ),
|
||||
// FirkaIconButton(
|
||||
// child: FirkaIconWidget(
|
||||
// FirkaIconType.majesticons,
|
||||
// Majesticon.plusLine,
|
||||
// size: 20.0,
|
||||
// color: appStyle.colors.accent,
|
||||
// ),
|
||||
// ),
|
||||
GestureDetector(
|
||||
child: Card(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 26.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {
|
||||
showSettingsSheet(
|
||||
context,
|
||||
@@ -312,6 +292,12 @@ class _HomeTimetableMonthlyScreen
|
||||
timetableToastTree(widget.data.l10n),
|
||||
);
|
||||
},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.settingsCogSolid,
|
||||
size: 20.0,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -373,11 +359,20 @@ class _HomeTimetableMonthlyScreen
|
||||
left: 20,
|
||||
right: 20,
|
||||
),
|
||||
child: GridView.count(
|
||||
crossAxisCount: 7,
|
||||
mainAxisSpacing: 16,
|
||||
mainAxisExtent: 62,
|
||||
children: ttDays,
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () => widget.data.client!.pullRefresh(
|
||||
() => widget.data.client!.getLessonsCovering(
|
||||
currentMonthStart,
|
||||
currentMonthEnd,
|
||||
),
|
||||
),
|
||||
child: GridView.count(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
crossAxisCount: 7,
|
||||
mainAxisSpacing: 16,
|
||||
mainAxisExtent: 62,
|
||||
children: ttDays,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -20,10 +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';
|
||||
|
||||
@@ -43,6 +48,7 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
Uint8List? profilePictureData;
|
||||
|
||||
bool useCache = true;
|
||||
late TextEditingController _mockBackendUrlController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -50,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
|
||||
@@ -98,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(
|
||||
@@ -216,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();
|
||||
@@ -335,7 +448,7 @@ class _DebugScreen extends FirkaState<DebugScreen> {
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
getIconData(e),
|
||||
color: Colors.black,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -17,7 +17,6 @@ import 'package:firka/core/bloc/profile_picture_cubit.dart';
|
||||
import 'package:firka/core/bloc/settings_cubit.dart';
|
||||
import 'package:firka/core/state/firka_state.dart';
|
||||
import 'package:firka/core/image_preloader.dart';
|
||||
import 'package:firka/ui/shared/delayed_spinner.dart';
|
||||
|
||||
bool _fetching = false;
|
||||
bool _prefetched = false;
|
||||
@@ -34,7 +33,6 @@ class HomeScreen extends StatefulWidget {
|
||||
class _HomeScreenState extends FirkaState<HomeScreen>
|
||||
with WidgetsBindingObserver {
|
||||
bool _disposed = false;
|
||||
bool _preloadDone = false;
|
||||
bool _didRunLiveActivityLogin = false;
|
||||
bool _hasCompletedFirstPrefetch = false;
|
||||
|
||||
@@ -178,32 +176,11 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
||||
await ImagePreloader.preloadMultipleAssets(FirkaBundle(), imagePaths);
|
||||
} catch (e) {
|
||||
logger.severe('Home: error preloading images: $e');
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() => _preloadDone = true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!_preloadDone) {
|
||||
return Scaffold(
|
||||
backgroundColor: appStyle.colors.background,
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [SizedBox(), DelayedSpinnerWidget(), SizedBox()],
|
||||
),
|
||||
SizedBox(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
||||
return BlocListener<SettingsCubit, SettingsState>(
|
||||
listener: (context, state) {
|
||||
@@ -228,7 +205,7 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
||||
child: Stack(
|
||||
children: [
|
||||
widget.child,
|
||||
?(context.watch<ToastCubit>().state.buildWidget(context)),
|
||||
?(_toastOverlay(context)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -239,6 +216,14 @@ class _HomeScreenState extends FirkaState<HomeScreen>
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _toastOverlay(BuildContext context) {
|
||||
final toast = context.watch<ToastCubit>().state;
|
||||
if (toast.type == .fetching && !_hasCompletedFirstPrefetch) {
|
||||
return null;
|
||||
}
|
||||
return toast.buildWidget(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
super.didChangeAppLifecycleState(state);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:firka/core/extensions.dart';
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka_common/data/models/message_cache_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_html/flutter_html.dart';
|
||||
import 'package:majesticons_flutter/majesticons_flutter.dart';
|
||||
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:firka/core/firka_bundle.dart';
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
import 'package:firka/ui/shared/firka_icon.dart';
|
||||
@@ -12,7 +12,7 @@ import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
class MessageScreen extends StatelessWidget {
|
||||
final AppInitialization data;
|
||||
final MessageItem message;
|
||||
final MessageCacheModel message;
|
||||
|
||||
const MessageScreen(this.data, this.message, {super.key});
|
||||
|
||||
@@ -34,143 +34,150 @@ class MessageScreen extends StatelessWidget {
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: 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,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
data.l10n.s_a,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
child: SelectionArea(
|
||||
child: 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,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 56),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.85,
|
||||
child: Text(
|
||||
message.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
message.date.format(data.l10n, FormatMode.yyyymmdd),
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 56),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: ShapeDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
shape: CircleBorder(eccentricity: 1),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 28,
|
||||
height: 28,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Text(
|
||||
message.author[0],
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
fontSize: 20,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width / 1.4,
|
||||
child: Text(
|
||||
message.author,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
data.l10n.s_a,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.card,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 56),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.85,
|
||||
child: Text(
|
||||
message.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: SingleChildScrollView(
|
||||
child: Html(
|
||||
data: message.contentHTML,
|
||||
onLinkTap: (url, map, element) => {
|
||||
if (url != null) launchUrlString(url),
|
||||
},
|
||||
style: {
|
||||
"*": Style.fromTextStyle(
|
||||
appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
message.createdAt.format(
|
||||
data.l10n,
|
||||
FormatMode.yyyymmdd,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 56),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: ShapeDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
shape: CircleBorder(eccentricity: 1),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 28,
|
||||
height: 28,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Text(
|
||||
message.author[0],
|
||||
style: appStyle.fonts.H_18px.copyWith(
|
||||
fontSize: 20,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width / 1.4,
|
||||
child: Text(
|
||||
message.author,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.card,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(16),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: SingleChildScrollView(
|
||||
child: Html(
|
||||
data: message.contentHtml
|
||||
.withoutFontFeatureSettings(),
|
||||
onLinkTap: (url, map, element) => {
|
||||
if (url != null) launchUrlString(url),
|
||||
},
|
||||
style: {
|
||||
"*": Style.fromTextStyle(
|
||||
appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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(
|
||||
@@ -22,13 +27,8 @@ Widget buildBoolRow(
|
||||
item.iconType!,
|
||||
item.iconData!,
|
||||
color: appStyle.colors.accent,
|
||||
package:
|
||||
item.iconType == FirkaIconType.icons ||
|
||||
item.iconType == FirkaIconType.majesticonsLocal
|
||||
? 'firka'
|
||||
: null,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
SizedBox(width: 12 * scale),
|
||||
],
|
||||
)
|
||||
: SizedBox(),
|
||||
@@ -38,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;
|
||||
@@ -0,0 +1,601 @@
|
||||
import "dart:io";
|
||||
|
||||
import "package:firka/app/app_state.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/settings/settings_ui.dart";
|
||||
import "package:firka/core/settings/title_font.dart";
|
||||
import "package:firka/l10n/app_localizations.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";
|
||||
import "package:flutter_bloc/flutter_bloc.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
import "package:majesticons_flutter/majesticons_flutter.dart";
|
||||
|
||||
class SettingsPersonalizationView extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
final SettingsUiPersonalization item;
|
||||
|
||||
const SettingsPersonalizationView({
|
||||
required this.data,
|
||||
required this.item,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<SettingsPersonalizationView> createState() =>
|
||||
_SettingsPersonalizationViewState();
|
||||
}
|
||||
|
||||
class _SettingsPersonalizationViewState
|
||||
extends State<SettingsPersonalizationView> {
|
||||
bool _fontPickerExpanded = false;
|
||||
|
||||
SettingsRepository get _settings => widget.data.settings;
|
||||
AppLocalizations get _l10n => widget.data.l10n;
|
||||
|
||||
Color get _mutedCardColor => appStyle.isLight
|
||||
? const Color(0xFFE4EBC8)
|
||||
: appStyle.colors.buttonSecondaryFill;
|
||||
|
||||
Color get _selectedSurface => appStyle.colors.buttonSecondaryFill;
|
||||
|
||||
Widget _sectionLabel(String text) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 4, bottom: 8, top: 16),
|
||||
child: Text(
|
||||
text,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _externalArrow() {
|
||||
return RotationTransition(
|
||||
turns: const AlwaysStoppedAnimation(-45 / 360),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.arrowRightLine,
|
||||
size: 20,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _shortcutRow({
|
||||
required String title,
|
||||
FirkaIconType? iconType,
|
||||
Object? iconData,
|
||||
VoidCallback? onTap,
|
||||
}) {
|
||||
final left = <Widget>[];
|
||||
if (iconType != null && iconData != null) {
|
||||
left.add(
|
||||
FirkaIconWidget(
|
||||
iconType,
|
||||
iconData,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
);
|
||||
left.add(const SizedBox(width: 8));
|
||||
}
|
||||
left.add(
|
||||
Text(
|
||||
title,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: FirkaCard(
|
||||
left: left,
|
||||
right: [_externalArrow()],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _chip(String label, {required bool selected}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? _selectedSurface : appStyle.colors.card,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.shadowColor,
|
||||
offset: const Offset(0, 1),
|
||||
blurRadius: appStyle.isLight ? 2 : 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: (selected ? appStyle.fonts.B_16SB : appStyle.fonts.B_16R).apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _swatchPreview(List<Color> colors) {
|
||||
return FirkaCard.single(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.zero,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: SizedBox(
|
||||
height: 88,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final color in colors)
|
||||
Expanded(child: ColoredBox(color: color)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _stubCustomizeButton() {
|
||||
return FirkaCard(
|
||||
left: [
|
||||
Text(
|
||||
_l10n.s_c_customize,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _checkMark() {
|
||||
return SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: Checkbox(
|
||||
value: true,
|
||||
fillColor: WidgetStateProperty.resolveWith<Color>((_) {
|
||||
return appStyle.colors.secondary;
|
||||
}),
|
||||
onChanged: (_) {},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _themeOption(String label, ThemeBrightness value) {
|
||||
final selected = _settings.get(SettingsRegistry.themeBrightness) == value;
|
||||
|
||||
final card = FirkaCard(
|
||||
height: 52 + 12,
|
||||
left: [
|
||||
Text(
|
||||
label,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
right: selected
|
||||
? [_checkMark(), const SizedBox(width: 8)]
|
||||
: [const SizedBox(height: 16 + 8)],
|
||||
);
|
||||
|
||||
if (selected) return card;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await _settings.set(SettingsRegistry.themeBrightness, value);
|
||||
setState(() {});
|
||||
},
|
||||
child: card,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _fontCard(TitleFont font, {required bool selected}) {
|
||||
final style = TextStyle(
|
||||
fontFamily: font.fontFamily,
|
||||
fontSize: 16,
|
||||
fontVariations: font.supportsWeight
|
||||
? [FontVariation("wght", _settings.get(SettingsRegistry.titleWeight))]
|
||||
: null,
|
||||
color: appStyle.colors.textPrimary,
|
||||
);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: selected
|
||||
? null
|
||||
: () async {
|
||||
await _settings.set(SettingsRegistry.titleFont, font);
|
||||
setState(() {});
|
||||
},
|
||||
child: FirkaCard(
|
||||
color: selected ? _selectedSurface : _mutedCardColor,
|
||||
left: [
|
||||
Text(font.displayName, style: style),
|
||||
],
|
||||
right: selected
|
||||
? [_checkMark(), const SizedBox(width: 8)]
|
||||
: const [],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _changeRow() {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() => _fontPickerExpanded = !_fontPickerExpanded);
|
||||
},
|
||||
child: FirkaCard(
|
||||
left: [
|
||||
Text(
|
||||
_l10n.s_c_change,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
right: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
_fontPickerExpanded
|
||||
? Majesticon.chevronUpLine
|
||||
: Majesticon.chevronDownLine,
|
||||
size: 24,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _fontPicker(TitleFont selected) {
|
||||
if (!_fontPickerExpanded) {
|
||||
return Column(
|
||||
children: [
|
||||
_fontCard(selected, selected: true),
|
||||
_changeRow(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
for (final font in TitleFont.values)
|
||||
_fontCard(font, selected: font == selected),
|
||||
_changeRow(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
double _textWidth(String text, TextStyle style) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: text, style: style),
|
||||
textDirection: TextDirection.ltr,
|
||||
maxLines: 1,
|
||||
)..layout();
|
||||
return painter.width;
|
||||
}
|
||||
|
||||
Widget _weightEndDot() {
|
||||
return Container(
|
||||
width: 12,
|
||||
height: 12,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: appStyle.colors.textTertiary.withValues(alpha: 0.22),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _weightThumb({required double size}) {
|
||||
return Container(
|
||||
width: size,
|
||||
height: size,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: appStyle.colors.accent,
|
||||
border: Border.all(
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
width: 3,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.shadowColor,
|
||||
offset: const Offset(0, 1),
|
||||
blurRadius: appStyle.isLight ? 3 : 0,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _weightSlider() {
|
||||
final setting = SettingsRegistry.titleWeight;
|
||||
final value = _settings.get(setting);
|
||||
const trackHeight = 52.0;
|
||||
const thumbSize = 28.0;
|
||||
const thumbRadius = thumbSize / 2;
|
||||
const edgePad = 16.0;
|
||||
const gap = 8.0;
|
||||
const endDotSize = 12.0;
|
||||
|
||||
final labelStyle = appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
);
|
||||
final thinLabel = _l10n.s_c_title_weight_thin;
|
||||
final thickLabel = _l10n.s_c_title_weight_thick;
|
||||
final thinWidth = _textWidth(thinLabel, labelStyle);
|
||||
final thickWidth = _textWidth(thickLabel, labelStyle);
|
||||
|
||||
Future<void> setFromLocalX(double localX, double width) async {
|
||||
final start = edgePad + thumbRadius;
|
||||
final end = width - edgePad - thumbRadius;
|
||||
if (end <= start) return;
|
||||
|
||||
final t = ((localX - start) / (end - start)).clamp(0.0, 1.0);
|
||||
final raw = setting.min + t * (setting.max - setting.min);
|
||||
final stepped = (raw / setting.step!).round() * setting.step!;
|
||||
final clamped = stepped.clamp(setting.min, setting.max).toDouble();
|
||||
if (clamped == value) return;
|
||||
|
||||
await _settings.set(setting, clamped);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_sectionLabel(_l10n.s_c_title_weight_header),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 4, bottom: 8),
|
||||
child: Text(
|
||||
_l10n.s_c_title_weight_subtitle,
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
FirkaCard.single(
|
||||
width: double.infinity,
|
||||
height: trackHeight,
|
||||
padding: EdgeInsets.zero,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final width = constraints.maxWidth;
|
||||
final start = edgePad + thumbRadius;
|
||||
final end = width - edgePad - thumbRadius;
|
||||
final t = ((value - setting.min) / (setting.max - setting.min))
|
||||
.clamp(0.0, 1.0);
|
||||
final thumbCenterX = start + t * (end - start);
|
||||
final thumbLeft = thumbCenterX - thumbRadius;
|
||||
final thumbRight = thumbCenterX + thumbRadius;
|
||||
|
||||
final thinLeft = edgePad + endDotSize + gap;
|
||||
final thinRight = thinLeft + thinWidth;
|
||||
final thickRight = width - edgePad - endDotSize - gap;
|
||||
final thickLeft = thickRight - thickWidth;
|
||||
|
||||
final showThin = thumbRight < thinLeft || thumbLeft > thinRight;
|
||||
final showThick = thumbRight < thickLeft || thumbLeft > thickRight;
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown: (details) {
|
||||
setFromLocalX(details.localPosition.dx, width);
|
||||
},
|
||||
onHorizontalDragUpdate: (details) {
|
||||
setFromLocalX(details.localPosition.dx, width);
|
||||
},
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: edgePad),
|
||||
child: Row(
|
||||
children: [
|
||||
_weightEndDot(),
|
||||
const SizedBox(width: gap),
|
||||
Opacity(
|
||||
opacity: showThin ? 1 : 0,
|
||||
child: Text(thinLabel, style: labelStyle),
|
||||
),
|
||||
const Spacer(),
|
||||
Opacity(
|
||||
opacity: showThick ? 1 : 0,
|
||||
child: Text(thickLabel, style: labelStyle),
|
||||
),
|
||||
const SizedBox(width: gap),
|
||||
_weightEndDot(),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: thumbLeft,
|
||||
child: _weightThumb(size: thumbSize),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _capitalizationControl() {
|
||||
final selected = _settings.get(SettingsRegistry.titleCapitalization);
|
||||
final options = [
|
||||
(TitleCapitalization.lower, _l10n.s_c_capitalization_lower),
|
||||
(TitleCapitalization.normal, _l10n.s_c_capitalization_normal),
|
||||
(TitleCapitalization.upper, _l10n.s_c_capitalization_upper),
|
||||
];
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_sectionLabel(_l10n.s_c_capitalization_header),
|
||||
FirkaCard.single(
|
||||
width: double.infinity,
|
||||
color: appStyle.colors.card,
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Row(
|
||||
children: [
|
||||
for (final (value, label) in options)
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
await _settings.set(
|
||||
SettingsRegistry.titleCapitalization,
|
||||
value,
|
||||
);
|
||||
setState(() {});
|
||||
},
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: selected == value
|
||||
? _selectedSurface
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: selected == value
|
||||
? [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.shadowColor,
|
||||
offset: const Offset(0, 1),
|
||||
blurRadius: appStyle.isLight ? 2 : 0,
|
||||
),
|
||||
]
|
||||
: null,
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ThemeCubit>.value(
|
||||
value: widget.data.themeCubit,
|
||||
child: BlocBuilder<ThemeCubit, ThemeState>(
|
||||
builder: (context, _) {
|
||||
final selectedFont = _settings.get(SettingsRegistry.titleFont);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 0),
|
||||
child: GestureDetector(
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
headingText(_l10n.s_customization),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
_chip(_l10n.s_c_tab_appearance, selected: true),
|
||||
const SizedBox(width: 8),
|
||||
_chip(_l10n.s_c_tab_subjects, selected: false),
|
||||
const SizedBox(width: 8),
|
||||
_chip(_l10n.s_c_tab_fonts, selected: false),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_shortcutRow(
|
||||
title: _l10n.s_c_my_themes,
|
||||
iconType: FirkaIconType.majesticons,
|
||||
iconData: Majesticon.editPen4Solid,
|
||||
onTap: () => context.push("/themes"),
|
||||
),
|
||||
_shortcutRow(
|
||||
title: _l10n.s_c_manage_subjects,
|
||||
iconType: FirkaIconType.majesticons,
|
||||
iconData: Majesticon.bookmarkSolid,
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
_shortcutRow(
|
||||
title: _l10n.s_c_change_app_icon,
|
||||
onTap: () {
|
||||
context.push("/settings", extra: [
|
||||
SettingsUiBackHeader(_l10n.s_customization, () => true),
|
||||
...widget.item.appIconPickerChildren,
|
||||
]);
|
||||
},
|
||||
),
|
||||
_sectionLabel(_l10n.s_c_colors_header),
|
||||
_swatchPreview([
|
||||
appStyle.colors.secondary,
|
||||
appStyle.colors.accent,
|
||||
appStyle.colors.background,
|
||||
appStyle.colors.card,
|
||||
]),
|
||||
_stubCustomizeButton(),
|
||||
_sectionLabel(_l10n.s_c_theme_header),
|
||||
_themeOption(_l10n.s_c_theme_auto, ThemeBrightness.auto),
|
||||
_themeOption(_l10n.s_c_theme_light, ThemeBrightness.light),
|
||||
_themeOption(_l10n.s_c_theme_dark, ThemeBrightness.dark),
|
||||
_sectionLabel(_l10n.s_c_grade_colors_header),
|
||||
_swatchPreview([
|
||||
appStyle.colors.grade5,
|
||||
appStyle.colors.grade4,
|
||||
appStyle.colors.grade3,
|
||||
appStyle.colors.grade2,
|
||||
appStyle.colors.grade1,
|
||||
]),
|
||||
_stubCustomizeButton(),
|
||||
_sectionLabel(_l10n.s_c_title_style_header),
|
||||
_fontPicker(selectedFont),
|
||||
_weightSlider(),
|
||||
_capitalizationControl(),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:firka_common/data/database.dart';
|
||||
import 'package:firka_common/data/models/token_model.dart';
|
||||
import 'package:firka/core/bloc/app_icon_picker_cubit.dart';
|
||||
import 'package:firka/core/bloc/theme_cubit.dart';
|
||||
import 'package:firka/core/settings/setting.dart';
|
||||
import 'package:firka/core/settings/settings_repository.dart';
|
||||
import 'package:firka/core/settings/settings_schema.dart';
|
||||
@@ -21,8 +24,10 @@ 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';
|
||||
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
@@ -39,6 +44,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
|
||||
late List<TokenModel> tokens;
|
||||
late final AppIconPickerCubit appIconPickerCubit;
|
||||
StreamSubscription<ThemeState>? _themeSub;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -46,10 +52,14 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
|
||||
tokens = isarInit.tokenModels.where().sortByUpdatedAtMsDesc().findAllSync();
|
||||
appIconPickerCubit = AppIconPickerCubit(Settings.appIcon.value);
|
||||
_themeSub = widget.data.themeCubit.stream.listen((_) {
|
||||
if (mounted) setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_themeSub?.cancel();
|
||||
appIconPickerCubit.close();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -68,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;
|
||||
@@ -84,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),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -121,7 +136,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
if (item is SettingsUiHeader) {
|
||||
widgets.add(
|
||||
Text(
|
||||
item.title,
|
||||
headingText(item.title),
|
||||
style: appStyle.fonts.H_H1.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
@@ -133,7 +148,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
if (item is SettingsUiMediumHeader) {
|
||||
widgets.add(
|
||||
Text(
|
||||
item.title,
|
||||
headingText(item.title),
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
@@ -163,28 +178,44 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
item.iconType!,
|
||||
item.iconData!,
|
||||
color: appStyle.colors.accent,
|
||||
package:
|
||||
item.iconType == FirkaIconType.icons ||
|
||||
item.iconType == FirkaIconType.majesticonsLocal
|
||||
? 'firka'
|
||||
: null,
|
||||
),
|
||||
);
|
||||
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",
|
||||
@@ -200,6 +231,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
},
|
||||
child: item.redirectTo != null
|
||||
? FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: cardWidgets,
|
||||
right: [
|
||||
RotationTransition(
|
||||
@@ -213,7 +246,11 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
),
|
||||
],
|
||||
)
|
||||
: FirkaCard(left: cardWidgets),
|
||||
: FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: cardWidgets,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -227,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(
|
||||
@@ -236,12 +274,6 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
item.iconType!,
|
||||
item.iconData!,
|
||||
color: appStyle.colors.accent,
|
||||
package:
|
||||
item.iconType == FirkaIconType.icons ||
|
||||
item.iconType ==
|
||||
FirkaIconType.majesticonsLocal
|
||||
? 'firka'
|
||||
: null,
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
],
|
||||
@@ -272,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;
|
||||
}
|
||||
@@ -284,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,
|
||||
@@ -322,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,
|
||||
@@ -354,6 +388,16 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsUiPersonalization) {
|
||||
widgets.add(
|
||||
SettingsPersonalizationView(
|
||||
data: widget.data,
|
||||
item: item,
|
||||
),
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (item is SettingsUiAppIconPicker) {
|
||||
widgets.add(
|
||||
SettingsAppIconPickerView(
|
||||
@@ -380,6 +424,8 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
widgets.add(
|
||||
GestureDetector(
|
||||
child: FirkaCard(
|
||||
height: settingsItemHeight * scale,
|
||||
rounding: settingsItemRounding * scale,
|
||||
left: [
|
||||
item.iconType != null
|
||||
? Row(
|
||||
@@ -388,12 +434,6 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
|
||||
item.iconType!,
|
||||
item.iconData!,
|
||||
color: appStyle.colors.accent,
|
||||
package:
|
||||
item.iconType == FirkaIconType.icons ||
|
||||
item.iconType ==
|
||||
FirkaIconType.majesticonsLocal
|
||||
? 'firka'
|
||||
: null,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
],
|
||||
@@ -435,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
44
firka/lib/ui/phone/screens/themes/builtin_theme_id.dart
Normal file
44
firka/lib/ui/phone/screens/themes/builtin_theme_id.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import "package:firka_common/ui/theme/core_theme.dart";
|
||||
import "package:firka_common/ui/theme/grade_theme.dart";
|
||||
|
||||
const defaultCoreThemeId = "firka";
|
||||
const defaultGradeThemeId = "firka";
|
||||
const defaultBuiltinThemeId = "builtin-firka-firka";
|
||||
|
||||
String composeBuiltinThemeId(String coreId, String gradeId) {
|
||||
return "builtin-$coreId-$gradeId";
|
||||
}
|
||||
|
||||
bool isBuiltinThemeId(String id) {
|
||||
return id == "builtin" || id.startsWith("builtin-");
|
||||
}
|
||||
|
||||
/// Parses `builtin-{core}-{grade}`. Legacy `builtin` and malformed ids
|
||||
/// fall back to firka / firka. Map lookup fallback happens at resolve sites.
|
||||
(String coreId, String gradeId) parseBuiltinThemeId(String id) {
|
||||
if (id == "builtin" || id == defaultBuiltinThemeId) {
|
||||
return (defaultCoreThemeId, defaultGradeThemeId);
|
||||
}
|
||||
if (!id.startsWith("builtin-")) {
|
||||
return (defaultCoreThemeId, defaultGradeThemeId);
|
||||
}
|
||||
final rest = id.substring("builtin-".length);
|
||||
final sep = rest.indexOf("-");
|
||||
if (sep <= 0 || sep >= rest.length - 1) {
|
||||
return (defaultCoreThemeId, defaultGradeThemeId);
|
||||
}
|
||||
final coreId = rest.substring(0, sep);
|
||||
final gradeId = rest.substring(sep + 1);
|
||||
if (coreId.isEmpty || gradeId.isEmpty) {
|
||||
return (defaultCoreThemeId, defaultGradeThemeId);
|
||||
}
|
||||
return (
|
||||
coreThemes.containsKey(coreId) ? coreId : defaultCoreThemeId,
|
||||
gradeThemes.containsKey(gradeId) ? gradeId : defaultGradeThemeId,
|
||||
);
|
||||
}
|
||||
|
||||
String normalizeSelectedThemeId(String id) {
|
||||
if (id == "builtin") return defaultBuiltinThemeId;
|
||||
return id;
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
import "package:firka/app/app_state.dart";
|
||||
import "package:firka/core/firka_bundle.dart";
|
||||
import "package:firka/ui/phone/widgets/bottom_nav_icon.dart";
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:intl/intl.dart";
|
||||
import "package:majesticons_flutter/majesticons_flutter.dart";
|
||||
|
||||
/// Which bottom-nav tab is highlighted inside a theme page preview.
|
||||
enum ThemePreviewNavTab { home, grades, timetable, omissions, other }
|
||||
|
||||
/// Phone-shaped frame that downscales a full-size home page for the theme carousel.
|
||||
class ThemePagePreview extends StatelessWidget {
|
||||
static const double designWidth = 390;
|
||||
static const double designHeight = 844;
|
||||
|
||||
final Widget body;
|
||||
final ThemePreviewNavTab activeTab;
|
||||
final AppInitialization data;
|
||||
|
||||
const ThemePagePreview({
|
||||
super.key,
|
||||
required this.body,
|
||||
required this.activeTab,
|
||||
required this.data,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.background,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: appStyle.colors.shadowColor,
|
||||
offset: const Offset(0, 1),
|
||||
blurRadius: 2,
|
||||
),
|
||||
],
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return FittedBox(
|
||||
fit: BoxFit.contain,
|
||||
alignment: Alignment.topCenter,
|
||||
child: SizedBox(
|
||||
width: designWidth,
|
||||
height: designHeight,
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
size: const Size(designWidth, designHeight),
|
||||
padding: EdgeInsets.zero,
|
||||
viewPadding: EdgeInsets.zero,
|
||||
viewInsets: EdgeInsets.zero,
|
||||
),
|
||||
child: IgnorePointer(
|
||||
child: DefaultAssetBundle(
|
||||
bundle: FirkaBundle(),
|
||||
child: ColoredBox(
|
||||
color: appStyle.colors.background,
|
||||
child: Column(
|
||||
children: [
|
||||
_PreviewStatusBar(),
|
||||
Expanded(child: body),
|
||||
_PreviewBottomNav(
|
||||
data: data,
|
||||
activeTab: activeTab,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PreviewStatusBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final time = DateFormat("H:mm").format(DateTime.now());
|
||||
return SizedBox(
|
||||
height: 28,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
time,
|
||||
style: appStyle.fonts.B_12SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Icon(
|
||||
Icons.signal_cellular_alt,
|
||||
size: 12,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.wifi,
|
||||
size: 12,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
Icons.battery_full,
|
||||
size: 12,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PreviewBottomNav extends StatelessWidget {
|
||||
final AppInitialization data;
|
||||
final ThemePreviewNavTab activeTab;
|
||||
|
||||
const _PreviewBottomNav({
|
||||
required this.data,
|
||||
required this.activeTab,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = data.l10n;
|
||||
final tabs = <(ThemePreviewNavTab, String, Object, Object)>[
|
||||
(
|
||||
ThemePreviewNavTab.home,
|
||||
l10n.home,
|
||||
Majesticon.homeSolid,
|
||||
Majesticon.homeLine,
|
||||
),
|
||||
(
|
||||
ThemePreviewNavTab.grades,
|
||||
l10n.grades,
|
||||
Majesticon.bookmarkSolid,
|
||||
Majesticon.bookmarkLine,
|
||||
),
|
||||
(
|
||||
ThemePreviewNavTab.timetable,
|
||||
l10n.timetable,
|
||||
Majesticon.calendarSolid,
|
||||
Majesticon.calendarLine,
|
||||
),
|
||||
(
|
||||
ThemePreviewNavTab.omissions,
|
||||
l10n.omissions,
|
||||
Majesticon.timerSolid,
|
||||
Majesticon.timerLine,
|
||||
),
|
||||
];
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
colors: [
|
||||
appStyle.colors.background,
|
||||
appStyle.colors.background.withValues(alpha: 0.0),
|
||||
],
|
||||
stops: const [0.0, 1.0],
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
...tabs.map((nav) {
|
||||
final active = activeTab == nav.$1;
|
||||
return BottomNavIconWidget(
|
||||
() {},
|
||||
active,
|
||||
active ? nav.$3 : nav.$4,
|
||||
nav.$2,
|
||||
);
|
||||
}),
|
||||
BottomNavIconWidget(
|
||||
() {},
|
||||
activeTab == ThemePreviewNavTab.other,
|
||||
data.profilePicture != null
|
||||
? data.profilePicture!
|
||||
: Majesticon.menuLine,
|
||||
l10n.other,
|
||||
isProfilePicture: data.profilePicture != null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
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/data/models/message_cache_model.dart";
|
||||
import "package:firka_common/data/models/omission_cache_model.dart";
|
||||
import "package:firka_common/data/models/student_cache_model.dart";
|
||||
import "package:firka_common/data/models/subject_cache_model.dart";
|
||||
import "package:firka_common/data/models/test_cache_model.dart";
|
||||
import "package:kreta_api/kreta_api.dart";
|
||||
|
||||
/// In-memory placeholder models for theme page previews (Figma sample content).
|
||||
class ThemePreviewData {
|
||||
ThemePreviewData._({
|
||||
required this.now,
|
||||
required this.student,
|
||||
required this.subjects,
|
||||
required this.homeLessons,
|
||||
required this.timetableLessons,
|
||||
required this.messages,
|
||||
required this.tests,
|
||||
required this.grades,
|
||||
required this.omissions,
|
||||
required this.omissionBarSegments,
|
||||
required this.omissionExcusedCount,
|
||||
required this.omissionPendingCount,
|
||||
required this.omissionUnexcusedCount,
|
||||
required this.monthDayMeta,
|
||||
required this.subjectDetailSubject,
|
||||
required this.subjectDetailGrades,
|
||||
required this.subjectDetailTeacher,
|
||||
});
|
||||
|
||||
final DateTime now;
|
||||
final StudentCacheModel student;
|
||||
final List<SubjectCacheModel> subjects;
|
||||
final List<LessonCacheModel> homeLessons;
|
||||
final List<LessonCacheModel> timetableLessons;
|
||||
final List<MessageCacheModel> messages;
|
||||
final List<TestCacheModel> tests;
|
||||
final List<GradeCacheModel> grades;
|
||||
final List<OmissionCacheModel> omissions;
|
||||
final List<OmissionState?> omissionBarSegments;
|
||||
final int omissionExcusedCount;
|
||||
final int omissionPendingCount;
|
||||
final int omissionUnexcusedCount;
|
||||
final Map<DateTime, ThemePreviewMonthDay> monthDayMeta;
|
||||
final SubjectCacheModel subjectDetailSubject;
|
||||
final List<GradeCacheModel> subjectDetailGrades;
|
||||
final String subjectDetailTeacher;
|
||||
|
||||
SubjectCacheModel get matematika => subjects[0];
|
||||
SubjectCacheModel get angol => subjects[1];
|
||||
SubjectCacheModel get tortenelem => subjects[2];
|
||||
SubjectCacheModel get nemet => subjects[3];
|
||||
SubjectCacheModel get informatika => subjects[4];
|
||||
SubjectCacheModel get fizika => subjects[5];
|
||||
|
||||
static ThemePreviewData build([DateTime? clock]) {
|
||||
final now = clock ?? timeNow();
|
||||
// Anchor to real time so LessonSlider / LessonBigWidget (which call
|
||||
// timeNow()) keep Matematika as the active lesson with ~35 min left.
|
||||
final midnight = DateTime(now.year, now.month, now.day);
|
||||
final day = now;
|
||||
|
||||
final subjects = [
|
||||
_subject(1, "Matematika"),
|
||||
_subject(2, "Angol nyelv"),
|
||||
_subject(3, "Történelem"),
|
||||
_subject(4, "Német"),
|
||||
_subject(5, "Informatika"),
|
||||
_subject(6, "Fizika"),
|
||||
];
|
||||
final matematika = subjects[0];
|
||||
final angol = subjects[1];
|
||||
final tortenelem = subjects[2];
|
||||
final nemet = subjects[3];
|
||||
final informatika = subjects[4];
|
||||
final fizika = subjects[5];
|
||||
|
||||
final student = StudentCacheModel()
|
||||
..cacheKey = 1
|
||||
..createdAt = midnight
|
||||
..name = "Kovács Ádám"
|
||||
..birthday = DateTime(2008, 3, 15);
|
||||
|
||||
// Active lesson: started 10 min ago, ends in 34 min => "35 perc" via timeLeft.
|
||||
final homeLessons = [
|
||||
_lesson(
|
||||
id: 101,
|
||||
subject: matematika,
|
||||
dailyNth: 1,
|
||||
start: now.subtract(const Duration(minutes: 10)),
|
||||
end: now.add(const Duration(minutes: 34)),
|
||||
roomName: "123",
|
||||
),
|
||||
_lesson(
|
||||
id: 102,
|
||||
subject: angol,
|
||||
dailyNth: 2,
|
||||
start: now.add(const Duration(minutes: 45)),
|
||||
end: now.add(const Duration(minutes: 90)),
|
||||
roomName: "123",
|
||||
),
|
||||
_lesson(
|
||||
id: 103,
|
||||
subject: tortenelem,
|
||||
dailyNth: 3,
|
||||
start: now.add(const Duration(minutes: 100)),
|
||||
end: now.add(const Duration(minutes: 145)),
|
||||
roomName: "201",
|
||||
),
|
||||
];
|
||||
|
||||
final testLektion = TestCacheModel()
|
||||
..cacheKey = 201
|
||||
..createdAt = midnight
|
||||
..topic = "Lektion 14"
|
||||
..method = "Írásbeli"
|
||||
..teacherName = "Müller Anna";
|
||||
|
||||
final testBinaris = TestCacheModel()
|
||||
..cacheKey = 202
|
||||
..createdAt = midnight
|
||||
..topic = "Bináris fák"
|
||||
..method = "Írásbeli"
|
||||
..teacherName = "Nagy Péter";
|
||||
|
||||
final ttBase = DateTime(day.year, day.month, day.day, 8, 0);
|
||||
final timetableLessons = [
|
||||
_lesson(
|
||||
id: 301,
|
||||
subject: nemet,
|
||||
dailyNth: 1,
|
||||
start: ttBase,
|
||||
end: ttBase.add(const Duration(minutes: 45)),
|
||||
roomName: "12",
|
||||
substituteTeacher: "Kiss Éva",
|
||||
),
|
||||
_lesson(
|
||||
id: 302,
|
||||
subject: matematika,
|
||||
dailyNth: 2,
|
||||
start: ttBase.add(const Duration(minutes: 55)),
|
||||
end: ttBase.add(const Duration(minutes: 100)),
|
||||
roomName: "123",
|
||||
test: testLektion,
|
||||
),
|
||||
_lesson(
|
||||
id: 303,
|
||||
subject: matematika,
|
||||
dailyNth: 3,
|
||||
start: ttBase.add(const Duration(minutes: 110)),
|
||||
end: ttBase.add(const Duration(minutes: 155)),
|
||||
roomName: "123",
|
||||
),
|
||||
_lesson(
|
||||
id: 304,
|
||||
subject: informatika,
|
||||
dailyNth: 4,
|
||||
start: ttBase.add(const Duration(minutes: 165)),
|
||||
end: ttBase.add(const Duration(minutes: 210)),
|
||||
roomName: "Inf1",
|
||||
test: testBinaris,
|
||||
),
|
||||
_lesson(
|
||||
id: 305,
|
||||
subject: informatika,
|
||||
dailyNth: 5,
|
||||
start: ttBase.add(const Duration(minutes: 220)),
|
||||
end: ttBase.add(const Duration(minutes: 265)),
|
||||
roomName: "Inf1",
|
||||
),
|
||||
];
|
||||
|
||||
final homeTest = TestCacheModel()
|
||||
..cacheKey = 203
|
||||
..createdAt = midnight.subtract(const Duration(days: 1))
|
||||
..topic = "Függvények"
|
||||
..method = "Írásbeli"
|
||||
..teacherName = "Szabó Gábor";
|
||||
homeTest.lesson.value = homeLessons[0];
|
||||
|
||||
final messages = [
|
||||
MessageCacheModel()
|
||||
..cacheKey = 401
|
||||
..createdAt = midnight.subtract(const Duration(days: 2))
|
||||
..author = "Pálfy Zoltán"
|
||||
..title = "2023 novemberi programok"
|
||||
..contentHtml = "",
|
||||
MessageCacheModel()
|
||||
..cacheKey = 402
|
||||
..createdAt = midnight.subtract(const Duration(days: 2))
|
||||
..author = ":3"
|
||||
..title = "Mrrp mrrp meow meow"
|
||||
..contentHtml = "",
|
||||
];
|
||||
|
||||
final grades = [
|
||||
_grade(501, matematika, 5, midnight.subtract(const Duration(days: 3))),
|
||||
_grade(502, matematika, 4, midnight.subtract(const Duration(days: 10))),
|
||||
_grade(503, angol, 5, midnight.subtract(const Duration(days: 4))),
|
||||
_grade(504, angol, 3, midnight.subtract(const Duration(days: 12))),
|
||||
_grade(505, tortenelem, 4, midnight.subtract(const Duration(days: 5))),
|
||||
_grade(506, nemet, 5, midnight.subtract(const Duration(days: 6))),
|
||||
_grade(507, informatika, 5, midnight.subtract(const Duration(days: 7))),
|
||||
_grade(508, fizika, 4, midnight.subtract(const Duration(days: 8))),
|
||||
_grade(509, matematika, 5, midnight.subtract(const Duration(days: 15))),
|
||||
];
|
||||
|
||||
final omissions = [
|
||||
_omission(
|
||||
601,
|
||||
homeLessons[1],
|
||||
OmissionState.excused,
|
||||
midnight.subtract(const Duration(days: 20)),
|
||||
),
|
||||
_omission(
|
||||
602,
|
||||
homeLessons[2],
|
||||
OmissionState.pending,
|
||||
midnight.subtract(const Duration(days: 14)),
|
||||
),
|
||||
_omission(
|
||||
603,
|
||||
timetableLessons[0],
|
||||
OmissionState.unexcused,
|
||||
midnight.subtract(const Duration(days: 9)),
|
||||
),
|
||||
_omission(
|
||||
604,
|
||||
timetableLessons[3],
|
||||
OmissionState.excused,
|
||||
midnight.subtract(const Duration(days: 3)),
|
||||
),
|
||||
];
|
||||
|
||||
// School-year style bar: mostly present days, sparse marks, a few clusters
|
||||
// for thicker ticks (matches the design "barcode" look).
|
||||
final omissionBarSegments = List<OmissionState?>.filled(132, null);
|
||||
const excusedClusters = <List<int>>[
|
||||
[2],
|
||||
[7, 8],
|
||||
[14],
|
||||
[19],
|
||||
[24, 25, 26],
|
||||
[33],
|
||||
[38],
|
||||
[44, 45],
|
||||
[52],
|
||||
[58],
|
||||
[64, 65],
|
||||
[71],
|
||||
[77],
|
||||
[83, 84, 85],
|
||||
[92],
|
||||
[104, 105],
|
||||
[112],
|
||||
[118],
|
||||
[124, 125],
|
||||
];
|
||||
for (final cluster in excusedClusters) {
|
||||
for (final i in cluster) {
|
||||
omissionBarSegments[i] = OmissionState.excused;
|
||||
}
|
||||
}
|
||||
// Pending (orange) ticks, including a short cluster.
|
||||
for (final i in [16, 48, 49, 88, 110]) {
|
||||
omissionBarSegments[i] = OmissionState.pending;
|
||||
}
|
||||
// Unexcused (red/pink) ticks.
|
||||
for (final i in [61, 96, 127]) {
|
||||
omissionBarSegments[i] = OmissionState.unexcused;
|
||||
}
|
||||
|
||||
final monthStart = DateTime(day.year, day.month, 1);
|
||||
final gridStart = monthStart
|
||||
.subtract(Duration(days: monthStart.weekday - 1))
|
||||
.subtract(const Duration(days: 7));
|
||||
final monthDayMeta = <DateTime, ThemePreviewMonthDay>{};
|
||||
for (var i = 0; i < 49; i++) {
|
||||
final d = DateTime(
|
||||
gridStart.year,
|
||||
gridStart.month,
|
||||
gridStart.day,
|
||||
).add(Duration(days: i));
|
||||
final key = DateTime(d.year, d.month, d.day);
|
||||
final inMonth = d.month == day.month;
|
||||
final weekday = d.weekday;
|
||||
final lessonCount = !inMonth
|
||||
? 0
|
||||
: weekday > 5
|
||||
? 0
|
||||
: 5 - ((d.day + weekday) % 3);
|
||||
OmissionState? omission;
|
||||
if (inMonth && weekday <= 5 && d.day % 9 == 0) {
|
||||
omission = OmissionState.pending;
|
||||
} else if (inMonth && weekday <= 5 && d.day % 13 == 0) {
|
||||
omission = OmissionState.unexcused;
|
||||
}
|
||||
monthDayMeta[key] = ThemePreviewMonthDay(
|
||||
lessonCount: lessonCount.clamp(0, 7),
|
||||
hasTest: inMonth && weekday <= 5 && d.day % 7 == 0,
|
||||
omission: omission,
|
||||
);
|
||||
}
|
||||
|
||||
final subjectDetailGrades = grades
|
||||
.where((g) => g.subject.value?.cacheKey == matematika.cacheKey)
|
||||
.toList();
|
||||
|
||||
return ThemePreviewData._(
|
||||
now: day,
|
||||
student: student,
|
||||
subjects: subjects,
|
||||
homeLessons: homeLessons,
|
||||
timetableLessons: timetableLessons,
|
||||
messages: messages,
|
||||
tests: [homeTest],
|
||||
grades: grades,
|
||||
omissions: omissions,
|
||||
omissionBarSegments: omissionBarSegments,
|
||||
omissionExcusedCount: 2,
|
||||
omissionPendingCount: 1,
|
||||
omissionUnexcusedCount: 1,
|
||||
monthDayMeta: monthDayMeta,
|
||||
subjectDetailSubject: matematika,
|
||||
subjectDetailGrades: subjectDetailGrades,
|
||||
subjectDetailTeacher: "Szabó Gábor (Osztály)",
|
||||
);
|
||||
}
|
||||
|
||||
static SubjectCacheModel _subject(int id, String name) {
|
||||
final subject = SubjectCacheModel()
|
||||
..cacheKey = id
|
||||
..createdAt = DateTime(2024, 9, 1)
|
||||
..name = name;
|
||||
subject.classAverage.value = null;
|
||||
return subject;
|
||||
}
|
||||
|
||||
static LessonCacheModel _lesson({
|
||||
required int id,
|
||||
required SubjectCacheModel subject,
|
||||
required int dailyNth,
|
||||
required DateTime start,
|
||||
required DateTime end,
|
||||
required String roomName,
|
||||
String? substituteTeacher,
|
||||
TestCacheModel? test,
|
||||
}) {
|
||||
final lesson = LessonCacheModel()
|
||||
..cacheKey = id
|
||||
..createdAt = start
|
||||
..start = start
|
||||
..end = end
|
||||
..dailyNth = dailyNth
|
||||
..yearlyNth = dailyNth
|
||||
..name = subject.name
|
||||
..roomName = roomName
|
||||
..state = "Naplozott"
|
||||
..type = "OrarendiOra"
|
||||
..teacher = "Tanár"
|
||||
..substituteTeacher = substituteTeacher;
|
||||
lesson.subject.value = subject;
|
||||
// Mark optional links loaded so loadAndGet() does not call loadSync on
|
||||
// unmanaged (non-Isar) preview objects.
|
||||
lesson.test.value = test;
|
||||
lesson.homework.value = null;
|
||||
lesson.classGroup.value = null;
|
||||
lesson.omission.value = null;
|
||||
if (test != null) {
|
||||
test.lesson.value = lesson;
|
||||
}
|
||||
return lesson;
|
||||
}
|
||||
|
||||
static GradeCacheModel _grade(
|
||||
int id,
|
||||
SubjectCacheModel subject,
|
||||
int value,
|
||||
DateTime at,
|
||||
) {
|
||||
final grade = GradeCacheModel()
|
||||
..cacheKey = id
|
||||
..createdAt = at
|
||||
..mode = "Írásbeli"
|
||||
..topic = subject.name
|
||||
..type = "Értékelés"
|
||||
..valueType = "Osztalyzat"
|
||||
..writtenAt = at
|
||||
..numericValue = value
|
||||
..weightPercentage = 100
|
||||
..textValue = value.toString()
|
||||
..teacherName = "Tanár";
|
||||
grade.subject.value = subject;
|
||||
grade.classGroup.value = null;
|
||||
return grade;
|
||||
}
|
||||
|
||||
static OmissionCacheModel _omission(
|
||||
int id,
|
||||
LessonCacheModel lesson,
|
||||
OmissionState state,
|
||||
DateTime at,
|
||||
) {
|
||||
final omission = OmissionCacheModel()
|
||||
..cacheKey = id
|
||||
..createdAt = at
|
||||
..state = state
|
||||
..teacherName = "Tanár";
|
||||
omission.lesson.value = lesson;
|
||||
return omission;
|
||||
}
|
||||
}
|
||||
|
||||
class ThemePreviewMonthDay {
|
||||
const ThemePreviewMonthDay({
|
||||
required this.lessonCount,
|
||||
required this.hasTest,
|
||||
this.omission,
|
||||
});
|
||||
|
||||
final int lessonCount;
|
||||
final bool hasTest;
|
||||
final OmissionState? omission;
|
||||
}
|
||||
1023
firka/lib/ui/phone/screens/themes/preview/theme_preview_pages.dart
Normal file
1023
firka/lib/ui/phone/screens/themes/preview/theme_preview_pages.dart
Normal file
File diff suppressed because it is too large
Load Diff
368
firka/lib/ui/phone/screens/themes/sheets/theme_sheets.dart
Normal file
368
firka/lib/ui/phone/screens/themes/sheets/theme_sheets.dart
Normal file
@@ -0,0 +1,368 @@
|
||||
import "package:flutter/material.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
import "package:majesticons_flutter/majesticons_flutter.dart";
|
||||
|
||||
import "package:firka/l10n/app_localizations.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";
|
||||
|
||||
Future<String?> showThemeNameSheet(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
) {
|
||||
return _showCenteredInputSheet(
|
||||
context: context,
|
||||
l10n: l10n,
|
||||
icon: Majesticon.plusLine,
|
||||
title: l10n.s_c_themes_create_title,
|
||||
subtitle: l10n.s_c_themes_create_subtitle,
|
||||
placeholder: l10n.s_c_themes_create_placeholder,
|
||||
confirmLabel: l10n.s_c_themes_continue,
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> showThemeDeleteSheet(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
) async {
|
||||
final result = await showModalBottomSheet<bool>(
|
||||
context: context,
|
||||
elevation: 100,
|
||||
isScrollControlled: true,
|
||||
enableDrag: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
barrierColor: appStyle.colors.a15p,
|
||||
builder: (context) {
|
||||
return _ThemeConfirmSheet(
|
||||
icon: Majesticon.deleteBinLine,
|
||||
title: l10n.s_c_themes_delete_title,
|
||||
subtitle: l10n.s_c_themes_delete_subtitle,
|
||||
confirmLabel: l10n.s_c_themes_delete_confirm,
|
||||
cancelLabel: l10n.cancel,
|
||||
confirmColor: appStyle.colors.accent,
|
||||
onConfirm: () => context.pop(true),
|
||||
onCancel: () => context.pop(false),
|
||||
);
|
||||
},
|
||||
);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
Future<String?> _showCenteredInputSheet({
|
||||
required BuildContext context,
|
||||
required AppLocalizations l10n,
|
||||
required Object icon,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required String placeholder,
|
||||
required String confirmLabel,
|
||||
}) {
|
||||
return showModalBottomSheet<String>(
|
||||
context: context,
|
||||
elevation: 100,
|
||||
isScrollControlled: true,
|
||||
enableDrag: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
barrierColor: appStyle.colors.a15p,
|
||||
builder: (context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.viewInsetsOf(context).bottom,
|
||||
),
|
||||
child: _ThemeNameInputSheet(
|
||||
icon: icon,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
placeholder: placeholder,
|
||||
confirmLabel: confirmLabel,
|
||||
cancelLabel: l10n.cancel,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class _ThemeNameInputSheet extends StatefulWidget {
|
||||
final Object icon;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String placeholder;
|
||||
final String confirmLabel;
|
||||
final String cancelLabel;
|
||||
|
||||
const _ThemeNameInputSheet({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.placeholder,
|
||||
required this.confirmLabel,
|
||||
required this.cancelLabel,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_ThemeNameInputSheet> createState() => _ThemeNameInputSheetState();
|
||||
}
|
||||
|
||||
class _ThemeNameInputSheetState extends State<_ThemeNameInputSheet> {
|
||||
late final TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = TextEditingController();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
final value = _controller.text.trim();
|
||||
if (value.isEmpty) return;
|
||||
context.pop(value);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _ThemeSheetShell(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_sheetIcon(widget.icon),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
widget.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
widget.subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.card,
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
),
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
autofocus: true,
|
||||
textAlign: TextAlign.center,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => _submit(),
|
||||
cursorColor: appStyle.colors.accent,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: widget.placeholder,
|
||||
hintStyle: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textTertiary,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_sheetButton(
|
||||
label: widget.confirmLabel,
|
||||
color: appStyle.colors.accent,
|
||||
onTap: _submit,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_sheetButton(
|
||||
label: widget.cancelLabel,
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
onTap: () => context.pop(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ThemeConfirmSheet extends StatelessWidget {
|
||||
final Object icon;
|
||||
final String title;
|
||||
final String subtitle;
|
||||
final String confirmLabel;
|
||||
final String cancelLabel;
|
||||
final Color confirmColor;
|
||||
final VoidCallback onConfirm;
|
||||
final VoidCallback onCancel;
|
||||
|
||||
const _ThemeConfirmSheet({
|
||||
required this.icon,
|
||||
required this.title,
|
||||
required this.subtitle,
|
||||
required this.confirmLabel,
|
||||
required this.cancelLabel,
|
||||
required this.confirmColor,
|
||||
required this.onConfirm,
|
||||
required this.onCancel,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _ThemeSheetShell(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_sheetIcon(icon),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_sheetButton(
|
||||
label: confirmLabel,
|
||||
color: confirmColor,
|
||||
onTap: onConfirm,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_sheetButton(
|
||||
label: cancelLabel,
|
||||
color: appStyle.colors.buttonSecondaryFill,
|
||||
onTap: onCancel,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ThemeSheetShell extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const _ThemeSheetShell({required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: GestureDetector(
|
||||
onTap: () => context.pop(),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const ColoredBox(color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.background,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(24),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Align(
|
||||
heightFactor: 0,
|
||||
alignment: Alignment.topCenter,
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(top: 18),
|
||||
width: 40,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.shadowColor,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
child,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _sheetIcon(Object icon) {
|
||||
return Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.accent.withValues(alpha: 0.25),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
decoration: BoxDecoration(
|
||||
color: appStyle.colors.accent,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Center(
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
icon,
|
||||
size: 20,
|
||||
color: appStyle.colors.textPrimaryLight,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _sheetButton({
|
||||
required String label,
|
||||
required Color color,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: FirkaCard(
|
||||
color: color,
|
||||
left: const [],
|
||||
center: [
|
||||
Text(
|
||||
label,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
207
firka/lib/ui/phone/screens/themes/theme_screen.dart
Normal file
207
firka/lib/ui/phone/screens/themes/theme_screen.dart
Normal file
@@ -0,0 +1,207 @@
|
||||
import "package:carousel_slider/carousel_slider.dart";
|
||||
import "package:flutter/material.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
import "package:majesticons_flutter/majesticons_flutter.dart";
|
||||
|
||||
import "package:firka/app/app_state.dart";
|
||||
import "package:firka/ui/components/firka_icon_button.dart";
|
||||
import "package:firka/ui/phone/screens/themes/preview/theme_preview_data.dart";
|
||||
import "package:firka/ui/phone/screens/themes/preview/theme_preview_pages.dart";
|
||||
import "package:firka/ui/phone/screens/themes/sheets/theme_sheets.dart";
|
||||
import "package:firka/ui/phone/screens/themes/user_theme.dart";
|
||||
import "package:firka/ui/phone/screens/themes/widgets/theme_name_label.dart";
|
||||
import "package:firka/ui/phone/screens/themes/widgets/theme_swatch_icon.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";
|
||||
|
||||
class ThemeScreen extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
final ThemeScreenArgs args;
|
||||
|
||||
const ThemeScreen(this.data, this.args, {super.key});
|
||||
|
||||
@override
|
||||
State<ThemeScreen> createState() => _ThemeScreenState();
|
||||
}
|
||||
|
||||
class _ThemeScreenState extends State<ThemeScreen> {
|
||||
late final ThemePreviewData _preview;
|
||||
|
||||
UserTheme get _theme => widget.args.theme;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_preview = ThemePreviewData.build();
|
||||
}
|
||||
|
||||
String get _originLabel {
|
||||
final l10n = widget.data.l10n;
|
||||
switch (_theme.origin) {
|
||||
case ThemeOrigin.builtin:
|
||||
return l10n.s_c_themes_builtin_label;
|
||||
case ThemeOrigin.own:
|
||||
return l10n.s_c_themes_own_label;
|
||||
case ThemeOrigin.downloaded:
|
||||
return l10n.s_c_themes_imported_label;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _delete() async {
|
||||
final confirmed = await showThemeDeleteSheet(context, widget.data.l10n);
|
||||
if (!confirmed || !mounted) return;
|
||||
await widget.args.onDelete(_theme.id);
|
||||
if (!mounted) return;
|
||||
context.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = widget.data.l10n;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: appStyle.colors.background,
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 0),
|
||||
child: GestureDetector(
|
||||
onTap: () => context.pop(),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
l10n.s_c_theme_header,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ThemeSwatchIcon(swatch: _theme.swatch, size: 48),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ThemeNameLabel(
|
||||
name: _theme.name,
|
||||
editable: _theme.canRename,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() => _theme.name = value);
|
||||
widget.args.onChanged();
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
_originLabel,
|
||||
style: appStyle.fonts.B_14R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
if (_theme.isOwn) ...[
|
||||
FirkaIconButton(
|
||||
onTap: () {},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.editPen4Line,
|
||||
size: 18,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.shareLine,
|
||||
size: 18,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
if (_theme.canDelete)
|
||||
FirkaIconButton(
|
||||
onTap: _delete,
|
||||
color: appStyle.colors.accent,
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.deleteBinLine,
|
||||
size: 18,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
Expanded(
|
||||
child: CarouselSlider(
|
||||
options: CarouselOptions(
|
||||
height: double.infinity,
|
||||
viewportFraction: 0.72,
|
||||
enableInfiniteScroll: false,
|
||||
enlargeCenterPage: false,
|
||||
padEnds: false,
|
||||
),
|
||||
items: buildThemePreviewCarouselItems(
|
||||
data: widget.data,
|
||||
preview: _preview,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await widget.args.onUse(_theme.id);
|
||||
if (!context.mounted) return;
|
||||
context.pop();
|
||||
},
|
||||
child: FirkaCard(
|
||||
color: appStyle.colors.accent,
|
||||
left: const [],
|
||||
center: [
|
||||
Text(
|
||||
l10n.s_c_themes_use,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
372
firka/lib/ui/phone/screens/themes/themes_screen.dart
Normal file
372
firka/lib/ui/phone/screens/themes/themes_screen.dart
Normal file
@@ -0,0 +1,372 @@
|
||||
import "package:flutter/material.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
import "package:isar_community/isar.dart";
|
||||
import "package:majesticons_flutter/majesticons_flutter.dart";
|
||||
|
||||
import "package:firka/app/app_state.dart";
|
||||
import "package:firka/core/settings/settings_repository.dart";
|
||||
import "package:firka/core/settings/settings_schema.dart";
|
||||
import "package:firka/core/snowflake.dart";
|
||||
import "package:firka/ui/components/firka_icon_button.dart";
|
||||
import "package:firka/ui/phone/screens/themes/builtin_theme_id.dart";
|
||||
import "package:firka/ui/phone/screens/themes/sheets/theme_sheets.dart";
|
||||
import "package:firka/ui/phone/screens/themes/user_theme.dart";
|
||||
import "package:firka/ui/phone/screens/themes/widgets/theme_name_label.dart";
|
||||
import "package:firka/ui/phone/screens/themes/widgets/theme_swatch_icon.dart";
|
||||
import "package:firka/ui/shared/firka_icon.dart";
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
import "package:firka_common/data/database.dart";
|
||||
import "package:firka_common/data/models/user_theme_model.dart";
|
||||
import "package:firka_common/ui/components/firka_card.dart";
|
||||
|
||||
class ThemesScreen extends StatefulWidget {
|
||||
final AppInitialization data;
|
||||
|
||||
const ThemesScreen(this.data, {super.key});
|
||||
|
||||
@override
|
||||
State<ThemesScreen> createState() => _ThemesScreenState();
|
||||
}
|
||||
|
||||
class _ThemesScreenState extends State<ThemesScreen> {
|
||||
late List<UserTheme> _storedThemes;
|
||||
late String _selectedId;
|
||||
bool _loading = true;
|
||||
|
||||
UserTheme get _builtin => UserTheme.builtin(
|
||||
widget.data.l10n.s_c_themes_builtin_name,
|
||||
coreId: Settings.selectedCoreThemeId.value,
|
||||
gradeId: Settings.selectedGradeThemeId.value,
|
||||
isLight: appStyle.isLight,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_storedThemes = [];
|
||||
_selectedId = normalizeSelectedThemeId(Settings.selectedThemeId.value);
|
||||
_loadThemes();
|
||||
}
|
||||
|
||||
Future<void> _loadThemes() async {
|
||||
final stored = await isarInit.userThemeModels.where().findAll();
|
||||
if (!mounted) return;
|
||||
|
||||
final normalized = normalizeSelectedThemeId(Settings.selectedThemeId.value);
|
||||
if (normalized != Settings.selectedThemeId.value) {
|
||||
await Settings.selectedThemeId.set(normalized);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_storedThemes = stored.map(UserTheme.fromModel).toList();
|
||||
_selectedId = normalized;
|
||||
final knownIds = {
|
||||
_builtin.id,
|
||||
..._storedThemes.map((t) => t.id),
|
||||
};
|
||||
if (isBuiltinThemeId(_selectedId)) {
|
||||
// Always use the composed builtin id for the current core/grade.
|
||||
_selectedId = _builtin.id;
|
||||
} else if (!knownIds.contains(_selectedId)) {
|
||||
_selectedId = _builtin.id;
|
||||
}
|
||||
_loading = false;
|
||||
});
|
||||
|
||||
if (isBuiltinThemeId(_selectedId) &&
|
||||
Settings.selectedThemeId.value != _builtin.id) {
|
||||
await Settings.selectedThemeId.set(_builtin.id);
|
||||
}
|
||||
}
|
||||
|
||||
UserTheme get _selected {
|
||||
if (isBuiltinThemeId(_selectedId)) {
|
||||
return _builtin;
|
||||
}
|
||||
return _storedThemes.firstWhere(
|
||||
(t) => t.id == _selectedId,
|
||||
orElse: () => _builtin,
|
||||
);
|
||||
}
|
||||
|
||||
List<UserTheme> get _ownThemes =>
|
||||
_storedThemes.where((t) => t.isOwn).toList(growable: false);
|
||||
|
||||
List<UserTheme> get _downloadedThemes =>
|
||||
_storedThemes.where((t) => t.isDownloaded).toList(growable: false);
|
||||
|
||||
Future<void> _persistTheme(UserTheme theme) async {
|
||||
if (theme.isBuiltin) return;
|
||||
await isarInit.writeTxn(() async {
|
||||
await isarInit.userThemeModels.putByThemeId(theme.toModel());
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _deleteTheme(String id) async {
|
||||
await isarInit.writeTxn(() async {
|
||||
await isarInit.userThemeModels.deleteByThemeId(id);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _setSelected(String id) async {
|
||||
final next = isBuiltinThemeId(id) ? _builtin.id : id;
|
||||
if (isBuiltinThemeId(next)) {
|
||||
final (coreId, gradeId) = parseBuiltinThemeId(next);
|
||||
await Settings.selectedCoreThemeId.set(coreId);
|
||||
await Settings.selectedGradeThemeId.set(gradeId);
|
||||
}
|
||||
setState(() => _selectedId = next);
|
||||
await Settings.selectedThemeId.set(next);
|
||||
}
|
||||
|
||||
Future<void> _selectBuiltin() async {
|
||||
final id = composeBuiltinThemeId(
|
||||
Settings.selectedCoreThemeId.value,
|
||||
Settings.selectedGradeThemeId.value,
|
||||
);
|
||||
await _setSelected(id);
|
||||
}
|
||||
|
||||
Future<void> _createTheme() async {
|
||||
final name = await showThemeNameSheet(context, widget.data.l10n);
|
||||
if (name == null || !mounted) return;
|
||||
|
||||
final theme = UserTheme(
|
||||
id: Snowflake.nextId(),
|
||||
name: name,
|
||||
origin: ThemeOrigin.own,
|
||||
swatch: UserTheme.swatchFromAppStyle(),
|
||||
);
|
||||
await _persistTheme(theme);
|
||||
if (!mounted) return;
|
||||
setState(() => _storedThemes.add(theme));
|
||||
await _openTheme(theme);
|
||||
}
|
||||
|
||||
Future<void> _renameTheme(UserTheme theme, String name) async {
|
||||
setState(() => theme.name = name);
|
||||
await _persistTheme(theme);
|
||||
}
|
||||
|
||||
Future<void> _openTheme(UserTheme theme) async {
|
||||
final openTheme = theme.isBuiltin ? _builtin : theme;
|
||||
await context.push(
|
||||
"/theme",
|
||||
extra: ThemeScreenArgs(
|
||||
theme: openTheme,
|
||||
onUse: (id) => _setSelected(id),
|
||||
onDelete: (id) async {
|
||||
await _deleteTheme(id);
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_storedThemes.removeWhere((t) => t.id == id);
|
||||
if (_selectedId == id) {
|
||||
_selectedId = _builtin.id;
|
||||
}
|
||||
});
|
||||
if (isBuiltinThemeId(_selectedId)) {
|
||||
await _selectBuiltin();
|
||||
}
|
||||
},
|
||||
onChanged: () {
|
||||
_persistTheme(theme);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
);
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
Widget _sectionLabel(String text) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(left: 4, bottom: 8, top: 16),
|
||||
child: Text(
|
||||
text,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _checkMark() {
|
||||
return SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: Checkbox(
|
||||
value: true,
|
||||
fillColor: WidgetStateProperty.resolveWith<Color>((_) {
|
||||
return appStyle.colors.secondary;
|
||||
}),
|
||||
onChanged: (_) {},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _themeRow(UserTheme theme, {required bool selected}) {
|
||||
return GestureDetector(
|
||||
onTap: () => _openTheme(theme),
|
||||
child: FirkaCard(
|
||||
left: [
|
||||
ThemeSwatchIcon(swatch: theme.swatch, size: 36),
|
||||
const SizedBox(width: 10),
|
||||
ThemeNameLabel(
|
||||
name: theme.name,
|
||||
editable: theme.canRename,
|
||||
onChanged: (value) => _renameTheme(theme, value),
|
||||
),
|
||||
],
|
||||
right: selected
|
||||
? [_checkMark(), const SizedBox(width: 4)]
|
||||
: const [SizedBox(width: 20)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _actionRow({
|
||||
required Object icon,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: FirkaCard(
|
||||
left: [
|
||||
FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
icon,
|
||||
size: 20,
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
label,
|
||||
style: appStyle.fonts.B_16SB.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = widget.data.l10n;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: appStyle.colors.background,
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 0),
|
||||
child: GestureDetector(
|
||||
onTap: () => context.pop(),
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.chevronLeftLine,
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Transform.translate(
|
||||
offset: const Offset(-4, 1),
|
||||
child: Text(
|
||||
l10n.s_c_my_themes,
|
||||
style: appStyle.fonts.H_H2.apply(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
FirkaIconButton(
|
||||
onTap: _createTheme,
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.plusLine,
|
||||
size: 20,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.shareLine,
|
||||
size: 20,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
FirkaIconButton(
|
||||
onTap: () {},
|
||||
child: FirkaIconWidget(
|
||||
FirkaIconType.majesticons,
|
||||
Majesticon.arrowDownCircleLine,
|
||||
size: 20,
|
||||
color: appStyle.colors.accent,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: _loading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
children: [
|
||||
_sectionLabel(l10n.s_c_themes_current),
|
||||
_themeRow(_selected, selected: true),
|
||||
if (!_selected.isBuiltin)
|
||||
_actionRow(
|
||||
icon: Majesticon.shareLine,
|
||||
label: l10n.s_c_themes_share_current,
|
||||
onTap: () {},
|
||||
),
|
||||
_sectionLabel(l10n.s_c_themes_own),
|
||||
for (final theme in _ownThemes)
|
||||
_themeRow(
|
||||
theme,
|
||||
selected: theme.id == _selectedId,
|
||||
),
|
||||
_actionRow(
|
||||
icon: Majesticon.plusLine,
|
||||
label: l10n.s_c_themes_create_new,
|
||||
onTap: _createTheme,
|
||||
),
|
||||
_sectionLabel(l10n.s_c_themes_downloaded),
|
||||
for (final theme in _downloadedThemes)
|
||||
_themeRow(
|
||||
theme,
|
||||
selected: theme.id == _selectedId,
|
||||
),
|
||||
_actionRow(
|
||||
icon: Majesticon.arrowDownCircleLine,
|
||||
label: l10n.s_c_themes_import,
|
||||
onTap: () {},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
97
firka/lib/ui/phone/screens/themes/user_theme.dart
Normal file
97
firka/lib/ui/phone/screens/themes/user_theme.dart
Normal file
@@ -0,0 +1,97 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:firka_common/data/models/user_theme_model.dart";
|
||||
import "package:firka_common/ui/theme/core_theme.dart";
|
||||
import "package:firka_common/ui/theme/grade_theme.dart";
|
||||
|
||||
import "package:firka/ui/phone/screens/themes/builtin_theme_id.dart";
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
|
||||
enum ThemeOrigin { builtin, own, downloaded }
|
||||
|
||||
class UserTheme {
|
||||
final String id;
|
||||
String name;
|
||||
final ThemeOrigin origin;
|
||||
final List<Color> swatch;
|
||||
|
||||
UserTheme({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.origin,
|
||||
required this.swatch,
|
||||
});
|
||||
|
||||
bool get isBuiltin =>
|
||||
origin == ThemeOrigin.builtin || isBuiltinThemeId(id);
|
||||
bool get isOwn => origin == ThemeOrigin.own && !isBuiltinThemeId(id);
|
||||
bool get isDownloaded => origin == ThemeOrigin.downloaded;
|
||||
bool get canRename => isOwn;
|
||||
bool get canDelete => !isBuiltin;
|
||||
|
||||
static List<Color> swatchFromCore(CoreTheme core, {bool isLight = true}) {
|
||||
final colors = core.forBrightness(isLight);
|
||||
return [colors.accent, colors.textPrimary, colors.background];
|
||||
}
|
||||
|
||||
static List<Color> swatchFromAppStyle() {
|
||||
return [
|
||||
appStyle.colors.accent,
|
||||
appStyle.colors.textPrimary,
|
||||
appStyle.colors.background,
|
||||
];
|
||||
}
|
||||
|
||||
static UserTheme builtin(
|
||||
String displayName, {
|
||||
String coreId = defaultCoreThemeId,
|
||||
String gradeId = defaultGradeThemeId,
|
||||
bool isLight = true,
|
||||
}) {
|
||||
final core = resolveCore(coreId);
|
||||
final grade = resolveGrade(gradeId);
|
||||
return UserTheme(
|
||||
id: composeBuiltinThemeId(core.id, grade.id),
|
||||
name: displayName,
|
||||
origin: ThemeOrigin.builtin,
|
||||
swatch: swatchFromCore(core, isLight: isLight),
|
||||
);
|
||||
}
|
||||
|
||||
factory UserTheme.fromModel(UserThemeModel model) {
|
||||
return UserTheme(
|
||||
id: model.themeId,
|
||||
name: model.name,
|
||||
origin: switch (model.origin) {
|
||||
"downloaded" => ThemeOrigin.downloaded,
|
||||
_ => ThemeOrigin.own,
|
||||
},
|
||||
swatch: model.swatchArgb.map(Color.new).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
UserThemeModel toModel() {
|
||||
return UserThemeModel()
|
||||
..themeId = id
|
||||
..name = name
|
||||
..origin = switch (origin) {
|
||||
ThemeOrigin.downloaded => "downloaded",
|
||||
ThemeOrigin.own || ThemeOrigin.builtin => "own",
|
||||
}
|
||||
..swatchArgb = swatch.map((c) => c.toARGB32()).toList();
|
||||
}
|
||||
}
|
||||
|
||||
class ThemeScreenArgs {
|
||||
final UserTheme theme;
|
||||
final Future<void> Function(String id) onUse;
|
||||
final Future<void> Function(String id) onDelete;
|
||||
final VoidCallback onChanged;
|
||||
|
||||
const ThemeScreenArgs({
|
||||
required this.theme,
|
||||
required this.onUse,
|
||||
required this.onDelete,
|
||||
required this.onChanged,
|
||||
});
|
||||
}
|
||||
123
firka/lib/ui/phone/screens/themes/widgets/theme_name_label.dart
Normal file
123
firka/lib/ui/phone/screens/themes/widgets/theme_name_label.dart
Normal file
@@ -0,0 +1,123 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:firka/ui/theme/style.dart";
|
||||
|
||||
/// Plain-looking theme name that becomes an undecorated text field when tapped
|
||||
/// (own themes only).
|
||||
class ThemeNameLabel extends StatefulWidget {
|
||||
final String name;
|
||||
final bool editable;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final TextStyle? style;
|
||||
|
||||
const ThemeNameLabel({
|
||||
required this.name,
|
||||
required this.editable,
|
||||
this.onChanged,
|
||||
this.style,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ThemeNameLabel> createState() => _ThemeNameLabelState();
|
||||
}
|
||||
|
||||
class _ThemeNameLabelState extends State<ThemeNameLabel> {
|
||||
late final TextEditingController _controller;
|
||||
late final FocusNode _focusNode;
|
||||
bool _editing = false;
|
||||
late String _committed;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_committed = widget.name;
|
||||
_controller = TextEditingController(text: widget.name);
|
||||
_focusNode = FocusNode();
|
||||
_focusNode.addListener(_onFocusChange);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant ThemeNameLabel oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (!_editing && widget.name != _committed) {
|
||||
_committed = widget.name;
|
||||
_controller.text = widget.name;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.removeListener(_onFocusChange);
|
||||
_focusNode.dispose();
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
TextStyle get _style =>
|
||||
widget.style ??
|
||||
appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary);
|
||||
|
||||
void _onFocusChange() {
|
||||
if (!_focusNode.hasFocus && _editing) {
|
||||
_commit();
|
||||
}
|
||||
}
|
||||
|
||||
void _startEditing() {
|
||||
if (!widget.editable) return;
|
||||
setState(() {
|
||||
_editing = true;
|
||||
_controller.text = _committed;
|
||||
_controller.selection = TextSelection(
|
||||
baseOffset: 0,
|
||||
extentOffset: _controller.text.length,
|
||||
);
|
||||
});
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_focusNode.requestFocus();
|
||||
});
|
||||
}
|
||||
|
||||
void _commit() {
|
||||
final next = _controller.text.trim();
|
||||
final value = next.isEmpty ? _committed : next;
|
||||
_controller.text = value;
|
||||
if (value != _committed) {
|
||||
_committed = value;
|
||||
widget.onChanged?.call(value);
|
||||
}
|
||||
setState(() => _editing = false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (!widget.editable) {
|
||||
return Text(widget.name, style: _style);
|
||||
}
|
||||
|
||||
if (!_editing) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: _startEditing,
|
||||
child: Text(_committed, style: _style),
|
||||
);
|
||||
}
|
||||
|
||||
return TextField(
|
||||
controller: _controller,
|
||||
focusNode: _focusNode,
|
||||
style: _style,
|
||||
cursorColor: appStyle.colors.accent,
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => _commit(),
|
||||
decoration: const InputDecoration(
|
||||
isDense: true,
|
||||
border: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.zero,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
class ThemeSwatchIcon extends StatelessWidget {
|
||||
final List<Color> swatch;
|
||||
final double size;
|
||||
|
||||
const ThemeSwatchIcon({
|
||||
required this.swatch,
|
||||
this.size = 40,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = swatch.length >= 3
|
||||
? swatch.take(3).toList()
|
||||
: [
|
||||
...swatch,
|
||||
...List.filled(3 - swatch.length, Colors.grey),
|
||||
];
|
||||
|
||||
return SizedBox(
|
||||
width: size,
|
||||
height: size,
|
||||
child: CustomPaint(
|
||||
painter: _SwatchPainter(colors: colors),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SwatchPainter extends CustomPainter {
|
||||
final List<Color> colors;
|
||||
|
||||
_SwatchPainter({required this.colors});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final r = size.shortestSide * 0.29;
|
||||
final cx = size.width / 2;
|
||||
final cy = size.height / 2;
|
||||
final d = r * 1.5;
|
||||
final left = Offset(cx - d / 2, cy - d * 0.29);
|
||||
final right = Offset(cx + d / 2, cy - d * 0.29);
|
||||
final bottom = Offset(cx, cy + d * 0.58);
|
||||
final centers = [left, right, bottom];
|
||||
|
||||
// Soft per-circle halo.
|
||||
for (var i = 0; i < 3; i++) {
|
||||
canvas.drawCircle(
|
||||
centers[i],
|
||||
r,
|
||||
Paint()
|
||||
..color = colors[i].withValues(alpha: 0.4)
|
||||
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 2.5),
|
||||
);
|
||||
}
|
||||
|
||||
// Union blend: no white backdrop (that was leaking). First SrcOver, then
|
||||
// Multiply so overlaps mix; bottom on top with opacity to lighten.
|
||||
final bounds = Offset.zero & size;
|
||||
canvas.saveLayer(bounds, Paint());
|
||||
canvas.drawCircle(left, r, Paint()..color = colors[0]);
|
||||
canvas.drawCircle(
|
||||
right,
|
||||
r,
|
||||
Paint()
|
||||
..color = colors[1]
|
||||
..blendMode = BlendMode.multiply,
|
||||
);
|
||||
canvas.restore();
|
||||
|
||||
canvas.drawCircle(
|
||||
bottom,
|
||||
r,
|
||||
Paint()..color = colors[2].withValues(alpha: 0.75),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant _SwatchPainter oldDelegate) {
|
||||
return oldDelegate.colors != colors;
|
||||
}
|
||||
}
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class _WelcomeWidgetState extends State<WelcomeWidget> {
|
||||
getIconForCycle(dayCycle),
|
||||
const SizedBox(height: 16.0),
|
||||
Text(
|
||||
getTitle(dayCycle),
|
||||
headingText(getTitle(dayCycle)),
|
||||
style: appStyle.fonts.H_H2.copyWith(
|
||||
color: appStyle.colors.textPrimary,
|
||||
),
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,97 +1,113 @@
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.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/firka_card.dart';
|
||||
import 'package:firka_common/data/models/omission_cache_model.dart';
|
||||
import 'package:firka_common/data/util.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
|
||||
class OmissionBar extends StatelessWidget {
|
||||
const OmissionBar({super.key});
|
||||
|
||||
static Color stateToColor(OmissionCacheModel? o) {
|
||||
if (o == null) {
|
||||
return appStyle.colors.a15p;
|
||||
}
|
||||
switch (o.state) {
|
||||
case OmissionState.excused:
|
||||
return appStyle.colors.accent;
|
||||
case OmissionState.unexcused:
|
||||
return appStyle.colors.errorAccent;
|
||||
default:
|
||||
return appStyle.colors.warningAccent;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime now = timeNow();
|
||||
DateTime startOfTheYear = now.getFirstSchoolDay();
|
||||
|
||||
final dates = initData.client!.cache
|
||||
.getTimeTable()
|
||||
.between(startOfTheYear, now)
|
||||
.findAllSync()
|
||||
.map((l) => l.start.getMidnight())
|
||||
.toSet();
|
||||
|
||||
final omittedDates = initData.client!.cache
|
||||
.getOmissions()
|
||||
.findAllSync()
|
||||
.groupList((o) => o.lesson.loadAndGet()!.start);
|
||||
|
||||
final bar = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Row(
|
||||
children: dates
|
||||
.map(
|
||||
(i) => Expanded(
|
||||
child: Container(
|
||||
height: 12,
|
||||
color: stateToColor(omittedDates[i]?.firstOrNull),
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
|
||||
return FirkaCard.single(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
bar,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat.MMMM(
|
||||
initData.l10n.localeName,
|
||||
).format(startOfTheYear).firstUpper(),
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
initData.l10n.now,
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:firka/app/app_state.dart';
|
||||
import 'package:firka/core/extensions.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/firka_card.dart';
|
||||
import 'package:firka_common/data/models/omission_cache_model.dart';
|
||||
import 'package:firka_common/data/util.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
import 'package:kreta_api/kreta_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:firka/ui/theme/style.dart';
|
||||
|
||||
class OmissionBar extends StatelessWidget {
|
||||
/// When set, draws these segments instead of reading the Isar cache.
|
||||
final List<OmissionState?>? previewSegments;
|
||||
|
||||
const OmissionBar({super.key, this.previewSegments});
|
||||
|
||||
static Color stateToColor(OmissionCacheModel? o) {
|
||||
return stateColor(o?.state);
|
||||
}
|
||||
|
||||
static Color stateColor(OmissionState? state) {
|
||||
if (state == null) {
|
||||
return appStyle.colors.a15p;
|
||||
}
|
||||
switch (state) {
|
||||
case OmissionState.excused:
|
||||
return appStyle.colors.accent;
|
||||
case OmissionState.unexcused:
|
||||
return appStyle.colors.errorAccent;
|
||||
default:
|
||||
return appStyle.colors.warningAccent;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
DateTime now = timeNow();
|
||||
DateTime startOfTheYear = now.getFirstSchoolDay();
|
||||
|
||||
late final List<Color> segmentColors;
|
||||
if (previewSegments != null) {
|
||||
segmentColors = previewSegments!.map(stateColor).toList();
|
||||
} else {
|
||||
final dates = initData.client!.cache
|
||||
.getTimeTable()
|
||||
.between(startOfTheYear, now)
|
||||
.findAllSync()
|
||||
.map((l) => l.start.getMidnight())
|
||||
.toSet();
|
||||
|
||||
final omittedDates = initData.client!.cache
|
||||
.getOmissions()
|
||||
.findAllSync()
|
||||
.groupList((o) => o.lesson.loadAndGet()!.start);
|
||||
|
||||
segmentColors = dates
|
||||
.map((i) => stateToColor(omittedDates[i]?.firstOrNull))
|
||||
.toList();
|
||||
}
|
||||
|
||||
final bar = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Row(
|
||||
children: segmentColors
|
||||
.map(
|
||||
(color) => Expanded(
|
||||
child: Container(
|
||||
height: 12,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
|
||||
return FirkaCard.single(
|
||||
margin: EdgeInsets.zero,
|
||||
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
bar,
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
DateFormat.MMMM(
|
||||
initData.l10n.localeName,
|
||||
).format(startOfTheYear).firstUpper(),
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
initData.l10n.now,
|
||||
style: appStyle.fonts.B_14R.copyWith(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
0
firka/lib/ui/phone/widgets/teacher_label.dart
Normal file
0
firka/lib/ui/phone/widgets/teacher_label.dart
Normal file
@@ -14,8 +14,14 @@ import 'lesson.dart';
|
||||
class TimeTableDayWidget extends StatelessWidget {
|
||||
final List<LessonCacheModel> lessons;
|
||||
final List<LessonCacheModel> events;
|
||||
final Future<void> Function()? onRefresh;
|
||||
|
||||
const TimeTableDayWidget(this.lessons, this.events, {super.key});
|
||||
const TimeTableDayWidget(
|
||||
this.lessons,
|
||||
this.events, {
|
||||
this.onRefresh,
|
||||
super.key,
|
||||
});
|
||||
|
||||
static String simplifyEventName(String e) {
|
||||
return e
|
||||
@@ -58,40 +64,52 @@ class TimeTableDayWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (lessons.isEmpty) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/logos/dave.svg",
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
initData.l10n.tt_no_classes_l1,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
initData.l10n.tt_no_classes_l2,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
if (events.isNotEmpty)
|
||||
...events.map(
|
||||
(event) => Center(
|
||||
child: Text(
|
||||
simplifyEventName(event.name),
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
return RefreshIndicator(
|
||||
onRefresh: onRefresh ?? () async {},
|
||||
child: ListView(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.only(top: 70 + 16 + 20, left: 20, right: 20),
|
||||
children: [
|
||||
SizedBox(
|
||||
height: MediaQuery.sizeOf(context).height * 0.45,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SvgPicture.asset(
|
||||
"assets/images/logos/dave.svg",
|
||||
width: 48,
|
||||
height: 48,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
Text(
|
||||
initData.l10n.tt_no_classes_l1,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
initData.l10n.tt_no_classes_l2,
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
if (events.isNotEmpty)
|
||||
...events.map(
|
||||
(event) => Center(
|
||||
child: Text(
|
||||
simplifyEventName(event.name),
|
||||
style: appStyle.fonts.B_16R.apply(
|
||||
color: appStyle.colors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,15 +182,19 @@ class TimeTableDayWidget extends StatelessWidget {
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 70 + 16 + 20, left: 20, right: 20),
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (context, index) => SizedBox(height: 16),
|
||||
itemBuilder: (context, index) {
|
||||
if (ttLessons.length == index) {
|
||||
return SizedBox(height: 55);
|
||||
}
|
||||
return ttLessons[index];
|
||||
},
|
||||
itemCount: ttLessons.length + 1,
|
||||
child: RefreshIndicator(
|
||||
onRefresh: onRefresh ?? () async {},
|
||||
child: ListView.separated(
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
separatorBuilder: (context, index) => SizedBox(height: 16),
|
||||
itemBuilder: (context, index) {
|
||||
if (ttLessons.length == index) {
|
||||
return SizedBox(height: 55);
|
||||
}
|
||||
return ttLessons[index];
|
||||
},
|
||||
itemCount: ttLessons.length + 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -110,6 +111,27 @@ flutter:
|
||||
fonts:
|
||||
- asset: assets/fonts/RobotoMono-VariableFont_wght.ttf
|
||||
style: normal
|
||||
- family: Monoton
|
||||
fonts:
|
||||
- asset: assets/fonts/Monoton-Regular.ttf
|
||||
style: normal
|
||||
- family: Pirata One
|
||||
fonts:
|
||||
- asset: assets/fonts/PirataOne-Regular.ttf
|
||||
style: normal
|
||||
- family: Just Me Again Down Here
|
||||
fonts:
|
||||
- asset: assets/fonts/JustMeAgainDownHere.ttf
|
||||
style: normal
|
||||
- family: Fira Code
|
||||
fonts:
|
||||
- asset: assets/fonts/FiraCode-VariableFont_wght.ttf
|
||||
style: normal
|
||||
- family: Vollkorn
|
||||
fonts:
|
||||
- asset: assets/fonts/Vollkorn-VariableFont_wght.ttf
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ enum ClassIcon {
|
||||
technika,
|
||||
dance,
|
||||
philosophy,
|
||||
erettsegi,
|
||||
ofo,
|
||||
diligence,
|
||||
attitude,
|
||||
@@ -65,6 +66,7 @@ Map<ClassIcon, RegExp> _descriptors = {
|
||||
ClassIcon.technika: RegExp(r'technika'),
|
||||
ClassIcon.dance: RegExp(r'tanc'),
|
||||
ClassIcon.philosophy: RegExp(r'filozofia'),
|
||||
ClassIcon.erettsegi: RegExp(r'erettsegi'),
|
||||
ClassIcon.ofo: RegExp(r'osztaly(fonoki|kozosseg)|kozossegi|neveles'),
|
||||
ClassIcon.diligence: RegExp(r'szorgalom'),
|
||||
ClassIcon.attitude: RegExp(r'magatartas'),
|
||||
@@ -84,15 +86,33 @@ Map<ClassIcon, Uint8List> _iconMap = {
|
||||
ClassIcon.history: Majesticon.compass2Solid,
|
||||
ClassIcon.geography: Majesticon.globeEarth2Solid,
|
||||
ClassIcon.art: Majesticon.editPen2Solid,
|
||||
ClassIcon.physics: Majesticon.atom2Solid,
|
||||
ClassIcon.music: Majesticon.musicNoteSolid,
|
||||
ClassIcon.pe: Majesticon.pulseSolid,
|
||||
ClassIcon.chemistry: Majesticon.testTubeFilledSolid,
|
||||
ClassIcon.biology: Majesticon.covidSolid,
|
||||
ClassIcon.env: Majesticon.leaf3AngledSolid,
|
||||
ClassIcon.religion: Majesticon.churchSolid,
|
||||
ClassIcon.economics: Majesticon.coinsSolid,
|
||||
ClassIcon.it: Majesticon.laptopSolid,
|
||||
ClassIcon.code: Majesticon.curlyBracesSolid,
|
||||
ClassIcon.networking: Majesticon.cloudSolid,
|
||||
ClassIcon.theatre: Majesticon.presentationPlaySolid,
|
||||
ClassIcon.film: Majesticon.videoSolid,
|
||||
ClassIcon.electricalEngineering: Majesticon.lightningBoltSolid,
|
||||
ClassIcon.mechanicalEngineering: Majesticon.settingsCogSolid,
|
||||
ClassIcon.technika: Majesticon.ruler2Solid,
|
||||
ClassIcon.dance: Majesticon.pinwheelSolid,
|
||||
ClassIcon.philosophy: Majesticon.lightbulbShineSolid,
|
||||
ClassIcon.erettsegi: Majesticon.awardSolid,
|
||||
ClassIcon.ofo: Majesticon.usersSolid,
|
||||
ClassIcon.diligence: Majesticon.clipboardCheckSolid,
|
||||
ClassIcon.attitude: Majesticon.userSolid,
|
||||
ClassIcon.language: Majesticon.tooltipsSolid,
|
||||
ClassIcon.linux: Majesticon.robotSolid,
|
||||
ClassIcon.database: Majesticon.dataSolid,
|
||||
ClassIcon.applications: Majesticon.monitorSolid,
|
||||
ClassIcon.project: Majesticon.presentationSolid,
|
||||
};
|
||||
|
||||
ClassIcon? getIconType(SubjectCacheModel subject) {
|
||||
|
||||
@@ -27,10 +27,16 @@ class CacheManager {
|
||||
CacheManager(this.token);
|
||||
|
||||
StudentCacheModel findStudent() {
|
||||
return findStudentOrNull()!;
|
||||
}
|
||||
|
||||
/// Same as [findStudent], but returns null instead of throwing when the
|
||||
/// student hasn't been synced yet (e.g. before the first successful sync).
|
||||
StudentCacheModel? findStudentOrNull() {
|
||||
return isarInit.studentCacheModels
|
||||
.filter()
|
||||
.group(isCurrentStudent)
|
||||
.findFirstSync()!;
|
||||
.findFirstSync();
|
||||
}
|
||||
|
||||
int genCacheKey(Identifiable identifiable) {
|
||||
@@ -101,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) =>
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:firka_common/data/models/subject_cache_model.dart';
|
||||
import 'package:firka_common/data/models/teacher_model.dart';
|
||||
import 'package:firka_common/data/models/test_cache_model.dart';
|
||||
import 'package:firka_common/data/models/token_model.dart';
|
||||
import 'package:firka_common/data/models/user_theme_model.dart';
|
||||
import 'package:isar_community/isar.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
@@ -34,6 +35,7 @@ Future<Isar> initDB() async {
|
||||
AppSettingsModelSchema,
|
||||
SubjectCacheModelSchema,
|
||||
StudentCacheModelSchema,
|
||||
UserThemeModelSchema,
|
||||
],
|
||||
inspector: true,
|
||||
directory: dir.path,
|
||||
|
||||
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";
|
||||
}
|
||||
20
firka_common/lib/data/models/user_theme_model.dart
Normal file
20
firka_common/lib/data/models/user_theme_model.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import "package:isar_community/isar.dart";
|
||||
|
||||
part "user_theme_model.g.dart";
|
||||
|
||||
@collection
|
||||
class UserThemeModel {
|
||||
Id id = Isar.autoIncrement;
|
||||
|
||||
@Index(unique: true, replace: true)
|
||||
late String themeId;
|
||||
|
||||
late String name;
|
||||
|
||||
/// `own` or `downloaded`. Built-in is not persisted.
|
||||
late String origin;
|
||||
|
||||
late List<int> swatchArgb;
|
||||
|
||||
UserThemeModel();
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
67
firka_common/lib/ui/theme/core/firka.dart
Normal file
67
firka_common/lib/ui/theme/core/firka.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
part of "../core_theme.dart";
|
||||
|
||||
const firkaCore = CoreTheme(
|
||||
id: "firka",
|
||||
light: CoreThemeColors(
|
||||
background: Color(0xFFFAFFF0),
|
||||
backgroundAmoled: Colors.black,
|
||||
background0p: Color(0x00fafff0),
|
||||
success: Color(0xFF92EA3B),
|
||||
shadowBlur: 2,
|
||||
textPrimary: Color(0xFF394C0A),
|
||||
textSecondary: Color(0xCC394C0A),
|
||||
textTertiary: Color(0x80394C0A),
|
||||
textTeritary: Color(0xFF97A474),
|
||||
textPrimaryLight: Color(0xFF394C0A),
|
||||
textSecondaryLight: Color(0xCC394C0A),
|
||||
textTertiaryLight: Color(0x80394C0A),
|
||||
card: Color(0xFFF3FBDE),
|
||||
cardTranslucent: Color(0x80F3FBDE),
|
||||
buttonSecondaryFill: Color(0xFFFEFFFD),
|
||||
buttonDisabledIcon: Color(0xFFCDD9B3),
|
||||
accent: Color(0xFFA7DC22),
|
||||
secondary: Color(0xFF6E8F1B),
|
||||
shadowColor: Color(0x33647e22),
|
||||
a10p: Color(0x1aa7dc22),
|
||||
a15p: Color(0x26a7dc22),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFF8F531B),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFFFAEBDC),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFF8F1B4F),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFFFADCE9),
|
||||
),
|
||||
dark: CoreThemeColors(
|
||||
background: Color(0xFF0D1202),
|
||||
backgroundAmoled: Colors.black,
|
||||
background0p: Color(0x00fafff0),
|
||||
success: Color(0xFF92EA3B),
|
||||
shadowBlur: 0,
|
||||
textPrimary: Color(0xFFEAF7CC),
|
||||
textSecondary: Color(0xB3EAF7CC),
|
||||
textTertiary: Color(0x80EAF7CC),
|
||||
textTeritary: Color(0xFF97A474),
|
||||
textPrimaryLight: Color(0xFF394C0A),
|
||||
textSecondaryLight: Color(0xCC394C0A),
|
||||
textTertiaryLight: Color(0x80394C0A),
|
||||
card: Color(0xFF141905),
|
||||
cardTranslucent: Color(0x80141905),
|
||||
buttonSecondaryFill: Color(0xFF20290B),
|
||||
buttonDisabledIcon: Color(0xFF465422),
|
||||
accent: Color(0xFFA7DC22),
|
||||
secondary: Color(0xFFCBEE71),
|
||||
shadowColor: Color(0x26CBEE71),
|
||||
a10p: Color(0x1AA7DC22),
|
||||
a15p: Color(0x26A7DC22),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFFF0B37A),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFF201203),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFFF59EC5),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFF1E030F),
|
||||
),
|
||||
);
|
||||
95
firka_common/lib/ui/theme/core_theme.dart
Normal file
95
firka_common/lib/ui/theme/core_theme.dart
Normal file
@@ -0,0 +1,95 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
part "core/firka.dart";
|
||||
|
||||
const Map<String, CoreTheme> coreThemes = {
|
||||
"firka": firkaCore,
|
||||
};
|
||||
|
||||
/// App chrome colors (everything except grade colors)
|
||||
class CoreThemeColors {
|
||||
final Color background;
|
||||
final Color backgroundAmoled;
|
||||
final Color background0p;
|
||||
final Color success;
|
||||
final int shadowBlur;
|
||||
|
||||
final Color textPrimary;
|
||||
final Color textSecondary;
|
||||
final Color textTertiary;
|
||||
final Color? textTeritary;
|
||||
|
||||
final Color textPrimaryLight;
|
||||
final Color textSecondaryLight;
|
||||
final Color textTertiaryLight;
|
||||
|
||||
final Color card;
|
||||
final Color cardTranslucent;
|
||||
|
||||
final Color buttonSecondaryFill;
|
||||
final Color buttonDisabledIcon;
|
||||
|
||||
final Color accent;
|
||||
final Color secondary;
|
||||
final Color shadowColor;
|
||||
final Color a10p;
|
||||
final Color a15p;
|
||||
|
||||
final Color warningAccent;
|
||||
final Color warningText;
|
||||
final Color warning15p;
|
||||
final Color warningCard;
|
||||
|
||||
final Color errorAccent;
|
||||
final Color errorText;
|
||||
final Color error15p;
|
||||
final Color errorCard;
|
||||
|
||||
const CoreThemeColors({
|
||||
required this.background,
|
||||
required this.backgroundAmoled,
|
||||
required this.background0p,
|
||||
required this.success,
|
||||
required this.shadowBlur,
|
||||
required this.textPrimary,
|
||||
required this.textSecondary,
|
||||
required this.textTertiary,
|
||||
this.textTeritary,
|
||||
required this.textPrimaryLight,
|
||||
required this.textSecondaryLight,
|
||||
required this.textTertiaryLight,
|
||||
required this.card,
|
||||
required this.cardTranslucent,
|
||||
required this.buttonSecondaryFill,
|
||||
required this.buttonDisabledIcon,
|
||||
required this.accent,
|
||||
required this.secondary,
|
||||
required this.shadowColor,
|
||||
required this.a10p,
|
||||
required this.a15p,
|
||||
required this.warningAccent,
|
||||
required this.warningText,
|
||||
required this.warning15p,
|
||||
required this.warningCard,
|
||||
required this.errorAccent,
|
||||
required this.errorText,
|
||||
required this.error15p,
|
||||
required this.errorCard,
|
||||
});
|
||||
}
|
||||
|
||||
class CoreTheme {
|
||||
final String id;
|
||||
final CoreThemeColors light;
|
||||
final CoreThemeColors dark;
|
||||
|
||||
const CoreTheme({
|
||||
required this.id,
|
||||
required this.light,
|
||||
required this.dark,
|
||||
});
|
||||
|
||||
CoreThemeColors forBrightness(bool isLight) => isLight ? light : dark;
|
||||
}
|
||||
|
||||
CoreTheme resolveCore(String id) => coreThemes[id] ?? firkaCore;
|
||||
15
firka_common/lib/ui/theme/grade/firka.dart
Normal file
15
firka_common/lib/ui/theme/grade/firka.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
part of "../grade_theme.dart";
|
||||
|
||||
const _firkaGradeColors = GradeThemeColors(
|
||||
grade5: Color(0xFF22CCAD),
|
||||
grade4: Color(0xFF92EA3B),
|
||||
grade3: Color(0xFFF9CF00),
|
||||
grade2: Color(0xFFFFA046),
|
||||
grade1: Color(0xFFFF54A1),
|
||||
);
|
||||
|
||||
const firkaGrade = GradeTheme(
|
||||
id: "firka",
|
||||
light: _firkaGradeColors,
|
||||
dark: _firkaGradeColors,
|
||||
);
|
||||
39
firka_common/lib/ui/theme/grade_theme.dart
Normal file
39
firka_common/lib/ui/theme/grade_theme.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
part "grade/firka.dart";
|
||||
|
||||
class GradeThemeColors {
|
||||
final Color grade5;
|
||||
final Color grade4;
|
||||
final Color grade3;
|
||||
final Color grade2;
|
||||
final Color grade1;
|
||||
|
||||
const GradeThemeColors({
|
||||
required this.grade5,
|
||||
required this.grade4,
|
||||
required this.grade3,
|
||||
required this.grade2,
|
||||
required this.grade1,
|
||||
});
|
||||
}
|
||||
|
||||
class GradeTheme {
|
||||
final String id;
|
||||
final GradeThemeColors light;
|
||||
final GradeThemeColors dark;
|
||||
|
||||
const GradeTheme({
|
||||
required this.id,
|
||||
required this.light,
|
||||
required this.dark,
|
||||
});
|
||||
|
||||
GradeThemeColors forBrightness(bool isLight) => isLight ? light : dark;
|
||||
}
|
||||
|
||||
const Map<String, GradeTheme> gradeThemes = {
|
||||
"firka": firkaGrade,
|
||||
};
|
||||
|
||||
GradeTheme resolveGrade(String id) => gradeThemes[id] ?? firkaGrade;
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:firka_common/ui/theme/core_theme.dart';
|
||||
import 'package:firka_common/ui/theme/grade_theme.dart';
|
||||
|
||||
// Design system token names; ignore non_constant_identifier_names for consistency with design specs
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
@@ -140,176 +142,195 @@ class FirkaStyle {
|
||||
});
|
||||
}
|
||||
|
||||
final _defaultFonts = FirkaFonts(
|
||||
H_H1: TextStyle(
|
||||
fontSize: 30,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
H_18px: TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
H_H2: TextStyle(
|
||||
fontSize: 20,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
H_16px: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
),
|
||||
H_14px: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
),
|
||||
H_12px: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
),
|
||||
H_16px_trimmed: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Montserrat',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_16R: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 500)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_16SB: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_14R: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 500)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_14SB: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_15SB: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_12R: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_12SB: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'Figtree',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
height: 1.3,
|
||||
),
|
||||
P_14: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: 'RobotoMono',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
P_12: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: 'RobotoMono',
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
);
|
||||
enum HeadingTextCase { lower, normal, upper }
|
||||
|
||||
final FirkaStyle lightStyle = FirkaStyle(
|
||||
HeadingTextCase appHeadingTextCase = HeadingTextCase.normal;
|
||||
|
||||
String headingText(String text) {
|
||||
switch (appHeadingTextCase) {
|
||||
case HeadingTextCase.lower:
|
||||
return text.toLowerCase();
|
||||
case HeadingTextCase.upper:
|
||||
return text.toUpperCase();
|
||||
case HeadingTextCase.normal:
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
FirkaFonts buildAppFonts({
|
||||
String headingFamily = "Montserrat",
|
||||
double headingWeight = 700,
|
||||
bool supportsWeight = true,
|
||||
}) {
|
||||
List<FontVariation>? headingVariations(double weight) {
|
||||
if (!supportsWeight) return null;
|
||||
return [FontVariation("wght", weight)];
|
||||
}
|
||||
|
||||
final boldWeight = supportsWeight ? headingWeight : 700.0;
|
||||
final semiWeight = supportsWeight
|
||||
? (headingWeight * 600 / 700).clamp(100.0, 900.0).toDouble()
|
||||
: 600.0;
|
||||
|
||||
return FirkaFonts(
|
||||
H_H1: TextStyle(
|
||||
fontSize: 30,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(boldWeight),
|
||||
),
|
||||
H_18px: TextStyle(
|
||||
fontSize: 18,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(boldWeight),
|
||||
),
|
||||
H_H2: TextStyle(
|
||||
fontSize: 20,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(boldWeight),
|
||||
),
|
||||
H_16px: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(semiWeight),
|
||||
),
|
||||
H_14px: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(semiWeight),
|
||||
),
|
||||
H_12px: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(semiWeight),
|
||||
),
|
||||
H_16px_trimmed: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: headingFamily,
|
||||
fontVariations: headingVariations(semiWeight),
|
||||
height: 1.3,
|
||||
),
|
||||
B_16R: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 500)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_16SB: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_14R: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 500)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_14SB: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_15SB: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_12R: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 600)],
|
||||
height: 1.3,
|
||||
),
|
||||
B_12SB: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: "Figtree",
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
height: 1.3,
|
||||
),
|
||||
P_14: TextStyle(
|
||||
fontSize: 14,
|
||||
fontFamily: "RobotoMono",
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
P_12: TextStyle(
|
||||
fontSize: 12,
|
||||
fontFamily: "RobotoMono",
|
||||
fontVariations: [FontVariation("wght", 700)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final _defaultFonts = buildAppFonts();
|
||||
|
||||
FirkaColors mergeColors(CoreThemeColors core, GradeThemeColors grades) {
|
||||
return FirkaColors(
|
||||
background: core.background,
|
||||
backgroundAmoled: core.backgroundAmoled,
|
||||
background0p: core.background0p,
|
||||
success: core.success,
|
||||
shadowBlur: core.shadowBlur,
|
||||
textPrimary: core.textPrimary,
|
||||
textSecondary: core.textSecondary,
|
||||
textTertiary: core.textTertiary,
|
||||
textTeritary: core.textTeritary,
|
||||
textPrimaryLight: core.textPrimaryLight,
|
||||
textSecondaryLight: core.textSecondaryLight,
|
||||
textTertiaryLight: core.textTertiaryLight,
|
||||
card: core.card,
|
||||
cardTranslucent: core.cardTranslucent,
|
||||
buttonSecondaryFill: core.buttonSecondaryFill,
|
||||
buttonDisabledIcon: core.buttonDisabledIcon,
|
||||
accent: core.accent,
|
||||
secondary: core.secondary,
|
||||
shadowColor: core.shadowColor,
|
||||
a10p: core.a10p,
|
||||
a15p: core.a15p,
|
||||
warningAccent: core.warningAccent,
|
||||
warningText: core.warningText,
|
||||
warning15p: core.warning15p,
|
||||
warningCard: core.warningCard,
|
||||
errorAccent: core.errorAccent,
|
||||
errorText: core.errorText,
|
||||
error15p: core.error15p,
|
||||
errorCard: core.errorCard,
|
||||
grade5: grades.grade5,
|
||||
grade4: grades.grade4,
|
||||
grade3: grades.grade3,
|
||||
grade2: grades.grade2,
|
||||
grade1: grades.grade1,
|
||||
);
|
||||
}
|
||||
|
||||
FirkaStyle styleFor({
|
||||
required String coreId,
|
||||
required String gradeId,
|
||||
required bool isLight,
|
||||
required FirkaFonts fonts,
|
||||
}) {
|
||||
final core = resolveCore(coreId).forBrightness(isLight);
|
||||
final grades = resolveGrade(gradeId).forBrightness(isLight);
|
||||
return FirkaStyle(
|
||||
isLight: isLight,
|
||||
colors: mergeColors(core, grades),
|
||||
fonts: fonts,
|
||||
);
|
||||
}
|
||||
|
||||
FirkaStyle get lightStyle => styleFor(
|
||||
coreId: "firka",
|
||||
gradeId: "firka",
|
||||
isLight: true,
|
||||
colors: FirkaColors(
|
||||
background: Color(0xFFFAFFF0),
|
||||
backgroundAmoled: Colors.black,
|
||||
background0p: Color(0x00fafff0),
|
||||
success: Color(0xFF92EA3B),
|
||||
shadowBlur: 2,
|
||||
textPrimary: Color(0xFF394C0A),
|
||||
textSecondary: Color(0xCC394C0A),
|
||||
textTertiary: Color(0x80394C0A),
|
||||
textTeritary: Color(0xFF97A474),
|
||||
textPrimaryLight: Color(0xFF394C0A),
|
||||
textSecondaryLight: Color(0xCC394C0A),
|
||||
textTertiaryLight: Color(0x80394C0A),
|
||||
card: Color(0xFFF3FBDE),
|
||||
cardTranslucent: Color(0x80F3FBDE),
|
||||
buttonSecondaryFill: Color(0xFFFEFFFD),
|
||||
buttonDisabledIcon: Color(0xFFCDD9B3),
|
||||
accent: Color(0xFFA7DC22),
|
||||
secondary: Color(0xFF6E8F1B),
|
||||
shadowColor: Color(0x33647e22),
|
||||
a10p: Color(0x1aa7dc22),
|
||||
a15p: Color(0x26a7dc22),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFF8F531B),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFFFAEBDC),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFF8F1B4F),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFFFADCE9),
|
||||
grade5: Color(0xFF22CCAD),
|
||||
grade4: Color(0xFF92EA3B),
|
||||
grade3: Color(0xFFF9CF00),
|
||||
grade2: Color(0xFFFFA046),
|
||||
grade1: Color(0xFFFF54A1),
|
||||
),
|
||||
fonts: _defaultFonts,
|
||||
);
|
||||
|
||||
final FirkaStyle darkStyle = FirkaStyle(
|
||||
FirkaStyle get darkStyle => styleFor(
|
||||
coreId: "firka",
|
||||
gradeId: "firka",
|
||||
isLight: false,
|
||||
colors: FirkaColors(
|
||||
background: Color(0xFF0D1202),
|
||||
backgroundAmoled: Colors.black,
|
||||
background0p: Color(0x00fafff0),
|
||||
success: Color(0xFF92EA3B),
|
||||
shadowBlur: 0,
|
||||
textPrimary: Color(0xFFEAF7CC),
|
||||
textSecondary: Color(0xB3EAF7CC),
|
||||
textTertiary: Color(0x80EAF7CC),
|
||||
textTeritary: Color(0xFF97A474),
|
||||
textPrimaryLight: Color(0xFF394C0A),
|
||||
textSecondaryLight: Color(0xCC394C0A),
|
||||
textTertiaryLight: Color(0x80394C0A),
|
||||
card: Color(0xFF141905),
|
||||
cardTranslucent: Color(0x80141905),
|
||||
buttonSecondaryFill: Color(0xFF20290B),
|
||||
buttonDisabledIcon: Color(0xFF465422),
|
||||
accent: Color(0xFFA7DC22),
|
||||
secondary: Color(0xFFCBEE71),
|
||||
shadowColor: Color(0x26CBEE71),
|
||||
a10p: Color(0x1AA7DC22),
|
||||
a15p: Color(0x26A7DC22),
|
||||
warningAccent: Color(0xFFFFA046),
|
||||
warningText: Color(0xFFF0B37A),
|
||||
warning15p: Color(0x26FFA046),
|
||||
warningCard: Color(0xFF201203),
|
||||
errorAccent: Color(0xFFFF54A1),
|
||||
errorText: Color(0xFFF59EC5),
|
||||
error15p: Color(0x26FF54A1),
|
||||
errorCard: Color(0xFF1E030F),
|
||||
grade5: Color(0xFF22CCAD),
|
||||
grade4: Color(0xFF92EA3B),
|
||||
grade3: Color(0xFFF9CF00),
|
||||
grade2: Color(0xFFFFA046),
|
||||
grade1: Color(0xFFFF54A1),
|
||||
),
|
||||
fonts: _defaultFonts,
|
||||
);
|
||||
|
||||
|
||||
Submodule firka_wear/lib/l10n updated: 2dd94691b7...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