1
0
forked from firka/firka

3 Commits

Author SHA1 Message Date
zypherift
c5a3dc0b5e fix: icon changer, theme preview, KRÉTA retry, Isar mutex, checkmarks, layout fixes 2026-11-29 22:35:26 +01:00
zypherift
9b87e2c3e4 fix: 401 token retry, reauth UX, consistent headers, feedback screen, login spinner
- Add 401 retry with race-condition protection in kreta_client
- Fix ThemeSync null cast crash on missing code field
- Consistent H_H2 header style across all screens
- Reauth: clear toast on tap, proper bottom sheet sizing
- Login WebView: show loading spinner during token exchange
- Feedback screen: combined back button with H_H2 title
- Notification service, settings, widget, and l10n updates
- Theme screen: prevent visual flash on theme selection
2026-11-29 16:27:58 +01:00
zypherift
25f303e1e9 feat(themes): keep themes per account and keep shared ones live
A theme now follows the account rather than the install: it is pulled
on login and when the theme list opens, and every edit is pushed back,
so signing in elsewhere brings the theme along.

Sharing no longer hands over a dead snapshot. The link carries the
whole theme so it still imports with no network, plus a share id the
copy refetches by, which is how an edit by the owner reaches everyone
who scanned the code. Imported themes catch up on app open.

The editor's per-slot settings lookup moved to theme_palette, where
the share format already needed the same mapping.
2026-11-29 01:10:12 +01:00
344 changed files with 10971 additions and 7627 deletions

41
CHANGELOG.md Normal file
View File

@@ -0,0 +1,41 @@
# Changelog
## Unreleased
### Fixed
- Grades, timetable and the rest of the data failed to load when KRÉTA had
invalidated the access token server side. Requests now retry once after
refreshing, and a refresh that lands while another request is in flight no
longer overwrites the fresh token with an expired one.
- Startup could fail with `IsarError: An async write transaction is already in
progress` and show an error toast. Every Isar write now goes through one
queue, so the cache writes (which have to stay synchronous to save their
links) can no longer collide with the theme or settings writes.
- Themes synced from the server with no code no longer crash on a null cast.
- Opening a theme no longer applies it. The preview renders from the theme's
own colours without touching the app's, so backing out leaves the current
theme alone.
- The whole theme preview follows the previewed theme: cards, charts, grade
colours, lesson rows, the quick view card and the nav bar, rather than a
mix of the previewed and the active theme.
- The app icon picker works again. It never did on a debug build, and the
alias names it used were wrong on any build whose application id has a
suffix.
- Changing the app icon no longer closes the app, and the launcher is no
longer briefly left without an entry.
- Notification taps could open nothing after changing the app icon, because
the pending intent still pointed at the retired launcher alias.
- The app icon list scrolls on its own and keeps the buttons above the
bottom safe area, instead of the page scrolling and cutting off the end.
- Hot restarting on the theme screen threw a type error instead of falling
back to the theme list.
- The reauth prompt stayed on top of the login page, the sheet was the wrong
height, and nothing indicated progress while the token was exchanged.
### Changed
- Screen titles next to the back button use one style throughout.
- The selected theme, app theme and title font are marked with the check
used in the design rather than a Material checkbox.
- Removed the duplicate Creative Cloud entry from the app icon list.

View File

@@ -54,11 +54,23 @@
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
</activity>
<!-- The launcher entry lives on an alias, never on MainActivity
itself: switching icons disables the outgoing entry, and
disabling the component that hosts the running task kills it. -->
<activity-alias
android:name=".Default"
android:targetActivity=".MainActivity"
android:exported="true"
android:enabled="true"
android:icon="@mipmap/launcher_icon" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</activity-alias>
<activity-alias
android:name=".ace"

View File

@@ -20,7 +20,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlin.system.exitProcess
class MainActivity : FlutterActivity() {
@@ -163,62 +162,81 @@ class MainActivity : FlutterActivity() {
"${Build.VERSION.RELEASE};" +
"${Build.VERSION.SDK_INT}")
}
// ".Default" ships enabled so a fresh install always has a
// launcher entry, which means an update lands with it on even
// for someone already using a custom icon — two icons. Called
// on startup to put that right.
"reconcile_icon" -> {
try {
val pn = context.packageName
val ns = MainActivity::class.java.name.substringBeforeLast('.')
val custom = call.argument<String?>("icon")
val def = ComponentName(pn, "$ns.Default")
val want = if (custom == null) {
PackageManager.COMPONENT_ENABLED_STATE_ENABLED
} else {
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
}
if (packageManager.getComponentEnabledSetting(def) != want) {
Log.d("firka", "Reconciling $ns.Default -> $want")
packageManager.setComponentEnabledSetting(
def, want, PackageManager.DONT_KILL_APP
)
}
result.success(true)
} catch (e: Exception) {
e.printStackTrace()
result.success(false)
}
}
"set_icon" -> {
try {
val pn = context.packageName
if (pn.endsWith(".debug")) {
result.success(true)
return@setMethodCallHandler
}
// The aliases are declared relative to the manifest
// namespace, not the applicationId, so on a build with
// an id suffix (.debug) the two differ and the class
// names have to come from the namespace.
val ns = MainActivity::class.java.name.substringBeforeLast('.')
val icon = call.argument<String?>("icon")
val icons = call.argument<String>("icons")!!.split(",")
if (icon != null) {
for (ic in icons) {
if (ic != icon) {
Log.d("firka", "Disabling activity: $pn.$ic")
packageManager.setComponentEnabledSetting(
ComponentName(pn, "$pn.$ic"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
}
// ".Default" is the launcher entry used when no custom
// icon is picked. MainActivity is never touched: it
// hosts the running task, and disabling that kills it.
val target = icon ?: "Default"
// Enable the new entry before retiring the old ones, so
// the package is never left with no launcher component.
Log.d("firka", "Enabling activity: $ns.$target")
packageManager.setComponentEnabledSetting(
ComponentName(pn, "$ns.$target"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
)
for (ic in icons + "Default") {
if (ic == target) continue
// The custom aliases ship as enabled="false", so
// DEFAULT turns them off without an explicit
// disable, which is what tends to take the task
// down with it. ".Default" ships enabled, so that
// one has to be disabled outright or the launcher
// ends up showing two icons.
val state = if (ic == "Default") {
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
} else {
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
}
Log.d("firka", "Enabling acitvity: $pn.$icon")
Log.d("firka", "Retiring activity: $ns.$ic")
packageManager.setComponentEnabledSetting(
ComponentName(pn, "$pn.$icon"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
)
Log.d("firka" ,"Disabling activity: $pn.MainActivity")
packageManager.setComponentEnabledSetting(
ComponentName(pn, "$pn.MainActivity"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
} else {
for (ic in icons) {
Log.d("firka", "Disabling activity: $pn.$ic")
packageManager.setComponentEnabledSetting(
ComponentName(pn, "$pn.$ic"),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
}
Log.d("firka", "Enabling acitvity: $pn.MainActivity")
packageManager.setComponentEnabledSetting(
ComponentName(pn, "$pn.MainActivity"),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
ComponentName(pn, "$ns.$ic"),
state,
PackageManager.DONT_KILL_APP
)
}
forceIconUpdate()
exitProcess(-1)
} catch (e: Exception) {
e.printStackTrace()
}

View File

@@ -209,7 +209,15 @@ class ProgressNotificationForegroundService : Service() {
val pendingIntent = PendingIntent.getActivity(
this,
0,
packageManager.getLaunchIntentForPackage(packageName),
// MainActivity directly, not getLaunchIntentForPackage: that
// resolves to whichever alias is enabled now, and the icon picker
// retires that alias later, leaving a tap that opens nothing.
Intent(this, MainActivity::class.java).apply {
action = Intent.ACTION_MAIN
addCategory(Intent.CATEGORY_LAUNCHER)
flags = Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TOP
},
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)

View File

@@ -124,7 +124,15 @@ class WearSyncForegroundService : Service(), MessageClient.OnMessageReceivedList
val pendingIntent = PendingIntent.getActivity(
this,
0,
packageManager.getLaunchIntentForPackage(packageName),
// MainActivity directly, not getLaunchIntentForPackage: that
// resolves to whichever alias is enabled now, and the icon picker
// retires that alias later, leaving a tap that opens nothing.
Intent(this, MainActivity::class.java).apply {
action = Intent.ACTION_MAIN
addCategory(Intent.CATEGORY_LAUNCHER)
flags = Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_CLEAR_TOP
},
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
return NotificationCompat.Builder(this, channelId)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,6 +1,6 @@
icons:
"flutter_launcher_icons.yaml": "993c1cd3a99db70747299601e556d19ec959b0a16fd9ff2dbf2386cb6f2a640d"
"pubspec.yaml": "97e478fd72968c34de0c0ad4421daa9b2e2531d60bb28a893d7d3b5a9a90116c"
"pubspec.yaml": "5f054e5c3d601a26cc9fade986f20c68ef5a8ac85d2bc983a5b456b60c50d072"
"assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983"
"assets/images/logos/monochrome_logo.png": "c269a5e689622484d800a4fda5927591a0bf99d34790a4f146b93cf6edabd455"
"assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3"

View File

@@ -24,6 +24,7 @@ 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/isar_writes.dart';
import 'package:firka_common/data/util.dart';
import '../token_grant.dart';
@@ -213,7 +214,10 @@ class KretaClient {
// whenComplete() would return an unawaited derived future, so an
// error here would get reported as unhandled even though real
// callers already catch it via the returned `future`.
future.then((_) => _initInFlight = null, onError: (_) => _initInFlight = null);
future.then(
(_) => _initInFlight = null,
onError: (_) => _initInFlight = null,
);
return future;
}
@@ -260,7 +264,7 @@ class KretaClient {
// manual link
await getOmissions();
cache.resolveTeachers();
await isarWrite(() => cache.resolveTeachers());
_toastCubit.setActiveToast(.none);
} catch (e) {
if (!isTokenExpired(e)) {
@@ -295,7 +299,7 @@ class KretaClient {
]);
// manual link
await getOmissions();
cache.resolveTeachers();
await isarWrite(() => cache.resolveTeachers());
});
}
@@ -336,9 +340,9 @@ class KretaClient {
try {
var tokenModel = await _refreshModelWithCrossDeviceLease(cache.token);
await isarInit.writeTxn(() async {
await isarInit.tokenModels.put(tokenModel);
});
await isarWrite(
() => isarInit.writeTxn(() => isarInit.tokenModels.put(tokenModel)),
);
cache.token = tokenModel;
logger.info("[Recovery] Step 1 SUCCESS: Local refresh succeeded");
@@ -390,18 +394,22 @@ class KretaClient {
}).whenComplete(() => _tokenMutexCompleter = null);
}
Future<Response> _authReq(String method, String url, [Object? data]) async {
Future<Response> _authReq(
String method,
String url, [
Object? data,
bool isRetry = false,
]) async {
var localToken = (await _lockAndRecoverToken()).accessToken;
final headers = <String, String>{
// "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"accept": "*/*",
"user-agent": initData.userAgent,
"authorization": "Bearer $localToken",
"apiKey": "21ff6c25-d1da-4a68-a811-c881a6057463",
};
return await dio.get(
final resp = await dio.get(
MockBackend.rewrite(url),
options: Options(
method: method,
@@ -410,6 +418,16 @@ class KretaClient {
),
data: data,
);
if (resp.statusCode == 401 && !isRetry) {
logger.info("[AuthRetry] 401 on $url, forcing token refresh...");
if (cache.token.accessToken == localToken) {
cache.token.expiryDate = DateTime.now();
}
return _authReq(method, url, data, true);
}
return resp;
}
Future<(dynamic, int)> _authJson(
@@ -468,44 +486,49 @@ class KretaClient {
var (resp, statusCode) = await _authJson("GET", url);
var data = resp;
final caches = <C>[];
if (data is Map<String, dynamic>) {
data = [data];
}
if (data is List) {
for (final e in data) {
if (e is Map<String, dynamic>) {
late I dto;
try {
dto = makeDto(e);
} catch (ex) {
logger.shout(
"failed to make dto for $C",
ex,
ex is Error ? ex.stackTrace : null,
);
continue;
}
// apply() creates missing subject rows in a sync transaction, so the
// whole loop queues as one unit — it has no await points of its own.
final caches = await isarWrite(() {
final caches = <C>[];
if (data is List) {
for (final e in data) {
if (e is Map<String, dynamic>) {
late I dto;
try {
dto = makeDto(e);
} catch (ex) {
logger.shout(
"failed to make dto for $C",
ex,
ex is Error ? ex.stackTrace : null,
);
continue;
}
try {
caches.add(
makeCache()
..createdAt = DateTime.now()
..cacheKey = cache.genCacheKey(dto)
..apply(CacheContext(cache, dto)),
);
} catch (ex) {
logger.shout(
"failed to make cache $C: ${ex.toString()}",
ex,
ex is Error ? ex.stackTrace : null,
);
logger.shout("object: $e");
continue;
try {
caches.add(
makeCache()
..createdAt = DateTime.now()
..cacheKey = cache.genCacheKey(dto)
..apply(CacheContext(cache, dto)),
);
} catch (ex) {
logger.shout(
"failed to make cache $C: ${ex.toString()}",
ex,
ex is Error ? ex.stackTrace : null,
);
logger.shout("object: $e");
continue;
}
}
}
}
}
return caches;
});
return caches;
} catch (ex) {
@@ -544,17 +567,21 @@ class KretaClient {
List<C> caches,
QueryBuilder<C, C, QAfterFilterCondition>? staleScope,
) async {
isarInit.writeTxnSync(() {
if (staleScope != null) {
final freshKeys = caches.map((c) => c.cacheKey).toSet();
final staleIds = staleScope
.findAllSync()
.map((c) => c.cacheKey)
.where((key) => !freshKeys.contains(key))
.toList();
isarInit.collection<C>().deleteAllSync(staleIds);
}
isarInit.collection<C>().putAllSync(caches);
// Must stay sync: the async putAll has no saveLinks parameter, so it
// writes the rows without their IsarLinks and the cache reads back empty.
await isarWrite(() {
isarInit.writeTxnSync(() {
if (staleScope != null) {
final freshKeys = caches.map((c) => c.cacheKey).toSet();
final staleIds = staleScope
.findAllSync()
.map((c) => c.cacheKey)
.where((key) => !freshKeys.contains(key))
.toList();
isarInit.collection<C>().deleteAllSync(staleIds);
}
isarInit.collection<C>().putAllSync(caches);
});
});
initData.homeRefreshCubit.requestRefresh();
return caches;
@@ -582,10 +609,14 @@ class KretaClient {
}
final existing = cache.findStudentOrNull();
if (existing != null) {
logger.warning("getStudent returned empty, falling back to cached student");
logger.warning(
"getStudent returned empty, falling back to cached student",
);
return existing;
}
throw StateError("No student data returned from Kreta and no cached student found");
throw StateError(
"No student data returned from Kreta and no cached student found",
);
}
Future<List<ClassGroupCacheModel>> getClassGroups() async {
@@ -602,7 +633,9 @@ class KretaClient {
.group(cache.isCurrentClassGroup)
.findAllSync();
if (existing.isNotEmpty) {
logger.warning("getClassGroups returned empty, falling back to cached class groups");
logger.warning(
"getClassGroups returned empty, falling back to cached class groups",
);
return existing;
}
return list;
@@ -660,18 +693,20 @@ class KretaClient {
) async {
late int existingCount;
late int deletedCount;
isarInit.writeTxnSync(() {
// NOT between(from, to): it's inclusive of `to`'s whole day, but
// `to` here is exclusive (matches what was actually fetched) — the
// inclusive version deleted a day beyond what `caches` covers.
final scope = cache.getTimeTable().and().startBetween(
from.getMidnight(),
to.getMidnight(),
includeUpper: false,
);
existingCount = scope.countSync();
deletedCount = scope.deleteAllSync();
isarInit.lessonCacheModels.putAllSync(caches);
await isarWrite(() {
isarInit.writeTxnSync(() {
// NOT between(from, to): it's inclusive of `to`'s whole day, but
// `to` here is exclusive (matches what was actually fetched) — the
// inclusive version deleted a day beyond what `caches` covers.
final scope = cache.getTimeTable().and().startBetween(
from.getMidnight(),
to.getMidnight(),
includeUpper: false,
);
existingCount = scope.countSync();
deletedCount = scope.deleteAllSync();
isarInit.lessonCacheModels.putAllSync(caches);
});
});
logger.fine(

View File

@@ -125,9 +125,7 @@ class NotificationBackendClient {
return true;
}
_logger.warning(
'Failed to unregister FCM token: ${response.statusCode}',
);
_logger.warning('Failed to unregister FCM token: ${response.statusCode}');
return false;
} catch (e) {
_logger.severe('Error unregistering FCM token: $e');

View File

@@ -1,5 +1,7 @@
import 'package:firka_common/data/isar_writes.dart';
import "package:firka/app/app_state.dart";
import "package:firka/app/initialization.dart";
import "package:firka/core/theme_sync.dart";
import "package:firka/services/notification_delivery_service.dart";
import "package:firka_common/data/models/token_model.dart";
import "package:kreta_api/kreta_api.dart";
@@ -10,16 +12,17 @@ Future<void> completeLogin(
) async {
var tokenModel = TokenModel.fromResp(resp);
await data.isar.writeTxn(() async {
await data.isar.tokenModels.put(tokenModel);
});
await isarWrite(
() => data.isar.writeTxn(() => data.isar.tokenModels.put(tokenModel)),
);
await data.settings.setSelectedAccountKey(tokenModel.key);
await initializeApp();
// this account may already have a theme stored server side
await syncThemeFromServer(data.settings);
if (data.client != null) {
await NotificationDeliveryService.onUserLogin(
client: data.client!,
);
await NotificationDeliveryService.onUserLogin(client: data.client!);
}
}

View File

@@ -0,0 +1,75 @@
import 'package:dio/dio.dart';
import 'package:firka/app/app_state.dart';
const _base = 'https://api.firka.app/v1';
Options _options(String? writeKey) => Options(
contentType: Headers.jsonContentType,
receiveTimeout: const Duration(seconds: 10),
sendTimeout: const Duration(seconds: 10),
headers: writeKey == null ? null : {'X-Theme-Key': writeKey},
);
/// the owner's own copy, by vault. null when nothing is stored yet.
Future<({String code, String name, String shareId})?> fetchTheme(
String vault,
) async {
try {
final res = await dio.get(
'$_base/theme-sync/$vault',
options: _options(null),
);
final data = res.data as Map<String, dynamic>;
return (
code: (data['code'] as String?) ?? '',
name: (data['name'] as String?) ?? '',
shareId: (data['share_id'] as String?) ?? '',
);
} on DioException catch (e) {
if (e.response?.statusCode == 404) return null;
rethrow;
}
}
/// what a share link points at right now. null when the link is dead.
Future<({String code, String name})?> fetchSharedTheme(String shareId) async {
try {
final res = await dio.get(
'$_base/theme-share/$shareId',
options: _options(null),
);
final data = res.data as Map<String, dynamic>;
return (
code: data['code'] as String,
name: (data['name'] as String?) ?? '',
);
} on DioException catch (e) {
if (e.response?.statusCode == 404) return null;
rethrow;
}
}
/// stores the theme under the vault. the write key claims the vault on the
/// first push and proves ownership on every later one.
Future<void> pushTheme(
String vault, {
required String writeKey,
required String code,
required String name,
}) async {
await dio.put(
'$_base/theme-sync/$vault',
data: {'code': code, 'name': name},
options: _options(writeKey),
);
}
/// publishes the theme and returns its public, read-only share id
Future<String> shareTheme(String vault, {required String writeKey}) async {
final res = await dio.post(
'$_base/theme-sync/$vault/share',
options: _options(writeKey),
);
return (res.data as Map<String, dynamic>)['share_id'] as String;
}

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui;
import 'package:firka_common/data/isar_writes.dart';
import 'package:firka_common/data/database.dart';
import 'package:firka_common/data/models/lesson_cache_model.dart';
import 'package:flutter/foundation.dart';
@@ -25,13 +26,13 @@ import 'package:firka/ui/phone/screens/themes/builtin_theme_id.dart';
import 'package:firka/ui/theme/style.dart';
import 'package:firka_common/ui/theme/core_theme.dart';
import 'package:intl/intl.dart';
import 'package:firka/core/theme_sync.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart' as p;
import 'package:isar_community/isar.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
Future<void> initLang(AppInitialization data) async {
switch (Settings.language.value) {
case AppLanguage.hu:
@@ -67,6 +68,7 @@ FirkaStyle buildStyleForBrightness(
bool isLight, {
bool? isCustomTheme,
bool forceCustomColors = false,
Map<int, String>? colorOverrides,
}) {
final titleFont = Settings.titleFont.value;
final titleWeight = Settings.titleWeight.value;
@@ -88,6 +90,7 @@ FirkaStyle buildStyleForBrightness(
style,
isCustomTheme: isCustomTheme,
force: forceCustomColors,
colorOverrides: colorOverrides,
);
return style;
}
@@ -117,14 +120,20 @@ void _applyCustomColors(
FirkaStyle style, {
bool? isCustomTheme,
bool force = false,
Map<int, String>? colorOverrides,
}) {
// colorOverrides lets a theme be rendered from its own share code without
// writing it into the settings first — see themeCodeOverrides().
String read(SilentlySettable<String> s) =>
colorOverrides?[s.setting.id] ?? s.value;
final colors = style.colors;
colors.grade5 = Settings.customGradeColor5.value.toColorFromHexSetting();
colors.grade4 = Settings.customGradeColor4.value.toColorFromHexSetting();
colors.grade3 = Settings.customGradeColor3.value.toColorFromHexSetting();
colors.grade2 = Settings.customGradeColor2.value.toColorFromHexSetting();
colors.grade1 = Settings.customGradeColor1.value.toColorFromHexSetting();
colors.grade5 = read(Settings.customGradeColor5).toColorFromHexSetting();
colors.grade4 = read(Settings.customGradeColor4).toColorFromHexSetting();
colors.grade3 = read(Settings.customGradeColor3).toColorFromHexSetting();
colors.grade2 = read(Settings.customGradeColor2).toColorFromHexSetting();
colors.grade1 = read(Settings.customGradeColor1).toColorFromHexSetting();
final customActive =
isCustomTheme ?? !isBuiltinThemeId(Settings.selectedThemeId.value);
@@ -134,60 +143,49 @@ void _applyCustomColors(
final isLight = style.isLight;
colors.accent =
(isLight
? Settings.customAccentColorLight
: Settings.customAccentColorDark)
.value
.toColorFromHexSetting();
colors.accent = read(
isLight ? Settings.customAccentColorLight : Settings.customAccentColorDark,
).toColorFromHexSetting();
colors.a10p = colors.accent.withAlpha(0x1a);
colors.a15p = colors.accent.withAlpha(0x26);
final bgGrad = (isLight
? Settings.customBackgroundGradientLight
: Settings.customBackgroundGradientDark)
.value
.toColorListFromHexSetting();
final bgGrad = read(
isLight
? Settings.customBackgroundGradientLight
: Settings.customBackgroundGradientDark,
).toColorListFromHexSetting();
if (bgGrad.isNotEmpty) {
colors.backgroundGradient = bgGrad;
colors.background = bgGrad.first;
} else {
colors.background =
(isLight
? Settings.customBackgroundColorLight
: Settings.customBackgroundColorDark)
.value
.toColorFromHexSetting();
colors.background = read(
isLight
? Settings.customBackgroundColorLight
: Settings.customBackgroundColorDark,
).toColorFromHexSetting();
colors.backgroundGradient = null;
}
colors.background0p = colors.background.withAlpha(0);
colors.card =
(isLight
? Settings.customCardColorLight
: Settings.customCardColorDark)
.value
.toColorFromHexSetting();
colors.card = read(
isLight ? Settings.customCardColorLight : Settings.customCardColorDark,
).toColorFromHexSetting();
colors.cardTranslucent = colors.card.withAlpha(0x80);
colors.buttonSecondaryFill =
(isLight
? Settings.customButtonColorLight
: Settings.customButtonColorDark)
.value
.toColorFromHexSetting();
colors.buttonSecondaryFill = read(
isLight ? Settings.customButtonColorLight : Settings.customButtonColorDark,
).toColorFromHexSetting();
colors.secondary =
(isLight
? Settings.customSecondaryColorLight
: Settings.customSecondaryColorDark)
.value
.toColorFromHexSetting();
colors.secondary = read(
isLight
? Settings.customSecondaryColorLight
: Settings.customSecondaryColorDark,
).toColorFromHexSetting();
colors.buttonDisabledIcon = colors.secondary.withAlpha(0x80);
final customTextLight = Settings.customTextColorLight.value;
final customTextDark = Settings.customTextColorDark.value;
final customTextLight = read(Settings.customTextColorLight);
final customTextDark = read(Settings.customTextColorDark);
final isCustomTextLight =
customTextLight != SettingsRegistry.customTextColorLight.defaultValue;
final isCustomTextDark =
@@ -197,114 +195,108 @@ void _applyCustomColors(
final textDark = customTextDark.toColorFromHexSetting();
colors.textPrimary = isLight ? textLight : textDark;
final customSecLight = Settings.customTextSecondaryColorLight.value;
final customSecDark = Settings.customTextSecondaryColorDark.value;
final isCustomSecLight = customSecLight !=
final customSecLight = read(Settings.customTextSecondaryColorLight);
final customSecDark = read(Settings.customTextSecondaryColorDark);
final isCustomSecLight =
customSecLight !=
SettingsRegistry.customTextSecondaryColorLight.defaultValue;
final isCustomSecDark = customSecDark !=
final isCustomSecDark =
customSecDark !=
SettingsRegistry.customTextSecondaryColorDark.defaultValue;
colors.textSecondary = isLight
? (isCustomSecLight
? customSecLight.toColorFromHexSetting()
: (isCustomTextLight
? textLight.withAlpha(0xCC)
: customSecLight.toColorFromHexSetting()))
? customSecLight.toColorFromHexSetting()
: (isCustomTextLight
? textLight.withAlpha(0xCC)
: customSecLight.toColorFromHexSetting()))
: (isCustomSecDark
? customSecDark.toColorFromHexSetting()
: (isCustomTextDark
? textDark.withAlpha(0xB3)
: customSecDark.toColorFromHexSetting()));
? customSecDark.toColorFromHexSetting()
: (isCustomTextDark
? textDark.withAlpha(0xB3)
: customSecDark.toColorFromHexSetting()));
final customTertLight = Settings.customTextTertiaryColorLight.value;
final customTertDark = Settings.customTextTertiaryColorDark.value;
final isCustomTertLight = customTertLight !=
final customTertLight = read(Settings.customTextTertiaryColorLight);
final customTertDark = read(Settings.customTextTertiaryColorDark);
final isCustomTertLight =
customTertLight !=
SettingsRegistry.customTextTertiaryColorLight.defaultValue;
final isCustomTertDark = customTertDark !=
final isCustomTertDark =
customTertDark !=
SettingsRegistry.customTextTertiaryColorDark.defaultValue;
colors.textTertiary = isLight
? (isCustomTertLight
? customTertLight.toColorFromHexSetting()
: (isCustomTextLight
? textLight.withAlpha(0x80)
: customTertLight.toColorFromHexSetting()))
? customTertLight.toColorFromHexSetting()
: (isCustomTextLight
? textLight.withAlpha(0x80)
: customTertLight.toColorFromHexSetting()))
: (isCustomTertDark
? customTertDark.toColorFromHexSetting()
: (isCustomTextDark
? textDark.withAlpha(0x80)
: customTertDark.toColorFromHexSetting()));
? customTertDark.toColorFromHexSetting()
: (isCustomTextDark
? textDark.withAlpha(0x80)
: customTertDark.toColorFromHexSetting()));
colors.textTeritary = colors.textTertiary;
colors.textPrimaryLight = textLight;
colors.textSecondaryLight = isCustomSecLight
? customSecLight.toColorFromHexSetting()
: (isCustomTextLight
? textLight.withAlpha(0xCC)
: customSecLight.toColorFromHexSetting());
? textLight.withAlpha(0xCC)
: customSecLight.toColorFromHexSetting());
colors.textTertiaryLight = isCustomTertLight
? customTertLight.toColorFromHexSetting()
: (isCustomTextLight
? textLight.withAlpha(0x80)
: customTertLight.toColorFromHexSetting());
? textLight.withAlpha(0x80)
: customTertLight.toColorFromHexSetting());
colors.shadowColor =
(isLight
? Settings.customShadowColorLight
: Settings.customShadowColorDark)
.value
.toColorFromHexSetting();
colors.shadowColor = read(
isLight ? Settings.customShadowColorLight : Settings.customShadowColorDark,
).toColorFromHexSetting();
colors.success =
(isLight
? Settings.customSuccessColorLight
: Settings.customSuccessColorDark)
.value
.toColorFromHexSetting();
colors.success = read(
isLight
? Settings.customSuccessColorLight
: Settings.customSuccessColorDark,
).toColorFromHexSetting();
colors.warningAccent =
(isLight
? Settings.customWarningAccentColorLight
: Settings.customWarningAccentColorDark)
.value
.toColorFromHexSetting();
colors.warningAccent = read(
isLight
? Settings.customWarningAccentColorLight
: Settings.customWarningAccentColorDark,
).toColorFromHexSetting();
colors.warning15p = colors.warningAccent.withAlpha(0x26);
colors.warningText =
(isLight
? Settings.customWarningTextColorLight
: Settings.customWarningTextColorDark)
.value
.toColorFromHexSetting();
colors.warningText = read(
isLight
? Settings.customWarningTextColorLight
: Settings.customWarningTextColorDark,
).toColorFromHexSetting();
colors.warningCard =
(isLight
? Settings.customWarningCardColorLight
: Settings.customWarningCardColorDark)
.value
.toColorFromHexSetting();
colors.warningCard = read(
isLight
? Settings.customWarningCardColorLight
: Settings.customWarningCardColorDark,
).toColorFromHexSetting();
colors.errorAccent =
(isLight
? Settings.customErrorAccentColorLight
: Settings.customErrorAccentColorDark)
.value
.toColorFromHexSetting();
colors.errorAccent = read(
isLight
? Settings.customErrorAccentColorLight
: Settings.customErrorAccentColorDark,
).toColorFromHexSetting();
colors.error15p = colors.errorAccent.withAlpha(0x26);
colors.errorText =
(isLight
? Settings.customErrorTextColorLight
: Settings.customErrorTextColorDark)
.value
.toColorFromHexSetting();
colors.errorText = read(
isLight
? Settings.customErrorTextColorLight
: Settings.customErrorTextColorDark,
).toColorFromHexSetting();
colors.errorCard =
(isLight
? Settings.customErrorCardColorLight
: Settings.customErrorCardColorDark)
.value
.toColorFromHexSetting();
colors.errorCard = read(
isLight
? Settings.customErrorCardColorLight
: Settings.customErrorCardColorDark,
).toColorFromHexSetting();
}
DateTime? _lastInitDataAt;
@@ -313,12 +305,27 @@ String? _lastInitDataUsername;
Future<void> _initData(AppInitialization init) async {
await init.settings.loadAll();
// an update ships ".Default" enabled, which would leave anyone already on a
// custom icon with two launcher entries. Needs the settings, so it cannot
// run with the rest of the platform setup in initializeApp().
if (Platform.isAndroid) {
final icon = Settings.appIcon.value;
unawaited(
const MethodChannel("firka.app/main").invokeMethod("reconcile_icon", {
"icon": icon == "original" ? null : icon,
}).catchError((Object e) {
logger.warning("[Init] reconcile_icon failed: $e");
return null;
}),
);
}
// Old cacheKey scheme could collide across dates; wipe once so stale
// rows don't linger until their date range naturally resyncs.
if (!Settings.lessonCacheKeyMigrationDone.value) {
await isarInit.writeTxn(() async {
await isarInit.lessonCacheModels.clear();
});
await isarWrite(
() => isarInit.writeTxn(() => isarInit.lessonCacheModels.clear()),
);
await Settings.lessonCacheKeyMigrationDone.set(true);
logger.info(
"[Init] One-time migration: cleared the lesson cache to drop rows "
@@ -369,6 +376,9 @@ Future<void> _initData(AppInitialization init) async {
return;
}
// the owner of a shared theme keeps editing it, so catch up on app open
unawaited(refreshSharedThemes(init.settings));
// _initData reruns on ordinary resumes too (Android can recreate the
// Activity/engine without a real config change), and used to always
// build a fresh KretaClient — discarding its in-flight guards and
@@ -452,6 +462,7 @@ Future<void> initializeApp() async {
devInfo = DeviceInfo(rawInfo[0], rawInfo[1], rawInfo[2]);
devInfoFetched = true;
}
} catch (e) {
if (e is Error) {

View File

@@ -15,6 +15,7 @@ import 'package:firka/core/bloc/settings_cubit.dart';
import 'package:firka/core/bloc/theme_cubit.dart';
import 'package:firka/core/firka_bundle.dart';
import 'package:firka/routing/app_router.dart';
import 'package:firka/services/shake_detector.dart';
import 'package:firka/services/wear_sync_helper.dart';
import 'package:firka/ui/theme/style.dart';
import 'package:firka/ui/phone/pages/extras/main_wear_pair.dart';
@@ -29,9 +30,44 @@ class InitializationScreen extends StatefulWidget {
State<InitializationScreen> createState() => _InitializationScreenState();
}
class _InitializationScreenState extends State<InitializationScreen> {
class _InitializationScreenState extends State<InitializationScreen>
with WidgetsBindingObserver {
GoRouter? _router;
final Future<void> _init = initializeApp();
late final _shake = ShakeDetector(_openFeedback);
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_shake.stop();
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (_router == null) return;
if (state == AppLifecycleState.resumed) {
_shake.start();
} else if (state == AppLifecycleState.paused) {
_shake.stop();
}
}
/// shaking the phone opens the feedback form, unless it is already open
void _openFeedback() {
final router = _router;
if (router == null) return;
if (router.routerDelegate.currentConfiguration.uri.path == '/feedback') {
return;
}
router.push('/feedback');
}
ThemeData _buildTheme(FirkaStyle style) {
return ThemeData(
@@ -156,6 +192,7 @@ class _InitializationScreenState extends State<InitializationScreen> {
if (_router == null) {
_router = createAppRouter();
appRouter = _router;
_shake.start();
}
final themeCubit = initData.themeCubit;

View File

@@ -0,0 +1,54 @@
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
/// characters of log that are sent, the newest ones. the api keeps up to 150 000
const feedbackLogLimit = 100000;
final _logFile = RegExp(r'^\d{4}_\d{2}_\d{2}\.log$');
/// things that look like a secret, in case one ever ends up in a log line
final _secrets = <RegExp>[
RegExp(r'Bearer\s+[A-Za-z0-9._~+/=-]+', caseSensitive: false),
RegExp(r'eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}(\.[A-Za-z0-9_-]*)?'),
RegExp(r'[\w.+-]+@[\w-]+(\.[\w-]+)+'),
];
final _urlSecret = RegExp(
r'([?&](?:code|access_token|refresh_token|id_token)=)[^&\s"]+',
);
String redactSecrets(String text) {
var out = text.replaceAllMapped(_urlSecret, (m) => '${m[1]}[redacted]');
for (final pattern in _secrets) {
out = out.replaceAll(pattern, '[redacted]');
}
return out;
}
/// the newest log lines of the app, oldest first, with anything secret removed.
/// [error] is the error the person is reporting, it goes on top.
Future<String> collectFeedbackLogs(Directory appDir, {String? error}) async {
final files =
appDir
.listSync()
.whereType<File>()
.where((file) => _logFile.hasMatch(p.basename(file.path)))
.toList()
..sort((a, b) => p.basename(b.path).compareTo(p.basename(a.path)));
final parts = <String>[];
var size = 0;
for (final file in files) {
if (size >= feedbackLogLimit) break;
final text = utf8.decode(await file.readAsBytes(), allowMalformed: true);
parts.insert(0, '--- ${p.basename(file.path)} ---\n$text');
size += text.length;
}
var logs = redactSecrets(parts.join('\n'));
if (logs.length > feedbackLogLimit) {
logs = logs.substring(logs.length - feedbackLogLimit);
}
return error == null ? logs : 'Hibaüzenet:\n${redactSecrets(error)}\n\n$logs';
}

View File

@@ -124,7 +124,6 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
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),
@@ -138,7 +137,6 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
l10n.s_ci_icon_g3: const ["old", "refilc", "filc", "szivacs"],
l10n.s_ci_icon_g4: const [
"modern",
"cc",
"paper",
"filco",
"o1g",
@@ -271,9 +269,7 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
FirkaIconType.majesticons,
Majesticon.flower2Solid,
l10n.s_c,
[
SettingsUiPersonalization(appIconPickerTree, always),
],
[SettingsUiPersonalization(appIconPickerTree, always)],
always,
null,
l10n.s_c_desc,
@@ -300,18 +296,27 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
SettingsRegistry.progressNotificationEnabled,
isPushNotificationsEnabled,
),
SettingsUiHeaderSmall(l10n.s_notif_delivery_method_header, isPushNotificationsEnabled),
SettingsUiHeaderSmall(
l10n.s_notif_delivery_method_header,
isPushNotificationsEnabled,
),
SettingsUiEnum(SettingsRegistry.notificationDeliveryMethod, [
l10n.s_notif_delivery_auto,
l10n.s_notif_delivery_fcm,
l10n.s_notif_delivery_alarm,
], isPushNotificationsEnabled),
SettingsUiHeaderSmall(l10n.s_notif_wakeup_interval_header, isPushNotificationsEnabled),
SettingsUiHeaderSmall(
l10n.s_notif_wakeup_interval_header,
isPushNotificationsEnabled,
),
SettingsUiEnum(SettingsRegistry.notifyWakeupInterval, [
l10n.s_notif_wakeup_hourly,
l10n.s_notif_wakeup_two_hourly,
], isPushNotificationsEnabled),
SettingsUiHeaderSmall(l10n.s_notif_categories_header, isPushNotificationsEnabled),
SettingsUiHeaderSmall(
l10n.s_notif_categories_header,
isPushNotificationsEnabled,
),
SettingsUiBoolean(
null,
null,
@@ -529,8 +534,7 @@ SettingsUiGroup buildSettingsTree(AppLocalizations l10n) {
l10n.s_feedback,
const [],
always,
null,
l10n.s_todo,
"feedback",
),
SettingsUiBoolean(
null,

View File

@@ -8,6 +8,7 @@ import "package:firka/services/fcm_service.dart";
import "package:firka/services/notification_delivery_service.dart";
import "package:firka/services/progress_notification_service.dart";
import "package:firka/services/wear_sync_helper.dart";
import "package:firka/core/theme_palette.dart";
import "package:firka/ui/phone/screens/themes/builtin_theme_id.dart";
import "package:firka_common/ui/theme/core_theme.dart";
@@ -73,6 +74,8 @@ void registerSettingsEffects(
initTheme(initData);
initData.themeCubit.refresh();
initData.homeRefreshCubit.requestRefresh();
// persist the new colors into the selected user theme
scheduleActiveThemeSave(repo);
}
for (final setting in [

View File

@@ -4,6 +4,7 @@ import "package:isar_community/isar.dart";
import "package:firka/core/bloc/settings_cubit.dart";
import "package:firka_common/core/grade_helper.dart" as grade_helper;
import "package:firka_common/data/database.dart";
import "package:firka_common/data/isar_writes.dart";
import "package:firka_common/data/models/app_settings_model.dart";
import "package:firka_common/data/models/token_model.dart";
import "package:firka_common/ui/theme/style.dart";
@@ -33,6 +34,10 @@ class SilentlySettable<T> {
const SilentlySettable(this._repo, this._setting);
/// The typed key behind this accessor, so callers can identify the setting
/// (by [Setting.id]) without reaching for the registry entry separately.
Setting<T> get setting => _setting;
T get value => _repo.get(_setting);
Future<void> set(T value) => _repo.set(_setting, value);
@@ -80,9 +85,7 @@ class SettingsRepository {
case String v:
row.valueString = v;
}
await isar.writeTxn(() async {
await box.put(row);
});
await isarWrite(() => isar.writeTxn(() => box.put(row)));
cubit?.notifyChanged();
}
@@ -116,13 +119,14 @@ class SettingsRepository {
);
}
Color getGradeColor(num grade) {
Color getGradeColor(num grade, {FirkaStyle? style}) {
final colors = (style ?? appStyle).colors;
return switch (roundGrade(grade)) {
2 => appStyle.colors.grade2,
3 => appStyle.colors.grade3,
4 => appStyle.colors.grade4,
5 => appStyle.colors.grade5,
_ => appStyle.colors.grade1,
2 => colors.grade2,
3 => colors.grade3,
4 => colors.grade4,
5 => colors.grade5,
_ => colors.grade1,
};
}
@@ -130,13 +134,15 @@ class SettingsRepository {
box.getSync(_selectedAccountId)?.valueIndex ?? 0;
Future<void> setSelectedAccountKey(int key) async {
await isar.writeTxn(() async {
await box.put(
AppSettingsModel()
..id = _selectedAccountId
..valueIndex = key,
);
});
await isarWrite(
() => isar.writeTxn(
() => box.put(
AppSettingsModel()
..id = _selectedAccountId
..valueIndex = key,
),
),
);
}
TokenModel? getSelectedToken() {

View File

@@ -310,15 +310,9 @@ abstract class SettingsSchema {
@StringSetting(id: 1086, defaultValue: "0xFF1E030F")
String get customErrorCardColorDark;
@StringSetting(
id: 1087,
defaultValue: "[\"0xFFFAFFF0\",\"0xFFE8F7C8\"]",
)
@StringSetting(id: 1087, defaultValue: "[\"0xFFFAFFF0\",\"0xFFE8F7C8\"]")
String get customBackgroundGradientLight;
@StringSetting(
id: 1088,
defaultValue: "[\"0xFF0D1202\",\"0xFF1A2405\"]",
)
@StringSetting(id: 1088, defaultValue: "[\"0xFF0D1202\",\"0xFF1A2405\"]")
String get customBackgroundGradientDark;
}

View File

@@ -3,14 +3,47 @@
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);
@@ -18,19 +51,53 @@ 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 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 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 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);
@@ -41,139 +108,441 @@ class SettingsRegistry {
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 notifyWakeupInterval = EnumSetting(id: 1045, defaultValue: NotifyWakeupInterval.hourly, values: NotifyWakeupInterval.values);
static const fcmDebugNotifyOnMessage = BoolSetting(id: 1046, defaultValue: false);
static const notificationDeliveryMethod = EnumSetting(id: 1047, defaultValue: NotificationDeliveryMethod.auto, values: NotificationDeliveryMethod.values);
static const lessonCacheKeyMigrationDone = BoolSetting(id: 1048, defaultValue: false);
static const progressNotificationEnabled = BoolSetting(id: 1049, defaultValue: false);
static const customGradeColor5 = StringSetting(id: 1050, defaultValue: "0xFF22CCAD");
static const customGradeColor4 = StringSetting(id: 1051, defaultValue: "0xFF92EA3B");
static const customGradeColor3 = StringSetting(id: 1052, defaultValue: "0xFFF9CF00");
static const customGradeColor2 = StringSetting(id: 1053, defaultValue: "0xFFFFA046");
static const customGradeColor1 = StringSetting(id: 1054, defaultValue: "0xFFFF54A1");
static const customAccentColorLight = StringSetting(id: 1055, defaultValue: "0xFFA7DC22");
static const customAccentColorDark = StringSetting(id: 1056, defaultValue: "0xFFA7DC22");
static const customBackgroundColorLight = StringSetting(id: 1057, defaultValue: "0xFFFAFFF0");
static const customBackgroundColorDark = StringSetting(id: 1058, defaultValue: "0xFF0D1202");
static const customCardColorLight = StringSetting(id: 1059, defaultValue: "0xFFF3FBDE");
static const customCardColorDark = StringSetting(id: 1060, defaultValue: "0xFF141905");
static const customButtonColorLight = StringSetting(id: 1061, defaultValue: "0xFFFEFFFD");
static const customButtonColorDark = StringSetting(id: 1062, defaultValue: "0xFF20290B");
static const customSecondaryColorLight = StringSetting(id: 1063, defaultValue: "0xFF6E8F1B");
static const customSecondaryColorDark = StringSetting(id: 1064, defaultValue: "0xFFCBEE71");
static const customTextColorLight = StringSetting(id: 1065, defaultValue: "0xFF394C0A");
static const customTextColorDark = StringSetting(id: 1066, defaultValue: "0xFFEAF7CC");
static const customTextSecondaryColorLight = StringSetting(id: 1067, defaultValue: "0xCC394C0A");
static const customTextSecondaryColorDark = StringSetting(id: 1068, defaultValue: "0xB3EAF7CC");
static const customTextTertiaryColorLight = StringSetting(id: 1069, defaultValue: "0x80394C0A");
static const customTextTertiaryColorDark = StringSetting(id: 1070, defaultValue: "0x80EAF7CC");
static const customShadowColorLight = StringSetting(id: 1071, defaultValue: "0x33647E22");
static const customShadowColorDark = StringSetting(id: 1072, defaultValue: "0x26CBEE71");
static const customSuccessColorLight = StringSetting(id: 1073, defaultValue: "0xFF92EA3B");
static const customSuccessColorDark = StringSetting(id: 1074, defaultValue: "0xFF92EA3B");
static const customWarningAccentColorLight = StringSetting(id: 1075, defaultValue: "0xFFFFA046");
static const customWarningAccentColorDark = StringSetting(id: 1076, defaultValue: "0xFFFFA046");
static const customWarningTextColorLight = StringSetting(id: 1077, defaultValue: "0xFF8F531B");
static const customWarningTextColorDark = StringSetting(id: 1078, defaultValue: "0xFFF0B37A");
static const customWarningCardColorLight = StringSetting(id: 1079, defaultValue: "0xFFFAEBDC");
static const customWarningCardColorDark = StringSetting(id: 1080, defaultValue: "0xFF201203");
static const customErrorAccentColorLight = StringSetting(id: 1081, defaultValue: "0xFFFF54A1");
static const customErrorAccentColorDark = StringSetting(id: 1082, defaultValue: "0xFFFF54A1");
static const customErrorTextColorLight = StringSetting(id: 1083, defaultValue: "0xFF8F1B4F");
static const customErrorTextColorDark = StringSetting(id: 1084, defaultValue: "0xFFF59EC5");
static const customErrorCardColorLight = StringSetting(id: 1085, defaultValue: "0xFFFADCE9");
static const customErrorCardColorDark = StringSetting(id: 1086, defaultValue: "0xFF1E030F");
static const customBackgroundGradientLight = StringSetting(id: 1087, defaultValue: "[\"0xFFFAFFF0\",\"0xFFE8F7C8\"]");
static const customBackgroundGradientDark = StringSetting(id: 1088, defaultValue: "[\"0xFF0D1202\",\"0xFF1A2405\"]");
static const notifyMutedSubjects = StringSetting(
id: 1044,
defaultValue: "[]",
);
static const notifyWakeupInterval = EnumSetting(
id: 1045,
defaultValue: NotifyWakeupInterval.hourly,
values: NotifyWakeupInterval.values,
);
static const fcmDebugNotifyOnMessage = BoolSetting(
id: 1046,
defaultValue: false,
);
static const notificationDeliveryMethod = EnumSetting(
id: 1047,
defaultValue: NotificationDeliveryMethod.auto,
values: NotificationDeliveryMethod.values,
);
static const lessonCacheKeyMigrationDone = BoolSetting(
id: 1048,
defaultValue: false,
);
static const progressNotificationEnabled = BoolSetting(
id: 1049,
defaultValue: false,
);
static const customGradeColor5 = StringSetting(
id: 1050,
defaultValue: "0xFF22CCAD",
);
static const customGradeColor4 = StringSetting(
id: 1051,
defaultValue: "0xFF92EA3B",
);
static const customGradeColor3 = StringSetting(
id: 1052,
defaultValue: "0xFFF9CF00",
);
static const customGradeColor2 = StringSetting(
id: 1053,
defaultValue: "0xFFFFA046",
);
static const customGradeColor1 = StringSetting(
id: 1054,
defaultValue: "0xFFFF54A1",
);
static const customAccentColorLight = StringSetting(
id: 1055,
defaultValue: "0xFFA7DC22",
);
static const customAccentColorDark = StringSetting(
id: 1056,
defaultValue: "0xFFA7DC22",
);
static const customBackgroundColorLight = StringSetting(
id: 1057,
defaultValue: "0xFFFAFFF0",
);
static const customBackgroundColorDark = StringSetting(
id: 1058,
defaultValue: "0xFF0D1202",
);
static const customCardColorLight = StringSetting(
id: 1059,
defaultValue: "0xFFF3FBDE",
);
static const customCardColorDark = StringSetting(
id: 1060,
defaultValue: "0xFF141905",
);
static const customButtonColorLight = StringSetting(
id: 1061,
defaultValue: "0xFFFEFFFD",
);
static const customButtonColorDark = StringSetting(
id: 1062,
defaultValue: "0xFF20290B",
);
static const customSecondaryColorLight = StringSetting(
id: 1063,
defaultValue: "0xFF6E8F1B",
);
static const customSecondaryColorDark = StringSetting(
id: 1064,
defaultValue: "0xFFCBEE71",
);
static const customTextColorLight = StringSetting(
id: 1065,
defaultValue: "0xFF394C0A",
);
static const customTextColorDark = StringSetting(
id: 1066,
defaultValue: "0xFFEAF7CC",
);
static const customTextSecondaryColorLight = StringSetting(
id: 1067,
defaultValue: "0xCC394C0A",
);
static const customTextSecondaryColorDark = StringSetting(
id: 1068,
defaultValue: "0xB3EAF7CC",
);
static const customTextTertiaryColorLight = StringSetting(
id: 1069,
defaultValue: "0x80394C0A",
);
static const customTextTertiaryColorDark = StringSetting(
id: 1070,
defaultValue: "0x80EAF7CC",
);
static const customShadowColorLight = StringSetting(
id: 1071,
defaultValue: "0x33647E22",
);
static const customShadowColorDark = StringSetting(
id: 1072,
defaultValue: "0x26CBEE71",
);
static const customSuccessColorLight = StringSetting(
id: 1073,
defaultValue: "0xFF92EA3B",
);
static const customSuccessColorDark = StringSetting(
id: 1074,
defaultValue: "0xFF92EA3B",
);
static const customWarningAccentColorLight = StringSetting(
id: 1075,
defaultValue: "0xFFFFA046",
);
static const customWarningAccentColorDark = StringSetting(
id: 1076,
defaultValue: "0xFFFFA046",
);
static const customWarningTextColorLight = StringSetting(
id: 1077,
defaultValue: "0xFF8F531B",
);
static const customWarningTextColorDark = StringSetting(
id: 1078,
defaultValue: "0xFFF0B37A",
);
static const customWarningCardColorLight = StringSetting(
id: 1079,
defaultValue: "0xFFFAEBDC",
);
static const customWarningCardColorDark = StringSetting(
id: 1080,
defaultValue: "0xFF201203",
);
static const customErrorAccentColorLight = StringSetting(
id: 1081,
defaultValue: "0xFFFF54A1",
);
static const customErrorAccentColorDark = StringSetting(
id: 1082,
defaultValue: "0xFFFF54A1",
);
static const customErrorTextColorLight = StringSetting(
id: 1083,
defaultValue: "0xFF8F1B4F",
);
static const customErrorTextColorDark = StringSetting(
id: 1084,
defaultValue: "0xFFF59EC5",
);
static const customErrorCardColorLight = StringSetting(
id: 1085,
defaultValue: "0xFFFADCE9",
);
static const customErrorCardColorDark = StringSetting(
id: 1086,
defaultValue: "0xFF1E030F",
);
static const customBackgroundGradientLight = StringSetting(
id: 1087,
defaultValue: "[\"0xFFFAFFF0\",\"0xFFE8F7C8\"]",
);
static const customBackgroundGradientDark = StringSetting(
id: 1088,
defaultValue: "[\"0xFF0D1202\",\"0xFF1A2405\"]",
);
static const all = <Setting>[
bellDelay, rounding1, rounding2, rounding3, rounding4, classAvgOnGraph, leftHandedMode, language, appIcon, childProtection, betaWarning, ttToastLessonNo, ttToastTestsAndHw, ttToastBreaks, statsForNerds, developerOptsEnabled, themeBrightness, ttToastSubstitution, ttToastABTimetable, wearOsSupport, titleFont, titleWeight, titleCapitalization, selectedThemeId, selectedCoreThemeId, selectedGradeThemeId, mockBackendEnabled, mockBackendUrl, lastSeen, surpriseGrades, seasonalAppIcons, uwuMode, notifyAll, notifyGrades, notifyHomeworkTests, notifyAbsences, notifyLessons, notifyMessages, notifyMutedSubjects, notifyWakeupInterval, fcmDebugNotifyOnMessage, notificationDeliveryMethod, lessonCacheKeyMigrationDone, progressNotificationEnabled, customGradeColor5, customGradeColor4, customGradeColor3, customGradeColor2, customGradeColor1, customAccentColorLight, customAccentColorDark, customBackgroundColorLight, customBackgroundColorDark, customCardColorLight, customCardColorDark, customButtonColorLight, customButtonColorDark, customSecondaryColorLight, customSecondaryColorDark, customTextColorLight, customTextColorDark, customTextSecondaryColorLight, customTextSecondaryColorDark, customTextTertiaryColorLight, customTextTertiaryColorDark, customShadowColorLight, customShadowColorDark, customSuccessColorLight, customSuccessColorDark, customWarningAccentColorLight, customWarningAccentColorDark, customWarningTextColorLight, customWarningTextColorDark, customWarningCardColorLight, customWarningCardColorDark, customErrorAccentColorLight, customErrorAccentColorDark, customErrorTextColorLight, customErrorTextColorDark, customErrorCardColorLight, customErrorCardColorDark, customBackgroundGradientLight, customBackgroundGradientDark,
bellDelay,
rounding1,
rounding2,
rounding3,
rounding4,
classAvgOnGraph,
leftHandedMode,
language,
appIcon,
childProtection,
betaWarning,
ttToastLessonNo,
ttToastTestsAndHw,
ttToastBreaks,
statsForNerds,
developerOptsEnabled,
themeBrightness,
ttToastSubstitution,
ttToastABTimetable,
wearOsSupport,
titleFont,
titleWeight,
titleCapitalization,
selectedThemeId,
selectedCoreThemeId,
selectedGradeThemeId,
mockBackendEnabled,
mockBackendUrl,
lastSeen,
surpriseGrades,
seasonalAppIcons,
uwuMode,
notifyAll,
notifyGrades,
notifyHomeworkTests,
notifyAbsences,
notifyLessons,
notifyMessages,
notifyMutedSubjects,
notifyWakeupInterval,
fcmDebugNotifyOnMessage,
notificationDeliveryMethod,
lessonCacheKeyMigrationDone,
progressNotificationEnabled,
customGradeColor5,
customGradeColor4,
customGradeColor3,
customGradeColor2,
customGradeColor1,
customAccentColorLight,
customAccentColorDark,
customBackgroundColorLight,
customBackgroundColorDark,
customCardColorLight,
customCardColorDark,
customButtonColorLight,
customButtonColorDark,
customSecondaryColorLight,
customSecondaryColorDark,
customTextColorLight,
customTextColorDark,
customTextSecondaryColorLight,
customTextSecondaryColorDark,
customTextTertiaryColorLight,
customTextTertiaryColorDark,
customShadowColorLight,
customShadowColorDark,
customSuccessColorLight,
customSuccessColorDark,
customWarningAccentColorLight,
customWarningAccentColorDark,
customWarningTextColorLight,
customWarningTextColorDark,
customWarningCardColorLight,
customWarningCardColorDark,
customErrorAccentColorLight,
customErrorAccentColorDark,
customErrorTextColorLight,
customErrorTextColorDark,
customErrorCardColorLight,
customErrorCardColorDark,
customBackgroundGradientLight,
customBackgroundGradientDark,
];
}
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 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);
SilentlySettable<NotifyWakeupInterval> get notifyWakeupInterval => SilentlySettable(this, SettingsRegistry.notifyWakeupInterval);
SilentlySettable<bool> get fcmDebugNotifyOnMessage => SilentlySettable(this, SettingsRegistry.fcmDebugNotifyOnMessage);
SilentlySettable<NotificationDeliveryMethod> get notificationDeliveryMethod => SilentlySettable(this, SettingsRegistry.notificationDeliveryMethod);
SilentlySettable<bool> get lessonCacheKeyMigrationDone => SilentlySettable(this, SettingsRegistry.lessonCacheKeyMigrationDone);
SilentlySettable<bool> get progressNotificationEnabled => SilentlySettable(this, SettingsRegistry.progressNotificationEnabled);
SilentlySettable<String> get customGradeColor5 => SilentlySettable(this, SettingsRegistry.customGradeColor5);
SilentlySettable<String> get customGradeColor4 => SilentlySettable(this, SettingsRegistry.customGradeColor4);
SilentlySettable<String> get customGradeColor3 => SilentlySettable(this, SettingsRegistry.customGradeColor3);
SilentlySettable<String> get customGradeColor2 => SilentlySettable(this, SettingsRegistry.customGradeColor2);
SilentlySettable<String> get customGradeColor1 => SilentlySettable(this, SettingsRegistry.customGradeColor1);
SilentlySettable<String> get customAccentColorLight => SilentlySettable(this, SettingsRegistry.customAccentColorLight);
SilentlySettable<String> get customAccentColorDark => SilentlySettable(this, SettingsRegistry.customAccentColorDark);
SilentlySettable<String> get customBackgroundColorLight => SilentlySettable(this, SettingsRegistry.customBackgroundColorLight);
SilentlySettable<String> get customBackgroundColorDark => SilentlySettable(this, SettingsRegistry.customBackgroundColorDark);
SilentlySettable<String> get customCardColorLight => SilentlySettable(this, SettingsRegistry.customCardColorLight);
SilentlySettable<String> get customCardColorDark => SilentlySettable(this, SettingsRegistry.customCardColorDark);
SilentlySettable<String> get customButtonColorLight => SilentlySettable(this, SettingsRegistry.customButtonColorLight);
SilentlySettable<String> get customButtonColorDark => SilentlySettable(this, SettingsRegistry.customButtonColorDark);
SilentlySettable<String> get customSecondaryColorLight => SilentlySettable(this, SettingsRegistry.customSecondaryColorLight);
SilentlySettable<String> get customSecondaryColorDark => SilentlySettable(this, SettingsRegistry.customSecondaryColorDark);
SilentlySettable<String> get customTextColorLight => SilentlySettable(this, SettingsRegistry.customTextColorLight);
SilentlySettable<String> get customTextColorDark => SilentlySettable(this, SettingsRegistry.customTextColorDark);
SilentlySettable<String> get customTextSecondaryColorLight => SilentlySettable(this, SettingsRegistry.customTextSecondaryColorLight);
SilentlySettable<String> get customTextSecondaryColorDark => SilentlySettable(this, SettingsRegistry.customTextSecondaryColorDark);
SilentlySettable<String> get customTextTertiaryColorLight => SilentlySettable(this, SettingsRegistry.customTextTertiaryColorLight);
SilentlySettable<String> get customTextTertiaryColorDark => SilentlySettable(this, SettingsRegistry.customTextTertiaryColorDark);
SilentlySettable<String> get customShadowColorLight => SilentlySettable(this, SettingsRegistry.customShadowColorLight);
SilentlySettable<String> get customShadowColorDark => SilentlySettable(this, SettingsRegistry.customShadowColorDark);
SilentlySettable<String> get customSuccessColorLight => SilentlySettable(this, SettingsRegistry.customSuccessColorLight);
SilentlySettable<String> get customSuccessColorDark => SilentlySettable(this, SettingsRegistry.customSuccessColorDark);
SilentlySettable<String> get customWarningAccentColorLight => SilentlySettable(this, SettingsRegistry.customWarningAccentColorLight);
SilentlySettable<String> get customWarningAccentColorDark => SilentlySettable(this, SettingsRegistry.customWarningAccentColorDark);
SilentlySettable<String> get customWarningTextColorLight => SilentlySettable(this, SettingsRegistry.customWarningTextColorLight);
SilentlySettable<String> get customWarningTextColorDark => SilentlySettable(this, SettingsRegistry.customWarningTextColorDark);
SilentlySettable<String> get customWarningCardColorLight => SilentlySettable(this, SettingsRegistry.customWarningCardColorLight);
SilentlySettable<String> get customWarningCardColorDark => SilentlySettable(this, SettingsRegistry.customWarningCardColorDark);
SilentlySettable<String> get customErrorAccentColorLight => SilentlySettable(this, SettingsRegistry.customErrorAccentColorLight);
SilentlySettable<String> get customErrorAccentColorDark => SilentlySettable(this, SettingsRegistry.customErrorAccentColorDark);
SilentlySettable<String> get customErrorTextColorLight => SilentlySettable(this, SettingsRegistry.customErrorTextColorLight);
SilentlySettable<String> get customErrorTextColorDark => SilentlySettable(this, SettingsRegistry.customErrorTextColorDark);
SilentlySettable<String> get customErrorCardColorLight => SilentlySettable(this, SettingsRegistry.customErrorCardColorLight);
SilentlySettable<String> get customErrorCardColorDark => SilentlySettable(this, SettingsRegistry.customErrorCardColorDark);
SilentlySettable<String> get customBackgroundGradientLight => SilentlySettable(this, SettingsRegistry.customBackgroundGradientLight);
SilentlySettable<String> get customBackgroundGradientDark => SilentlySettable(this, SettingsRegistry.customBackgroundGradientDark);
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 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);
SilentlySettable<NotifyWakeupInterval> get notifyWakeupInterval =>
SilentlySettable(this, SettingsRegistry.notifyWakeupInterval);
SilentlySettable<bool> get fcmDebugNotifyOnMessage =>
SilentlySettable(this, SettingsRegistry.fcmDebugNotifyOnMessage);
SilentlySettable<NotificationDeliveryMethod> get notificationDeliveryMethod =>
SilentlySettable(this, SettingsRegistry.notificationDeliveryMethod);
SilentlySettable<bool> get lessonCacheKeyMigrationDone =>
SilentlySettable(this, SettingsRegistry.lessonCacheKeyMigrationDone);
SilentlySettable<bool> get progressNotificationEnabled =>
SilentlySettable(this, SettingsRegistry.progressNotificationEnabled);
SilentlySettable<String> get customGradeColor5 =>
SilentlySettable(this, SettingsRegistry.customGradeColor5);
SilentlySettable<String> get customGradeColor4 =>
SilentlySettable(this, SettingsRegistry.customGradeColor4);
SilentlySettable<String> get customGradeColor3 =>
SilentlySettable(this, SettingsRegistry.customGradeColor3);
SilentlySettable<String> get customGradeColor2 =>
SilentlySettable(this, SettingsRegistry.customGradeColor2);
SilentlySettable<String> get customGradeColor1 =>
SilentlySettable(this, SettingsRegistry.customGradeColor1);
SilentlySettable<String> get customAccentColorLight =>
SilentlySettable(this, SettingsRegistry.customAccentColorLight);
SilentlySettable<String> get customAccentColorDark =>
SilentlySettable(this, SettingsRegistry.customAccentColorDark);
SilentlySettable<String> get customBackgroundColorLight =>
SilentlySettable(this, SettingsRegistry.customBackgroundColorLight);
SilentlySettable<String> get customBackgroundColorDark =>
SilentlySettable(this, SettingsRegistry.customBackgroundColorDark);
SilentlySettable<String> get customCardColorLight =>
SilentlySettable(this, SettingsRegistry.customCardColorLight);
SilentlySettable<String> get customCardColorDark =>
SilentlySettable(this, SettingsRegistry.customCardColorDark);
SilentlySettable<String> get customButtonColorLight =>
SilentlySettable(this, SettingsRegistry.customButtonColorLight);
SilentlySettable<String> get customButtonColorDark =>
SilentlySettable(this, SettingsRegistry.customButtonColorDark);
SilentlySettable<String> get customSecondaryColorLight =>
SilentlySettable(this, SettingsRegistry.customSecondaryColorLight);
SilentlySettable<String> get customSecondaryColorDark =>
SilentlySettable(this, SettingsRegistry.customSecondaryColorDark);
SilentlySettable<String> get customTextColorLight =>
SilentlySettable(this, SettingsRegistry.customTextColorLight);
SilentlySettable<String> get customTextColorDark =>
SilentlySettable(this, SettingsRegistry.customTextColorDark);
SilentlySettable<String> get customTextSecondaryColorLight =>
SilentlySettable(this, SettingsRegistry.customTextSecondaryColorLight);
SilentlySettable<String> get customTextSecondaryColorDark =>
SilentlySettable(this, SettingsRegistry.customTextSecondaryColorDark);
SilentlySettable<String> get customTextTertiaryColorLight =>
SilentlySettable(this, SettingsRegistry.customTextTertiaryColorLight);
SilentlySettable<String> get customTextTertiaryColorDark =>
SilentlySettable(this, SettingsRegistry.customTextTertiaryColorDark);
SilentlySettable<String> get customShadowColorLight =>
SilentlySettable(this, SettingsRegistry.customShadowColorLight);
SilentlySettable<String> get customShadowColorDark =>
SilentlySettable(this, SettingsRegistry.customShadowColorDark);
SilentlySettable<String> get customSuccessColorLight =>
SilentlySettable(this, SettingsRegistry.customSuccessColorLight);
SilentlySettable<String> get customSuccessColorDark =>
SilentlySettable(this, SettingsRegistry.customSuccessColorDark);
SilentlySettable<String> get customWarningAccentColorLight =>
SilentlySettable(this, SettingsRegistry.customWarningAccentColorLight);
SilentlySettable<String> get customWarningAccentColorDark =>
SilentlySettable(this, SettingsRegistry.customWarningAccentColorDark);
SilentlySettable<String> get customWarningTextColorLight =>
SilentlySettable(this, SettingsRegistry.customWarningTextColorLight);
SilentlySettable<String> get customWarningTextColorDark =>
SilentlySettable(this, SettingsRegistry.customWarningTextColorDark);
SilentlySettable<String> get customWarningCardColorLight =>
SilentlySettable(this, SettingsRegistry.customWarningCardColorLight);
SilentlySettable<String> get customWarningCardColorDark =>
SilentlySettable(this, SettingsRegistry.customWarningCardColorDark);
SilentlySettable<String> get customErrorAccentColorLight =>
SilentlySettable(this, SettingsRegistry.customErrorAccentColorLight);
SilentlySettable<String> get customErrorAccentColorDark =>
SilentlySettable(this, SettingsRegistry.customErrorAccentColorDark);
SilentlySettable<String> get customErrorTextColorLight =>
SilentlySettable(this, SettingsRegistry.customErrorTextColorLight);
SilentlySettable<String> get customErrorTextColorDark =>
SilentlySettable(this, SettingsRegistry.customErrorTextColorDark);
SilentlySettable<String> get customErrorCardColorLight =>
SilentlySettable(this, SettingsRegistry.customErrorCardColorLight);
SilentlySettable<String> get customErrorCardColorDark =>
SilentlySettable(this, SettingsRegistry.customErrorCardColorDark);
SilentlySettable<String> get customBackgroundGradientLight =>
SilentlySettable(this, SettingsRegistry.customBackgroundGradientLight);
SilentlySettable<String> get customBackgroundGradientDark =>
SilentlySettable(this, SettingsRegistry.customBackgroundGradientDark);
}

View File

@@ -0,0 +1,221 @@
import 'dart:async';
import 'package:firka_common/data/isar_writes.dart';
import 'package:firka/core/extensions.dart';
import 'package:firka/core/settings/setting.dart';
import 'package:firka/core/settings/settings_repository.dart';
import 'package:firka/core/settings/settings_schema.dart';
import 'package:firka/core/theme_sync.dart';
import 'package:firka/ui/phone/screens/themes/builtin_theme_id.dart';
import 'package:firka/ui/phone/screens/themes/user_theme.dart';
import 'package:firka_common/data/database.dart';
import 'package:firka_common/data/models/user_theme_model.dart';
import 'package:firka_common/ui/theme/theme_binary_format.dart';
import 'package:flutter/painting.dart';
/// the settings that hold a slot's light and dark color
(StringSetting, StringSetting) themeSlotSettings(ThemeColorSlot slot) {
switch (slot) {
case ThemeColorSlot.accent:
return (
SettingsRegistry.customAccentColorLight,
SettingsRegistry.customAccentColorDark,
);
case ThemeColorSlot.background:
return (
SettingsRegistry.customBackgroundColorLight,
SettingsRegistry.customBackgroundColorDark,
);
case ThemeColorSlot.card:
return (
SettingsRegistry.customCardColorLight,
SettingsRegistry.customCardColorDark,
);
case ThemeColorSlot.button:
return (
SettingsRegistry.customButtonColorLight,
SettingsRegistry.customButtonColorDark,
);
case ThemeColorSlot.secondary:
return (
SettingsRegistry.customSecondaryColorLight,
SettingsRegistry.customSecondaryColorDark,
);
case ThemeColorSlot.textPrimary:
return (
SettingsRegistry.customTextColorLight,
SettingsRegistry.customTextColorDark,
);
case ThemeColorSlot.textSecondary:
return (
SettingsRegistry.customTextSecondaryColorLight,
SettingsRegistry.customTextSecondaryColorDark,
);
case ThemeColorSlot.textTertiary:
return (
SettingsRegistry.customTextTertiaryColorLight,
SettingsRegistry.customTextTertiaryColorDark,
);
case ThemeColorSlot.shadowColor:
return (
SettingsRegistry.customShadowColorLight,
SettingsRegistry.customShadowColorDark,
);
case ThemeColorSlot.success:
return (
SettingsRegistry.customSuccessColorLight,
SettingsRegistry.customSuccessColorDark,
);
case ThemeColorSlot.warningAccent:
return (
SettingsRegistry.customWarningAccentColorLight,
SettingsRegistry.customWarningAccentColorDark,
);
case ThemeColorSlot.warningText:
return (
SettingsRegistry.customWarningTextColorLight,
SettingsRegistry.customWarningTextColorDark,
);
case ThemeColorSlot.warningCard:
return (
SettingsRegistry.customWarningCardColorLight,
SettingsRegistry.customWarningCardColorDark,
);
case ThemeColorSlot.errorAccent:
return (
SettingsRegistry.customErrorAccentColorLight,
SettingsRegistry.customErrorAccentColorDark,
);
case ThemeColorSlot.errorText:
return (
SettingsRegistry.customErrorTextColorLight,
SettingsRegistry.customErrorTextColorDark,
);
case ThemeColorSlot.errorCard:
return (
SettingsRegistry.customErrorCardColorLight,
SettingsRegistry.customErrorCardColorDark,
);
}
}
/// the grade color settings, grade 1 first, the order of the share format
final _gradeSettings = [
SettingsRegistry.customGradeColor1,
SettingsRegistry.customGradeColor2,
SettingsRegistry.customGradeColor3,
SettingsRegistry.customGradeColor4,
SettingsRegistry.customGradeColor5,
];
/// the colors the app has right now as a share code: every slot, the grade
/// colors and both background gradients
String captureThemeCode(SettingsRepository settings) {
Color read(StringSetting setting) =>
settings.get(setting).toColorFromHexSetting();
final bytes = ThemeBinaryFormat.encodeFullTheme(
light: {
for (final slot in ThemeColorSlot.values)
slot: read(themeSlotSettings(slot).$1),
},
dark: {
for (final slot in ThemeColorSlot.values)
slot: read(themeSlotSettings(slot).$2),
},
gradeColors: [for (final setting in _gradeSettings) read(setting)],
gradientLight: settings
.get(SettingsRegistry.customBackgroundGradientLight)
.toColorListFromHexSetting(),
gradientDark: settings
.get(SettingsRegistry.customBackgroundGradientDark)
.toColorListFromHexSetting(),
);
return ThemeBinaryFormat.toBase64(bytes);
}
/// puts the colors of a share code into the settings. everything is written
/// quietly except the last one, so the app refreshes once and not forty times.
/// throws a [FormatException] when the code is not a theme.
Future<void> applyThemeCode(SettingsRepository settings, String code) async {
final data = ThemeBinaryFormat.decodeFromBase64(code);
final slots = data.toThemeSlots();
for (final slot in ThemeColorSlot.values) {
final (light, dark) = themeSlotSettings(slot);
await settings.setSilently(light, slots.light[slot]!.toHexSetting());
await settings.setSilently(dark, slots.dark[slot]!.toHexSetting());
}
for (var i = 0; i < _gradeSettings.length; i++) {
await settings.setSilently(
_gradeSettings[i],
data.gradeColors[i].toHexSetting(),
);
}
await settings.setSilently(
SettingsRegistry.customBackgroundGradientLight,
data.gradientLight.toHexSettingJson(),
);
await settings.set(
SettingsRegistry.customBackgroundGradientDark,
data.gradientDark.toHexSettingJson(),
);
}
/// Decodes [code] into the override map [buildStyleForBrightness] renders
/// from, so a theme can be previewed without writing it to the settings.
/// Keyed by [Setting.id]. Throws a [FormatException] when the code is not a
/// theme, same as [applyThemeCode].
Map<int, String> themeCodeOverrides(String code) {
final data = ThemeBinaryFormat.decodeFromBase64(code);
final slots = data.toThemeSlots();
final overrides = <int, String>{};
for (final slot in ThemeColorSlot.values) {
final (light, dark) = themeSlotSettings(slot);
overrides[light.id] = slots.light[slot]!.toHexSetting();
overrides[dark.id] = slots.dark[slot]!.toHexSetting();
}
for (var i = 0; i < _gradeSettings.length; i++) {
overrides[_gradeSettings[i].id] = data.gradeColors[i].toHexSetting();
}
overrides[SettingsRegistry.customBackgroundGradientLight.id] = data
.gradientLight
.toHexSettingJson();
overrides[SettingsRegistry.customBackgroundGradientDark.id] = data
.gradientDark
.toHexSettingJson();
return overrides;
}
/// writes the colors being edited back into the selected theme, so each theme
/// keeps its own. nothing to do while a built-in theme is selected.
Future<void> saveActiveThemeCode(SettingsRepository settings) async {
final id = settings.get(SettingsRegistry.selectedThemeId);
if (isBuiltinThemeId(id)) return;
final stored = await isarInit.userThemeModels.getByThemeId(id);
if (stored == null) return;
stored.code = captureThemeCode(settings);
stored.swatchArgb = [
for (final color in UserTheme.swatchFromAppStyle()) color.toARGB32(),
];
await isarWrite(
() =>
isarInit.writeTxn(() => isarInit.userThemeModels.putByThemeId(stored)),
);
await pushThemeToServer(settings);
}
Timer? _saveTimer;
/// saves the selected theme a moment after the last change, dragging a slider
/// changes a color many times a second
void scheduleActiveThemeSave(SettingsRepository settings) {
_saveTimer?.cancel();
_saveTimer = Timer(
const Duration(milliseconds: 300),
() => saveActiveThemeCode(settings),
);
}

View File

@@ -0,0 +1,222 @@
import 'dart:convert';
import 'package:firka_common/data/isar_writes.dart';
import 'package:crypto/crypto.dart';
import 'package:isar_community/isar.dart';
import 'package:firka/api/theme_sync_api.dart' as api;
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/theme_palette.dart';
import 'package:firka/ui/phone/screens/themes/builtin_theme_id.dart';
import 'package:firka/ui/phone/screens/themes/user_theme.dart';
import 'package:firka_common/data/database.dart';
import 'package:firka_common/data/models/token_model.dart';
import 'package:firka_common/data/models/user_theme_model.dart';
import 'package:firka_common/ui/theme/theme_binary_format.dart';
/// identifies the account's row. baked into the app so the vault can't be
/// worked out from a student's institute code and id alone.
const _vaultSalt = 'firka-theme-sync-2026';
/// a different secret for the write key, so seeing a vault never tells
/// anyone what it takes to change what is in it
const _writeSalt = 'firka-theme-write-2026';
/// the account's row id. the only thing that leaves the device is this hash,
/// never the institute code or the student id behind it. both survive a token
/// refresh, so the vault stays the same for the life of the account.
String computeVault(TokenModel token) => sha256
.convert(utf8.encode('$_vaultSalt:${token.iss}:${token.studentId}'))
.toString();
/// proves to the server that this client owns the vault. the server only
/// ever stores a hash of it, and it never goes into a share link.
String computeWriteKey(TokenModel token) => Hmac(
sha256,
utf8.encode(_writeSalt),
).convert(utf8.encode('${token.iss}:${token.studentId}')).toString();
/// the local id of the theme mirroring the account's vault
String syncedThemeId(String vault) => 'sync-${vault.substring(0, 24)}';
/// pulls this account's own theme down, so signing in on another device
/// brings the theme along. quietly does nothing while nobody is logged in
/// or the network is down.
Future<void> syncThemeFromServer(SettingsRepository settings) async {
try {
final token = settings.getSelectedToken();
if (token == null) return;
final vault = computeVault(token);
final remote = await api.fetchTheme(vault);
if (remote == null) return;
final local = await isarInit.userThemeModels.where().findAll();
// the server's copy is usually a theme of ours pushed from another
// device, so match on the colors before making a second one
final stored =
local.where((t) => t.code == remote.code).firstOrNull ??
local.where((t) => t.themeId == syncedThemeId(vault)).firstOrNull;
if (stored != null &&
stored.code == remote.code &&
stored.shareId == remote.shareId) {
return;
}
final id = stored?.themeId ?? syncedThemeId(vault);
final model = (stored ?? UserThemeModel())
..themeId = id
..name = remote.name.isNotEmpty ? remote.name : (stored?.name ?? 'Firka')
..origin = stored?.origin ?? 'own'
..code = remote.code
..shareId = remote.shareId
..swatchArgb = _swatchOf(remote.code) ?? stored?.swatchArgb ?? const [];
await isarWrite(
() => isarInit.writeTxn(
() => isarInit.userThemeModels.putByThemeId(model),
),
);
// applying the code makes the app save the theme, which would otherwise
// push this very theme straight back up
_lastPushed = '${remote.code}:${model.name}';
// only take the colors over while the user is still on a built-in theme
final selected = settings.get(SettingsRegistry.selectedThemeId);
if (isBuiltinThemeId(selected) || selected == id) {
await settings.setSilently(SettingsRegistry.selectedThemeId, id);
await applyThemeCode(settings, remote.code);
}
} catch (e) {
logger.warning('[ThemeSync] fetch failed: $e');
}
}
/// re-reads every theme imported from a share link. the owner of a shared
/// theme keeps editing it, so these follow along on their own.
Future<void> refreshSharedThemes(SettingsRepository settings) async {
try {
final local = await isarInit.userThemeModels.where().findAll();
final followed = local.where(
(t) => t.origin == 'downloaded' && t.shareId.isNotEmpty,
);
final selected = settings.get(SettingsRegistry.selectedThemeId);
var changedSelected = false;
for (final theme in followed) {
final remote = await api.fetchSharedTheme(theme.shareId);
// a dead link keeps the copy that was imported, rather than losing it
if (remote == null || remote.code == theme.code) continue;
theme.code = remote.code;
theme.swatchArgb = _swatchOf(remote.code) ?? theme.swatchArgb;
await isarWrite(
() => isarInit.writeTxn(
() => isarInit.userThemeModels.putByThemeId(theme),
),
);
if (theme.themeId == selected) changedSelected = true;
}
// repaint right away when the theme being worn is the one that moved
if (changedSelected) {
final theme = await isarInit.userThemeModels.getByThemeId(selected);
if (theme != null) await applyThemeCode(settings, theme.code);
}
} catch (e) {
logger.warning('[ThemeSync] shared refresh failed: $e');
}
}
/// what the server was last told, so dragging a colour slider and pulling a
/// theme back down don't each cost a request that changes nothing
String? _lastPushed;
/// pushes the selected theme up. a shared theme is pushed like any other —
/// that is how everyone following the link sees the edit.
Future<void> pushThemeToServer(SettingsRepository settings) async {
final id = settings.get(SettingsRegistry.selectedThemeId);
if (isBuiltinThemeId(id)) return;
final stored = await isarInit.userThemeModels.getByThemeId(id);
// someone else's theme is theirs to change, we only follow it
if (stored == null || stored.origin == 'downloaded') return;
await _push(settings, stored, captureThemeCode(settings));
}
/// publishes [theme] and returns the share id to put in the link, or an
/// empty string when it couldn't be published. the theme stays editable:
/// later edits reach everyone holding the link on their own.
Future<String> publishTheme(
SettingsRepository settings,
UserTheme theme,
) async {
try {
final token = settings.getSelectedToken();
if (token == null || theme.isBuiltin) return '';
final stored = await isarInit.userThemeModels.getByThemeId(theme.id);
if (stored == null) return '';
// the link has to point at the colours it was made from
await _push(settings, stored, theme.code, force: true);
final shareId = await api.shareTheme(
computeVault(token),
writeKey: computeWriteKey(token),
);
stored.shareId = shareId;
await isarWrite(
() => isarInit.writeTxn(
() => isarInit.userThemeModels.putByThemeId(stored),
),
);
return shareId;
} catch (e) {
logger.warning('[ThemeSync] publish failed: $e');
return '';
}
}
Future<void> _push(
SettingsRepository settings,
UserThemeModel stored,
String code, {
bool force = false,
}) async {
try {
final token = settings.getSelectedToken();
if (token == null) return;
final sent = '$code:${stored.name}';
if (!force && sent == _lastPushed) return;
await api.pushTheme(
computeVault(token),
writeKey: computeWriteKey(token),
code: code,
name: stored.name,
);
_lastPushed = sent;
} catch (e) {
logger.warning('[ThemeSync] push failed: $e');
}
}
List<int>? _swatchOf(String code) {
final data = code.tryDecodeThemeData();
if (data == null) return null;
return [
data.lightSlot(ThemeColorSlot.accent).toARGB32(),
data.lightSlot(ThemeColorSlot.textPrimary).toARGB32(),
data.lightSlot(ThemeColorSlot.background).toARGB32(),
];
}

View File

@@ -212,7 +212,10 @@ class WidgetCacheHelper {
.sortByStart()
.findAll();
if (lessons.isEmpty) {
lessons = await isarInit.lessonCacheModels.where().sortByStart().findAll();
lessons = await isarInit.lessonCacheModels
.where()
.sortByStart()
.findAll();
}
await updateWidgetCacheFromLessons(
lessons,

View File

@@ -1,447 +1,448 @@
{
"restart_title": "App neu starten",
"restart_body": "Klicke hier, um die App zu öffnen.",
"loginBtn": "Login mit E-Kréta",
"privacyLabel": "Datenschutzerklärung",
"title1": "Alles auf einen Blick",
"subtitle1": "Oben auf der Startseite findest du nützliche Informationen zu deinem Tag.",
"title2": "Hier finden deine Fächer Platz",
"subtitle2": "Hier findest du Statistiken, bevorstehende Prüfungen und sogar deine Noten aus früheren Schuljahren.",
"title3": "Individuell anpassbarer Stundenplan",
"subtitle3": "Wähle auf der Stundenplanseite aus, was du sehen möchtest, und schalte Tests, Hausaufgaben, Pausen und Freistunden ein oder aus.",
"title4": "Viele Extras, die du in Kreta niemals finden wirst",
"subtitle4": "",
"yesterday": "Gestern",
"today": "Heute",
"tomorrow": "Morgen",
"debug_screen": "Entwicklermenü",
"settings_screen": "Einstellungen",
"home": "Startseite",
"grades": "Noten",
"timetable": "Stundenplan",
"other": "Andere",
"refreshing": "Daten werden aktualisiert...",
"reauth": "Login notwendig",
"api_error": "Kréta API Fehler",
"pairing": "Koppel deine Uhr",
"pairing_description": "Möchtest du diese Uhr mit der Firka App koppeln?\nNach der Kopplung kannst du deinen Stundenplan, neue Noten, Tests und Aufgaben einsehen.",
"cancel": "Abbrechen",
"save": "Speichern",
"okay": "Okay",
"pair": "Kopplung",
"beta_title": "Firka - öffentliche Beta",
"beta_body": "Die Anwendung befindet sich noch in der Entwicklung; einige Funktionen sind möglicherweise noch nicht fertiggestellt, funktionieren nicht richtig oder weisen Fehler auf.",
"good_morning": "Guten Morgen, {p}!",
"@good_morning": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"good_day": "Guten Tag, {p}!",
"@good_day": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"n_left_subtitle": "Halte durch, es sind nur noch {n} Stunden übrig!",
"@n_left_subtitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"suffering_almost_over_subtitle": "Du hast es fast geschafft. Pass weiterhin bei deinem Lehrer gut auf.",
"school_ending": "Bist du nervös, {p}?",
"@school_ending": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"tomorrow_subtitle": "So sieht dein morgiger Tag aus.",
"good_afternoon": "Guten Nachmittag, {p}!",
"@good_afternoon": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"good_night": "Guten Abend, {p}!",
"@good_night": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"starting_soon": "Deine erste Unterrichtstunde beginnt gleich!",
"starting_hour": "Stunde",
"starting_hour_plural": "Stunden",
"starting_min": "Minute",
"starting_min_plural": "Minuten",
"starting_sec": "Sekunde",
"starting_sec_plural": "Sekunden",
"subjects": "Fächer",
"your_subjects": "Deine Fächer",
"data": "Details",
"subject_avg": "Notendurchschnitt",
"subject_avg_rounded": "Notendurchschnitt nach Rundung",
"class_avg": "Klassendurchschnitt",
"class_n": "Wöchentliche Stundenzahl",
"tt_no_classes_l1": "Diese Woche hast du keinen Unterricht!",
"tt_no_classes_l2": "Yippee!",
"class_dismissed": "Abgesagte Unterrichtsstunde",
"class_substitution": "Vertretung",
"lesson_subject": "Thema der Stunde",
"tt_settings_toast": "Stundenplan Einstellungen",
"tt_settings_toast_lesson_nos": "Anzahl von Stunden",
"tt_settings_toast_lesson_tests": "Tests & Sonstiges",
"tt_settings_toast_lesson_breaks": "Pausen",
"a_week": "A Woche",
"b_week": "B Woche",
"stats_date": "Datum",
"stats_created_at": "Erstellt am",
"stats_last_mod": "Zuletzt bearbeitet",
"s_developer": "Entwicklereinstellungen",
"s_stats_for_nerds": "Statistiken für Nerds",
"s_settings": "Einstellungen",
"s_a": "Applikation",
"s_ag": "Allgemein",
"s_ag_bell_delay": "Glockenverzögerung",
"s_ag_rounding": "Standardmäßige Rundung",
"s_customization": "Personalisierung",
"s_ag_r1": "1 → 2",
"s_ag_r2": "2 → 3",
"s_ag_r3": "3 → 4",
"s_ag_r4": "4 → 5",
"s_ag_class_avg_on_graph": "Klassendurchschnitt in der Grafik",
"s_ag_navbar": "Navigationsleiste",
"s_ag_left_handed_mode": "Linkshänder Modus",
"s_ag_language_header": "Sprache",
"s_ag_language_auto": "Automatisch",
"s_ag_language_hu": "Ungarisch",
"s_ag_language_en": "Englisch",
"s_ag_language_de": "Deutsch",
"s_c": "Personalisierung",
"s_c_icon_header": "App Symbole",
"s_c_replace_icon": "Symbol ersetzen",
"s_ci_icon_header": "App Symbol",
"s_ci_warning_header": "[!] Im Debug-Modus funktioniert das Ändern des Symbols nicht",
"s_ci_icon_subtitle": "Such dir ein hübsches App-Symbol aus, wenn du das grüne satt hast.",
"s_ci_icon_g1": "Catboy domain",
"s_ci_icon_g2": "Filc-Stift",
"s_ci_icon_g3": "Nostalgie",
"s_ci_icon_g4": "Neu gedacht",
"s_ci_icon_g5": "Referenz",
"s_ci_icon_g6": "Weihnachtslogo-Wettbewerb 2024",
"s_ci_icon_g6_desc": "Von @emilia6_6",
"s_ci_icon_g7": "Pride",
"s_ci_icon_g8": "Pride ",
"s_c_theme_header": "Thema",
"s_c_theme_auto": "Automatisch",
"s_c_theme_light": "Hell",
"s_c_theme_dark": "Dunkel",
"s_ci_child_protection": "Kinderschutz",
"ic_ace": "Asexuell",
"ic_ace_f": "Asexuell",
"ic_bi": "Bisexuell",
"ic_bi_f": "Bisexuell",
"ic_cactus": "Kaktusgarten",
"ic_cc": "Kreative Wolke",
"ic_enby": "Nicht-binär",
"ic_enby_f": "Nicht-binär",
"ic_fidesz": "Orange",
"ic_filc": "Filc Tagebuch",
"ic_filco": "Filc . O",
"ic_galaxy": "Galaxie",
"ic_gay": "Schwul",
"ic_gay_f": "Schwul",
"ic_half_firka_2": "Revolution",
"ic_kreta": "eFirka",
"ic_lesb": "Lesbisch",
"ic_lesb_f": "Lesbisch",
"ic_lgbtq": "LGBTQ+",
"ic_lgbtq_f": "LGBTQ+",
"ic_lgbtqp": "Progression",
"ic_lgbtqp_f": "Progression",
"ic_lidl": "Einkaufen",
"ic_mkkp": "Freikarten",
"ic_nuke": "Nuklear",
"ic_modern": "Modern",
"ic_o1g": "Orbán ist ein Arschloch",
"ic_old": "Domain David",
"ic_original": "Original",
"ic_paper": "Papier",
"ic_pear": "Birne",
"ic_pixel": "Pixel",
"ic_pixelized": "Verpixelt",
"ic_pride": "Weltraumregenbogen",
"ic_proto": "Prototyp",
"ic_refilc": "reFilc",
"ic_refulc": "firk’a",
"ic_repont": "Fünfzig Forint",
"ic_szivacs": "Schwamm",
"ic_tisza": "Árad a firka",
"ic_trans": "Trans",
"ic_trans_f": "Trans",
"ic_void_icon": "Leere",
"ic_xmas1": "Liste der Bösen",
"ic_xmas2": "Geschenk",
"ic_xmas3": "FirWeihnachten",
"wear_phone_unpaired": "Deine Uhr ist nicht mit deinem Handy gekoppelt!",
"wear_phone_disconnected": "Deine Uhr ist nicht mit deinem Handy verbunden!",
"wear_pairing_request_sent": "Die Kopplung läuft, öffne die App auf deinem Smartphone",
"wear_pairing_check_phone": "Setze die Kopplung auf deinem Smartphone fort",
"wear_try_again": "Erneut versuchen",
"breakTxt": "Pause",
"empty_class": "Freistunde",
"timeLeft": "{mins} Minuten übrig",
"@timeLeft": {
"placeholders": {
"mins": {
"type": "num"
}
}
},
"noClasses": "Heute ist Schulfrei, ruh dich aus!",
"noMoreClasses": "Du hast heute keinen Unterricht mehr",
"firstIn": "Deine erste Stunde: {t}",
"@firstIn": {
"placeholders": {
"t": {
"type": "String"
}
}
},
"wearTitle": "{n}. Stunde",
"@wearTitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"view_subject_btn": "Fach anzeigen",
"view_lesson_btn": "Stunde anzeigen",
"date": "Datum",
"tt_settings_toast_lesson_substitution": "Vertretungen",
"tt_settings_toast_lesson_ab_timetable": "Zweiwöchiger Stundenplan",
"s_ag_navbar_desc": "Wähle aus, was in der Navigationsleiste angezeigt werden soll, und ordne die Elemente an. Die übrigen Seiten sind über die Schaltfläche „Mehr“ erreichbar. Du kannst maximal 4 Seiten festlegen.",
"s_ag_navbar_home": "Startseite",
"s_ag_navbar_visible": "Erscheint",
"s_ag_navbar_hidden": "Versteckt",
"tests_tomorrow": "Du hast {tests} Prüfungen",
"@tests_tomorrow": {
"placeholders": {
"tests": {
"type": "String"
}
}
},
"no_tests_tomorrow": "Du hast morgen keine Prüfungen",
"get_ready": "Entspann dich und mach dich bereit für morgen",
"mark_as_done": "Als erledigt markieren",
"mark_as_not_done": "Als unvollständig markieren",
"grade_teacherName": "Name des Lehrers: ",
"grade_strValue": "Textbasierte Bewertung: ",
"no_grades": "Du hast noch keine Noten für dieses Fach.",
"unknown_teacher": "Unbekannter Lehrer",
"s_your_account": "Dein Konto",
"s_acc_kreta": "eKRÉTA Konto",
"s_acc_add": "Neues Konto hinzufügen",
"s_acc_logout": "Abmelden",
"close": "Schließen",
"licensesLabel": "Lizenzen",
"tt_added": "Eingetragen: ",
"happy_birthday": "Alles Gute zum Geburtstag, {p}!",
"@happy_birthday": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"licenseDescription": "Lizenzen für die von der Applikation verwendeten externen Bibliotheken",
"homework": "Hausaufgaben",
"tt_non_instructional_day": "Unterrichtsfreier Schultag",
"tt_public_holiday": "Feiertag",
"tt_spring_break": "Frühlingsferien",
"tt_winter_break": "Winterferien",
"tt_autumn_break": "Herbstferien",
"tt_instructional_day": "Unterrichtstag",
"tt_first_semester_end": "Ende des ersten Semesters",
"tt_holiday": "Ferien",
"tt_rest_day": "Ruhetag",
"tt_first_instructional_day": "Erster Schultag",
"tt_last_instructional_day": "Letzter Schultag",
"tt_last_instructional_day_graduates": "Letzter Schultag für die Absolventen",
"tt_full_day_trip": "Ganztägiger Ausflug",
"tt_quarter_end": "Quartalsende",
"lessons_tomorrow": "{lessons} Stunden morgen",
"@lessons_tomorrow": {
"placeholders": {
"lessons": {
"type": "String"
}
}
},
"subject": "Fach",
"grade_calculator": "Notenrechner",
"grade_calculator_add": "Hinzufügen",
"ghost_grade": "Geist-Note",
"ghost_grades": "Geist-Noten",
"gradesCount": "{count} Note(n)",
"@gradesCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"overall_avg": "Gesamtdurchschnitt",
"now": "Jetzt",
"s_n": "Benachrichtigungen",
"s_n_morning": "Morgendliche Benachrichtigung",
"s_n_morning_time": "Zeitpunkt der Benachrichtigung vor Schulbeginn",
"s_n_live_activity": "Live Aktivität",
"s_n_test": "Testbenachrichtigung senden",
"s_wear": "Wear OS",
"s_wear_os_support": "Wear OS Unterstützung",
"wearSyncNotificationTitle": "Mit Uhr synchronisieren",
"wearSyncNotificationText": "Daten mit Uhr synchronisieren",
"wear_sync_with_phone": "Öffne die Smartphone App, um die Synchronisierung durchzuführen",
"wear_syncing": "Synchronisieren...",
"la_privacy_header": "Datenschutzerklärung für Live Aktivität",
"la_privacy_intro": "Um die Funktion „Live Aktivität“ nutzen zu können, müssen wir bestimmte Daten speichern und verarbeiten. Bitte lies dir die folgenden Informationen sorgfältig durch.",
"la_privacy_section1_title": "Welche Daten speichern wir?",
"la_privacy_section1_body": "Für den Betrieb von Live Aktivität speichern wir die folgenden Daten zusammen mit deiner Gerätekennung:\n\n• Gerätekennung (UUID)\n• Gerätetoken\n• Live-Aktivität-Push-Token\n• APNs-Push-Token\n• Geräte-Hash\n• Spracheinstellung\n• Glockenverzögerung\n\nDeine Stundenplandaten (Tabelle „lessons“) enthalten Folgendes:\n• Fach und Uhrzeit der Unterrichtsstunde\n• Name des Lehrers\n• Name des Raums\n• Nummer der Unterrichtsstunde\n• Thema der Unterrichtsstunde\n• Daten zur Vertretung\n• Kennzeichnung einer ausgefallenen Unterrichtsstunde\n\nDie zeitgesteuerten Benachrichtigungen (Tabelle „scheduled_notifications“) enthalten Folgendes:\n• ID\n• Geräte-ID\n• Zeitpunkt der Benachrichtigung\n• Status und Zeitpunkt der Übermittlung\n• Erstellungs- und Aktualisierungszeitpunkt",
"la_privacy_section2_title": "Wie schützen wir deine Daten?",
"la_privacy_section2_body": "Wir nehmen die Sicherheit deiner Daten ernst:\n\n• Alle Daten in den Tabellen „Geräte“ und „Stunden“ sind verschlüsselt\n• Die Daten werden auf einem sicheren Server gespeichert\n• Wir speichern die Daten nur so lange, wie es erforderlich ist",
"la_privacy_section3_title": "Wie lange speichern wir die Daten?",
"la_privacy_section3_body": "Die Speicherung der Daten ist auf einen minimalen Zeitraum beschränkt:\n\n• Live-Aktivität-Push-Token: Wird so lange gespeichert, wie du an diesem Tag Stunden hast (einschließlich des Zeitraums von zwei Stunden vor der ersten Stunde). Wenn du keine Stunden mehr hast, wird der Wert auf Null gesetzt.\n\n• Stundenplan-Daten: Sie werden nur für die Dauer der Stunden gespeichert und anschließend automatisch gelöscht. Am Freitag nach der letzten Stunde ist die Tabelle mit dem Stundenplan vollständig leer.\n\n• Gerätedaten (Token, Identifikatoren): Sie werden so lange gespeichert, wie die Live-Aktivität-Funktion aktiviert ist. Beim Deaktivieren der Funktion werden diese Daten sofort gelöscht.",
"la_privacy_section4_title": "Wofür verwenden wir die Daten?",
"la_privacy_section4_body": "Wir verwenden die Daten ausschließlich für den Betrieb der Live-Aktivität-Funktion:\n\n• Anzeige des Live-Stundenplans auf dem Sperrbildschirm\n• Versand von Push-Benachrichtigungen bei Stundenwechseln\n• Synchronisierung des Stundenplans auf deinem Gerät\n• Sicherstellung der Zustellung der Benachrichtigungen am Montagmorgen auch nach der wöchentlichen Datenbankbereinigung\n\nWir geben deine Daten nicht an Dritte weiter und verwenden sie nicht für Marketingzwecke.",
"la_privacy_section5_title": "Deine Rechte",
"la_privacy_section5_body": "Gemäß der DSGVO stehen dir folgende Rechte zu:\n\n• Recht auf Auskunft: Die Art der gespeicherten Daten kannst du in dieser Datenschutzerklärung einsehen.\n• Recht auf Löschung: Durch das Deaktivieren der Live-Aktivität-Funktion werden alle mit dieser Funktion verbundenen Daten (Geräte-IDs, Stundenplan) sofort und endgültig von unseren Servern gelöscht.\n• Recht auf Berichtigung: Die Änderung der Stundenplandaten erfolgt im Kréta-System durch die dazu berechtigten Personen (z. B. Lehrkräfte).\n• Widerspruchsrecht: Du kannst der Datenverarbeitung jederzeit widersprechen, indem du die Live-Aktivität-Funktion deaktivierst.",
"la_privacy_footer": "Letzte Aktualisierung der Datenschutzerklärung: November 2025",
"la_privacy_contact": "Hast du eine Frage? Schreib uns an support@firka.app.",
"la_privacy_summary1": "Gerätetoken, Live-Aktivität-Token, Stundenplandaten",
"la_privacy_summary2": "Verschlüsselte Speicherung, sichere Server",
"la_privacy_summary3": "Die Daten werden automatisch gelöscht, sobald sie nicht mehr benötigt werden",
"la_title": "Live Aktivität",
"la_subtitle": "Live-Anzeige des Stundenplans auf dem Sperrbildschirm des Geräts",
"la_privacy_title": "Datenschutzerklärung",
"la_privacy_required": "Um Live Aktivität nutzen zu können, musst du der Datenschutzerklärung zustimmen",
"la_learn_more": "Mehr dazu",
"la_accept": "Ich stimme zu",
"la_decline": "Ich lehne ab",
"runningInDomainBrowser": "Domain-Browser",
"copied": "Kopiert",
"view_day_btn": "Tag anzeigen",
"omission": "Abwesenheit",
"omissions": "Abwesenheiten",
"omission_state_excused": "Entschuldigt",
"omission_state_unexcused": "Unentschuldigt",
"omission_state_pending": "Ausstehend",
"omissions_count": "{state, select, unexcused{{count} unentschuldigt} pending{{count} zu entschuldigen} other{{count}}} Fehlzeiten",
"@omissions_count": {
"placeholders": {
"state": {
"type": "String"
},
"count": {
"type": "int"
}
}
},
"s_beta_warning": "Beta-Warnung",
"s_ag_privacy_ever_declined": "Datenschutz zuvor abgelehnt",
"s_c_tab_appearance": "App-Design",
"s_c_tab_subjects": "Fächer",
"s_c_tab_fonts": "Schriftarten",
"s_c_my_themes": "Meine Themes",
"s_c_manage_subjects": "Fächer verwalten",
"s_c_change_app_icon": "App-Icon ändern",
"s_c_colors_header": "Farben",
"s_c_grade_colors_header": "Notenfarben",
"s_c_title_style_header": "Titelstil",
"s_c_title_weight_header": "Titelstärke",
"s_c_title_weight_subtitle": "Wird nicht von allen Schriftarten unterstützt",
"s_c_title_weight_thin": "Dünn",
"s_c_title_weight_thick": "Fett",
"s_c_capitalization_header": "Groß-/Kleinschreibung",
"s_c_capitalization_lower": "kleinbuchstaben",
"s_c_capitalization_normal": "Normal",
"s_c_capitalization_upper": "GROSSBUCHSTABEN",
"s_c_change": "Ändern",
"s_c_customize": "Anpassen",
"s_c_themes_current": "Aktuell",
"s_c_themes_own": "Eigene",
"s_c_themes_downloaded": "Heruntergeladen",
"s_c_themes_share_current": "Aktuelles Theme teilen",
"s_c_themes_create_new": "Neues Theme erstellen",
"s_c_themes_import": "Theme importieren",
"s_c_themes_use": "Verwenden",
"s_c_themes_continue": "Weiter",
"s_c_themes_own_label": "Eigenes Theme",
"s_c_themes_imported_label": "Importiertes Theme",
"s_c_themes_builtin_label": "Integriertes Theme",
"s_c_themes_builtin_name": "Standard",
"s_c_themes_create_title": "Neues Theme erstellen",
"s_c_themes_create_subtitle": "Gib einen Namen für das Theme ein",
"s_c_themes_create_placeholder": "Themename",
"s_c_themes_delete_title": "Theme löschen",
"s_c_themes_delete_subtitle": "Möchtest du dieses Theme wirklich löschen? Diese Aktion kann rückgängig gemacht werden.",
"s_c_themes_delete_confirm": "Löschen",
"s_about": "Über die App",
"s_extras": "Extras",
"s_other": "Sonstiges",
"grade_weight_x1": "einfache Gewichtung",
"grade_weight_x2": "doppelte Gewichtung",
"grade_weight_x3": "dreifache Gewichtung",
"grade_weight_x4": "vierfache Gewichtung",
"grade_weight_x5": "fünffache Gewichtung",
"grade_weight_percent": "{percent}%ige Gewichtung",
"@grade_weight_percent": {
"placeholders": {
"percent": {
"type": "int"
}
}
},
"surprise_grade_rank_5": "LEGENDÄR",
"surprise_grade_rank_4": "AUSGEZEICHNET",
"surprise_grade_rank_3": "OKAY",
"surprise_grade_rank_2": "SCHWACH",
"surprise_grade_rank_1": "KATASTROPHE",
"new_grades_card": "Du hast neue Noten",
"s_notifications": "Benachrichtigungen",
"s_sticker_map": "Stickerkarte",
"s_qr_reader": "QR-Code-Scanner",
"s_feedback": "Feedback",
"s_a_desc": "Navigation, Sprache, Glocke, Rundung",
"s_c_desc": "Notenfarben, Thema, App-Symbol",
"s_todo": "túdú: program this",
"s_surprise_grades": "Überraschungsnoten",
"s_seasonal_icons": "Saisonale App-Symbole",
"s_uwu_mode": "UwU-Modus",
"s_calendar_sync": "Kalendersynchronisierung",
"s_save_grades": "Noten speichern",
"s_welcome_msg": "Begrüßungsnachricht",
"s_extras_desc": "Überraschungsnoten, Kalendersynchronisierung",
"s_notifications_desc": "Noten, Stundenplanänderungen, Fehlzeiten",
"s_n_all": "Alle",
"s_n_grades": "Neue Noten",
"s_n_homework_tests": "Hausaufgaben & Prüfungen",
"s_n_absences": "Fehlzeiten",
"s_n_lessons": "Stunden",
"s_n_messages": "Nachrichten",
"s_n_by_subject": "Nach Fach"
"restart_title": "App neu starten",
"restart_body": "Klicke hier, um die App zu öffnen.",
"loginBtn": "Login mit E-Kréta",
"privacyLabel": "Datenschutzerklärung",
"title1": "Alles auf einen Blick",
"subtitle1": "Oben auf der Startseite findest du nützliche Informationen zu deinem Tag.",
"title2": "Hier finden deine Fächer Platz",
"subtitle2": "Hier findest du Statistiken, bevorstehende Prüfungen und sogar deine Noten aus früheren Schuljahren.",
"title3": "Individuell anpassbarer Stundenplan",
"subtitle3": "Wähle auf der Stundenplanseite aus, was du sehen möchtest, und schalte Tests, Hausaufgaben, Pausen und Freistunden ein oder aus.",
"title4": "Viele Extras, die du in Kreta niemals finden wirst",
"subtitle4": "",
"yesterday": "Gestern",
"today": "Heute",
"tomorrow": "Morgen",
"debug_screen": "Entwicklermenü",
"settings_screen": "Einstellungen",
"home": "Startseite",
"grades": "Noten",
"timetable": "Stundenplan",
"other": "Andere",
"refreshing": "Daten werden aktualisiert...",
"reauth": "Login notwendig",
"api_error": "Kréta API Fehler",
"pairing": "Koppel deine Uhr",
"pairing_description": "Möchtest du diese Uhr mit der Firka App koppeln?\nNach der Kopplung kannst du deinen Stundenplan, neue Noten, Tests und Aufgaben einsehen.",
"cancel": "Abbrechen",
"save": "Speichern",
"okay": "Okay",
"pair": "Kopplung",
"beta_title": "Firka - öffentliche Beta",
"beta_body": "Die Anwendung befindet sich noch in der Entwicklung; einige Funktionen sind möglicherweise noch nicht fertiggestellt, funktionieren nicht richtig oder weisen Fehler auf.",
"good_morning": "Guten Morgen, {p}!",
"@good_morning": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"good_day": "Guten Tag, {p}!",
"@good_day": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"n_left_subtitle": "Halte durch, es sind nur noch {n} Stunden übrig!",
"@n_left_subtitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"suffering_almost_over_subtitle": "Du hast es fast geschafft. Pass weiterhin bei deinem Lehrer gut auf.",
"school_ending": "Bist du nervös, {p}?",
"@school_ending": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"tomorrow_subtitle": "So sieht dein morgiger Tag aus.",
"good_afternoon": "Guten Nachmittag, {p}!",
"@good_afternoon": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"good_night": "Guten Abend, {p}!",
"@good_night": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"starting_soon": "Deine erste Unterrichtstunde beginnt gleich!",
"starting_hour": "Stunde",
"starting_hour_plural": "Stunden",
"starting_min": "Minute",
"starting_min_plural": "Minuten",
"starting_sec": "Sekunde",
"starting_sec_plural": "Sekunden",
"subjects": "Fächer",
"your_subjects": "Deine Fächer",
"data": "Details",
"subject_avg": "Notendurchschnitt",
"subject_avg_rounded": "Notendurchschnitt nach Rundung",
"class_avg": "Klassendurchschnitt",
"class_n": "Wöchentliche Stundenzahl",
"tt_no_classes_l1": "Diese Woche hast du keinen Unterricht!",
"tt_no_classes_l2": "Yippee!",
"class_dismissed": "Abgesagte Unterrichtsstunde",
"class_substitution": "Vertretung",
"lesson_subject": "Thema der Stunde",
"tt_settings_toast": "Stundenplan Einstellungen",
"tt_settings_toast_lesson_nos": "Anzahl von Stunden",
"tt_settings_toast_lesson_tests": "Tests & Sonstiges",
"tt_settings_toast_lesson_breaks": "Pausen",
"a_week": "A Woche",
"b_week": "B Woche",
"stats_date": "Datum",
"stats_created_at": "Erstellt am",
"stats_last_mod": "Zuletzt bearbeitet",
"s_developer": "Entwicklereinstellungen",
"s_stats_for_nerds": "Statistiken für Nerds",
"s_settings": "Einstellungen",
"s_a": "Applikation",
"s_ag": "Allgemein",
"s_ag_bell_delay": "Glockenverzögerung",
"s_ag_rounding": "Standardmäßige Rundung",
"s_customization": "Personalisierung",
"s_ag_r1": "1 → 2",
"s_ag_r2": "2 → 3",
"s_ag_r3": "3 → 4",
"s_ag_r4": "4 → 5",
"s_ag_class_avg_on_graph": "Klassendurchschnitt in der Grafik",
"s_ag_navbar": "Navigationsleiste",
"s_ag_left_handed_mode": "Linkshänder Modus",
"s_ag_language_header": "Sprache",
"s_ag_language_auto": "Automatisch",
"s_ag_language_hu": "Ungarisch",
"s_ag_language_en": "Englisch",
"s_ag_language_de": "Deutsch",
"s_c": "Personalisierung",
"s_c_icon_header": "App Symbole",
"s_c_replace_icon": "Symbol ersetzen",
"s_ci_icon_header": "App Symbol",
"s_ci_restart_notice": "Bei manchen Launchern erscheint das neue Symbol erst, wenn die App neu geöffnet wird.",
"s_ci_warning_header": "[!] Im Debug-Modus funktioniert das Ändern des Symbols nicht",
"s_ci_icon_subtitle": "Such dir ein hübsches App-Symbol aus, wenn du das grüne satt hast.",
"s_ci_icon_g1": "Catboy domain",
"s_ci_icon_g2": "Filc-Stift",
"s_ci_icon_g3": "Nostalgie",
"s_ci_icon_g4": "Neu gedacht",
"s_ci_icon_g5": "Referenz",
"s_ci_icon_g6": "Weihnachtslogo-Wettbewerb 2024",
"s_ci_icon_g6_desc": "Von @emilia6_6",
"s_ci_icon_g7": "Pride",
"s_ci_icon_g8": "Pride ",
"s_c_theme_header": "Thema",
"s_c_theme_auto": "Automatisch",
"s_c_theme_light": "Hell",
"s_c_theme_dark": "Dunkel",
"s_ci_child_protection": "Kinderschutz",
"ic_ace": "Asexuell",
"ic_ace_f": "Asexuell",
"ic_bi": "Bisexuell",
"ic_bi_f": "Bisexuell",
"ic_cactus": "Kaktusgarten",
"ic_cc": "Kreative Wolke",
"ic_enby": "Nicht-binär",
"ic_enby_f": "Nicht-binär",
"ic_fidesz": "Orange",
"ic_filc": "Filc Tagebuch",
"ic_filco": "Filc . O",
"ic_galaxy": "Galaxie",
"ic_gay": "Schwul",
"ic_gay_f": "Schwul",
"ic_half_firka_2": "Revolution",
"ic_kreta": "eFirka",
"ic_lesb": "Lesbisch",
"ic_lesb_f": "Lesbisch",
"ic_lgbtq": "LGBTQ+",
"ic_lgbtq_f": "LGBTQ+",
"ic_lgbtqp": "Progression",
"ic_lgbtqp_f": "Progression",
"ic_lidl": "Einkaufen",
"ic_mkkp": "Freikarten",
"ic_nuke": "Nuklear",
"ic_modern": "Modern",
"ic_o1g": "Orbán ist ein Arschloch",
"ic_old": "Domain David",
"ic_original": "Original",
"ic_paper": "Papier",
"ic_pear": "Birne",
"ic_pixel": "Pixel",
"ic_pixelized": "Verpixelt",
"ic_pride": "Weltraumregenbogen",
"ic_proto": "Prototyp",
"ic_refilc": "reFilc",
"ic_refulc": "firk’a",
"ic_repont": "Fünfzig Forint",
"ic_szivacs": "Schwamm",
"ic_tisza": "Árad a firka",
"ic_trans": "Trans",
"ic_trans_f": "Trans",
"ic_void_icon": "Leere",
"ic_xmas1": "Liste der Bösen",
"ic_xmas2": "Geschenk",
"ic_xmas3": "FirWeihnachten",
"wear_phone_unpaired": "Deine Uhr ist nicht mit deinem Handy gekoppelt!",
"wear_phone_disconnected": "Deine Uhr ist nicht mit deinem Handy verbunden!",
"wear_pairing_request_sent": "Die Kopplung läuft, öffne die App auf deinem Smartphone",
"wear_pairing_check_phone": "Setze die Kopplung auf deinem Smartphone fort",
"wear_try_again": "Erneut versuchen",
"breakTxt": "Pause",
"empty_class": "Freistunde",
"timeLeft": "{mins} Minuten übrig",
"@timeLeft": {
"placeholders": {
"mins": {
"type": "num"
}
}
},
"noClasses": "Heute ist Schulfrei, ruh dich aus!",
"noMoreClasses": "Du hast heute keinen Unterricht mehr",
"firstIn": "Deine erste Stunde: {t}",
"@firstIn": {
"placeholders": {
"t": {
"type": "String"
}
}
},
"wearTitle": "{n}. Stunde",
"@wearTitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"view_subject_btn": "Fach anzeigen",
"view_lesson_btn": "Stunde anzeigen",
"date": "Datum",
"tt_settings_toast_lesson_substitution": "Vertretungen",
"tt_settings_toast_lesson_ab_timetable": "Zweiwöchiger Stundenplan",
"s_ag_navbar_desc": "Wähle aus, was in der Navigationsleiste angezeigt werden soll, und ordne die Elemente an. Die übrigen Seiten sind über die Schaltfläche „Mehr“ erreichbar. Du kannst maximal 4 Seiten festlegen.",
"s_ag_navbar_home": "Startseite",
"s_ag_navbar_visible": "Erscheint",
"s_ag_navbar_hidden": "Versteckt",
"tests_tomorrow": "Du hast {tests} Prüfungen",
"@tests_tomorrow": {
"placeholders": {
"tests": {
"type": "String"
}
}
},
"no_tests_tomorrow": "Du hast morgen keine Prüfungen",
"get_ready": "Entspann dich und mach dich bereit für morgen",
"mark_as_done": "Als erledigt markieren",
"mark_as_not_done": "Als unvollständig markieren",
"grade_teacherName": "Name des Lehrers: ",
"grade_strValue": "Textbasierte Bewertung: ",
"no_grades": "Du hast noch keine Noten für dieses Fach.",
"unknown_teacher": "Unbekannter Lehrer",
"s_your_account": "Dein Konto",
"s_acc_kreta": "eKRÉTA Konto",
"s_acc_add": "Neues Konto hinzufügen",
"s_acc_logout": "Abmelden",
"close": "Schließen",
"licensesLabel": "Lizenzen",
"tt_added": "Eingetragen: ",
"happy_birthday": "Alles Gute zum Geburtstag, {p}!",
"@happy_birthday": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"licenseDescription": "Lizenzen für die von der Applikation verwendeten externen Bibliotheken",
"homework": "Hausaufgaben",
"tt_non_instructional_day": "Unterrichtsfreier Schultag",
"tt_public_holiday": "Feiertag",
"tt_spring_break": "Frühlingsferien",
"tt_winter_break": "Winterferien",
"tt_autumn_break": "Herbstferien",
"tt_instructional_day": "Unterrichtstag",
"tt_first_semester_end": "Ende des ersten Semesters",
"tt_holiday": "Ferien",
"tt_rest_day": "Ruhetag",
"tt_first_instructional_day": "Erster Schultag",
"tt_last_instructional_day": "Letzter Schultag",
"tt_last_instructional_day_graduates": "Letzter Schultag für die Absolventen",
"tt_full_day_trip": "Ganztägiger Ausflug",
"tt_quarter_end": "Quartalsende",
"lessons_tomorrow": "{lessons} Stunden morgen",
"@lessons_tomorrow": {
"placeholders": {
"lessons": {
"type": "String"
}
}
},
"subject": "Fach",
"grade_calculator": "Notenrechner",
"grade_calculator_add": "Hinzufügen",
"ghost_grade": "Geist-Note",
"ghost_grades": "Geist-Noten",
"gradesCount": "{count} Note(n)",
"@gradesCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"overall_avg": "Gesamtdurchschnitt",
"now": "Jetzt",
"s_n": "Benachrichtigungen",
"s_n_morning": "Morgendliche Benachrichtigung",
"s_n_morning_time": "Zeitpunkt der Benachrichtigung vor Schulbeginn",
"s_n_live_activity": "Live Aktivität",
"s_n_test": "Testbenachrichtigung senden",
"s_wear": "Wear OS",
"s_wear_os_support": "Wear OS Unterstützung",
"wearSyncNotificationTitle": "Mit Uhr synchronisieren",
"wearSyncNotificationText": "Daten mit Uhr synchronisieren",
"wear_sync_with_phone": "Öffne die Smartphone App, um die Synchronisierung durchzuführen",
"wear_syncing": "Synchronisieren...",
"la_privacy_header": "Datenschutzerklärung für Live Aktivität",
"la_privacy_intro": "Um die Funktion „Live Aktivität“ nutzen zu können, müssen wir bestimmte Daten speichern und verarbeiten. Bitte lies dir die folgenden Informationen sorgfältig durch.",
"la_privacy_section1_title": "Welche Daten speichern wir?",
"la_privacy_section1_body": "Für den Betrieb von Live Aktivität speichern wir die folgenden Daten zusammen mit deiner Gerätekennung:\n\n• Gerätekennung (UUID)\n• Gerätetoken\n• Live-Aktivität-Push-Token\n• APNs-Push-Token\n• Geräte-Hash\n• Spracheinstellung\n• Glockenverzögerung\n\nDeine Stundenplandaten (Tabelle „lessons“) enthalten Folgendes:\n• Fach und Uhrzeit der Unterrichtsstunde\n• Name des Lehrers\n• Name des Raums\n• Nummer der Unterrichtsstunde\n• Thema der Unterrichtsstunde\n• Daten zur Vertretung\n• Kennzeichnung einer ausgefallenen Unterrichtsstunde\n\nDie zeitgesteuerten Benachrichtigungen (Tabelle „scheduled_notifications“) enthalten Folgendes:\n• ID\n• Geräte-ID\n• Zeitpunkt der Benachrichtigung\n• Status und Zeitpunkt der Übermittlung\n• Erstellungs- und Aktualisierungszeitpunkt",
"la_privacy_section2_title": "Wie schützen wir deine Daten?",
"la_privacy_section2_body": "Wir nehmen die Sicherheit deiner Daten ernst:\n\n• Alle Daten in den Tabellen „Geräte“ und „Stunden“ sind verschlüsselt\n• Die Daten werden auf einem sicheren Server gespeichert\n• Wir speichern die Daten nur so lange, wie es erforderlich ist",
"la_privacy_section3_title": "Wie lange speichern wir die Daten?",
"la_privacy_section3_body": "Die Speicherung der Daten ist auf einen minimalen Zeitraum beschränkt:\n\n• Live-Aktivität-Push-Token: Wird so lange gespeichert, wie du an diesem Tag Stunden hast (einschließlich des Zeitraums von zwei Stunden vor der ersten Stunde). Wenn du keine Stunden mehr hast, wird der Wert auf Null gesetzt.\n\n• Stundenplan-Daten: Sie werden nur für die Dauer der Stunden gespeichert und anschließend automatisch gelöscht. Am Freitag nach der letzten Stunde ist die Tabelle mit dem Stundenplan vollständig leer.\n\n• Gerätedaten (Token, Identifikatoren): Sie werden so lange gespeichert, wie die Live-Aktivität-Funktion aktiviert ist. Beim Deaktivieren der Funktion werden diese Daten sofort gelöscht.",
"la_privacy_section4_title": "Wofür verwenden wir die Daten?",
"la_privacy_section4_body": "Wir verwenden die Daten ausschließlich für den Betrieb der Live-Aktivität-Funktion:\n\n• Anzeige des Live-Stundenplans auf dem Sperrbildschirm\n• Versand von Push-Benachrichtigungen bei Stundenwechseln\n• Synchronisierung des Stundenplans auf deinem Gerät\n• Sicherstellung der Zustellung der Benachrichtigungen am Montagmorgen auch nach der wöchentlichen Datenbankbereinigung\n\nWir geben deine Daten nicht an Dritte weiter und verwenden sie nicht für Marketingzwecke.",
"la_privacy_section5_title": "Deine Rechte",
"la_privacy_section5_body": "Gemäß der DSGVO stehen dir folgende Rechte zu:\n\n• Recht auf Auskunft: Die Art der gespeicherten Daten kannst du in dieser Datenschutzerklärung einsehen.\n• Recht auf Löschung: Durch das Deaktivieren der Live-Aktivität-Funktion werden alle mit dieser Funktion verbundenen Daten (Geräte-IDs, Stundenplan) sofort und endgültig von unseren Servern gelöscht.\n• Recht auf Berichtigung: Die Änderung der Stundenplandaten erfolgt im Kréta-System durch die dazu berechtigten Personen (z. B. Lehrkräfte).\n• Widerspruchsrecht: Du kannst der Datenverarbeitung jederzeit widersprechen, indem du die Live-Aktivität-Funktion deaktivierst.",
"la_privacy_footer": "Letzte Aktualisierung der Datenschutzerklärung: November 2025",
"la_privacy_contact": "Hast du eine Frage? Schreib uns an support@firka.app.",
"la_privacy_summary1": "Gerätetoken, Live-Aktivität-Token, Stundenplandaten",
"la_privacy_summary2": "Verschlüsselte Speicherung, sichere Server",
"la_privacy_summary3": "Die Daten werden automatisch gelöscht, sobald sie nicht mehr benötigt werden",
"la_title": "Live Aktivität",
"la_subtitle": "Live-Anzeige des Stundenplans auf dem Sperrbildschirm des Geräts",
"la_privacy_title": "Datenschutzerklärung",
"la_privacy_required": "Um Live Aktivität nutzen zu können, musst du der Datenschutzerklärung zustimmen",
"la_learn_more": "Mehr dazu",
"la_accept": "Ich stimme zu",
"la_decline": "Ich lehne ab",
"runningInDomainBrowser": "Domain-Browser",
"copied": "Kopiert",
"view_day_btn": "Tag anzeigen",
"omission": "Abwesenheit",
"omissions": "Abwesenheiten",
"omission_state_excused": "Entschuldigt",
"omission_state_unexcused": "Unentschuldigt",
"omission_state_pending": "Ausstehend",
"omissions_count": "{state, select, unexcused{{count} unentschuldigt} pending{{count} zu entschuldigen} other{{count}}} Fehlzeiten",
"@omissions_count": {
"placeholders": {
"state": {
"type": "String"
},
"count": {
"type": "int"
}
}
},
"s_beta_warning": "Beta-Warnung",
"s_ag_privacy_ever_declined": "Datenschutz zuvor abgelehnt",
"s_c_tab_appearance": "App-Design",
"s_c_tab_subjects": "Fächer",
"s_c_tab_fonts": "Schriftarten",
"s_c_my_themes": "Meine Themes",
"s_c_manage_subjects": "Fächer verwalten",
"s_c_change_app_icon": "App-Icon ändern",
"s_c_colors_header": "Farben",
"s_c_grade_colors_header": "Notenfarben",
"s_c_title_style_header": "Titelstil",
"s_c_title_weight_header": "Titelstärke",
"s_c_title_weight_subtitle": "Wird nicht von allen Schriftarten unterstützt",
"s_c_title_weight_thin": "Dünn",
"s_c_title_weight_thick": "Fett",
"s_c_capitalization_header": "Groß-/Kleinschreibung",
"s_c_capitalization_lower": "kleinbuchstaben",
"s_c_capitalization_normal": "Normal",
"s_c_capitalization_upper": "GROSSBUCHSTABEN",
"s_c_change": "Ändern",
"s_c_customize": "Anpassen",
"s_c_themes_current": "Aktuell",
"s_c_themes_own": "Eigene",
"s_c_themes_downloaded": "Heruntergeladen",
"s_c_themes_share_current": "Aktuelles Theme teilen",
"s_c_themes_create_new": "Neues Theme erstellen",
"s_c_themes_import": "Theme importieren",
"s_c_themes_use": "Verwenden",
"s_c_themes_continue": "Weiter",
"s_c_themes_own_label": "Eigenes Theme",
"s_c_themes_imported_label": "Importiertes Theme",
"s_c_themes_builtin_label": "Integriertes Theme",
"s_c_themes_builtin_name": "Standard",
"s_c_themes_create_title": "Neues Theme erstellen",
"s_c_themes_create_subtitle": "Gib einen Namen für das Theme ein",
"s_c_themes_create_placeholder": "Themename",
"s_c_themes_delete_title": "Theme löschen",
"s_c_themes_delete_subtitle": "Möchtest du dieses Theme wirklich löschen? Diese Aktion kann rückgängig gemacht werden.",
"s_c_themes_delete_confirm": "Löschen",
"s_about": "Über die App",
"s_extras": "Extras",
"s_other": "Sonstiges",
"grade_weight_x1": "einfache Gewichtung",
"grade_weight_x2": "doppelte Gewichtung",
"grade_weight_x3": "dreifache Gewichtung",
"grade_weight_x4": "vierfache Gewichtung",
"grade_weight_x5": "fünffache Gewichtung",
"grade_weight_percent": "{percent}%ige Gewichtung",
"@grade_weight_percent": {
"placeholders": {
"percent": {
"type": "int"
}
}
},
"surprise_grade_rank_5": "LEGENDÄR",
"surprise_grade_rank_4": "AUSGEZEICHNET",
"surprise_grade_rank_3": "OKAY",
"surprise_grade_rank_2": "SCHWACH",
"surprise_grade_rank_1": "KATASTROPHE",
"new_grades_card": "Du hast neue Noten",
"s_notifications": "Benachrichtigungen",
"s_sticker_map": "Stickerkarte",
"s_qr_reader": "QR-Code-Scanner",
"s_feedback": "Feedback",
"s_a_desc": "Navigation, Sprache, Glocke, Rundung",
"s_c_desc": "Notenfarben, Thema, App-Symbol",
"s_todo": "túdú: program this",
"s_surprise_grades": "Überraschungsnoten",
"s_seasonal_icons": "Saisonale App-Symbole",
"s_uwu_mode": "UwU-Modus",
"s_calendar_sync": "Kalendersynchronisierung",
"s_save_grades": "Noten speichern",
"s_welcome_msg": "Begrüßungsnachricht",
"s_extras_desc": "Überraschungsnoten, Kalendersynchronisierung",
"s_notifications_desc": "Noten, Stundenplanänderungen, Fehlzeiten",
"s_n_all": "Alle",
"s_n_grades": "Neue Noten",
"s_n_homework_tests": "Hausaufgaben & Prüfungen",
"s_n_absences": "Fehlzeiten",
"s_n_lessons": "Stunden",
"s_n_messages": "Nachrichten",
"s_n_by_subject": "Nach Fach"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,406 +1,407 @@
{
"tt_settings_toast_lesson_ab_timetable": "Dwutygodniowy plan lekcji",
"restart_title": "Uruchom ponownie aplikację",
"s_wear": "Wear OS",
"s_ag_navbar_home": "Strona główna",
"tt_holiday": "Dzień świąteczny",
"pairing": "Łączenie lekcji",
"s_c_replace_icon": "­Zmiana ikony",
"close": "Zamknij",
"ghost_grade": "Szellem jegy",
"la_privacy_required": "A Live Activity használatához el kell fogadnod az adatvédelmi tájékoztatót",
"debug_screen": "Menu deweloperskie",
"save": "Zapisz",
"starting_hour_plural": "godzina",
"ic_void_icon": "Nic",
"wearSyncNotificationText": "Óra adatainak szinkronban tartása",
"wear_pairing_check_phone": "Folytasd a párosítást a telefonodon",
"la_privacy_section2_body": "Komolyan vesszük az adataid biztonságát:\n\n• A devices és lessons táblákban lévő összes adat titkosítva van\n• Az adatokat biztonságos szerveren tároljuk\n• Csak a szükséges időtartamig tároljuk az adatokat",
"unknown_teacher": "Nieznany nauczyciel",
"la_privacy_header": "Live Activity adatvédelmi tájékoztató",
"title4": "Wiele dodatkowych rzeczy, których nigdy nie znajdziesz w Kréta.",
"gradesCount": "{count} jegy",
"@gradesCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"s_ag_rounding": "Domyślne zaokrąglanie",
"wear_syncing": "Szinkronizálás...",
"s_ci_icon_g8": "Pride ",
"ic_lgbtq_f": "LGBTQ+",
"licensesLabel": "Licencek",
"s_c": "Dostosowanie",
"starting_hour": "godzina",
"wear_try_again": "Újra",
"title1": "Poznaj wszystko na pierwszy rzut oka",
"subtitle1": "Na górze strony głównej możesz zobaczyć przydatne informacje o swoim dniu.",
"subject_avg": "Średnia z przedmiotu",
"view_subject_btn": "Zobacz przedmiot",
"tt_winter_break": "Zimowa przerwa",
"stats_created_at": "Utworzono",
"s_n": "Értesítések",
"tt_settings_toast": "Ustawienia planu lekcji",
"refreshing": "Aktualizowanie danych...",
"la_privacy_footer": "Az adatvédelmi tájékoztató utolsó frissítése: 2025. november",
"la_privacy_section5_body": "A GDPR alapján az alábbi jogokkal rendelkezel:\n\n• Hozzáférési jog: A tárolt adatok típusát ebben az adatvédelmi tájékoztatóban tekintheted meg.\n• Törlési jog: A Live Activity funkció kikapcsolásával minden, a funkcióhoz kapcsolódó adat (eszközazonosítók, órarend) azonnal és véglegesen törlődik a szervereinkről.\n• Módosítási jog: Az órarendi adatok módosítása a Kréta rendszerben történik, az arra jogosult személyek (pl. tanárok) által.\n• Tiltakozási jog: Az adatkezelés ellen bármikor tiltakozhatsz a Live Activity funkció kikapcsolásával.",
"grades": "Oceny",
"good_afternoon": "Miłego popołudnia, {p}!",
"@good_afternoon": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"tt_last_instructional_day_graduates": "Ostatni dzień zajęć dla klas kończących szkołę",
"s_ci_icon_g3": "Nostalgia",
"tt_first_instructional_day": "Pierwszy dzień nauki",
"ic_gay": "Gej",
"ic_nuke": "Nuklearny",
"noMoreClasses": "Nincs több órád ma",
"ic_lesb_f": "Lesbijka",
"s_acc_add": "Dodaj nowe konto",
"ic_old": "Domain Dave",
"licenseDescription": "Az alkalmazás által használt külső könyvtárak licencei",
"tt_autumn_break": "Jesienna przerwa",
"s_ci_icon_header": "Ikona aplikacji",
"empty_class": "Lyukasóra",
"lesson_subject": "Przedmiot lekcji",
"pairing_description": "Czy chcesz połączyć tę lekcję z aplikacją Firka?\nPo połączeniu zobaczysz plan lekcji oraz swoje najnowsze oceny, sprawdziany i zadania.",
"date": "Godzina lekcji",
"ic_szivacs": "Gąbka",
"starting_sec_plural": "sekunda",
"s_ci_icon_g6_desc": "przez @emilia6_6",
"ic_filco": "Filc . O",
"good_day": "Miłego dnia, {p}!",
"@good_day": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"tt_full_day_trip": "Całodniowa wycieczka",
"wear_pairing_request_sent": "Párosítás folyamatban, nyisd meg az appot a telefonodon",
"grade_calculator_add": "Hozzáadás",
"ic_kreta": "eFIRKA",
"subtitle2": "Zobacz statystyki, nadchodzące sprawdziany, a nawet oceny z poprzednich lat szkolnych.",
"s_n_live_activity": "Live Activity",
"wear_phone_disconnected": "Az órád nincs csatlakoztatva a telefonoddal!",
"la_privacy_section3_body": "Az adatok tárolása minimális időtartamra korlátozódik:\n\n• Live Activity push token: Addig van tárolva, amíg óráid vannak az adott napon (beleértve az első óra előtti 2 órás időszakot is). Ha nincs több órád, az érték null lesz.\n\n• Órarendi adatok: Csak az órák időtartamára tárolódnak, majd automatikusan törlődnek. Pénteken az utolsó óra után az órarendet tartalmazó tábla teljesen üres lesz.\n\n• Eszközadatok (token, azonosítók): Addig van tárolva, amíg a Live Activity funkció engedélyezve van. A funkció kikapcsolásakor ezek az adatok azonnal törlésre kerülnek.",
"tt_last_instructional_day": "Ostatni dzień nauki",
"tt_settings_toast_lesson_nos": "Numery lekcji",
"s_ci_icon_g5": "Referencja",
"tt_settings_toast_lesson_substitution": "Zastępstwa",
"tt_added": "Utworzono: ",
"la_privacy_section3_title": "Meddig tároljuk az adatokat?",
"school_ending": "Denerwujesz się, {p}?",
"@school_ending": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"s_wear_os_support": "Wear OS támogatás",
"ic_enby": "Niebinarna",
"tt_settings_toast_lesson_tests": "Sprawdziany i inne",
"happy_birthday": "Wszystkiego najlepszego, {p}!",
"@happy_birthday": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"api_error": "Błąd API Kréta",
"ic_trans_f": "Trans",
"ic_enby_f": "Niebinarna",
"ic_lidl": "Zakupy",
"tests_tomorrow": "Masz {tests} sprawdzianów",
"@tests_tomorrow": {
"placeholders": {
"tests": {
"type": "String"
}
}
},
"ic_trans": "Trans",
"s_ci_icon_g4": "Przeprojektowany",
"tt_public_holiday": "Dzień wolny od pracy",
"s_ag_language_header": "Język",
"tt_instructional_day": "Dzień zajęć szkolnych",
"ic_cc": "Chmura Kreatywna",
"la_privacy_title": "Adatvédelmi tájékoztató",
"s_ag_r1": "1 → 2",
"s_c_theme_light": "Jasny",
"title2": "Twoje przedmioty wygodnie się tutaj mieszczą",
"tomorrow_subtitle": "Oto Twój jutrzejszy dzień.",
"s_n_test": "Teszt értesítés küldése",
"starting_min_plural": "minuta",
"ic_mkkp": "Darmowe oceny",
"subjects": "­Przedmioty",
"s_c_theme_header": "Motyw",
"s_a": "Aplikacja",
"loginBtn": "Zaloguj się za pomocą konta E-Kréta",
"mark_as_not_done": "Oznacz jako nieukończone",
"wearSyncNotificationTitle": "Szinkronizálás az órával",
"mark_as_done": "­Oznacz jako ukończone",
"s_ag": "Ogólne",
"ic_xmas3": "FirŚwięta",
"data": "Dane",
"la_learn_more": "Bővebben",
"ic_pixelized": "Spikselizowany",
"other": "Więcej",
"ic_o1g": "Orbán to pizda",
"la_privacy_section2_title": "Hogyan védjük az adataidat?",
"good_night": "Miłego wieczoru, {p}!",
"@good_night": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"s_ag_r4": "4 → 5",
"s_ci_icon_g1": "Catboy domain",
"starting_min": "minuta",
"ic_pride": "Kosmiczna tęcza",
"suffering_almost_over_subtitle": "Już niedługo będziesz wolny. Uważaj na nauczyciela.",
"la_privacy_section5_title": "Jogaid",
"ghost_grades": "Szellem jegyek",
"s_customization": "Personalizacja",
"tomorrow": "Jutro",
"breakTxt": "Szünet",
"la_privacy_section1_title": "Milyen adatokat tárolunk?",
"s_ci_warning_header": "[!] W trybie debug zmiana ikony nie będzie działać",
"tt_spring_break": "Wiosenna przerwa",
"s_ag_language_hu": "Węgierski",
"tt_no_classes_l2": "Yippee!",
"class_n": "­Liczba godzin tygodniowo",
"s_settings": "Ustawienia",
"subject_avg_rounded": "Średnia z przedmiotu po zaokrągleniu",
"class_dismissed": "Odwołana lekcja",
"s_ci_icon_subtitle": "Wybierz piękną ikonę aplikacji, jeśli znudził Ci się zielony kolor.",
"s_ci_icon_g6": "Konkurs na świąteczne logo 2024",
"ic_lgbtqp": "Postęp",
"beta_title": "Firka – publiczna beta",
"la_title": "Live Activity",
"n_left_subtitle": "Wytrzymaj, zostało tylko {n} godzin!",
"@n_left_subtitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"pair": "Parowanie",
"grade_strValue": "Ocena opisowa: ",
"s_acc_kreta": "Konta eKRÉTA",
"ic_pear": "Gruszka",
"s_ag_bell_delay": "Przesunięcie dzwonka",
"s_your_account": "Twoje konto",
"wear_phone_unpaired": "Az órád nincs párosítva a telefonoddal!",
"tt_non_instructional_day": "Dzień wolny od zajęć dydaktycznych",
"b_week": "Tydzień B",
"home": "Strona główna",
"subject": "Tantárgy",
"s_c_icon_header": "Ikony aplikacji",
"cancel": "Anuluj",
"yesterday": "Wczoraj",
"ic_repont": "Pięćdziesiąt groszy",
"ic_cactus": "Kaktusowy zagajnik",
"get_ready": "Odpocznij i przygotuj się",
"ic_lesb": "Lesbijka",
"s_acc_logout": "Wyloguj się",
"stats_date": "Data",
"your_subjects": "Twoje przedmioty",
"reauth": "Wymagane logowanie",
"good_morning": "Dzień dobry, {p}!",
"@good_morning": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"firstIn": "Első órád: {t}",
"@firstIn": {
"placeholders": {
"t": {
"type": "String"
}
}
},
"la_privacy_section4_title": "Mire használjuk az adatokat?",
"ic_xmas2": "Prezent",
"settings_screen": "Ustawienia",
"la_privacy_summary1": "Eszköz tokenek, Live Activity tokenek, órarendi adatok",
"title3": "Personalizowany plan lekcji",
"ic_filc": "Filc Dziennik",
"s_c_theme_dark": "Ciemny",
"grade_calculator": "Jegy kalkulátor",
"la_accept": "Elfogadom",
"s_stats_for_nerds": "Pokaż dodatkowe informacje",
"s_ag_r3": "3 → 4",
"ic_tisza": "Árad a firka",
"okay": "Ok",
"s_developer": "Ustawienia deweloperskie",
"privacyLabel": "Polityka prywatności",
"stats_last_mod": "Ostatnio zmodyfikowano",
"s_ag_navbar_desc": "Wybierz, co ma się wyświetlać na pasku nawigacyjnym, i uporządkuj elementy. Pozostałe strony są dostępne przez przycisk „więcej”. Możesz przypiąć maksymalnie 4 strony.",
"a_week": "Tydzień",
"s_ag_r2": "2 → 3",
"wearTitle": "{n}. óra",
"@wearTitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"timetable": "Plan lekcji",
"ic_ace": "Aseksualny",
"s_ci_icon_g2": "­Pisak",
"s_ci_child_protection": "Ochrona dzieci",
"s_ag_navbar_hidden": "Ukryte",
"runningInDomainBrowser": "Przeglądarka domen",
"noClasses": "Nincs ma iskola, pihend ki magad!",
"ic_bi": "Biseksualny",
"ic_proto": "Prototyp",
"tt_first_semester_end": "Koniec pierwszego semestru",
"la_decline": "Elutasítom",
"s_c_theme_auto": "Automatyczny",
"ic_paper": "Papier",
"ic_xmas1": "Lista złych",
"s_ci_icon_g7": "Pride",
"lessons_tomorrow": "{lessons} órád lesz",
"@lessons_tomorrow": {
"placeholders": {
"lessons": {
"type": "String"
}
}
},
"ic_lgbtq": "LGBTQ+",
"subtitle3": "Wybierz, co chcesz widzieć na stronie planu lekcji. Włącz lub wyłącz sprawdziany, prace domowe, przerwy oraz okienka.",
"ic_original": "Oryginał",
"ic_refilc": "reFilc",
"la_privacy_contact": "Kérdésed van? Keress minket a support @firka.app címen.",
"tt_no_classes_l1": "W tym dniu nie masz lekcji!",
"s_ag_class_avg_on_graph": "Średnia klasy na wykresie",
"class_substitution": "Zastępstwo",
"ic_half_firka_2": "Rewolucja",
"no_tests_tomorrow": "Jutro nie masz sprawdzianu",
"overall_avg": "Összesített átlag",
"s_n_morning_time": "Értesítés ideje iskola előtt",
"ic_ace_f": "Aseksualny",
"wear_sync_with_phone": "Nyisd meg a telefonos appot a szinkronizáláshoz",
"s_ag_navbar": "Pasek nawigacyjny",
"class_avg": "Średnia klasy",
"tt_quarter_end": "koniec kwartału",
"la_privacy_section4_body": "Az adatokat kizárólag a Live Activity funkció működtetésére használjuk:\n\n• Élő órarend megjelenítése a lezárási képernyőn\n• Push értesítések küldése óraváltásokkor\n• Az órarend szinkronizálása az eszközödön\n• A hétfő reggeli értesítések kézbesítésének biztosítása a heti adatbázis-ürítés után is\n\nAz adataidat nem adjuk át harmadik félnek, és nem használjuk marketing célokra.",
"no_grades": "Z tego przedmiotu nie masz jeszcze ocen.",
"la_privacy_summary2": "Titkosított tárolás, biztonságos szerverek",
"ic_lgbtqp_f": "Postęp",
"ic_bi_f": "Biseksualny",
"now": "Most",
"la_privacy_section1_body": "A Live Activity működéséhez az alábbi adatokat tároljuk eszközazonosítóddal együtt:\n\n• Eszköz azonosító (UUID)\n• Eszköz token\n• Live Activity push token\n• APNs push token\n• Eszköz hash\n• Nyelvi beállítás\n• Csengő eltolódása\n\nAz órarendi adataid (lessons tábla) a következőket tartalmazzák:\n• Óra tárgya és időpontja\n• Tanár neve\n• Terem neve\n• Óra sorszáma\n• Óra témája\n• Helyettesítés adatai\n• Elmaradt óra jelzése\n\nAz időzített értesítések (scheduled_notifications tábla) a következőket tartalmazzák:\n• Azonosító\n• Eszköz azonosító\n• Időzített időpont\n• Küldés állapota és ideje\n• Létrehozás és frissítés ideje",
"starting_soon": "Już wkrótce zaczyna się Twoja pierwsza lekcja!",
"ic_refulc": "firk’a",
"s_ag_left_handed_mode": "Tryb dla leworęcznych",
"tt_rest_day": "Dzień wolny",
"la_privacy_summary3": "Az adatok automatikusan törlődnek, ha már nincs rájuk szükség",
"tt_settings_toast_lesson_breaks": "Przerwy",
"s_ag_language_auto": "Automatyczny",
"s_ag_navbar_visible": "Wyświetlane",
"starting_sec": "sekunda",
"la_subtitle": "Az órarended élő megjelenítése az eszköz lezárási képernyőjén",
"grade_teacherName": "Imię i nazwisko nauczyciela: ",
"ic_modern": "Nowoczesny",
"timeLeft": "Még {mins} perc",
"@timeLeft": {
"placeholders": {
"mins": {
"type": "num"
}
}
},
"s_ag_language_de": "Niemiecki",
"today": "Dziś",
"ic_gay_f": "Gej",
"ic_fidesz": "Fidesz",
"s_n_morning": "Reggeli értesítés",
"restart_body": "Kliknij tutaj, aby otworzyć aplikację.",
"s_ag_language_en": "Angielski",
"homework": "Praca domowa",
"ic_pixel": "Pixel",
"view_lesson_btn": "Zobacz lekcję",
"la_privacy_intro": "A Live Activity funkció használatához bizonyos adatokat kell tárolnunk és feldolgoznunk. Kérjük, olvasd el figyelmesen az alábbi tájékoztatót.",
"beta_body": "Aplikacja jest w trakcie rozwoju; niektóre funkcje mogą działać nieprawidłowo, nie działać lub jeszcze nie być ukończone.",
"ic_galaxy": "Galaktyka",
"copied": "Másolva",
"view_day_btn": "Zobacz dzień",
"omission": "Hiányzás",
"omissions": "Hiányzások",
"omission_state_excused": "Igazolt",
"omission_state_unexcused": "Igazolatlan",
"omission_state_pending": "Függőben",
"omissions_count": "{state, select, unexcused{{count} igazolatlan} pending{{count} igazolandó} other{{count}}} hiányzás",
"@omissions_count": {
"placeholders": {
"state": {
"type": "String"
},
"count": {
"type": "int"
}
}
},
"s_beta_warning": "Ostrzeżenie beta",
"s_ag_privacy_ever_declined": "Wcześniej odrzucono politykę prywatności",
"s_c_tab_appearance": "Wygląd aplikacji",
"s_c_tab_subjects": "Przedmioty",
"s_c_tab_fonts": "Czcionki",
"s_c_my_themes": "Moje motywy",
"s_c_manage_subjects": "Zarządzaj przedmiotami",
"s_c_change_app_icon": "Zmień ikonę aplikacji",
"s_c_colors_header": "Kolory",
"s_c_grade_colors_header": "Kolory ocen",
"s_c_title_style_header": "Styl tytułów",
"s_c_title_weight_header": "Grubość tytułów",
"s_c_title_weight_subtitle": "Nie wszystkie czcionki to obsługują",
"s_c_title_weight_thin": "Cienka",
"s_c_title_weight_thick": "Gruba",
"s_c_capitalization_header": "Wielkość liter",
"s_c_capitalization_lower": "małe litery",
"s_c_capitalization_normal": "Normalna",
"s_c_capitalization_upper": "WIELKIE LITERY",
"s_c_change": "Zmień",
"s_c_customize": "Dostosuj",
"s_c_themes_current": "Bieżący",
"s_c_themes_own": "Własne",
"s_c_themes_downloaded": "Pobrane",
"s_c_themes_share_current": "Udostępnij bieżący motyw",
"s_c_themes_create_new": "Utwórz nowy motyw",
"s_c_themes_import": "Importuj motyw",
"s_c_themes_use": "Użyj",
"s_c_themes_continue": "Kontynuuj",
"s_c_themes_own_label": "Własny motyw",
"s_c_themes_imported_label": "Zaimportowany motyw",
"s_c_themes_builtin_label": "Wbudowany motyw",
"s_c_themes_builtin_name": "Domyślny",
"s_c_themes_create_title": "Utwórz nowy motyw",
"s_c_themes_create_subtitle": "Podaj nazwę motywu",
"s_c_themes_create_placeholder": "Nazwa motywu",
"s_c_themes_delete_title": "Usuń motyw",
"s_c_themes_delete_subtitle": "Czy na pewno chcesz usunąć ten motyw? Tę czynność można cofnąć.",
"s_c_themes_delete_confirm": "Usuń",
"s_about": "O aplikacji",
"s_extras": "Dodatki",
"s_other": "Inne",
"subtitle4": ""
"tt_settings_toast_lesson_ab_timetable": "Dwutygodniowy plan lekcji",
"restart_title": "Uruchom ponownie aplikację",
"s_wear": "Wear OS",
"s_ag_navbar_home": "Strona główna",
"tt_holiday": "Dzień świąteczny",
"pairing": "Łączenie lekcji",
"s_c_replace_icon": "­Zmiana ikony",
"close": "Zamknij",
"ghost_grade": "Szellem jegy",
"la_privacy_required": "A Live Activity használatához el kell fogadnod az adatvédelmi tájékoztatót",
"debug_screen": "Menu deweloperskie",
"save": "Zapisz",
"starting_hour_plural": "godzina",
"ic_void_icon": "Nic",
"wearSyncNotificationText": "Óra adatainak szinkronban tartása",
"wear_pairing_check_phone": "Folytasd a párosítást a telefonodon",
"la_privacy_section2_body": "Komolyan vesszük az adataid biztonságát:\n\n• A devices és lessons táblákban lévő összes adat titkosítva van\n• Az adatokat biztonságos szerveren tároljuk\n• Csak a szükséges időtartamig tároljuk az adatokat",
"unknown_teacher": "Nieznany nauczyciel",
"la_privacy_header": "Live Activity adatvédelmi tájékoztató",
"title4": "Wiele dodatkowych rzeczy, których nigdy nie znajdziesz w Kréta.",
"gradesCount": "{count} jegy",
"@gradesCount": {
"placeholders": {
"count": {
"type": "int"
}
}
},
"s_ag_rounding": "Domyślne zaokrąglanie",
"wear_syncing": "Szinkronizálás...",
"s_ci_icon_g8": "Pride ",
"ic_lgbtq_f": "LGBTQ+",
"licensesLabel": "Licencek",
"s_c": "Dostosowanie",
"starting_hour": "godzina",
"wear_try_again": "Újra",
"title1": "Poznaj wszystko na pierwszy rzut oka",
"subtitle1": "Na górze strony głównej możesz zobaczyć przydatne informacje o swoim dniu.",
"subject_avg": "Średnia z przedmiotu",
"view_subject_btn": "Zobacz przedmiot",
"tt_winter_break": "Zimowa przerwa",
"stats_created_at": "Utworzono",
"s_n": "Értesítések",
"tt_settings_toast": "Ustawienia planu lekcji",
"refreshing": "Aktualizowanie danych...",
"la_privacy_footer": "Az adatvédelmi tájékoztató utolsó frissítése: 2025. november",
"la_privacy_section5_body": "A GDPR alapján az alábbi jogokkal rendelkezel:\n\n• Hozzáférési jog: A tárolt adatok típusát ebben az adatvédelmi tájékoztatóban tekintheted meg.\n• Törlési jog: A Live Activity funkció kikapcsolásával minden, a funkcióhoz kapcsolódó adat (eszközazonosítók, órarend) azonnal és véglegesen törlődik a szervereinkről.\n• Módosítási jog: Az órarendi adatok módosítása a Kréta rendszerben történik, az arra jogosult személyek (pl. tanárok) által.\n• Tiltakozási jog: Az adatkezelés ellen bármikor tiltakozhatsz a Live Activity funkció kikapcsolásával.",
"grades": "Oceny",
"good_afternoon": "Miłego popołudnia, {p}!",
"@good_afternoon": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"tt_last_instructional_day_graduates": "Ostatni dzień zajęć dla klas kończących szkołę",
"s_ci_icon_g3": "Nostalgia",
"tt_first_instructional_day": "Pierwszy dzień nauki",
"ic_gay": "Gej",
"ic_nuke": "Nuklearny",
"noMoreClasses": "Nincs több órád ma",
"ic_lesb_f": "Lesbijka",
"s_acc_add": "Dodaj nowe konto",
"ic_old": "Domain Dave",
"licenseDescription": "Az alkalmazás által használt külső könyvtárak licencei",
"tt_autumn_break": "Jesienna przerwa",
"s_ci_icon_header": "Ikona aplikacji",
"s_ci_restart_notice": "W niektórych launcherach nowa ikona pojawi się dopiero po ponownym otwarciu aplikacji.",
"empty_class": "Lyukasóra",
"lesson_subject": "Przedmiot lekcji",
"pairing_description": "Czy chcesz połączyć tę lekcję z aplikacją Firka?\nPo połączeniu zobaczysz plan lekcji oraz swoje najnowsze oceny, sprawdziany i zadania.",
"date": "Godzina lekcji",
"ic_szivacs": "Gąbka",
"starting_sec_plural": "sekunda",
"s_ci_icon_g6_desc": "przez @emilia6_6",
"ic_filco": "Filc . O",
"good_day": "Miłego dnia, {p}!",
"@good_day": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"tt_full_day_trip": "Całodniowa wycieczka",
"wear_pairing_request_sent": "Párosítás folyamatban, nyisd meg az appot a telefonodon",
"grade_calculator_add": "Hozzáadás",
"ic_kreta": "eFIRKA",
"subtitle2": "Zobacz statystyki, nadchodzące sprawdziany, a nawet oceny z poprzednich lat szkolnych.",
"s_n_live_activity": "Live Activity",
"wear_phone_disconnected": "Az órád nincs csatlakoztatva a telefonoddal!",
"la_privacy_section3_body": "Az adatok tárolása minimális időtartamra korlátozódik:\n\n• Live Activity push token: Addig van tárolva, amíg óráid vannak az adott napon (beleértve az első óra előtti 2 órás időszakot is). Ha nincs több órád, az érték null lesz.\n\n• Órarendi adatok: Csak az órák időtartamára tárolódnak, majd automatikusan törlődnek. Pénteken az utolsó óra után az órarendet tartalmazó tábla teljesen üres lesz.\n\n• Eszközadatok (token, azonosítók): Addig van tárolva, amíg a Live Activity funkció engedélyezve van. A funkció kikapcsolásakor ezek az adatok azonnal törlésre kerülnek.",
"tt_last_instructional_day": "Ostatni dzień nauki",
"tt_settings_toast_lesson_nos": "Numery lekcji",
"s_ci_icon_g5": "Referencja",
"tt_settings_toast_lesson_substitution": "Zastępstwa",
"tt_added": "Utworzono: ",
"la_privacy_section3_title": "Meddig tároljuk az adatokat?",
"school_ending": "Denerwujesz się, {p}?",
"@school_ending": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"s_wear_os_support": "Wear OS támogatás",
"ic_enby": "Niebinarna",
"tt_settings_toast_lesson_tests": "Sprawdziany i inne",
"happy_birthday": "Wszystkiego najlepszego, {p}!",
"@happy_birthday": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"api_error": "Błąd API Kréta",
"ic_trans_f": "Trans",
"ic_enby_f": "Niebinarna",
"ic_lidl": "Zakupy",
"tests_tomorrow": "Masz {tests} sprawdzianów",
"@tests_tomorrow": {
"placeholders": {
"tests": {
"type": "String"
}
}
},
"ic_trans": "Trans",
"s_ci_icon_g4": "Przeprojektowany",
"tt_public_holiday": "Dzień wolny od pracy",
"s_ag_language_header": "Język",
"tt_instructional_day": "Dzień zajęć szkolnych",
"ic_cc": "Chmura Kreatywna",
"la_privacy_title": "Adatvédelmi tájékoztató",
"s_ag_r1": "1 → 2",
"s_c_theme_light": "Jasny",
"title2": "Twoje przedmioty wygodnie się tutaj mieszczą",
"tomorrow_subtitle": "Oto Twój jutrzejszy dzień.",
"s_n_test": "Teszt értesítés küldése",
"starting_min_plural": "minuta",
"ic_mkkp": "Darmowe oceny",
"subjects": "­Przedmioty",
"s_c_theme_header": "Motyw",
"s_a": "Aplikacja",
"loginBtn": "Zaloguj się za pomocą konta E-Kréta",
"mark_as_not_done": "Oznacz jako nieukończone",
"wearSyncNotificationTitle": "Szinkronizálás az órával",
"mark_as_done": "­Oznacz jako ukończone",
"s_ag": "Ogólne",
"ic_xmas3": "FirŚwięta",
"data": "Dane",
"la_learn_more": "Bővebben",
"ic_pixelized": "Spikselizowany",
"other": "Więcej",
"ic_o1g": "Orbán to pizda",
"la_privacy_section2_title": "Hogyan védjük az adataidat?",
"good_night": "Miłego wieczoru, {p}!",
"@good_night": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"s_ag_r4": "4 → 5",
"s_ci_icon_g1": "Catboy domain",
"starting_min": "minuta",
"ic_pride": "Kosmiczna tęcza",
"suffering_almost_over_subtitle": "Już niedługo będziesz wolny. Uważaj na nauczyciela.",
"la_privacy_section5_title": "Jogaid",
"ghost_grades": "Szellem jegyek",
"s_customization": "Personalizacja",
"tomorrow": "Jutro",
"breakTxt": "Szünet",
"la_privacy_section1_title": "Milyen adatokat tárolunk?",
"s_ci_warning_header": "[!] W trybie debug zmiana ikony nie będzie działać",
"tt_spring_break": "Wiosenna przerwa",
"s_ag_language_hu": "Węgierski",
"tt_no_classes_l2": "Yippee!",
"class_n": "­Liczba godzin tygodniowo",
"s_settings": "Ustawienia",
"subject_avg_rounded": "Średnia z przedmiotu po zaokrągleniu",
"class_dismissed": "Odwołana lekcja",
"s_ci_icon_subtitle": "Wybierz piękną ikonę aplikacji, jeśli znudził Ci się zielony kolor.",
"s_ci_icon_g6": "Konkurs na świąteczne logo 2024",
"ic_lgbtqp": "Postęp",
"beta_title": "Firka – publiczna beta",
"la_title": "Live Activity",
"n_left_subtitle": "Wytrzymaj, zostało tylko {n} godzin!",
"@n_left_subtitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"pair": "Parowanie",
"grade_strValue": "Ocena opisowa: ",
"s_acc_kreta": "Konta eKRÉTA",
"ic_pear": "Gruszka",
"s_ag_bell_delay": "Przesunięcie dzwonka",
"s_your_account": "Twoje konto",
"wear_phone_unpaired": "Az órád nincs párosítva a telefonoddal!",
"tt_non_instructional_day": "Dzień wolny od zajęć dydaktycznych",
"b_week": "Tydzień B",
"home": "Strona główna",
"subject": "Tantárgy",
"s_c_icon_header": "Ikony aplikacji",
"cancel": "Anuluj",
"yesterday": "Wczoraj",
"ic_repont": "Pięćdziesiąt groszy",
"ic_cactus": "Kaktusowy zagajnik",
"get_ready": "Odpocznij i przygotuj się",
"ic_lesb": "Lesbijka",
"s_acc_logout": "Wyloguj się",
"stats_date": "Data",
"your_subjects": "Twoje przedmioty",
"reauth": "Wymagane logowanie",
"good_morning": "Dzień dobry, {p}!",
"@good_morning": {
"placeholders": {
"p": {
"type": "String"
}
}
},
"firstIn": "Első órád: {t}",
"@firstIn": {
"placeholders": {
"t": {
"type": "String"
}
}
},
"la_privacy_section4_title": "Mire használjuk az adatokat?",
"ic_xmas2": "Prezent",
"settings_screen": "Ustawienia",
"la_privacy_summary1": "Eszköz tokenek, Live Activity tokenek, órarendi adatok",
"title3": "Personalizowany plan lekcji",
"ic_filc": "Filc Dziennik",
"s_c_theme_dark": "Ciemny",
"grade_calculator": "Jegy kalkulátor",
"la_accept": "Elfogadom",
"s_stats_for_nerds": "Pokaż dodatkowe informacje",
"s_ag_r3": "3 → 4",
"ic_tisza": "Árad a firka",
"okay": "Ok",
"s_developer": "Ustawienia deweloperskie",
"privacyLabel": "Polityka prywatności",
"stats_last_mod": "Ostatnio zmodyfikowano",
"s_ag_navbar_desc": "Wybierz, co ma się wyświetlać na pasku nawigacyjnym, i uporządkuj elementy. Pozostałe strony są dostępne przez przycisk „więcej”. Możesz przypiąć maksymalnie 4 strony.",
"a_week": "Tydzień",
"s_ag_r2": "2 → 3",
"wearTitle": "{n}. óra",
"@wearTitle": {
"placeholders": {
"n": {
"type": "num"
}
}
},
"timetable": "Plan lekcji",
"ic_ace": "Aseksualny",
"s_ci_icon_g2": "­Pisak",
"s_ci_child_protection": "Ochrona dzieci",
"s_ag_navbar_hidden": "Ukryte",
"runningInDomainBrowser": "Przeglądarka domen",
"noClasses": "Nincs ma iskola, pihend ki magad!",
"ic_bi": "Biseksualny",
"ic_proto": "Prototyp",
"tt_first_semester_end": "Koniec pierwszego semestru",
"la_decline": "Elutasítom",
"s_c_theme_auto": "Automatyczny",
"ic_paper": "Papier",
"ic_xmas1": "Lista złych",
"s_ci_icon_g7": "Pride",
"lessons_tomorrow": "{lessons} órád lesz",
"@lessons_tomorrow": {
"placeholders": {
"lessons": {
"type": "String"
}
}
},
"ic_lgbtq": "LGBTQ+",
"subtitle3": "Wybierz, co chcesz widzieć na stronie planu lekcji. Włącz lub wyłącz sprawdziany, prace domowe, przerwy oraz okienka.",
"ic_original": "Oryginał",
"ic_refilc": "reFilc",
"la_privacy_contact": "Kérdésed van? Keress minket a support @firka.app címen.",
"tt_no_classes_l1": "W tym dniu nie masz lekcji!",
"s_ag_class_avg_on_graph": "Średnia klasy na wykresie",
"class_substitution": "Zastępstwo",
"ic_half_firka_2": "Rewolucja",
"no_tests_tomorrow": "Jutro nie masz sprawdzianu",
"overall_avg": "Összesített átlag",
"s_n_morning_time": "Értesítés ideje iskola előtt",
"ic_ace_f": "Aseksualny",
"wear_sync_with_phone": "Nyisd meg a telefonos appot a szinkronizáláshoz",
"s_ag_navbar": "Pasek nawigacyjny",
"class_avg": "Średnia klasy",
"tt_quarter_end": "koniec kwartału",
"la_privacy_section4_body": "Az adatokat kizárólag a Live Activity funkció működtetésére használjuk:\n\n• Élő órarend megjelenítése a lezárási képernyőn\n• Push értesítések küldése óraváltásokkor\n• Az órarend szinkronizálása az eszközödön\n• A hétfő reggeli értesítések kézbesítésének biztosítása a heti adatbázis-ürítés után is\n\nAz adataidat nem adjuk át harmadik félnek, és nem használjuk marketing célokra.",
"no_grades": "Z tego przedmiotu nie masz jeszcze ocen.",
"la_privacy_summary2": "Titkosított tárolás, biztonságos szerverek",
"ic_lgbtqp_f": "Postęp",
"ic_bi_f": "Biseksualny",
"now": "Most",
"la_privacy_section1_body": "A Live Activity működéséhez az alábbi adatokat tároljuk eszközazonosítóddal együtt:\n\n• Eszköz azonosító (UUID)\n• Eszköz token\n• Live Activity push token\n• APNs push token\n• Eszköz hash\n• Nyelvi beállítás\n• Csengő eltolódása\n\nAz órarendi adataid (lessons tábla) a következőket tartalmazzák:\n• Óra tárgya és időpontja\n• Tanár neve\n• Terem neve\n• Óra sorszáma\n• Óra témája\n• Helyettesítés adatai\n• Elmaradt óra jelzése\n\nAz időzített értesítések (scheduled_notifications tábla) a következőket tartalmazzák:\n• Azonosító\n• Eszköz azonosító\n• Időzített időpont\n• Küldés állapota és ideje\n• Létrehozás és frissítés ideje",
"starting_soon": "Już wkrótce zaczyna się Twoja pierwsza lekcja!",
"ic_refulc": "firk’a",
"s_ag_left_handed_mode": "Tryb dla leworęcznych",
"tt_rest_day": "Dzień wolny",
"la_privacy_summary3": "Az adatok automatikusan törlődnek, ha már nincs rájuk szükség",
"tt_settings_toast_lesson_breaks": "Przerwy",
"s_ag_language_auto": "Automatyczny",
"s_ag_navbar_visible": "Wyświetlane",
"starting_sec": "sekunda",
"la_subtitle": "Az órarended élő megjelenítése az eszköz lezárási képernyőjén",
"grade_teacherName": "Imię i nazwisko nauczyciela: ",
"ic_modern": "Nowoczesny",
"timeLeft": "Még {mins} perc",
"@timeLeft": {
"placeholders": {
"mins": {
"type": "num"
}
}
},
"s_ag_language_de": "Niemiecki",
"today": "Dziś",
"ic_gay_f": "Gej",
"ic_fidesz": "Fidesz",
"s_n_morning": "Reggeli értesítés",
"restart_body": "Kliknij tutaj, aby otworzyć aplikację.",
"s_ag_language_en": "Angielski",
"homework": "Praca domowa",
"ic_pixel": "Pixel",
"view_lesson_btn": "Zobacz lekcję",
"la_privacy_intro": "A Live Activity funkció használatához bizonyos adatokat kell tárolnunk és feldolgoznunk. Kérjük, olvasd el figyelmesen az alábbi tájékoztatót.",
"beta_body": "Aplikacja jest w trakcie rozwoju; niektóre funkcje mogą działać nieprawidłowo, nie działać lub jeszcze nie być ukończone.",
"ic_galaxy": "Galaktyka",
"copied": "Másolva",
"view_day_btn": "Zobacz dzień",
"omission": "Hiányzás",
"omissions": "Hiányzások",
"omission_state_excused": "Igazolt",
"omission_state_unexcused": "Igazolatlan",
"omission_state_pending": "Függőben",
"omissions_count": "{state, select, unexcused{{count} igazolatlan} pending{{count} igazolandó} other{{count}}} hiányzás",
"@omissions_count": {
"placeholders": {
"state": {
"type": "String"
},
"count": {
"type": "int"
}
}
},
"s_beta_warning": "Ostrzeżenie beta",
"s_ag_privacy_ever_declined": "Wcześniej odrzucono politykę prywatności",
"s_c_tab_appearance": "Wygląd aplikacji",
"s_c_tab_subjects": "Przedmioty",
"s_c_tab_fonts": "Czcionki",
"s_c_my_themes": "Moje motywy",
"s_c_manage_subjects": "Zarządzaj przedmiotami",
"s_c_change_app_icon": "Zmień ikonę aplikacji",
"s_c_colors_header": "Kolory",
"s_c_grade_colors_header": "Kolory ocen",
"s_c_title_style_header": "Styl tytułów",
"s_c_title_weight_header": "Grubość tytułów",
"s_c_title_weight_subtitle": "Nie wszystkie czcionki to obsługują",
"s_c_title_weight_thin": "Cienka",
"s_c_title_weight_thick": "Gruba",
"s_c_capitalization_header": "Wielkość liter",
"s_c_capitalization_lower": "małe litery",
"s_c_capitalization_normal": "Normalna",
"s_c_capitalization_upper": "WIELKIE LITERY",
"s_c_change": "Zmień",
"s_c_customize": "Dostosuj",
"s_c_themes_current": "Bieżący",
"s_c_themes_own": "Własne",
"s_c_themes_downloaded": "Pobrane",
"s_c_themes_share_current": "Udostępnij bieżący motyw",
"s_c_themes_create_new": "Utwórz nowy motyw",
"s_c_themes_import": "Importuj motyw",
"s_c_themes_use": "Użyj",
"s_c_themes_continue": "Kontynuuj",
"s_c_themes_own_label": "Własny motyw",
"s_c_themes_imported_label": "Zaimportowany motyw",
"s_c_themes_builtin_label": "Wbudowany motyw",
"s_c_themes_builtin_name": "Domyślny",
"s_c_themes_create_title": "Utwórz nowy motyw",
"s_c_themes_create_subtitle": "Podaj nazwę motywu",
"s_c_themes_create_placeholder": "Nazwa motywu",
"s_c_themes_delete_title": "Usuń motyw",
"s_c_themes_delete_subtitle": "Czy na pewno chcesz usunąć ten motyw? Tę czynność można cofnąć.",
"s_c_themes_delete_confirm": "Usuń",
"s_about": "O aplikacji",
"s_extras": "Dodatki",
"s_other": "Inne",
"subtitle4": ""
}

View File

@@ -16,6 +16,7 @@ import 'package:firka/ui/phone/pages/home/home_timetable_mo.dart';
import 'package:firka/ui/phone/screens/debug/debug_screen.dart';
import 'package:firka/ui/phone/screens/home/beta_screen.dart';
import 'package:firka/ui/phone/pages/error/error_page.dart';
import 'package:firka/ui/phone/screens/feedback/feedback_screen.dart';
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';
@@ -81,6 +82,17 @@ GoRouter createAppRouter() {
child: BetaScreen(initData, key: state.pageKey),
),
),
GoRoute(
path: '/feedback',
builder: (context, state) => DefaultAssetBundle(
bundle: FirkaBundle(),
child: FeedbackScreen(
initData,
error: state.extra as String?,
key: state.pageKey,
),
),
),
GoRoute(
path: '/debug',
builder: (context, state) => DefaultAssetBundle(
@@ -110,7 +122,16 @@ GoRouter createAppRouter() {
GoRoute(
path: '/theme',
builder: (context, state) {
final args = state.extra as ThemeScreenArgs;
// go_router drops `extra` on a rebuild without one (a hot restart,
// or toggling the inspector), and there is no theme to show without
// it — fall back to the list rather than throwing a type error.
final args = state.extra;
if (args is! ThemeScreenArgs) {
return DefaultAssetBundle(
bundle: FirkaBundle(),
child: ThemesScreen(initData, key: state.pageKey),
);
}
return DefaultAssetBundle(
bundle: FirkaBundle(),
child: ThemeScreen(initData, args, key: state.pageKey),
@@ -251,6 +272,8 @@ String get _initialLocation {
String? _redirect(BuildContext context, GoRouterState state) {
if (!initDone) return null;
final location = state.matchedLocation;
// people who can not log in need it the most
if (location == '/feedback') return null;
final hasTokens = initData.client != null;
final betaWarning = Settings.betaWarning.value;

View File

@@ -41,10 +41,7 @@ class ShellWithNavBar extends StatelessWidget {
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
bottomBg,
bottomBg.withValues(alpha: 0.0),
],
colors: [bottomBg, bottomBg.withValues(alpha: 0.0)],
stops: const [0.0, 1.0],
),
),

View File

@@ -41,7 +41,11 @@ class AlarmNotificationService {
_isInitialized = true;
_logger.info('AlarmNotificationService initialized');
} catch (e, st) {
_logger.severe('Failed to initialize AlarmNotificationService: $e', e, st);
_logger.severe(
'Failed to initialize AlarmNotificationService: $e',
e,
st,
);
}
}

View File

@@ -69,7 +69,8 @@ class FcmService {
static Future<AuthorizationStatus?> permissionStatus() async {
if (!_isInitialized) return null;
try {
final settings = await FirebaseMessaging.instance.getNotificationSettings();
final settings = await FirebaseMessaging.instance
.getNotificationSettings();
return settings.authorizationStatus;
} catch (e) {
_logger.warning('Error reading notification permission status: $e');
@@ -88,15 +89,14 @@ class FcmService {
options: DefaultFirebaseOptions.currentPlatform,
);
FirebaseMessaging.onBackgroundMessage(
firebaseMessagingBackgroundHandler,
);
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
await FirebaseMessaging.instance
.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
FirebaseMessaging.instance.onTokenRefresh.listen((token) {
_cachedToken = token;
@@ -147,7 +147,11 @@ class FcmService {
body: '${DateTime.now().toIso8601String()} - ${_channelLabel(message)}',
);
} catch (e, st) {
_logger.warning('Failed to show debug FCM message notification: $e', e, st);
_logger.warning(
'Failed to show debug FCM message notification: $e',
e,
st,
);
}
}
@@ -218,7 +222,8 @@ class FcmService {
static Future<void> _register({required String studentId}) async {
try {
final token = _cachedToken ??= await FirebaseMessaging.instance.getToken();
final token = _cachedToken ??= await FirebaseMessaging.instance
.getToken();
if (token == null) {
_logger.warning('No FCM token available to register');
return;
@@ -329,7 +334,11 @@ class FcmService {
notifyMessages: Settings.notifyMessages.value,
);
} catch (e, st) {
_logger.severe('Failed to update FCM notification preferences: $e', e, st);
_logger.severe(
'Failed to update FCM notification preferences: $e',
e,
st,
);
}
}
}

View File

@@ -15,7 +15,8 @@ class LocalNotificationService {
FlutterLocalNotificationsPlugin();
static bool _initialized = false;
static final List<({int id, String title, String body})> postedNotifications = [];
static final List<({int id, String title, String body})> postedNotifications =
[];
static Future<void> init() async {
if (_initialized) return;

View File

@@ -60,14 +60,18 @@ class NotificationDeliveryService {
return configured;
}
final gms = await isGmsAvailable();
return gms ? NotificationDeliveryMethod.fcm : NotificationDeliveryMethod.alarm;
return gms
? NotificationDeliveryMethod.fcm
: NotificationDeliveryMethod.alarm;
}
static Future<void> initialize() async {
if (!_isAndroid) return;
final gms = await isGmsAvailable();
_logger.info('Initializing NotificationDeliveryService (GMS available: $gms)');
_logger.info(
'Initializing NotificationDeliveryService (GMS available: $gms)',
);
await AlarmNotificationService.initialize();
@@ -83,14 +87,18 @@ class NotificationDeliveryService {
try {
if (!Settings.notifyAll.value) {
_logger.info('Push notifications disabled, tearing down delivery backends');
_logger.info(
'Push notifications disabled, tearing down delivery backends',
);
await FcmService.handleEnabledChange(false);
await AlarmNotificationService.cancel();
return;
}
final effectiveMethod = await getEffectiveMethod();
_logger.info('Syncing delivery backend for effective method: $effectiveMethod');
_logger.info(
'Syncing delivery backend for effective method: $effectiveMethod',
);
switch (effectiveMethod) {
case NotificationDeliveryMethod.fcm:

View File

@@ -44,7 +44,11 @@ class NotificationDiffService {
final client = KretaClient(token);
await _checkAccount(client, token.key, token.username);
} catch (e, st) {
_logger.warning('checkAll: account ${token.username} failed: $e', e, st);
_logger.warning(
'checkAll: account ${token.username} failed: $e',
e,
st,
);
}
}
@@ -62,10 +66,18 @@ class NotificationDiffService {
await _diffAndNotify(
accountKey: accountKey,
kind: LastSeenHelper.notifGrades,
items: _excludeMuted(await client.getGrades(), mutedSubjects, (g) => g.subject.value?.name),
title: (n) => n.length == 1 ? 'Új jegy érkezett' : '${n.length} új jegy érkezett',
items: _excludeMuted(
await client.getGrades(),
mutedSubjects,
(g) => g.subject.value?.name,
),
title: (n) =>
n.length == 1 ? 'Új jegy érkezett' : '${n.length} új jegy érkezett',
body: (n) => n
.map((g) => '${g.subject.value?.name ?? "?"}: ${g.textValue} (${_fmtDate(g.writtenAt)})')
.map(
(g) =>
'${g.subject.value?.name ?? "?"}: ${g.textValue} (${_fmtDate(g.writtenAt)})',
)
.take(5)
.join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifGrades),
@@ -76,17 +88,28 @@ class NotificationDiffService {
await _diffAndNotify(
accountKey: accountKey,
kind: LastSeenHelper.notifHomework,
items: _excludeMuted(await client.getHomework(), mutedSubjects, (h) => h.subject.value?.name),
title: (n) => n.length == 1 ? 'Új házi feladat' : '${n.length} új házi feladat',
body: (n) => n.map((h) => h.subject.value?.name ?? "?").take(5).join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifHomework),
items: _excludeMuted(
await client.getHomework(),
mutedSubjects,
(h) => h.subject.value?.name,
),
title: (n) =>
n.length == 1 ? 'Új házi feladat' : '${n.length} új házi feladat',
body: (n) =>
n.map((h) => h.subject.value?.name ?? "?").take(5).join(', '),
notificationId: _notificationId(
accountKey,
LastSeenHelper.notifHomework,
),
);
await _diffAndNotify(
accountKey: accountKey,
kind: LastSeenHelper.notifTests,
items: await client.getTests(),
title: (n) => n.length == 1 ? 'Új témazáró/dolgozat' : '${n.length} új témazáró/dolgozat',
title: (n) => n.length == 1
? 'Új témazáró/dolgozat'
: '${n.length} új témazáró/dolgozat',
body: (n) => n.map((t) => t.topic ?? t.method).take(5).join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifTests),
);
@@ -97,17 +120,26 @@ class NotificationDiffService {
accountKey: accountKey,
kind: LastSeenHelper.notifAbsences,
items: await client.getOmissions(),
title: (n) => n.length == 1 ? 'Új hiányzás/késés' : '${n.length} új hiányzás/késés',
title: (n) => n.length == 1
? 'Új hiányzás/késés'
: '${n.length} új hiányzás/késés',
body: (n) => n.map((o) => o.state.name).take(5).join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifAbsences),
notificationId: _notificationId(
accountKey,
LastSeenHelper.notifAbsences,
),
);
}
final now = DateTime.now();
final lessons = await client.getLessons(now, now.add(const Duration(days: 7)));
final lessons = await client.getLessons(
now,
now.add(const Duration(days: 7)),
);
final selectedToken = Settings.getSelectedToken();
final isActiveAccount = selectedToken == null || selectedToken.key == accountKey;
final isActiveAccount =
selectedToken == null || selectedToken.key == accountKey;
if (isActiveAccount) {
await _checkAndUpdateWidget(lessons);
}
@@ -129,7 +161,8 @@ class NotificationDiffService {
accountKey: accountKey,
kind: LastSeenHelper.notifLessonsCancelled,
items: cancelled,
title: (n) => n.length == 1 ? 'Elmaradt óra' : '${n.length} elmaradt óra',
title: (n) =>
n.length == 1 ? 'Elmaradt óra' : '${n.length} elmaradt óra',
body: (n) => n
.map(
(l) =>
@@ -138,14 +171,18 @@ class NotificationDiffService {
)
.take(5)
.join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifLessonsCancelled),
notificationId: _notificationId(
accountKey,
LastSeenHelper.notifLessonsCancelled,
),
);
await _diffAndNotify(
accountKey: accountKey,
kind: LastSeenHelper.notifLessonsSubstituted,
items: substituted,
title: (n) => n.length == 1 ? 'Helyettesítés' : '${n.length} helyettesítés',
title: (n) =>
n.length == 1 ? 'Helyettesítés' : '${n.length} helyettesítés',
body: (n) => n
.map(
(l) =>
@@ -154,21 +191,29 @@ class NotificationDiffService {
)
.take(5)
.join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifLessonsSubstituted),
notificationId: _notificationId(
accountKey,
LastSeenHelper.notifLessonsSubstituted,
),
);
await _diffAndNotify(
accountKey: accountKey,
kind: LastSeenHelper.notifLessons,
items: otherChanges,
title: (n) => n.length == 1
? 'Órarendváltozás'
: '${n.length} órarendváltozás',
title: (n) =>
n.length == 1 ? 'Órarendváltozás' : '${n.length} órarendváltozás',
body: (n) => n
.map((l) => '${l.subject.value?.name ?? l.name} (${l.roomName ?? "?"})')
.map(
(l) =>
'${l.subject.value?.name ?? l.name} (${l.roomName ?? "?"})',
)
.take(5)
.join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifLessons),
notificationId: _notificationId(
accountKey,
LastSeenHelper.notifLessons,
),
);
}
@@ -183,7 +228,10 @@ class NotificationDiffService {
items: combined,
title: (n) => n.length == 1 ? 'Új üzenet' : '${n.length} új üzenet',
body: (n) => n.map((m) => m.title).take(5).join(', '),
notificationId: _notificationId(accountKey, LastSeenHelper.notifMessages),
notificationId: _notificationId(
accountKey,
LastSeenHelper.notifMessages,
),
);
}
}
@@ -249,7 +297,9 @@ class NotificationDiffService {
static int _notificationId(int accountKey, String kind) =>
Object.hash(accountKey, kind) & 0x7fffffff;
static Future<void> _checkAndUpdateWidget(List<LessonCacheModel> lessons) async {
static Future<void> _checkAndUpdateWidget(
List<LessonCacheModel> lessons,
) async {
try {
final dataDir = await getApplicationDocumentsDirectory();
final widgetFile = File(p.join(dataDir.path, "widget_state.json"));
@@ -262,7 +312,10 @@ class NotificationDiffService {
}
}
static bool _hasTimetableChanged(List<LessonCacheModel> lessons, File widgetFile) {
static bool _hasTimetableChanged(
List<LessonCacheModel> lessons,
File widgetFile,
) {
if (!widgetFile.existsSync()) return true;
try {
final content = jsonDecode(widgetFile.readAsStringSync());
@@ -344,7 +397,8 @@ class NotificationDiffService {
LastSeenHelper.notifMessages: (
titleSingle: 'Új üzeneted érkezett',
titleMulti: 'Új üzenet érkezett',
body: 'Nulladik óra átnevezése első órára - Müller Attila (2026-01-15 07:42)',
body:
'Nulladik óra átnevezése első órára - Müller Attila (2026-01-15 07:42)',
),
};

View File

@@ -18,7 +18,9 @@ import 'package:firka/services/notification_delivery_service.dart';
class ProgressNotificationService {
static final Logger _logger = Logger('ProgressNotificationService');
static const MethodChannel _channel = MethodChannel('app.firka/progress_notification');
static const MethodChannel _channel = MethodChannel(
'app.firka/progress_notification',
);
@visibleForTesting
static bool? isAndroidOverride;
@@ -34,7 +36,10 @@ class ProgressNotificationService {
final strings = <String, String>{
'progress_notif_channel_name': l10n.progress_notif_channel_name,
'progress_notif_channel_desc': l10n.progress_notif_channel_desc,
'progress_notif_lesson_title': l10n.progress_notif_lesson_title('{number}', '{name}'),
'progress_notif_lesson_title': l10n.progress_notif_lesson_title(
'{number}',
'{name}',
),
'progress_notif_substitution': l10n.progress_notif_substitution,
'progress_notif_case1_text': l10n.progress_notif_case1_text(
'{minutes}',
@@ -43,26 +48,36 @@ class ProgressNotificationService {
'{substitution}',
'{remaining}',
),
'progress_notif_case2_lesson_text': l10n.progress_notif_case2_lesson_text(
'{minutes}',
'{timeRange}',
'{room}',
'{substitution}',
'{remaining}',
),
'progress_notif_case2_break_title': l10n.progress_notif_case2_break_title,
'progress_notif_case2_lesson_text': l10n
.progress_notif_case2_lesson_text(
'{minutes}',
'{timeRange}',
'{room}',
'{substitution}',
'{remaining}',
),
'progress_notif_case2_break_title':
l10n.progress_notif_case2_break_title,
'progress_notif_case2_break_text': l10n.progress_notif_case2_break_text(
'{minutes}',
'{remaining}',
),
'progress_notif_critical_text': l10n.progress_notif_critical_text('{minutes}'),
'progress_notif_remaining_lessons_one': l10n.progress_notif_remaining_lessons_one,
'progress_notif_remaining_lessons_other': l10n.progress_notif_remaining_lessons_other('{count}'),
'progress_notif_critical_text': l10n.progress_notif_critical_text(
'{minutes}',
),
'progress_notif_remaining_lessons_one':
l10n.progress_notif_remaining_lessons_one,
'progress_notif_remaining_lessons_other': l10n
.progress_notif_remaining_lessons_other('{count}'),
};
await _channel.invokeMethod<bool>('updateProgressStrings', strings);
_logger.info('Synced progress notification strings to native platform');
} catch (e, st) {
_logger.warning('Failed to sync progress notification strings: $e', e, st);
_logger.warning(
'Failed to sync progress notification strings: $e',
e,
st,
);
}
}
@@ -74,7 +89,11 @@ class ProgressNotificationService {
_logger.info('Started ProgressNotificationForegroundService: $res');
return res ?? true;
} catch (e, st) {
_logger.warning('Failed to start ProgressNotificationForegroundService: $e', e, st);
_logger.warning(
'Failed to start ProgressNotificationForegroundService: $e',
e,
st,
);
return false;
}
}
@@ -86,7 +105,11 @@ class ProgressNotificationService {
_logger.info('Stopped ProgressNotificationForegroundService: $res');
return res ?? true;
} catch (e, st) {
_logger.warning('Failed to stop ProgressNotificationForegroundService: $e', e, st);
_logger.warning(
'Failed to stop ProgressNotificationForegroundService: $e',
e,
st,
);
return false;
}
}
@@ -121,7 +144,11 @@ class ProgressNotificationService {
final res = await _channel.invokeMethod<bool>('isProgressServiceRunning');
return res ?? false;
} catch (e, st) {
_logger.warning('Failed to check if progress service is running: $e', e, st);
_logger.warning(
'Failed to check if progress service is running: $e',
e,
st,
);
return false;
}
}
@@ -132,15 +159,19 @@ class ProgressNotificationService {
await syncStrings();
final isEnabled = Settings.progressNotificationEnabled.value && Settings.notifyAll.value;
final isEnabled =
Settings.progressNotificationEnabled.value && Settings.notifyAll.value;
if (!isEnabled) {
_logger.info('Progress notifications disabled, stopping service and cancelling alarm');
_logger.info(
'Progress notifications disabled, stopping service and cancelling alarm',
);
await stopService();
await cancel6AmAlarm();
return;
}
final deliveryMethod = await NotificationDeliveryService.getEffectiveMethod();
final deliveryMethod =
await NotificationDeliveryService.getEffectiveMethod();
if (deliveryMethod == NotificationDeliveryMethod.alarm) {
await schedule6AmAlarm();
} else {
@@ -155,7 +186,9 @@ class ProgressNotificationService {
/// notification is not running, starts it up.
static Future<void> checkAndStartOnAppOpen() async {
if (!_isAndroid) return;
if (!Settings.progressNotificationEnabled.value || !Settings.notifyAll.value) return;
if (!Settings.progressNotificationEnabled.value ||
!Settings.notifyAll.value)
return;
try {
final now = timeNow();
@@ -177,7 +210,9 @@ class ProgressNotificationService {
}
if (lessons.isEmpty) {
_logger.info('No lessons for today; not starting progress service on app open');
_logger.info(
'No lessons for today; not starting progress service on app open',
);
return;
}
@@ -185,16 +220,21 @@ class ProgressNotificationService {
final lastLesson = lessons.last;
final startDate = firstLesson.start;
final isAboveStartDate = now.isAfter(startDate) || now.isAtSameMomentAs(startDate);
final isAboveStartDate =
now.isAfter(startDate) || now.isAtSameMomentAs(startDate);
final isBelowLastLesson = now.isBefore(lastLesson.end);
if (!isAboveStartDate) {
_logger.info('Current time ($now) is before start date ($startDate); not starting progress service');
_logger.info(
'Current time ($now) is before start date ($startDate); not starting progress service',
);
return;
}
if (!isBelowLastLesson) {
_logger.info('Current time ($now) is after last lesson end (${lastLesson.end}); stopping/not starting progress service');
_logger.info(
'Current time ($now) is after last lesson end (${lastLesson.end}); stopping/not starting progress service',
);
final running = await isRunning();
if (running) {
await stopService();
@@ -204,7 +244,9 @@ class ProgressNotificationService {
final running = await isRunning();
if (!running) {
_logger.info('Time is within school day and progress service is not running; starting up');
_logger.info(
'Time is within school day and progress service is not running; starting up',
);
await WidgetCacheHelper.updateWidgetCacheFromIsar();
await startService();
} else {

View File

@@ -0,0 +1,56 @@
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:sensors_plus/sensors_plus.dart';
/// calls [onShake] when the phone is shaken: a few hard jolts within a second.
class ShakeDetector {
static const _gravity = 9.81;
/// how far the pull may be from gravity (m/s²) before it counts as a jolt
static const _joltThreshold = 14.0;
static const _joltsNeeded = 3;
static const _window = Duration(milliseconds: 1000);
/// two samples of one jolt are one jolt
static const _minGap = Duration(milliseconds: 120);
static const _cooldown = Duration(seconds: 3);
final VoidCallback onShake;
final _jolts = <DateTime>[];
StreamSubscription<AccelerometerEvent>? _subscription;
DateTime? _lastShake;
ShakeDetector(this.onShake);
void start() {
_subscription ??= accelerometerEventStream(
samplingPeriod: SensorInterval.gameInterval,
).listen((event) => handle(event.x, event.y, event.z, DateTime.now()));
}
void stop() {
_subscription?.cancel();
_subscription = null;
_jolts.clear();
}
@visibleForTesting
void handle(double x, double y, double z, DateTime now) {
final pull = math.sqrt(x * x + y * y + z * z);
if ((pull - _gravity).abs() < _joltThreshold) return;
final last = _lastShake;
if (last != null && now.difference(last) < _cooldown) return;
if (_jolts.isNotEmpty && now.difference(_jolts.last) < _minGap) return;
_jolts
..add(now)
..removeWhere((jolt) => now.difference(jolt) > _window);
if (_jolts.length >= _joltsNeeded) {
_jolts.clear();
_lastShake = now;
onShake();
}
}
}

View File

@@ -1,3 +1,4 @@
import 'package:firka_common/data/isar_writes.dart';
import 'package:firka_common/core/consts.dart';
import 'package:firka/core/bloc/home_refresh_cubit.dart';
import 'package:firka_common/core/grade_helper.dart';
@@ -91,7 +92,6 @@ Future<void> showFirkaBottomSheet(
);
}
Future<void> showLessonBottomSheet(
BuildContext context,
AppInitialization data,
@@ -108,10 +108,9 @@ Future<void> showLessonBottomSheet(
final y2k = DateTime(2000, 1);
String fmt(DateTime? dt) =>
(dt != null && dt.isAfter(y2k))
? dt.format(data.l10n, FormatMode.yyyymmddhhmmss)
: 'N/A';
String fmt(DateTime? dt) => (dt != null && dt.isAfter(y2k))
? dt.format(data.l10n, FormatMode.yyyymmddhhmmss)
: 'N/A';
if (statsForNerdsEnabled) {
final cg = lesson.classGroup.loadAndGet();
@@ -142,7 +141,12 @@ Future<void> showLessonBottomSheet(
('edu. order', cg?.educationalOrderName ?? 'N/A'),
('homework', hw != null ? 'Yes (id: ${hw.cacheKey})' : 'None'),
('test', tst != null ? '${tst.method}: ${tst.topic ?? "N/A"}' : 'None'),
('omission', omission != null ? '${omission.state.name}${omission.lateMins != null ? " (${omission.lateMins}m)" : ""}' : 'None'),
(
'omission',
omission != null
? '${omission.state.name}${omission.lateMins != null ? " (${omission.lateMins}m)" : ""}'
: 'None',
),
];
statsForNerds = StatsForNerdsTable(rows: rows);
}
@@ -310,8 +314,6 @@ Future<void> showLessonBottomSheet(
]);
}
Future<void> showOmissionBottomSheet(
BuildContext context,
AppInitialization data,
@@ -608,11 +610,14 @@ Future<void> showHomeworkBottomSheet(
],
color: appStyle.colors.accent,
),
onTap: () {
data.isar.writeTxnSync(() {
homework.isDone = true;
data.isar.homeworkCacheModels.putSync(homework);
onTap: () async {
await isarWrite(() {
data.isar.writeTxnSync(() {
homework.isDone = true;
data.isar.homeworkCacheModels.putSync(homework);
});
});
if (!context.mounted) return;
context.read<HomeRefreshCubit>().requestRefresh();
Navigator.pop(context);
},

View File

@@ -7,28 +7,34 @@ class FirkaIconButton extends StatelessWidget {
final VoidCallback? onTap;
final Color? color;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const FirkaIconButton({
required this.child,
this.onTap,
this.color,
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
final button = Container(
width: 32,
height: 32,
padding: const EdgeInsets.all(6),
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
color: color ?? appStyle.colors.buttonSecondaryFill,
color: color ?? style.colors.buttonSecondaryFill,
borderRadius: BorderRadius.circular(8),
boxShadow: [
BoxShadow(
color: appStyle.colors.shadowColor,
color: style.colors.shadowColor,
offset: const Offset(0, 1),
blurRadius: appStyle.colors.shadowBlur.toDouble(),
blurRadius: style.colors.shadowBlur.toDouble(),
),
],
),

View File

@@ -23,10 +23,7 @@ class ErrorPage extends StatelessWidget {
Column(
children: [
SizedBox(height: 48),
const DaveMascot.error(
width: 50,
height: 50,
),
const DaveMascot.error(width: 50, height: 50),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 24,
@@ -115,8 +112,8 @@ class ErrorPage extends StatelessWidget {
),
SizedBox(height: 20),
ElevatedButton(
// TODO: report bug
onPressed: () => Navigator.pop(context),
onPressed: () =>
appRouter?.push('/feedback', extra: exception),
style: ElevatedButton.styleFrom(
foregroundColor: appStyle.colors.textPrimary,
backgroundColor: appStyle.colors.accent,

View File

@@ -76,6 +76,7 @@ class FirkaToastWidget extends StatefulWidget {
return FirkaToastWidget(
backgroundColor: appStyle.colors.errorCard,
onTap: () {
initData.toastCubit.clear();
showReauthBottomSheet(context, initData, initData.l10n.reauth);
},
onDismiss: () {

View File

@@ -8,6 +8,7 @@ void showReauthBottomSheet(
AppInitialization data,
String message,
) {
data.toastCubit.clear();
showModalBottomSheet(
context: context,
elevation: 100,
@@ -16,36 +17,41 @@ void showReauthBottomSheet(
enableDrag: false,
backgroundColor: Colors.transparent,
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
color: appStyle.colors.background,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
color: appStyle.colors.errorCard,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
child: Text(
message,
style: appStyle.fonts.B_16R.copyWith(
color: appStyle.colors.errorText,
final height = MediaQuery.of(context).size.height * 0.92;
return SizedBox(
height: height,
child: Container(
decoration: BoxDecoration(
color: appStyle.colors.background,
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
children: [
Container(
width: double.infinity,
padding: const EdgeInsets.all(16.0),
decoration: BoxDecoration(
color: appStyle.colors.errorCard,
borderRadius:
BorderRadius.vertical(top: Radius.circular(16)),
),
child: Text(
message,
style: appStyle.fonts.B_16R.copyWith(
color: appStyle.colors.errorText,
),
textAlign: TextAlign.center,
),
textAlign: TextAlign.center,
),
),
Expanded(
child: LoginWebviewWidget(
data,
username: data.client!.cache.token.username,
schoolId: data.client!.cache.token.iss,
Expanded(
child: LoginWebviewWidget(
data,
username: data.client!.cache.token.username,
schoolId: data.client!.cache.token.iss,
),
),
),
],
],
),
),
);
},

View File

@@ -104,125 +104,125 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: [
Text(
widget.data.l10n.your_subjects,
style: appStyle.fonts.H_14px.apply(
color: appStyle.colors.textSecondary,
),
),
SizedBox(height: 16),
Column(
spacing: 16,
mainAxisSize: MainAxisSize.min,
children: gradeCards,
),
SizedBox(height: 16),
Text(
widget.data.l10n.data,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textSecondary,
),
),
SizedBox(height: 16),
FirkaCard(
left: [
Text(
widget.data.l10n.subject_avg,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
Text(
widget.data.l10n.your_subjects,
style: appStyle.fonts.H_14px.apply(
color: appStyle.colors.textSecondary,
),
],
right: [
if (subjectAverage != null)
Container(
width: 48,
height: 26,
decoration: ShapeDecoration(
color: getGradeColor(subjectAverage).withAlpha(38),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
subjectAverage.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(subjectAverage),
),
),
),
),
],
),
FirkaCard(
left: [
Text(
widget.data.l10n.subject_avg_rounded,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
SizedBox(height: 16),
Column(
spacing: 16,
mainAxisSize: MainAxisSize.min,
children: gradeCards,
),
SizedBox(height: 16),
Text(
widget.data.l10n.data,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textSecondary,
),
],
right: [
if (roundedSubjectAverage != null)
Container(
width: 48,
height: 26,
decoration: ShapeDecoration(
color: getGradeColor(
roundedSubjectAverage,
).withAlpha(38),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
roundedSubjectAverage.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(roundedSubjectAverage),
),
),
),
),
],
),
if (classAverage != null)
),
SizedBox(height: 16),
FirkaCard(
left: [
Text(
widget.data.l10n.class_avg,
widget.data.l10n.subject_avg,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
],
right: [
Container(
width: 48,
height: 26,
decoration: ShapeDecoration(
color: Colors.transparent,
shape: RoundedRectangleBorder(
side: BorderSide(
color: getGradeColor(classAverage),
if (subjectAverage != null)
Container(
width: 48,
height: 26,
decoration: ShapeDecoration(
color: getGradeColor(subjectAverage).withAlpha(38),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
subjectAverage.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(subjectAverage),
),
),
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
classAverage.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(classAverage),
),
),
],
),
FirkaCard(
left: [
Text(
widget.data.l10n.subject_avg_rounded,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
],
right: [
if (roundedSubjectAverage != null)
Container(
width: 48,
height: 26,
decoration: ShapeDecoration(
color: getGradeColor(
roundedSubjectAverage,
).withAlpha(38),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
roundedSubjectAverage.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(roundedSubjectAverage),
),
),
),
),
],
),
/*
if (classAverage != null)
FirkaCard(
left: [
Text(
widget.data.l10n.class_avg,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
],
right: [
Container(
width: 48,
height: 26,
decoration: ShapeDecoration(
color: Colors.transparent,
shape: RoundedRectangleBorder(
side: BorderSide(
color: getGradeColor(classAverage),
),
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
classAverage.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(classAverage),
),
),
),
),
],
),
/*
FirkaCard(
left: [
Text(
@@ -247,10 +247,10 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
),
],
),*/
],
],
),
),
),
),
],
),
);

View File

@@ -163,10 +163,7 @@ class _HomeGradesSubjectScreen extends FirkaState<HomeGradesSubjectScreen> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const DaveMascot(
width: 48,
height: 48,
),
const DaveMascot(width: 48, height: 48),
SizedBox(height: 12),
Text(
initData.l10n.no_grades,

View File

@@ -206,12 +206,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
_FadeInWhenLoaded(
loaded: student != null,
child: student != null
? WelcomeWidget(
widget.data.l10n,
now,
student,
todayLesson,
)
? WelcomeWidget(widget.data.l10n, now, student, todayLesson)
: const SizedBox.shrink(),
),
SizedBox(height: 48),
@@ -262,10 +257,7 @@ 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,
});
const _FadeInWhenLoaded({required this.loaded, required this.child});
final bool loaded;
final Widget child;

View File

@@ -186,119 +186,122 @@ class _HomeOmissionsScreen extends FirkaState<HomeOmissionsScreen> {
children: [
Text(
initData.l10n.subjects,
style: appStyle.fonts.B_16SB.copyWith(
color: appStyle.colors.textPrimary,
style: appStyle.fonts.B_16SB.copyWith(
color: appStyle.colors.textPrimary,
),
),
),
SizedBox(height: 10),
...omissionItems
.fold(
LinkedHashMap<
SubjectCacheModel,
List<OmissionCacheModel>
>(
equals: (a, b) => a.cacheKey == b.cacheKey,
hashCode: (a) => a.cacheKey,
),
(map, o) => map
..putIfAbsent(
o.lesson.loadAndGet()!.subject.loadAndGet()!,
() => [],
).add(o),
)
.entries
.map((entry) {
final excused = entry.value
.where((o) => o.state == OmissionState.excused)
.length;
final unexcused = entry.value
.where((o) => o.state == OmissionState.unexcused)
.length;
final pending = entry.value
.where((o) => o.state == OmissionState.pending)
.length;
return FirkaCard.single(
height: 64,
margin: EdgeInsets.only(bottom: 10),
padding: EdgeInsets.symmetric(horizontal: 16),
child: Row(
spacing: 12,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InfoCard.buildSubject(
appStyle.colors.accent,
entry.key,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
spacing: 2,
children: [
Text(
entry.key.name,
style: appStyle.fonts.B_16SB.copyWith(
color: appStyle.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
Row(
spacing: 4,
children: [
FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"checkSolid",
size: 12.0,
color: appStyle.colors.accent,
),
Text(
excused.toString(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
),
),
SizedBox(width: 4),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.timerSolid,
size: 12.0,
color: appStyle.colors.warningAccent,
),
Text(
pending.toString(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
),
),
SizedBox(width: 4),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.restrictedLine,
size: 12.0,
color: appStyle.colors.errorAccent,
),
Text(
unexcused.toString(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
),
),
],
),
],
),
),
],
SizedBox(height: 10),
...omissionItems
.fold(
LinkedHashMap<
SubjectCacheModel,
List<OmissionCacheModel>
>(
equals: (a, b) => a.cacheKey == b.cacheKey,
hashCode: (a) => a.cacheKey,
),
);
}),
],
(map, o) => map
..putIfAbsent(
o.lesson.loadAndGet()!.subject.loadAndGet()!,
() => [],
).add(o),
)
.entries
.map((entry) {
final excused = entry.value
.where((o) => o.state == OmissionState.excused)
.length;
final unexcused = entry.value
.where((o) => o.state == OmissionState.unexcused)
.length;
final pending = entry.value
.where((o) => o.state == OmissionState.pending)
.length;
return FirkaCard.single(
height: 64,
margin: EdgeInsets.only(bottom: 10),
padding: EdgeInsets.symmetric(horizontal: 16),
child: Row(
spacing: 12,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InfoCard.buildSubject(
appStyle.colors.accent,
entry.key,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
spacing: 2,
children: [
Text(
entry.key.name,
style: appStyle.fonts.B_16SB.copyWith(
color: appStyle.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
Row(
spacing: 4,
children: [
FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"checkSolid",
size: 12.0,
color: appStyle.colors.accent,
),
Text(
excused.toString(),
style: appStyle.fonts.B_14R.copyWith(
color:
appStyle.colors.textSecondary,
),
),
SizedBox(width: 4),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.timerSolid,
size: 12.0,
color: appStyle.colors.warningAccent,
),
Text(
pending.toString(),
style: appStyle.fonts.B_14R.copyWith(
color:
appStyle.colors.textSecondary,
),
),
SizedBox(width: 4),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.restrictedLine,
size: 12.0,
color: appStyle.colors.errorAccent,
),
Text(
unexcused.toString(),
style: appStyle.fonts.B_14R.copyWith(
color:
appStyle.colors.textSecondary,
),
),
],
),
],
),
),
],
),
);
}),
],
),
),
),
),
],
),
);

View File

@@ -132,7 +132,9 @@ class _DebugScreen extends FirkaState<DebugScreen> {
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextField(
controller: _mockBackendUrlController,
decoration: const InputDecoration(labelText: 'mock backend url'),
decoration: const InputDecoration(
labelText: 'mock backend url',
),
onSubmitted: (value) {
Settings.mockBackendUrl.set(value);
},
@@ -293,19 +295,23 @@ class _DebugScreen extends FirkaState<DebugScreen> {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
SurpriseCardFaceDebugScreen(grades.first, widget.data.l10n),
builder: (context) => SurpriseCardFaceDebugScreen(
grades.first,
widget.data.l10n,
),
),
);
},
child: const Text('Epikus jegyszerzés (card face debug)'),
),
ElevatedButton(
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')),
const SnackBar(
content: Text('No token available to copy'),
),
);
return;
}
@@ -540,11 +546,7 @@ Widget _themeColorSwatch(BuildContext context, String name, Color color) {
name,
style: TextTheme.of(context).bodySmall?.copyWith(color: labelColor),
),
FilledCircle(
diameter: 40,
color: color,
child: const SizedBox(),
),
FilledCircle(diameter: 40, color: color, child: const SizedBox()),
],
),
);

View File

@@ -0,0 +1,556 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:dio/dio.dart';
import 'package:firka/app/app_state.dart';
import 'package:firka/core/feedback_report.dart';
import 'package:firka/core/state/firka_state.dart';
import 'package:firka/ui/components/firka_icon_button.dart';
import 'package:firka/ui/phone/screens/settings/settings_toggle.dart';
import 'package:firka/ui/shared/dave_mascot.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:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import 'package:majesticons_flutter/majesticons_flutter.dart';
const _feedbackUrl = 'https://api.firka.app/v1/contact';
const _maxImages = 5;
const _maxImageBytes = 5 * 1024 * 1024;
const _maxImagesTotalBytes = 8 * 1024 * 1024;
final _emailPattern = RegExp(r'^[^\s@]+@[^\s@]+\.[^\s@]+$');
class _Picture {
final String name;
final Uint8List bytes;
const _Picture(this.name, this.bytes);
}
class FeedbackScreen extends StatefulWidget {
final AppInitialization data;
/// the error the person is reporting, when they come from the error page
final String? error;
const FeedbackScreen(this.data, {this.error, super.key});
@override
State<FeedbackScreen> createState() => _FeedbackScreenState();
}
class _FeedbackScreenState extends FirkaState<FeedbackScreen> {
final _email = TextEditingController();
final _message = TextEditingController();
final _emailFocus = FocusNode();
final _messageFocus = FocusNode();
final _pictures = <_Picture>[];
late bool _attachLogs = widget.error != null;
String? _emailError;
String? _messageError;
String? _pictureError;
String? _sendError;
bool _sending = false;
bool _sent = false;
Future<void> _pickPictures() async {
final l10n = widget.data.l10n;
final room = _maxImages - _pictures.length;
if (room <= 0) return;
try {
// on android this is the system photo picker, it needs no permission
final picker = ImagePicker();
final List<XFile> picked;
if (room == 1) {
final one = await picker.pickImage(
source: ImageSource.gallery,
maxWidth: 2000,
maxHeight: 2000,
imageQuality: 85,
);
picked = one == null ? [] : [one];
} else {
picked = await picker.pickMultiImage(
maxWidth: 2000,
maxHeight: 2000,
imageQuality: 85,
limit: room,
);
}
String? problem;
var total = _pictures.fold<int>(0, (sum, p) => sum + p.bytes.length);
final added = <_Picture>[];
for (final file in picked) {
final bytes = await file.readAsBytes();
if (bytes.length > _maxImageBytes) {
problem = l10n.fb_err_image_big;
} else if (total + bytes.length > _maxImagesTotalBytes) {
problem = l10n.fb_err_images_total;
} else {
total += bytes.length;
added.add(_Picture(file.name, bytes));
}
}
if (!mounted) return;
setState(() {
_pictures.addAll(added);
_pictureError = problem;
});
} catch (e) {
logger.warning('[Feedback] picking pictures failed: $e');
}
}
Future<void> _send() async {
if (_sending) return;
final l10n = widget.data.l10n;
final email = _email.text.trim();
final message = _message.text.trim();
// only the message is needed, an e-mail address just lets us answer
final emailError = email.isNotEmpty && !_emailPattern.hasMatch(email)
? l10n.fb_err_email_invalid
: null;
final messageError = message.isEmpty ? l10n.fb_err_message_empty : null;
setState(() {
_emailError = emailError;
_messageError = messageError;
_sendError = null;
});
if (messageError != null || emailError != null) {
(messageError != null ? _messageFocus : _emailFocus).requestFocus();
return;
}
setState(() => _sending = true);
try {
final logs = _attachLogs
? await collectFeedbackLogs(widget.data.appDir, error: widget.error)
: null;
final info = widget.data.packageInfo;
final device = widget.data.devInfo;
final res = await dio.post(
_feedbackUrl,
data: {
'email': email,
'message': message,
'source': 'app',
'app_version': '${info.version}+${info.buildNumber}',
'platform':
'Android ${device.versionRelease} '
'(API ${device.versionSdkInt}), ${device.model}',
'logs': ?logs,
'images': [
for (final picture in _pictures)
{'name': picture.name, 'data': base64Encode(picture.bytes)},
],
},
options: Options(
contentType: Headers.jsonContentType,
sendTimeout: const Duration(seconds: 40),
receiveTimeout: const Duration(seconds: 40),
),
);
if (!mounted) return;
final status = res.statusCode ?? 0;
if (status >= 200 && status < 300) {
setState(() => _sent = true);
} else {
final data = res.data;
setState(
() => _sendError = data is Map && data['error'] is String
? data['error'] as String
: l10n.fb_err_send,
);
}
} catch (e) {
logger.warning('[Feedback] sending failed: $e');
if (mounted) setState(() => _sendError = l10n.fb_err_send);
} finally {
if (mounted) setState(() => _sending = false);
}
}
void _close() {
if (context.canPop()) {
context.pop();
} else {
context.go('/home');
}
}
@override
Widget build(BuildContext context) {
final l10n = widget.data.l10n;
if (_sent) return _sentPage();
return Scaffold(
backgroundColor: appStyle.colors.background,
body: SafeArea(
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
padding: const EdgeInsets.fromLTRB(20, 8, 20, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_backButton(),
const SizedBox(height: 8),
..._formContent(),
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 16),
child: _primaryButton(
_sending ? l10n.fb_sending : l10n.fb_send,
_sending ? null : _send,
),
),
],
),
),
);
}
Widget _backButton() {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: _close,
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 8, 16, 8),
child: Row(
children: [
Transform.translate(
offset: const Offset(-4, 0),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.chevronLeftLine,
color: appStyle.colors.textSecondary,
),
),
Transform.translate(
offset: const Offset(-4, 1),
child: Text(
widget.data.l10n.s_feedback,
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
),
),
),
],
),
),
);
}
/// the same button as on the error screen, with the dark text every lime button has
Widget _primaryButton(String text, VoidCallback? onPressed) {
return ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
foregroundColor: appStyle.colors.textPrimaryLight,
backgroundColor: appStyle.colors.accent,
disabledForegroundColor: appStyle.colors.textPrimaryLight,
disabledBackgroundColor: appStyle.colors.accent.withValues(alpha: 0.6),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 1,
shadowColor: appStyle.colors.shadowColor,
minimumSize: Size.fromHeight(48),
),
child: Text(
text,
style: appStyle.fonts.H_18px.copyWith(
fontWeight: FontWeight.w700,
color: appStyle.colors.textPrimaryLight,
),
),
);
}
/// laid out like the error screen: the mascot, two lines, the button at the bottom
Widget _sentPage() {
final l10n = widget.data.l10n;
return Scaffold(
backgroundColor: appStyle.colors.background,
body: Padding(
padding: const EdgeInsets.symmetric(vertical: 64, horizontal: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
SizedBox(height: 48),
const DaveMascot.icon(width: 50, height: 50),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 24,
horizontal: 32,
),
child: Text(
l10n.fb_sent_title,
style: appStyle.fonts.H_H2.copyWith(
color: appStyle.colors.textPrimary,
fontSize: 24,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text(
// without an address nobody can be answered
_email.text.trim().isEmpty
? l10n.fb_sent_no_reply
: l10n.fb_sent,
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
),
textAlign: TextAlign.center,
),
),
],
),
_primaryButton(l10n.okay, _close),
],
),
),
);
}
List<Widget> _formContent() {
final l10n = widget.data.l10n;
return [
Text(
l10n.fb_intro,
style: appStyle.fonts.B_16R.apply(color: appStyle.colors.textSecondary),
),
const SizedBox(height: 20),
_field(
hint: l10n.fb_message,
controller: _message,
focus: _messageFocus,
error: _messageError,
keyboardType: TextInputType.multiline,
maxLength: 5000,
minLines: 6,
maxLines: 10,
onChanged: () => _messageError = null,
),
const SizedBox(height: 16),
_picturesSection(),
const SizedBox(height: 16),
_field(
hint: l10n.fb_email,
controller: _email,
focus: _emailFocus,
error: _emailError,
keyboardType: TextInputType.emailAddress,
maxLength: 254,
onChanged: () => _emailError = null,
),
const SizedBox(height: 16),
_logsCard(),
if (_sendError != null) ...[
const SizedBox(height: 16),
Text(
_sendError!,
style: appStyle.fonts.B_14R.apply(color: appStyle.colors.errorText),
),
],
];
}
Widget _field({
required String hint,
required TextEditingController controller,
required FocusNode focus,
required String? error,
required TextInputType keyboardType,
required int maxLength,
required VoidCallback onChanged,
int minLines = 1,
int maxLines = 1,
}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
FirkaCard.single(
margin: EdgeInsets.zero,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
borderColor: error != null ? appStyle.colors.errorAccent : null,
child: TextField(
controller: controller,
focusNode: focus,
keyboardType: keyboardType,
minLines: minLines,
maxLines: maxLines,
maxLength: maxLength,
onChanged: (_) {
if (error != null) setState(onChanged);
},
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,
counterText: '',
),
),
),
if (error != null) ...[
const SizedBox(height: 6),
Text(
error,
style: appStyle.fonts.B_14R.apply(color: appStyle.colors.errorText),
),
],
],
);
}
Widget _picturesSection() {
final l10n = widget.data.l10n;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Wrap(
spacing: 8,
runSpacing: 8,
children: [
for (var i = 0; i < _pictures.length; i++) _thumbnail(i),
if (_pictures.length < _maxImages)
Semantics(
button: true,
label: l10n.fb_add_images,
child: GestureDetector(
onTap: _pickPictures,
child: FirkaCard.single(
margin: EdgeInsets.zero,
width: 72,
height: 72,
child: Center(
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.imageLine,
color: appStyle.colors.accent,
),
),
),
),
),
],
),
const SizedBox(height: 8),
Text(
_pictureError ?? l10n.fb_images_hint,
style: appStyle.fonts.B_14R.apply(
color: _pictureError != null
? appStyle.colors.errorText
: appStyle.colors.textTertiary,
),
),
],
);
}
Widget _thumbnail(int index) {
return SizedBox(
width: 72,
height: 72,
child: Stack(
children: [
Positioned.fill(
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.memory(
_pictures[index].bytes,
fit: BoxFit.cover,
cacheWidth: 216,
),
),
),
Positioned(
top: 4,
right: 4,
child: Semantics(
button: true,
label: widget.data.l10n.fb_remove_image,
child: FirkaIconButton(
onTap: () => setState(() {
_pictures.removeAt(index);
_pictureError = null;
}),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.closeLine,
color: appStyle.colors.textSecondary,
),
),
),
),
],
),
);
}
Widget _logsCard() {
final l10n = widget.data.l10n;
return FirkaCard.single(
margin: EdgeInsets.zero,
padding: const EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: Text(
l10n.fb_attach_logs,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
),
const SizedBox(width: 12),
SettingsToggle(
value: _attachLogs,
onChanged: (value) => setState(() => _attachLogs = value),
),
],
),
const SizedBox(height: 8),
Text(
l10n.fb_attach_logs_desc,
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
),
),
],
),
);
}
@override
void dispose() {
_email.dispose();
_message.dispose();
_emailFocus.dispose();
_messageFocus.dispose();
super.dispose();
}
}

View File

@@ -147,10 +147,7 @@ class _HomeScreenState extends FirkaState<HomeScreen>
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Stack(
children: [
widget.child,
?(_toastOverlay(context)),
],
children: [widget.child, ?(_toastOverlay(context))],
),
),
),

View File

@@ -119,7 +119,9 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
TextButton(
child: Text(
wasEnabled ? 'Disable' : 'Enable',
style: appStyle.fonts.B_14R.apply(color: appStyle.colors.accent),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.accent,
),
),
onPressed: () => Navigator.of(dialogContext).pop(true),
),

View File

@@ -25,10 +25,9 @@ class MessageScreen extends StatelessWidget {
Widget build(BuildContext context) {
final statsForNerdsEnabled = Settings.statsForNerds.value;
final y2k = DateTime(2000, 1);
String fmt(DateTime? dt) =>
(dt != null && dt.isAfter(y2k))
? dt.format(data.l10n, FormatMode.yyyymmddhhmmss)
: '-';
String fmt(DateTime? dt) => (dt != null && dt.isAfter(y2k))
? dt.format(data.l10n, FormatMode.yyyymmddhhmmss)
: '-';
Widget? statsForNerds;
if (statsForNerdsEnabled) {
@@ -42,10 +41,8 @@ class MessageScreen extends StatelessWidget {
('date', fmt(message.createdAt)),
if (message.itemCreatedAt != null)
('created at', fmt(message.itemCreatedAt)),
if (message.validFrom != null)
('valid from', fmt(message.validFrom)),
if (message.validTo != null)
('valid to', fmt(message.validTo)),
if (message.validFrom != null) ('valid from', fmt(message.validFrom)),
if (message.validTo != null) ('valid to', fmt(message.validTo)),
('student', student?.name ?? '-'),
('student id', student?.cacheKey.toString() ?? '-'),
('html length', '${message.contentHtml.length} chars'),
@@ -94,7 +91,7 @@ class MessageScreen extends StatelessWidget {
offset: const Offset(-4, 1),
child: Text(
data.l10n.s_a,
style: appStyle.fonts.B_16R.apply(
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
),
),
@@ -111,7 +108,9 @@ class MessageScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.85,
width:
MediaQuery.of(context).size.width *
0.85,
child: Text(
message.title,
textAlign: TextAlign.center,
@@ -150,18 +149,24 @@ class MessageScreen extends StatelessWidget {
width: 28,
height: 28,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 6),
padding: const EdgeInsets.only(
bottom: 6,
),
child: Text(
message.author.isNotEmpty
? message.author[0]
: '?',
style: appStyle.fonts.H_18px.copyWith(
fontSize: 20,
color: appStyle.colors.textPrimary,
),
style: appStyle.fonts.H_18px
.copyWith(
fontSize: 20,
color: appStyle
.colors
.textPrimary,
),
),
),
],
@@ -170,14 +175,20 @@ class MessageScreen extends StatelessWidget {
),
SizedBox(width: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 1.4,
width:
MediaQuery.of(
context,
).size.width /
1.4,
child: Text(
message.author,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
color:
appStyle.colors.textPrimary,
),
),
),
@@ -207,7 +218,8 @@ class MessageScreen extends StatelessWidget {
style: {
"*": Style.fromTextStyle(
appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
color:
appStyle.colors.textPrimary,
),
),
},
@@ -223,12 +235,14 @@ class MessageScreen extends StatelessWidget {
margin: EdgeInsets.all(0),
padding: EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'Debug info',
style: appStyle.fonts.H_14px.apply(
color: appStyle.colors.textPrimary,
color:
appStyle.colors.textPrimary,
),
),
SizedBox(height: 10),

View File

@@ -1,3 +1,4 @@
import 'package:firka_common/data/isar_writes.dart';
import "package:dart_jsonwebtoken/dart_jsonwebtoken.dart";
import "package:firka/app/app_state.dart";
import "package:firka/app/initialization.dart";
@@ -143,9 +144,7 @@ class SettingsAccountPickerView extends StatelessWidget {
await initializeApp();
if (data.client != null) {
await NotificationDeliveryService.onUserLogin(
client: data.client!,
);
await NotificationDeliveryService.onUserLogin(client: data.client!);
}
if (!context.mounted) return;
@@ -166,9 +165,9 @@ class SettingsAccountPickerView extends StatelessWidget {
logger.warning('[Settings] Failed to clear cached data on logout: $e');
}
await data.isar.writeTxn(() async {
await data.isar.tokenModels.delete(active);
});
await isarWrite(
() => data.isar.writeTxn(() => data.isar.tokenModels.delete(active)),
);
await data.settings.setSelectedAccountKey(0);
final accounts = await data.isar.tokenModels.where().findAll();

View File

@@ -205,8 +205,9 @@ class SettingsAppIconPickerView extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: MediaQuery.of(context).size.height / 1.7,
// takes whatever height is left over, so the list is the only thing
// that scrolls and the buttons below stay on screen
Expanded(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -214,6 +215,15 @@ class SettingsAppIconPickerView extends StatelessWidget {
),
),
),
const SizedBox(height: 12),
// sits outside the scrolling grid so it is always visible
Text(
data.l10n.s_ci_restart_notice,
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
),
),
const SizedBox(height: 12),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [

View File

@@ -69,12 +69,19 @@ class _SettingsFcmStatusViewState extends State<SettingsFcmStatusView> {
(LastSeenHelper.notifAbsences, l10n.s_notif_absences),
(LastSeenHelper.notifLessons, l10n.s_notif_lessons),
(LastSeenHelper.notifLessonsCancelled, l10n.s_notif_lessons_cancelled),
(LastSeenHelper.notifLessonsSubstituted, l10n.s_notif_lessons_substituted),
(
LastSeenHelper.notifLessonsSubstituted,
l10n.s_notif_lessons_substituted,
),
(LastSeenHelper.notifMessages, l10n.s_notif_messages),
];
}
Widget _testButton(String kind, String label, {bool simulateMultiAccount = false}) {
Widget _testButton(
String kind,
String label, {
bool simulateMultiAccount = false,
}) {
final scale = settingsScale(context);
return GestureDetector(
@@ -153,7 +160,8 @@ class _SettingsFcmStatusViewState extends State<SettingsFcmStatusView> {
_row(l10n.s_fcm_status_topic_label, FcmService.subscribedTopic),
_row(
l10n.s_fcm_status_last_refresh_label,
lastRefresh?.toIso8601String() ?? l10n.s_fcm_status_last_refresh_never,
lastRefresh?.toIso8601String() ??
l10n.s_fcm_status_last_refresh_never,
),
GestureDetector(
onTap: _loadPermissionStatus,
@@ -179,13 +187,17 @@ class _SettingsFcmStatusViewState extends State<SettingsFcmStatusView> {
const SizedBox(height: 12),
Text(
l10n.s_fcm_test_notifications_title,
style: appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
for (final (kind, label) in _testKinds()) _testButton(kind, label),
const SizedBox(height: 12),
Text(
l10n.s_fcm_test_notifications_multi_title,
style: appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
),
),
for (final (kind, label) in _testKinds())
_testButton(kind, label, simulateMultiAccount: true),

View File

@@ -140,8 +140,9 @@ class _SettingsPersonalizationViewState
}
Widget _coreThemePager() {
final isCustomTheme =
!isBuiltinThemeId(_settings.get(SettingsRegistry.selectedThemeId));
final isCustomTheme = !isBuiltinThemeId(
_settings.get(SettingsRegistry.selectedThemeId),
);
if (isCustomTheme) {
return IgnorePointer(
@@ -221,16 +222,13 @@ class _SettingsPersonalizationViewState
}
Widget _checkMark() {
return SizedBox(
width: 16,
height: 16,
child: Checkbox(
value: true,
fillColor: WidgetStateProperty.resolveWith<Color>((_) {
return appStyle.colors.secondary;
}),
onChanged: (_) {},
),
// the design marks the selection with a bare check glyph, not a
// Material checkbox (Figma majesticons:check, 16x16)
return FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"check",
size: 16,
color: appStyle.colors.secondary,
);
}

View File

@@ -118,7 +118,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
offset: const Offset(-8, 1),
child: Text(
item.title,
style: appStyle.fonts.B_16R.apply(
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
),
),
@@ -226,11 +226,14 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
item.redirectTo == "privacy") {
launchUrlString("https://firka.app/privacy");
return;
} else if (item.redirectTo == "feedback") {
context.push('/feedback');
return;
} else {
context.push('/settings', extra: item.children);
}
},
child: item.redirectTo != null
child: item.redirectTo != null && item.redirectTo != "feedback"
? FirkaCard(
height: settingsItemHeight * scale,
rounding: settingsItemRounding * scale,
@@ -318,7 +321,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
widgets.add(
FirkaCard(
height: settingsItemHeight * scale,
rounding: settingsItemRounding * scale,
rounding: settingsItemRounding * scale,
left: [
Text(
k,
@@ -357,7 +360,7 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
GestureDetector(
child: FirkaCard(
height: settingsItemHeight * scale,
rounding: settingsItemRounding * scale,
rounding: settingsItemRounding * scale,
left: [
Text(
k,
@@ -390,22 +393,19 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
continue;
}
if (item is SettingsUiPersonalization) {
widgets.add(
SettingsPersonalizationView(
data: widget.data,
item: item,
),
);
widgets.add(SettingsPersonalizationView(data: widget.data, item: item));
continue;
}
if (item is SettingsUiAppIconPicker) {
widgets.add(
SettingsAppIconPickerView(
data: widget.data,
item: item,
settings: settings,
setStateOuter: setState,
Expanded(
child: SettingsAppIconPickerView(
data: widget.data,
item: item,
settings: settings,
setStateOuter: setState,
),
),
);
@@ -472,6 +472,9 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
@override
Widget build(BuildContext context) {
var body = createWidgetTree(widget.items, widget.data.settings);
// The icon picker fills the screen and scrolls its own grid, so the page
// around it must not be a scroll view (two nested ones cut off the end).
final fillsScreen = widget.items.any((i) => i is SettingsUiAppIconPicker);
return BlocProvider.value(
value: appIconPickerCubit,
@@ -482,13 +485,22 @@ class _SettingsScreenState extends FirkaState<SettingsScreen> {
body: SafeArea(
child: Stack(
children: [
SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: body,
if (fillsScreen)
Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: body,
),
)
else
SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 40),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: body,
),
),
),
],
),
),

View File

@@ -105,7 +105,7 @@ class _SurpriseGradesScreenState extends State<SurpriseGradesScreen> {
const SizedBox(width: 6),
Text(
"Főoldal",
style: appStyle.fonts.B_16R.apply(
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
),
),

View File

@@ -1,3 +1,4 @@
import 'package:firka_common/data/isar_writes.dart';
import "dart:math" as math;
import "package:carousel_slider/carousel_slider.dart";
@@ -10,6 +11,7 @@ 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/color_slider.dart";
import "package:firka/core/theme_palette.dart";
import "package:firka/ui/phone/screens/themes/builtin_theme_id.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";
@@ -19,6 +21,7 @@ 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";
import "package:firka_common/ui/theme/theme_binary_format.dart";
import "package:firka_common/ui/theme/style.dart";
import "package:flutter/material.dart";
import "package:flutter/services.dart";
@@ -80,90 +83,9 @@ const _defaultGradients = (
dark: [Color(0xFF0D1202), Color(0xFF1A2405)],
);
(StringSetting, StringSetting) _settingsFor(_ThemeSlot slot) {
switch (slot) {
case _ThemeSlot.accent:
return (
SettingsRegistry.customAccentColorLight,
SettingsRegistry.customAccentColorDark,
);
case _ThemeSlot.background:
return (
SettingsRegistry.customBackgroundColorLight,
SettingsRegistry.customBackgroundColorDark,
);
case _ThemeSlot.card:
return (
SettingsRegistry.customCardColorLight,
SettingsRegistry.customCardColorDark,
);
case _ThemeSlot.button:
return (
SettingsRegistry.customButtonColorLight,
SettingsRegistry.customButtonColorDark,
);
case _ThemeSlot.secondary:
return (
SettingsRegistry.customSecondaryColorLight,
SettingsRegistry.customSecondaryColorDark,
);
case _ThemeSlot.text:
return (
SettingsRegistry.customTextColorLight,
SettingsRegistry.customTextColorDark,
);
case _ThemeSlot.textSecondary:
return (
SettingsRegistry.customTextSecondaryColorLight,
SettingsRegistry.customTextSecondaryColorDark,
);
case _ThemeSlot.textTertiary:
return (
SettingsRegistry.customTextTertiaryColorLight,
SettingsRegistry.customTextTertiaryColorDark,
);
case _ThemeSlot.shadow:
return (
SettingsRegistry.customShadowColorLight,
SettingsRegistry.customShadowColorDark,
);
case _ThemeSlot.success:
return (
SettingsRegistry.customSuccessColorLight,
SettingsRegistry.customSuccessColorDark,
);
case _ThemeSlot.warningAccent:
return (
SettingsRegistry.customWarningAccentColorLight,
SettingsRegistry.customWarningAccentColorDark,
);
case _ThemeSlot.warningText:
return (
SettingsRegistry.customWarningTextColorLight,
SettingsRegistry.customWarningTextColorDark,
);
case _ThemeSlot.warningCard:
return (
SettingsRegistry.customWarningCardColorLight,
SettingsRegistry.customWarningCardColorDark,
);
case _ThemeSlot.errorAccent:
return (
SettingsRegistry.customErrorAccentColorLight,
SettingsRegistry.customErrorAccentColorDark,
);
case _ThemeSlot.errorText:
return (
SettingsRegistry.customErrorTextColorLight,
SettingsRegistry.customErrorTextColorDark,
);
case _ThemeSlot.errorCard:
return (
SettingsRegistry.customErrorCardColorLight,
SettingsRegistry.customErrorCardColorDark,
);
}
}
/// delegates to [themeSlotSettings] via the matching [ThemeColorSlot]
(StringSetting, StringSetting) _settingsFor(_ThemeSlot slot) =>
themeSlotSettings(ThemeColorSlot.values[slot.index]);
void _applySlotColor(FirkaColors colors, _ThemeSlot slot, Color color) {
switch (slot) {
@@ -232,9 +154,7 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
super.initState();
_originalIsLight = appStyle.isLight;
_preview = ThemePreviewData.build();
_hsv = HSVColor.fromColor(
_colorForSlotAndMode(_slot!, _mode),
);
_hsv = HSVColor.fromColor(_colorForSlotAndMode(_slot!, _mode));
_syncHexField();
_refreshPreviewStyle();
}
@@ -288,8 +208,9 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
final editingLight = _mode != _BrightnessMode.dark;
if (_mode == _BrightnessMode.both || editingLight == isLight) {
if (slot == _ThemeSlot.background) {
final stops =
List<Color>.from(_currentGradient(isLightSource: isLight));
final stops = List<Color>.from(
_currentGradient(isLightSource: isLight),
);
if (_bgStopIndex < stops.length) {
stops[_bgStopIndex] = _hsv.toColor();
} else {
@@ -346,8 +267,7 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
final color = _hsv.toColor();
final hex = color.toHexSetting();
_hexController.text =
(color.a >= 1.0 ? hex.substring(4) : hex.substring(2))
.toUpperCase();
(color.a >= 1.0 ? hex.substring(4) : hex.substring(2)).toUpperCase();
}
}
@@ -370,10 +290,12 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
final setting = isLightSource
? SettingsRegistry.customBackgroundGradientLight
: SettingsRegistry.customBackgroundGradientDark;
final stops =
List<Color>.from(_currentGradient(isLightSource: isLightSource));
final idx =
_bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt();
final stops = List<Color>.from(
_currentGradient(isLightSource: isLightSource),
);
final idx = _bgStopIndex
.clamp(0, math.max(0, stops.length - 1))
.toInt();
if (stops.isNotEmpty) {
stops[idx] = color;
} else {
@@ -417,10 +339,13 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
name: widget.data.l10n.s_c_themes_own_label,
origin: ThemeOrigin.own,
swatch: UserTheme.swatchFromAppStyle(),
code: captureThemeCode(_settings),
);
await isarWrite(
() => isarInit.writeTxn(
() => isarInit.userThemeModels.putByThemeId(theme.toModel()),
),
);
await isarInit.writeTxn(() async {
await isarInit.userThemeModels.putByThemeId(theme.toModel());
});
await Settings.selectedThemeId.set(id);
}
@@ -442,8 +367,9 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
_slot = slot;
if (slot == _ThemeSlot.background) {
final stops = _gradientForMode(_mode);
_bgStopIndex =
_bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt();
_bgStopIndex = _bgStopIndex
.clamp(0, math.max(0, stops.length - 1))
.toInt();
}
_hsv = HSVColor.fromColor(_colorForSlotAndMode(slot, _mode));
_refreshPreviewStyle();
@@ -458,8 +384,9 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
if (slot != null) {
if (slot == _ThemeSlot.background) {
final stops = _gradientForMode(mode);
_bgStopIndex =
_bgStopIndex.clamp(0, math.max(0, stops.length - 1)).toInt();
_bgStopIndex = _bgStopIndex
.clamp(0, math.max(0, stops.length - 1))
.toInt();
}
_hsv = HSVColor.fromColor(_colorForSlotAndMode(slot, mode));
}
@@ -473,13 +400,14 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
final setting = isLightSource
? SettingsRegistry.customBackgroundGradientLight
: SettingsRegistry.customBackgroundGradientDark;
final stops =
List<Color>.from(_currentGradient(isLightSource: isLightSource));
final stops = List<Color>.from(
_currentGradient(isLightSource: isLightSource),
);
final lastColor = stops.isNotEmpty
? stops.last
: (isLightSource
? _defaultGradients.light.last
: _defaultGradients.dark.last);
? _defaultGradients.light.last
: _defaultGradients.dark.last);
stops.add(lastColor);
await _settings.set(setting, stops.toHexSettingJson());
}
@@ -513,8 +441,9 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
final setting = isLightSource
? SettingsRegistry.customBackgroundGradientLight
: SettingsRegistry.customBackgroundGradientDark;
final stops =
List<Color>.from(_currentGradient(isLightSource: isLightSource));
final stops = List<Color>.from(
_currentGradient(isLightSource: isLightSource),
);
if (stops.length > 1 && index < stops.length) {
stops.removeAt(index);
await _settings.set(setting, stops.toHexSettingJson());
@@ -629,15 +558,14 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
if (!mounted) return;
setState(() {
_hsv = HSVColor.fromColor(
switch (_mode) {
_BrightnessMode.light => lightDefault,
_BrightnessMode.dark => darkDefault,
_BrightnessMode.both => lightDefault == darkDefault
_hsv = HSVColor.fromColor(switch (_mode) {
_BrightnessMode.light => lightDefault,
_BrightnessMode.dark => darkDefault,
_BrightnessMode.both =>
lightDefault == darkDefault
? lightDefault
: (_originalIsLight ? lightDefault : darkDefault),
},
);
});
_refreshPreviewStyle();
});
_syncHexField();
@@ -749,6 +677,7 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
items: buildThemePreviewCarouselItems(
data: widget.data,
preview: _preview,
style: appStyle,
),
);
}
@@ -838,12 +767,7 @@ class _ThemeEditorScreenState extends State<ThemeEditorScreen> {
final solid = _hsv.toColor().withAlpha(255);
return ColorSlider(
value: _hsv.alpha,
trackGradient: LinearGradient(
colors: [
solid.withAlpha(0),
solid,
],
),
trackGradient: LinearGradient(colors: [solid.withAlpha(0), solid]),
thumbColor: _hsv.toColor(),
onChanged: (t) => _applyHsv(_hsv.withAlpha(t.clamp(0.0, 1.0))),
);

View File

@@ -18,11 +18,16 @@ class ThemePagePreview extends StatelessWidget {
final ThemePreviewNavTab activeTab;
final AppInitialization data;
/// Passed in rather than read from the global style: this frame shows a
/// theme the user is only looking at, which must not escape the preview.
final FirkaStyle style;
const ThemePagePreview({
super.key,
required this.body,
required this.activeTab,
required this.data,
required this.style,
});
@override
@@ -30,14 +35,14 @@ class ThemePagePreview extends StatelessWidget {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 6),
decoration: BoxDecoration(
color: appStyle.colors.backgroundLinearGradient == null
? appStyle.colors.background
color: style.colors.backgroundLinearGradient == null
? style.colors.background
: null,
gradient: appStyle.colors.backgroundLinearGradient,
gradient: style.colors.backgroundLinearGradient,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: appStyle.colors.shadowColor,
color: style.colors.shadowColor,
offset: const Offset(0, 1),
blurRadius: 2,
),
@@ -64,18 +69,19 @@ class ThemePagePreview extends StatelessWidget {
bundle: FirkaBundle(),
child: Container(
decoration: BoxDecoration(
color: appStyle.colors.backgroundLinearGradient == null
? appStyle.colors.background
color: style.colors.backgroundLinearGradient == null
? style.colors.background
: null,
gradient: appStyle.colors.backgroundLinearGradient,
gradient: style.colors.backgroundLinearGradient,
),
child: Column(
children: [
_PreviewStatusBar(),
_PreviewStatusBar(style: style),
Expanded(child: body),
_PreviewBottomNav(
data: data,
activeTab: activeTab,
style: style,
),
],
),
@@ -92,6 +98,10 @@ class ThemePagePreview extends StatelessWidget {
}
class _PreviewStatusBar extends StatelessWidget {
final FirkaStyle style;
const _PreviewStatusBar({required this.style});
@override
Widget build(BuildContext context) {
final time = DateFormat("H:mm").format(DateTime.now());
@@ -103,27 +113,23 @@ class _PreviewStatusBar extends StatelessWidget {
children: [
Text(
time,
style: appStyle.fonts.B_12SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_12SB.apply(
color: style.colors.textPrimary,
),
),
const Spacer(),
Icon(
Icons.signal_cellular_alt,
size: 12,
color: appStyle.colors.textPrimary,
color: style.colors.textPrimary,
),
const SizedBox(width: 4),
Icon(
Icons.wifi,
size: 12,
color: appStyle.colors.textPrimary,
),
Icon(Icons.wifi, size: 12, color: style.colors.textPrimary),
const SizedBox(width: 4),
Icon(
Icons.battery_full,
size: 12,
color: appStyle.colors.textPrimary,
color: style.colors.textPrimary,
),
],
),
@@ -135,10 +141,12 @@ class _PreviewStatusBar extends StatelessWidget {
class _PreviewBottomNav extends StatelessWidget {
final AppInitialization data;
final ThemePreviewNavTab activeTab;
final FirkaStyle style;
const _PreviewBottomNav({
required this.data,
required this.activeTab,
required this.style,
});
@override
@@ -177,10 +185,10 @@ class _PreviewBottomNav extends StatelessWidget {
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [
appStyle.colors.backgroundGradient?.last ??
appStyle.colors.background,
(appStyle.colors.backgroundGradient?.last ??
appStyle.colors.background)
style.colors.backgroundGradient?.last ??
style.colors.background,
(style.colors.backgroundGradient?.last ??
style.colors.background)
.withValues(alpha: 0.0),
],
stops: const [0.0, 1.0],
@@ -198,7 +206,7 @@ class _PreviewBottomNav extends StatelessWidget {
active,
active ? nav.$3 : nav.$4,
nav.$2,
);
style: style,);
}),
BottomNavIconWidget(
() {},
@@ -208,7 +216,7 @@ class _PreviewBottomNav extends StatelessWidget {
: Majesticon.menuLine,
l10n.other,
isProfilePicture: data.profilePicture != null,
),
style: style,),
],
),
),

View File

@@ -217,11 +217,56 @@ class ThemePreviewData {
);
final chartSpanDays = day.difference(sept).inDays.clamp(1, 365);
const chartValues = [
1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
4, 4, 3, 3, 4, 4, 4, 4, 5, 5,
5, 4, 4, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
1,
1,
1,
1,
2,
2,
2,
2,
2,
2,
3,
3,
3,
3,
3,
3,
3,
4,
4,
4,
4,
4,
3,
3,
4,
4,
4,
4,
5,
5,
5,
4,
4,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
5,
];
final chartGrades = [
for (var i = 0; i < chartValues.length; i++)
@@ -230,7 +275,9 @@ class ThemePreviewData {
matematika,
chartValues[i],
sept.add(
Duration(days: (i * chartSpanDays / (chartValues.length - 1)).round()),
Duration(
days: (i * chartSpanDays / (chartValues.length - 1)).round(),
),
),
),
];

View File

@@ -25,40 +25,65 @@ import "package:flutter/material.dart";
import "package:kreta_api/kreta_api.dart";
import "package:majesticons_flutter/majesticons_flutter.dart";
/// [style] is what the pages render with, so a theme can be shown without
/// being applied. Callers that genuinely did apply it pass the global style.
List<Widget> buildThemePreviewCarouselItems({
required AppInitialization data,
required ThemePreviewData preview,
required FirkaStyle style,
}) {
return [
ThemePagePreview(
data: data,
style: style,
activeTab: ThemePreviewNavTab.home,
body: ThemePreviewHomeMain(data: data, preview: preview),
body: ThemePreviewHomeMain(data: data, preview: preview, style: style),
),
ThemePagePreview(
data: data,
style: style,
activeTab: ThemePreviewNavTab.grades,
body: ThemePreviewHomeGrades(data: data, preview: preview),
body: ThemePreviewHomeGrades(data: data, preview: preview, style: style),
),
ThemePagePreview(
data: data,
style: style,
activeTab: ThemePreviewNavTab.timetable,
body: ThemePreviewHomeTimetable(data: data, preview: preview),
body: ThemePreviewHomeTimetable(
data: data,
preview: preview,
style: style,
),
),
ThemePagePreview(
data: data,
style: style,
activeTab: ThemePreviewNavTab.timetable,
body: ThemePreviewHomeTimetableMonthly(data: data, preview: preview),
body: ThemePreviewHomeTimetableMonthly(
data: data,
preview: preview,
style: style,
),
),
ThemePagePreview(
data: data,
style: style,
activeTab: ThemePreviewNavTab.omissions,
body: ThemePreviewHomeOmissions(data: data, preview: preview),
body: ThemePreviewHomeOmissions(
data: data,
preview: preview,
style: style,
),
),
ThemePagePreview(
data: data,
style: style,
activeTab: ThemePreviewNavTab.grades,
body: ThemePreviewHomeGradesSubject(data: data, preview: preview),
body: ThemePreviewHomeGradesSubject(
data: data,
preview: preview,
style: style,
),
),
];
}
@@ -66,25 +91,31 @@ List<Widget> buildThemePreviewCarouselItems({
class ThemePreviewHomeMain extends StatelessWidget {
final AppInitialization data;
final ThemePreviewData preview;
final FirkaStyle style;
const ThemePreviewHomeMain({
super.key,
required this.data,
required this.preview,
required this.style,
});
@override
Widget build(BuildContext context) {
final noticeBoardWidgets = <(Widget, DateTime)>[];
for (final item in preview.messages) {
noticeBoardWidgets.add((InfoCard.messageItem(item), item.createdAt));
noticeBoardWidgets.add((
InfoCard.messageItem(item, style: style),
item.createdAt,
));
}
for (final test in preview.tests) {
noticeBoardWidgets.add((InfoCard.test(test), test.createdAt));
noticeBoardWidgets.add((
InfoCard.test(test, style: style),
test.createdAt,
));
}
noticeBoardWidgets.sort(
(a, b) => b.$2.difference(a.$2).inMilliseconds,
);
noticeBoardWidgets.sort((a, b) => b.$2.difference(a.$2).inMilliseconds);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
@@ -97,9 +128,10 @@ class ThemePreviewHomeMain extends StatelessWidget {
preview.now,
preview.student,
preview.homeLessons,
style: style,
),
const SizedBox(height: 48),
LessonSlider(preview.homeLessons, 0),
LessonSlider(preview.homeLessons, 0, style: style),
const SizedBox(height: 24),
...noticeBoardWidgets
.groupList((e) => e.$2)
@@ -111,8 +143,8 @@ class ThemePreviewHomeMain extends StatelessWidget {
children: [
Text(
e.key.format(data.l10n, FormatMode.main),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
...e.value.map((v) => v.$1),
@@ -129,11 +161,13 @@ class ThemePreviewHomeMain extends StatelessWidget {
class ThemePreviewHomeGrades extends StatelessWidget {
final AppInitialization data;
final ThemePreviewData preview;
final FirkaStyle style;
const ThemePreviewHomeGrades({
super.key,
required this.data,
required this.preview,
required this.style,
});
@override
@@ -151,6 +185,7 @@ class ThemePreviewHomeGrades extends StatelessWidget {
allGrades.getAverageBySubject(subject),
null,
subject,
style: style,
),
);
}
@@ -162,14 +197,20 @@ class ThemePreviewHomeGrades extends StatelessWidget {
children: [
Text(
headingText(data.l10n.subjects),
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
),
style: style.fonts.H_H2.apply(color: style.colors.textPrimary),
),
const SizedBox(height: 20),
GradeChart(grades: preview.chartGrades, plotRawValues: true),
GradeChart(
grades: preview.chartGrades,
plotRawValues: true,
style: style,
),
const SizedBox(height: 10),
GradeSummaryBar(grades: preview.chartGrades, l10n: data.l10n),
GradeSummaryBar(
grades: preview.chartGrades,
l10n: data.l10n,
style: style,
),
const SizedBox(height: 20),
Expanded(
child: ListView(
@@ -177,8 +218,8 @@ class ThemePreviewHomeGrades extends StatelessWidget {
children: [
Text(
data.l10n.your_subjects,
style: appStyle.fonts.H_14px.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.H_14px.apply(
color: style.colors.textSecondary,
),
),
const SizedBox(height: 16),
@@ -190,8 +231,8 @@ class ThemePreviewHomeGrades extends StatelessWidget {
const SizedBox(height: 16),
Text(
data.l10n.data,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16SB.apply(
color: style.colors.textSecondary,
),
),
const SizedBox(height: 16),
@@ -199,8 +240,8 @@ class ThemePreviewHomeGrades extends StatelessWidget {
left: [
Text(
data.l10n.subject_avg,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
),
],
@@ -208,13 +249,14 @@ class ThemePreviewHomeGrades extends StatelessWidget {
if (subjectAverage != null)
_avgPill(subjectAverage, filled: true),
],
style: style,
),
FirkaCard(
left: [
Text(
data.l10n.subject_avg_rounded,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
),
],
@@ -222,6 +264,7 @@ class ThemePreviewHomeGrades extends StatelessWidget {
if (roundedSubjectAverage != null)
_avgPill(roundedSubjectAverage, filled: true),
],
style: style,
),
],
),
@@ -237,14 +280,12 @@ class ThemePreviewHomeGrades extends StatelessWidget {
height: 26,
decoration: ShapeDecoration(
color: filled ? getGradeColor(value).withAlpha(38) : Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
),
child: Center(
child: Text(
value.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(color: getGradeColor(value)),
style: style.fonts.B_16R.apply(color: getGradeColor(value)),
),
),
);
@@ -254,24 +295,20 @@ class ThemePreviewHomeGrades extends StatelessWidget {
class ThemePreviewHomeTimetable extends StatelessWidget {
final AppInitialization data;
final ThemePreviewData preview;
final FirkaStyle style;
const ThemePreviewHomeTimetable({
super.key,
required this.data,
required this.preview,
required this.style,
});
@override
Widget build(BuildContext context) {
final day = DateTime(
preview.now.year,
preview.now.month,
preview.now.day,
);
final day = DateTime(preview.now.year, preview.now.month, preview.now.day);
final monday = day.getMonday();
final tabDays = [
for (var i = 0; i < 5; i++) monday.add(Duration(days: i)),
];
final tabDays = [for (var i = 0; i < 5; i++) monday.add(Duration(days: i))];
return Stack(
children: [
@@ -279,7 +316,11 @@ class ThemePreviewHomeTimetable extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: TimeTableDayWidget(preview.timetableLessons, const []),
child: TimeTableDayWidget(
preview.timetableLessons,
const [],
style: style,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 2),
@@ -293,6 +334,7 @@ class ThemePreviewHomeTimetable extends StatelessWidget {
() {},
d.isAtSameMomentAs(day),
d,
style: style,
),
],
),
@@ -311,8 +353,8 @@ class ThemePreviewHomeTimetable extends StatelessWidget {
children: [
Text(
headingText(data.l10n.timetable),
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.H_H2.apply(
color: style.colors.textPrimary,
),
),
Row(
@@ -322,13 +364,13 @@ class ThemePreviewHomeTimetable extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.tableSolid,
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.settingsCogSolid,
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
],
),
@@ -342,19 +384,19 @@ class ThemePreviewHomeTimetable extends StatelessWidget {
FirkaIconType.icons,
"dropdownLeft",
size: 24,
color: appStyle.colors.accent,
color: style.colors.accent,
),
Text(
monday.format(data.l10n, FormatMode.yyyymmddwedd),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
),
FirkaIconWidget(
FirkaIconType.icons,
"dropdownRight",
size: 24,
color: appStyle.colors.accent,
color: style.colors.accent,
),
],
),
@@ -370,11 +412,13 @@ class ThemePreviewHomeTimetable extends StatelessWidget {
class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
final AppInitialization data;
final ThemePreviewData preview;
final FirkaStyle style;
const ThemePreviewHomeTimetableMonthly({
super.key,
required this.data,
required this.preview,
required this.style,
});
@override
@@ -392,17 +436,15 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
var omissionCountMonth = 0;
for (var i = 0; i < 49; i++) {
final d = DateTime(
gridStart.year,
gridStart.month,
gridStart.day + i,
);
final d = DateTime(gridStart.year, gridStart.month, gridStart.day + i);
final key = DateTime(d.year, d.month, d.day);
final meta = preview.monthDayMeta[key] ??
final meta =
preview.monthDayMeta[key] ??
const ThemePreviewMonthDay(lessonCount: 0, hasTest: false);
final outOfRange =
d.isBefore(currentMonthStart) || d.isAfter(currentMonthEnd);
final isToday = !outOfRange &&
final isToday =
!outOfRange &&
now.year == d.year &&
now.day == d.day &&
now.month == d.month;
@@ -413,41 +455,42 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
if (meta.omission != null) omissionCountMonth++;
}
Color bodyBgColor = appStyle.colors.a15p;
Color bodyBgColor = style.colors.a15p;
Widget body = const SizedBox();
final todayAccent = isToday ? appStyle.colors.textPrimaryLight : null;
final todayAccent = isToday ? style.colors.textPrimaryLight : null;
if (meta.lessonCount > 0) {
body = Center(
child: Text(
meta.lessonCount.toString(),
style: appStyle.fonts.H_16px.apply(
color: (todayAccent ??
(meta.omission != null
? appStyle.colors.errorText
: appStyle.colors.secondary))
.withAlpha(outOfRange ? 77 : 255),
style: style.fonts.H_16px.apply(
color:
(todayAccent ??
(meta.omission != null
? style.colors.errorText
: style.colors.secondary))
.withAlpha(outOfRange ? 77 : 255),
),
),
);
if (meta.omission != null) {
bodyBgColor = appStyle.colors.error15p;
bodyBgColor = style.colors.error15p;
}
}
if (isToday) {
bodyBgColor = appStyle.colors.accent;
bodyBgColor = style.colors.accent;
}
if (outOfRange) {
bodyBgColor = appStyle.colors.cardTranslucent;
bodyBgColor = style.colors.cardTranslucent;
}
final isWeekend = d.weekday > 5 && meta.lessonCount == 0;
var textColor = isWeekend
? appStyle.colors.errorText
? style.colors.errorText
: isToday
? appStyle.colors.textPrimary
: appStyle.colors.textTertiary;
? style.colors.textPrimary
: style.colors.textTertiary;
if (outOfRange) {
textColor = textColor.withAlpha(77);
} else if (isWeekend) {
@@ -473,8 +516,9 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
const SizedBox(height: 4),
Text(
d.format(data.l10n, FormatMode.d),
style: (isToday ? appStyle.fonts.B_14SB : appStyle.fonts.B_14R)
.apply(color: textColor),
style: (isToday ? style.fonts.B_14SB : style.fonts.B_14R).apply(
color: textColor,
),
),
],
),
@@ -494,8 +538,8 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
children: [
Text(
headingText(data.l10n.timetable),
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.H_H2.apply(
color: style.colors.textPrimary,
),
),
Row(
@@ -505,13 +549,13 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.tableSolid,
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.settingsCogSolid,
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
],
),
@@ -525,21 +569,19 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
FirkaIconType.icons,
"dropdownLeft",
size: 24,
color: appStyle.colors.accent,
color: style.colors.accent,
),
Text(
now
.format(data.l10n, FormatMode.yyyymmmm)
.toLowerCase(),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
now.format(data.l10n, FormatMode.yyyymmmm).toLowerCase(),
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
),
FirkaIconWidget(
FirkaIconType.icons,
"dropdownRight",
size: 24,
color: appStyle.colors.accent,
color: style.colors.accent,
),
],
),
@@ -548,7 +590,11 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.only(top: 74 + 16 + 12, left: 20, right: 20),
padding: const EdgeInsets.only(
top: 74 + 16 + 12,
left: 20,
right: 20,
),
child: GridView.count(
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 7,
@@ -569,31 +615,34 @@ class ThemePreviewHomeTimetableMonthly extends StatelessWidget {
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.clockSolid,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 16,
),
lessonCountMonth,
true,
style: style,
),
_PreviewStatusToast(
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 16,
),
testCountMonth,
false,
style: style,
),
_PreviewStatusToast(
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.timerLine,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 16,
),
omissionCountMonth,
false,
style: style,
),
],
),
@@ -608,8 +657,14 @@ class _PreviewStatusToast extends StatelessWidget {
final FirkaIconWidget icon;
final int count;
final bool active;
final FirkaStyle style;
const _PreviewStatusToast(this.icon, this.count, this.active);
const _PreviewStatusToast(
this.icon,
this.count,
this.active, {
required this.style,
});
@override
Widget build(BuildContext context) {
@@ -618,11 +673,9 @@ class _PreviewStatusToast extends StatelessWidget {
clipBehavior: Clip.antiAlias,
decoration: ShapeDecoration(
color: active
? appStyle.colors.buttonSecondaryFill
: appStyle.colors.cardTranslucent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
? style.colors.buttonSecondaryFill
: style.colors.cardTranslucent,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
),
child: Row(
spacing: 6,
@@ -630,10 +683,10 @@ class _PreviewStatusToast extends StatelessWidget {
icon,
Text(
count.toString(),
style: appStyle.fonts.H_16px.apply(
style: style.fonts.H_16px.apply(
color: active
? appStyle.colors.textPrimary
: appStyle.colors.textSecondary,
? style.colors.textPrimary
: style.colors.textSecondary,
),
),
],
@@ -645,11 +698,13 @@ class _PreviewStatusToast extends StatelessWidget {
class ThemePreviewHomeOmissions extends StatelessWidget {
final AppInitialization data;
final ThemePreviewData preview;
final FirkaStyle style;
const ThemePreviewHomeOmissions({
super.key,
required this.data,
required this.preview,
required this.style,
});
@override
@@ -666,9 +721,7 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
children: [
Text(
headingText(data.l10n.omissions),
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
),
style: style.fonts.H_H2.apply(color: style.colors.textPrimary),
),
const SizedBox(height: 20),
Row(
@@ -676,6 +729,7 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
children: [
Expanded(
child: FirkaCard.single(
style: style,
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
children: [
@@ -687,20 +741,20 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
FirkaIconType.majesticonsLocal,
"checkSolid",
size: 12,
color: appStyle.colors.accent,
color: style.colors.accent,
),
Text(
overallExcused.toString(),
style: appStyle.fonts.H_18px.copyWith(
color: appStyle.colors.textPrimary,
style: style.fonts.H_18px.copyWith(
color: style.colors.textPrimary,
),
),
],
),
Text(
data.l10n.omission_state_excused,
style: appStyle.fonts.B_16R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.copyWith(
color: style.colors.textSecondary,
),
),
],
@@ -709,6 +763,7 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
),
Expanded(
child: FirkaCard.single(
style: style,
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
children: [
@@ -720,20 +775,20 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.timerSolid,
size: 12,
color: appStyle.colors.warningAccent,
color: style.colors.warningAccent,
),
Text(
overallPending.toString(),
style: appStyle.fonts.H_18px.copyWith(
color: appStyle.colors.warningAccent,
style: style.fonts.H_18px.copyWith(
color: style.colors.warningAccent,
),
),
],
),
Text(
data.l10n.omission_state_pending,
style: appStyle.fonts.B_16R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.copyWith(
color: style.colors.textSecondary,
),
),
],
@@ -742,6 +797,7 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
),
Expanded(
child: FirkaCard.single(
style: style,
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
children: [
@@ -753,20 +809,20 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.restrictedSolid,
size: 12,
color: appStyle.colors.errorAccent,
color: style.colors.errorAccent,
),
Text(
overallUnexcused.toString(),
style: appStyle.fonts.H_18px.copyWith(
color: appStyle.colors.errorAccent,
style: style.fonts.H_18px.copyWith(
color: style.colors.errorAccent,
),
),
],
),
Text(
data.l10n.omission_state_unexcused,
style: appStyle.fonts.B_16R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.copyWith(
color: style.colors.textSecondary,
),
),
],
@@ -776,7 +832,10 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
],
),
const SizedBox(height: 10),
OmissionBar(previewSegments: preview.omissionBarSegments),
OmissionBar(
previewSegments: preview.omissionBarSegments,
style: style,
),
const SizedBox(height: 20),
Expanded(
child: ListView(
@@ -784,8 +843,8 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
children: [
Text(
data.l10n.subjects,
style: appStyle.fonts.B_16SB.copyWith(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.copyWith(
color: style.colors.textPrimary,
),
),
const SizedBox(height: 10),
@@ -817,6 +876,7 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
.length;
return FirkaCard.single(
style: style,
height: 64,
margin: const EdgeInsets.only(bottom: 10),
padding: const EdgeInsets.symmetric(horizontal: 16),
@@ -825,7 +885,7 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
InfoCard.buildSubject(
appStyle.colors.accent,
style.colors.accent,
entry.key,
),
Expanded(
@@ -836,8 +896,8 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
children: [
Text(
entry.key.name,
style: appStyle.fonts.B_16SB.copyWith(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.copyWith(
color: style.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
@@ -848,12 +908,12 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
FirkaIconType.majesticonsLocal,
"checkSolid",
size: 12,
color: appStyle.colors.accent,
color: style.colors.accent,
),
Text(
excused.toString(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.copyWith(
color: style.colors.textSecondary,
),
),
const SizedBox(width: 4),
@@ -861,12 +921,12 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.timerSolid,
size: 12,
color: appStyle.colors.warningAccent,
color: style.colors.warningAccent,
),
Text(
pending.toString(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.copyWith(
color: style.colors.textSecondary,
),
),
const SizedBox(width: 4),
@@ -874,12 +934,12 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.restrictedLine,
size: 12,
color: appStyle.colors.errorAccent,
color: style.colors.errorAccent,
),
Text(
unexcused.toString(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.copyWith(
color: style.colors.textSecondary,
),
),
],
@@ -903,11 +963,13 @@ class ThemePreviewHomeOmissions extends StatelessWidget {
class ThemePreviewHomeGradesSubject extends StatelessWidget {
final AppInitialization data;
final ThemePreviewData preview;
final FirkaStyle style;
const ThemePreviewHomeGradesSubject({
super.key,
required this.data,
required this.preview,
required this.style,
});
@override
@@ -916,7 +978,7 @@ class ThemePreviewHomeGradesSubject extends StatelessWidget {
final subject = preview.subjectDetailSubject;
return Container(
color: appStyle.colors.background,
color: style.colors.background,
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -931,15 +993,15 @@ class ThemePreviewHomeGradesSubject extends StatelessWidget {
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.chevronLeftLine,
color: appStyle.colors.textSecondary,
color: style.colors.textSecondary,
),
),
Transform.translate(
offset: const Offset(-4, 0),
child: Text(
data.l10n.subjects,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
),
),
@@ -949,7 +1011,7 @@ class ThemePreviewHomeGradesSubject extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.menuSolid,
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
],
),
@@ -963,34 +1025,34 @@ class ThemePreviewHomeGradesSubject extends StatelessWidget {
children: [
FilledCircle(
diameter: 36,
color: appStyle.colors.a15p,
color: style.colors.a15p,
child: ClassIconWidget(
subject: subject,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 24,
),
),
const SizedBox(height: 16),
Text(
subject.name,
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.H_H2.apply(
color: style.colors.textPrimary,
),
),
const SizedBox(height: 4),
Text(
preview.subjectDetailTeacher,
textAlign: TextAlign.center,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
],
),
const SizedBox(height: 24),
GradeChart(grades: grades),
GradeChart(grades: grades, style: style),
const SizedBox(height: 10),
GradeSummaryBar(grades: grades, l10n: data.l10n),
GradeSummaryBar(grades: grades, l10n: data.l10n, style: style),
const SizedBox(height: 20),
...grades
.groupList((e) => e.writtenAt)
@@ -1002,12 +1064,16 @@ class ThemePreviewHomeGradesSubject extends StatelessWidget {
children: [
Text(
e.key.format(data.l10n, FormatMode.main),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
...e.value.map(
(v) => InfoCard.gradeDesc(v, onTap: (_) {}),
(v) => InfoCard.gradeDesc(
v,
onTap: (_) {},
style: style,
),
),
const SizedBox(height: 10),
],

View File

@@ -68,7 +68,15 @@ Future<void> showThemeShareSheet(
BuildContext context, {
required UserTheme theme,
required AppInitialization data,
}) {
Future<void> Function()? onPublish,
}) async {
// publish first so the link carries a share id and the people who scan it
// keep seeing this theme as it is edited
if (!theme.isBuiltin && theme.shareId.isEmpty) {
await onPublish?.call();
if (!context.mounted) return;
}
return showModalBottomSheet<void>(
context: context,
elevation: 100,
@@ -103,10 +111,7 @@ Future<void> showThemeImportSheet(
padding: EdgeInsets.only(
bottom: MediaQuery.viewInsetsOf(context).bottom,
),
child: _ThemeImportSheet(
l10n: data.l10n,
onImport: onImport,
),
child: _ThemeImportSheet(l10n: data.l10n, onImport: onImport),
);
},
);
@@ -145,7 +150,8 @@ class _ThemeShareSheetState extends State<_ThemeShareSheet> {
setState(() => _isSharing = true);
try {
final boundary = _cardKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;
final boundary =
_cardKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;
if (boundary == null) {
throw Exception("RenderRepaintBoundary not found");
}
@@ -158,23 +164,19 @@ class _ThemeShareSheetState extends State<_ThemeShareSheet> {
final pngBytes = byteData.buffer.asUint8List();
final tempDir = await getTemporaryDirectory();
final sanitizedName = widget.theme.name.replaceAll(RegExp(r'[^\w\s-]'), '').trim();
final sanitizedName = widget.theme.name
.replaceAll(RegExp(r'[^\w\s-]'), '')
.trim();
final safeName = sanitizedName.isEmpty ? 'firka' : sanitizedName;
final file = File('${tempDir.path}/firka_theme_$safeName.png');
await file.writeAsBytes(pngBytes);
await SharePlus.instance.share(
ShareParams(
files: [XFile(file.path)],
subject: widget.theme.name,
),
ShareParams(files: [XFile(file.path)], subject: widget.theme.name),
);
} catch (e) {
await SharePlus.instance.share(
ShareParams(
text: widget.shareUrl,
subject: widget.theme.name,
),
ShareParams(text: widget.shareUrl, subject: widget.theme.name),
);
} finally {
if (mounted) {
@@ -191,10 +193,7 @@ class _ThemeShareSheetState extends State<_ThemeShareSheet> {
children: [
RepaintBoundary(
key: _cardKey,
child: ThemeQrCard(
theme: widget.theme,
shareData: widget.shareUrl,
),
child: ThemeQrCard(theme: widget.theme, shareData: widget.shareUrl),
),
const SizedBox(height: 20),
_sheetButton(
@@ -221,10 +220,7 @@ class _ThemeImportSheet extends StatefulWidget {
final AppLocalizations l10n;
final Future<void> Function(UserTheme theme) onImport;
const _ThemeImportSheet({
required this.l10n,
required this.onImport,
});
const _ThemeImportSheet({required this.l10n, required this.onImport});
@override
State<_ThemeImportSheet> createState() => _ThemeImportSheetState();
@@ -234,6 +230,8 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
_ImportMode _mode = _ImportMode.camera;
final _controller = TextEditingController();
ThemeBinaryData? _previewData;
String? _code;
String _shareId = '';
String? _extractedName;
String? _error;
bool _isAnalyzingImage = false;
@@ -261,6 +259,8 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
setState(() {
_controller.text = trimmed;
_previewData = decoded;
_code = payload.code;
_shareId = payload.shareId;
_extractedName = payload.name;
_error = null;
});
@@ -280,6 +280,8 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
if (raw.isEmpty) {
setState(() {
_previewData = null;
_code = null;
_shareId = '';
_extractedName = null;
_error = null;
});
@@ -309,7 +311,9 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
return;
}
final capture = await MobileScannerPlatform.instance.analyzeImage(picked.path);
final capture = await MobileScannerPlatform.instance.analyzeImage(
picked.path,
);
if (capture != null && capture.barcodes.isNotEmpty) {
bool found = false;
for (final barcode in capture.barcodes) {
@@ -345,32 +349,24 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
Future<void> _import() async {
final preview = _previewData;
if (preview == null) return;
final code = _code;
if (preview == null || code == null) return;
final themeName = _extractedName != null && _extractedName!.isNotEmpty
? _extractedName!
: widget.l10n.s_c_themes_imported_label;
final List<Color> swatch;
if (preview.isFullTheme) {
swatch = [
preview.lightSlot(ThemeColorSlot.accent) ?? appStyle.colors.accent,
preview.lightSlot(ThemeColorSlot.textPrimary) ?? appStyle.colors.textPrimary,
preview.lightSlot(ThemeColorSlot.background) ?? appStyle.colors.background,
];
} else {
swatch = preview.colors.length >= 3
? preview.colors.take(3).toList()
: (preview.colors.isNotEmpty
? preview.colors
: [appStyle.colors.accent, appStyle.colors.textPrimary, appStyle.colors.background]);
}
final theme = UserTheme(
id: Snowflake.nextId(),
name: themeName,
origin: ThemeOrigin.downloaded,
swatch: swatch,
swatch: [
preview.lightSlot(ThemeColorSlot.accent),
preview.lightSlot(ThemeColorSlot.textPrimary),
preview.lightSlot(ThemeColorSlot.background),
],
code: code,
shareId: _shareId,
);
await widget.onImport(theme);
@@ -397,9 +393,7 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
: appStyle.colors.card,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: selected
? appStyle.colors.accent
: Colors.transparent,
color: selected ? appStyle.colors.accent : Colors.transparent,
width: 1.5,
),
),
@@ -479,13 +473,11 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (final color in (_previewData!.isFullTheme
? [
_previewData!.lightSlot(ThemeColorSlot.accent) ?? appStyle.colors.accent,
_previewData!.lightSlot(ThemeColorSlot.textPrimary) ?? appStyle.colors.textPrimary,
_previewData!.lightSlot(ThemeColorSlot.background) ?? appStyle.colors.background,
]
: _previewData!.colors.take(4)))
for (final color in [
_previewData!.lightSlot(ThemeColorSlot.accent),
_previewData!.lightSlot(ThemeColorSlot.textPrimary),
_previewData!.lightSlot(ThemeColorSlot.background),
])
Container(
margin: const EdgeInsets.symmetric(horizontal: 4),
width: 20,
@@ -494,7 +486,9 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
color: color,
shape: BoxShape.circle,
border: Border.all(
color: appStyle.colors.textPrimary.withValues(alpha: 0.25),
color: appStyle.colors.textPrimary.withValues(
alpha: 0.25,
),
width: 1.5,
),
),
@@ -503,9 +497,7 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
),
const SizedBox(height: 8),
Text(
_previewData!.isFullTheme
? "Teljes téma (32 szín)"
: "${_previewData!.colors.length} szín",
"Teljes téma (32 szín)",
style: appStyle.fonts.B_12R.apply(
color: appStyle.colors.textSecondary,
),
@@ -630,7 +622,9 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: appStyle.colors.accent.withValues(alpha: 0.15),
color: appStyle.colors.accent.withValues(
alpha: 0.15,
),
shape: BoxShape.circle,
),
child: Majesticon(
@@ -661,7 +655,10 @@ class _ThemeImportSheetState extends State<_ThemeImportSheet> {
] else if (_mode == _ImportMode.text) ...[
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 4,
),
decoration: BoxDecoration(
color: appStyle.colors.card,
borderRadius: BorderRadius.circular(24),

View File

@@ -10,6 +10,8 @@ import "package:firka/core/bloc/theme_cubit.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/core/theme_palette.dart";
import "package:firka/core/theme_sync.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";
@@ -31,22 +33,40 @@ class ThemeScreen extends StatefulWidget {
class _ThemeScreenState extends State<ThemeScreen> {
late final ThemePreviewData _preview;
/// The carousel renders with this instead of the global style, so looking at
/// a theme never recolors the rest of the app.
late FirkaStyle _previewStyle;
UserTheme get _theme => widget.args.theme;
@override
void initState() {
super.initState();
_preview = ThemePreviewData.build();
appStyle = buildStyleForBrightness(
_previewStyle = _buildPreviewStyle();
}
FirkaStyle _buildPreviewStyle() {
final overrides = _previewOverrides();
return buildStyleForBrightness(
appStyle.isLight,
isCustomTheme: !_theme.isBuiltin,
// the overrides already are this theme's colors, so they apply even
// when it is a builtin, which otherwise skips the custom slots
forceCustomColors: overrides != null,
colorOverrides: overrides,
);
}
@override
void dispose() {
initTheme(widget.data);
super.dispose();
Map<int, String>? _previewOverrides() {
// shareCode, not code: builtins keep no stored code, theirs is computed
final code = _theme.shareCode;
if (code.isEmpty) return null;
try {
return themeCodeOverrides(code);
} on FormatException {
return null;
}
}
String get _originLabel {
@@ -89,160 +109,179 @@ class _ThemeScreenState extends State<ThemeScreen> {
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,
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,
Transform.translate(
offset: const Offset(-4, 1),
child: Text(
l10n.s_c_theme_header,
style: appStyle.fonts.H_H2.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,
],
),
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: [
ThemeNameLabel(
name: _theme.name,
editable: _theme.canRename,
style: appStyle.fonts.H_H2.apply(
color: appStyle.colors.textPrimary,
if (_theme.canEdit)
FirkaIconButton(
onTap: () async {
// apply this theme before editing so the
// editor sees the right colors
await widget.args.onUse(_theme.id);
if (!mounted) return;
await context.push("/theme-editor");
if (!mounted) return;
setState(() {
_theme.swatch =
UserTheme.swatchFromAppStyle();
_theme.code = captureThemeCode(
widget.data.settings,
);
appStyle = buildStyleForBrightness(
appStyle.isLight,
isCustomTheme: true,
);
// _theme.code just changed, so rebuild the
// preview from the edited colors
_previewStyle = _buildPreviewStyle();
});
widget.args.onChanged();
},
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Line,
size: 18,
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,
if (_theme.canShare)
FirkaIconButton(
onTap: () => showThemeShareSheet(
context,
theme: _theme,
data: widget.data,
onPublish: () async {
_theme.shareId = await publishTheme(
widget.data.settings,
_theme,
);
widget.args.onChanged();
if (mounted) setState(() {});
},
),
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,
),
),
),
],
),
),
Row(
spacing: 8,
children: [
if (_theme.isOwn) ...[
FirkaIconButton(
onTap: () async {
await context.push("/theme-editor");
if (!mounted) return;
setState(() {
_theme.swatch =
UserTheme.swatchFromAppStyle();
appStyle = buildStyleForBrightness(
appStyle.isLight,
isCustomTheme: true,
);
});
widget.args.onChanged();
},
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Line,
size: 18,
color: appStyle.colors.textPrimary,
),
),
FirkaIconButton(
onTap: () => showThemeShareSheet(
context,
theme: _theme,
data: widget.data,
),
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,
style: _previewStyle,
),
],
),
],
),
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: 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),
],
),
),
const SizedBox(height: 8),
],
),
),
),
),
),
);
);
},
);
}

View File

@@ -1,3 +1,4 @@
import 'package:firka_common/data/isar_writes.dart';
import "package:flutter/material.dart";
import "package:go_router/go_router.dart";
import "package:isar_community/isar.dart";
@@ -8,6 +9,8 @@ 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/core/theme_palette.dart";
import "package:firka/core/theme_sync.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";
@@ -49,6 +52,12 @@ class _ThemesScreenState extends State<ThemesScreen> {
}
Future<void> _loadThemes() async {
// pull this account's own theme, and catch up on any edits the owners of
// the imported ones have made since
await syncThemeFromServer(widget.data.settings);
await refreshSharedThemes(widget.data.settings);
if (!mounted) return;
final stored = await isarInit.userThemeModels.where().findAll();
if (!mounted) return;
@@ -60,10 +69,7 @@ class _ThemesScreenState extends State<ThemesScreen> {
setState(() {
_storedThemes = stored.map(UserTheme.fromModel).toList();
_selectedId = normalized;
final knownIds = {
_builtin.id,
..._storedThemes.map((t) => t.id),
};
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;
@@ -97,15 +103,19 @@ class _ThemesScreenState extends State<ThemesScreen> {
Future<void> _persistTheme(UserTheme theme) async {
if (theme.isBuiltin) return;
await isarInit.writeTxn(() async {
await isarInit.userThemeModels.putByThemeId(theme.toModel());
});
await isarWrite(
() => isarInit.writeTxn(
() => isarInit.userThemeModels.putByThemeId(theme.toModel()),
),
);
}
Future<void> _deleteTheme(String id) async {
await isarInit.writeTxn(() async {
await isarInit.userThemeModels.deleteByThemeId(id);
});
await isarWrite(
() => isarInit.writeTxn(
() => isarInit.userThemeModels.deleteByThemeId(id),
),
);
}
Future<void> _setSelected(String id) async {
@@ -114,6 +124,13 @@ class _ThemesScreenState extends State<ThemesScreen> {
final (coreId, gradeId) = parseBuiltinThemeId(next);
await Settings.selectedCoreThemeId.set(coreId);
await Settings.selectedGradeThemeId.set(gradeId);
} else {
// select it first, the colors written next are then saved to this theme
await Settings.selectedThemeId.setSilently(next);
final code = _storedThemes.where((t) => t.id == next).firstOrNull?.code;
if (code != null && code.isNotEmpty) {
await applyThemeCode(widget.data.settings, code);
}
}
setState(() => _selectedId = next);
await Settings.selectedThemeId.set(next);
@@ -136,6 +153,7 @@ class _ThemesScreenState extends State<ThemesScreen> {
name: name,
origin: ThemeOrigin.own,
swatch: UserTheme.swatchFromAppStyle(),
code: captureThemeCode(widget.data.settings),
);
await _persistTheme(theme);
if (!mounted) return;
@@ -187,7 +205,8 @@ class _ThemesScreenState extends State<ThemesScreen> {
},
),
);
if (mounted) setState(() {});
if (!mounted) return;
setState(() {});
}
Widget _sectionLabel(String text) {
@@ -195,24 +214,19 @@ class _ThemesScreenState extends State<ThemesScreen> {
padding: const EdgeInsets.only(left: 4, bottom: 8, top: 16),
child: Text(
text,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
),
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: (_) {},
),
// the design marks the selection with a bare check glyph, not a
// Material checkbox (Figma majesticons:check, 16x16)
return FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"check",
size: 16,
color: appStyle.colors.secondary,
);
}
@@ -221,7 +235,7 @@ class _ThemesScreenState extends State<ThemesScreen> {
onTap: () => _openTheme(theme),
child: FirkaCard(
left: [
ThemeSwatchIcon(swatch: theme.swatch, size: 36),
ThemeSwatchIcon(swatch: theme.swatch, size: 26),
const SizedBox(width: 10),
ThemeNameLabel(
name: theme.name,
@@ -248,8 +262,8 @@ class _ThemesScreenState extends State<ThemesScreen> {
FirkaIconWidget(
FirkaIconType.majesticons,
icon,
size: 20,
color: appStyle.colors.textPrimary,
size: 24,
color: appStyle.colors.accent,
),
const SizedBox(width: 8),
Text(
@@ -348,7 +362,7 @@ class _ThemesScreenState extends State<ThemesScreen> {
children: [
_sectionLabel(l10n.s_c_themes_current),
_themeRow(_selected, selected: true),
if (!_selected.isBuiltin)
if (_selected.canShare)
_actionRow(
icon: Majesticon.shareLine,
label: l10n.s_c_themes_share_current,
@@ -364,10 +378,7 @@ class _ThemesScreenState extends State<ThemesScreen> {
selected: isBuiltinThemeId(_selectedId),
),
for (final theme in _ownThemes)
_themeRow(
theme,
selected: theme.id == _selectedId,
),
_themeRow(theme, selected: theme.id == _selectedId),
_actionRow(
icon: Majesticon.plusLine,
label: l10n.s_c_themes_create_new,
@@ -375,10 +386,7 @@ class _ThemesScreenState extends State<ThemesScreen> {
),
_sectionLabel(l10n.s_c_themes_downloaded),
for (final theme in _downloadedThemes)
_themeRow(
theme,
selected: theme.id == _selectedId,
),
_themeRow(theme, selected: theme.id == _selectedId),
_actionRow(
icon: Majesticon.arrowDownCircleLine,
label: l10n.s_c_themes_import,

View File

@@ -16,20 +16,36 @@ class UserTheme {
final ThemeOrigin origin;
List<Color> swatch;
/// the whole theme as a share code, see [UserThemeModel.code]
String code;
/// the server handle this theme is tied to, empty until it is shared or
/// imported, see [UserThemeModel.shareId]
String shareId;
UserTheme({
required this.id,
required this.name,
required this.origin,
required this.swatch,
this.code = '',
this.shareId = '',
});
bool get isBuiltin =>
origin == ThemeOrigin.builtin || isBuiltinThemeId(id);
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 canEdit => isOwn;
bool get canDelete => !isBuiltin;
/// a copy of someone else's shared theme, so it follows their edits
bool get followsShare => isDownloaded && shareId.isNotEmpty;
/// builtins can always be shared (the code is computed on the fly),
/// custom themes can be shared once their code has been captured
bool get canShare => isBuiltin || code.isNotEmpty;
static List<Color> swatchFromCore(CoreTheme core, {bool isLight = true}) {
final colors = core.forBrightness(isLight);
return [colors.accent, colors.textPrimary, colors.background];
@@ -68,6 +84,8 @@ class UserTheme {
_ => ThemeOrigin.own,
},
swatch: model.swatchArgb.map(Color.new).toList(),
code: model.code,
shareId: model.shareId,
);
}
@@ -79,7 +97,9 @@ class UserTheme {
ThemeOrigin.downloaded => "downloaded",
ThemeOrigin.own || ThemeOrigin.builtin => "own",
}
..swatchArgb = swatch.map((c) => c.toARGB32()).toList();
..swatchArgb = swatch.map((c) => c.toARGB32()).toList()
..code = code
..shareId = shareId;
}
}
@@ -98,29 +118,39 @@ class ThemeScreenArgs {
}
extension UserThemeShareExtension on UserTheme {
/// for builtins the code is computed from the core+grade themes,
/// for custom themes it comes from the stored code field
String get shareCode {
if (isBuiltin) {
final core = resolveCore(id);
return ThemeBinaryFormat.encodeToBase64(
ThemeBinaryFormat.decode(ThemeBinaryFormat.encodeCoreTheme(core)).colors,
final (coreId, gradeId) = parseBuiltinThemeId(id);
final core = resolveCore(coreId);
final grade = resolveGrade(gradeId);
final bytes = ThemeBinaryFormat.encodeCoreTheme(
core,
gradeColors: [
grade.light.grade1,
grade.light.grade2,
grade.light.grade3,
grade.light.grade4,
grade.light.grade5,
],
);
} else if (swatch.isNotEmpty) {
return ThemeBinaryFormat.encodeToBase64(swatch);
} else {
return ThemeBinaryFormat.encodeToBase64([
appStyle.colors.accent,
appStyle.colors.textPrimary,
appStyle.colors.background,
]);
return ThemeBinaryFormat.toBase64(bytes);
}
return code;
}
String get shareUrl =>
"https://firka.app/?d=$shareCode&n=${Uri.encodeComponent(name)}";
/// carries the whole theme so it imports with no network at all, plus the
/// share id so the copy can follow the owner's later edits
String get shareUrl {
final url =
"https://firka.app/?d=$shareCode&n=${Uri.encodeComponent(name)}";
return shareId.isEmpty ? url : "$url&s=$shareId";
}
}
extension ThemeShareCodeStringExtension on String {
({String code, String? name}) parseThemeSharePayload() {
({String code, String? name, String shareId}) parseThemeSharePayload() {
final trimmed = trim();
if (trimmed.startsWith('firka://') || trimmed.startsWith('http')) {
final uri = Uri.tryParse(trimmed);
@@ -128,10 +158,11 @@ extension ThemeShareCodeStringExtension on String {
return (
code: uri.queryParameters['d'] ?? trimmed,
name: uri.queryParameters['n'],
shareId: uri.queryParameters['s'] ?? '',
);
}
}
return (code: trimmed, name: null);
return (code: trimmed, name: null, shareId: '');
}
ThemeBinaryData? tryDecodeThemeData() {

View File

@@ -4,27 +4,18 @@ class ThemeSwatchIcon extends StatelessWidget {
final List<Color> swatch;
final double size;
const ThemeSwatchIcon({
required this.swatch,
this.size = 40,
super.key,
});
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),
];
: [...swatch, ...List.filled(3 - swatch.length, Colors.grey)];
return SizedBox(
width: size,
height: size,
child: CustomPaint(
painter: _SwatchPainter(colors: colors),
),
child: CustomPaint(painter: _SwatchPainter(colors: colors)),
);
}
}

View File

@@ -11,17 +11,23 @@ class BottomNavIconWidget extends StatelessWidget {
final String text;
final bool isProfilePicture;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const BottomNavIconWidget(
this.onTap,
this.active,
this.icon,
this.text, {
this.isProfilePicture = false,
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
return Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -49,8 +55,8 @@ class BottomNavIconWidget extends StatelessWidget {
FirkaIconType.majesticons,
icon as Uint8List,
color: active
? appStyle.colors.accent
: appStyle.colors.secondary.withAlpha(128),
? style.colors.accent
: style.colors.secondary.withAlpha(128),
size: 24,
),
const SizedBox(height: 2),
@@ -60,10 +66,10 @@ class BottomNavIconWidget extends StatelessWidget {
clipBehavior: Clip.none,
child: Text(
text,
style: appStyle.fonts.B_14R.apply(
style: style.fonts.B_14R.apply(
color: active
? appStyle.colors.textPrimary
: appStyle.colors.textSecondary,
? style.colors.textPrimary
: style.colors.textSecondary,
),
),
),

View File

@@ -10,16 +10,22 @@ class BottomTimeTableNavIconWidget extends StatelessWidget {
final bool active;
final DateTime? date;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const BottomTimeTableNavIconWidget(
this.l10n,
this.onTap,
this.active,
this.date, {
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
@@ -32,7 +38,7 @@ class BottomTimeTableNavIconWidget extends StatelessWidget {
shadows: active
? [
BoxShadow(
color: appStyle.colors.shadowColor,
color: style.colors.shadowColor,
offset: const Offset(0, 1),
),
]
@@ -41,7 +47,7 @@ class BottomTimeTableNavIconWidget extends StatelessWidget {
borderRadius: BorderRadius.circular(12),
),
color: active
? appStyle.colors.buttonSecondaryFill
? style.colors.buttonSecondaryFill
: Colors.transparent,
),
child: Center(
@@ -51,18 +57,18 @@ class BottomTimeTableNavIconWidget extends StatelessWidget {
? [
Text(
date!.format(l10n, FormatMode.da),
style: appStyle.fonts.H_16px.apply(
style: style.fonts.H_16px.apply(
color: active
? appStyle.colors.textPrimary
: appStyle.colors.textTertiary,
? style.colors.textPrimary
: style.colors.textTertiary,
),
),
Text(
date!.format(l10n, FormatMode.dd),
style: appStyle.fonts.B_16R.apply(
style: style.fonts.B_16R.apply(
color: active
? appStyle.colors.textSecondary
: appStyle.colors.textTertiary,
? style.colors.textSecondary
: style.colors.textTertiary,
),
),
]

View File

@@ -6,15 +6,20 @@ import 'package:majesticons_flutter/majesticons_flutter.dart';
import 'package:firka/ui/theme/style.dart';
class BubbleTest extends StatelessWidget {
const BubbleTest({super.key});
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const BubbleTest({this.style, super.key});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
return Stack(
children: [
SvgPicture.asset(
"assets/images/bubble.svg",
color: appStyle.colors.buttonSecondaryFill,
color: style.colors.buttonSecondaryFill,
width: 24,
height: 24,
),
@@ -23,7 +28,7 @@ class BubbleTest extends StatelessWidget {
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 16,
),
),

View File

@@ -119,10 +119,7 @@ class _DomainBrowserWebviewWidgetState
children: [
Padding(
padding: const EdgeInsets.only(left: 2),
child: const DaveMascot.icon(
width: 24,
height: 24,
),
child: const DaveMascot.icon(width: 24, height: 24),
),
const SizedBox(width: 8),
Expanded(

View File

@@ -14,7 +14,12 @@ class GradeChart extends StatefulWidget {
final List<GradeCacheModel> grades;
final bool halfYearFallback;
final bool plotRawValues;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
GradeChart({
this.style,
super.key,
required List<GradeCacheModel> grades,
this.halfYearFallback = true,
@@ -37,6 +42,8 @@ class DateSpot extends FlSpot {
}
class _GradeChartState extends State<GradeChart> {
FirkaStyle get style => widget.style ?? appStyle;
double? _tooltipY;
int? _touchedIndex;
DateFormat tooltipFormat = DateFormat("MM.dd.");
@@ -124,6 +131,7 @@ class _GradeChartState extends State<GradeChart> {
Widget build(BuildContext context) {
return FirkaCard.single(
margin: EdgeInsets.all(0),
style: widget.style,
child: ClipRRect(
borderRadius: BorderRadius.circular(16),
child: AspectRatio(aspectRatio: 1.82, child: LineChart(avgData())),
@@ -154,7 +162,7 @@ class _GradeChartState extends State<GradeChart> {
final text = Text(
content,
style: appStyle.fonts.B_12R.apply(color: appStyle.colors.textSecondary),
style: style.fonts.B_12R.apply(color: style.colors.textSecondary),
);
return SideTitleWidget(
@@ -168,7 +176,7 @@ class _GradeChartState extends State<GradeChart> {
? Container(
padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
decoration: ShapeDecoration(
color: appStyle.colors.background,
color: style.colors.background,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(27),
),
@@ -190,13 +198,13 @@ class _GradeChartState extends State<GradeChart> {
child: Text(
text,
textAlign: TextAlign.center,
style: appStyle.fonts.H_14px.copyWith(color: textColor),
style: style.fonts.H_14px.copyWith(color: textColor),
),
);
}
Color colorForY(double y) {
return y == 0 ? appStyle.colors.card : initData.settings.getGradeColor(y);
return y == 0 ? style.colors.card : initData.settings.getGradeColor(y, style: style);
}
Widget leftTitleWidgets(double value, TitleMeta meta) {
@@ -210,7 +218,7 @@ class _GradeChartState extends State<GradeChart> {
final isActive = value == currentValue;
if (isActive) {
final gradeColor = getGradeColor(value);
final gradeColor = getGradeColor(value, style: style);
return buildCircle(
text: value.toStringAsFixed(0),
bgColor: gradeColor.withAlpha(38),
@@ -220,8 +228,8 @@ class _GradeChartState extends State<GradeChart> {
return buildCircle(
text: value.toStringAsFixed(0),
bgColor: appStyle.colors.card,
textColor: appStyle.colors.textTertiary,
bgColor: style.colors.card,
textColor: style.colors.textTertiary,
);
// return Text(text, style: style, textAlign: TextAlign.left);
@@ -250,7 +258,7 @@ class _GradeChartState extends State<GradeChart> {
},
touchTooltipData: LineTouchTooltipData(
tooltipMargin: 4,
getTooltipColor: (touchedSpot) => appStyle.colors.buttonSecondaryFill,
getTooltipColor: (touchedSpot) => style.colors.buttonSecondaryFill,
tooltipBorderRadius: BorderRadius.circular(27),
tooltipPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 6),
fitInsideHorizontally: true,
@@ -262,7 +270,7 @@ class _GradeChartState extends State<GradeChart> {
return null;
}
final spot = spots[touchedSpot.spotIndex];
final textStyle = appStyle.fonts.B_14SB.apply(
final textStyle = style.fonts.B_14SB.apply(
color: colorForY(spot.y),
);
return LineTooltipItem(spot.y.toStringAsFixed(2), textStyle);
@@ -364,11 +372,13 @@ class _GradeChartState extends State<GradeChart> {
class GradeChartWithInteraction extends StatelessWidget {
final List<GradeCacheModel> grades;
final bool halfYearFallback;
final FirkaStyle? style;
const GradeChartWithInteraction({
super.key,
required this.grades,
this.halfYearFallback = true,
this.style,
});
@override
@@ -378,7 +388,11 @@ class GradeChartWithInteraction extends StatelessWidget {
onPointerDown: (_) => ChartInteractionScope.of(context).value = true,
onPointerUp: (_) => ChartInteractionScope.of(context).value = false,
onPointerCancel: (_) => ChartInteractionScope.of(context).value = false,
child: GradeChart(grades: grades, halfYearFallback: halfYearFallback),
child: GradeChart(
grades: grades,
halfYearFallback: halfYearFallback,
style: style,
),
);
}
}

View File

@@ -14,7 +14,12 @@ class GradeSummaryBar extends StatefulWidget {
final AppLocalizations l10n;
final bool showAverage;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const GradeSummaryBar({
this.style,
super.key,
required this.grades,
required this.l10n,
@@ -30,6 +35,7 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
@override
Widget build(BuildContext context) {
final style = widget.style ?? appStyle;
final (total, countsByGrade) = widget.grades.getGradeDistribution();
final averageText = widget.showAverage
? (widget.grades.getAverage() ?? 0).toStringAsFixed(2)
@@ -41,7 +47,7 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
final flex = total > 0 ? countsByGrade[i] : 1;
return Expanded(
flex: flex,
child: Container(height: 12, color: getGradeColor(i + 1)),
child: Container(height: 12, color: getGradeColor(i + 1, style: style)),
);
}),
),
@@ -50,6 +56,7 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
return GestureDetector(
onTap: () => setState(() => _expanded = !_expanded),
child: FirkaCard.single(
style: style,
margin: EdgeInsets.zero,
padding: EdgeInsets.symmetric(horizontal: 16),
height: _expanded ? 115 : 52,
@@ -65,8 +72,8 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
widget.showAverage
? '${widget.l10n.gradesCount(total)} ($averageText)'
: widget.l10n.gradesCount(total),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
),
Expanded(child: _expanded ? SizedBox() : bar),
@@ -75,7 +82,7 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
_expanded
? Majesticon.chevronUpLine
: Majesticon.chevronDownLine,
color: appStyle.colors.textPrimary,
color: style.colors.textPrimary,
size: 24,
),
],
@@ -90,11 +97,12 @@ class _GradeSummaryBarState extends State<GradeSummaryBar> {
mainAxisSize: MainAxisSize.min,
spacing: 6,
children: [
GradeWidget.gradeValue(grade, size: 27),
GradeWidget.gradeValue(
style: style,grade, size: 27),
Text(
countsByGrade[i].toString(),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
),
],

View File

@@ -25,13 +25,25 @@ class NewGradesWidget extends StatelessWidget {
final List<GradeCacheModel> grades;
final VoidCallback? onTap;
const NewGradesWidget(this.l10n, this.grades, {this.onTap, super.key});
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const NewGradesWidget(
this.l10n,
this.grades, {
this.onTap,
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
return GestureDetector(
onTap: onTap,
child: FirkaCard.single(
style: style,
margin: EdgeInsets.only(bottom: 1),
padding: EdgeInsets.zero,
child: ClipRRect(
@@ -63,8 +75,8 @@ class NewGradesWidget extends StatelessWidget {
top: 67 * s,
child: Text(
l10n.new_grades_card,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
),
),
@@ -78,11 +90,12 @@ class NewGradesWidget extends StatelessWidget {
}
Widget _icon(double s) {
final style = this.style ?? appStyle;
return Container(
width: 32 * s,
height: 32 * s,
decoration: BoxDecoration(
color: appStyle.colors.a15p,
color: style.colors.a15p,
borderRadius: BorderRadius.circular(16 * s),
),
alignment: Alignment.center,
@@ -90,7 +103,7 @@ class NewGradesWidget extends StatelessWidget {
_cardIcon,
width: 20 * s,
height: 20 * s,
color: appStyle.colors.accent,
color: style.colors.accent,
),
);
}

View File

@@ -13,10 +13,21 @@ class StartingSoonWidget extends StatelessWidget {
final List<LessonCacheModel> lessons;
final DateTime now;
const StartingSoonWidget(this.l10n, this.now, this.lessons, {super.key});
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const StartingSoonWidget(
this.l10n,
this.now,
this.lessons, {
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
var diff = lessons.first.start.difference(now.min(lessons.first.start));
var hour = diff.inHours % 60;
var min = diff.inMinutes % 60;
@@ -27,6 +38,7 @@ class StartingSoonWidget extends StatelessWidget {
var secTxt = hour == 1 ? l10n.starting_sec : l10n.starting_sec_plural;
return FirkaCard.single(
style: style,
margin: EdgeInsets.only(bottom: 1),
padding: EdgeInsets.all(16),
child: Column(
@@ -37,55 +49,55 @@ class StartingSoonWidget extends StatelessWidget {
children: [
FilledCircle(
diameter: 32,
color: appStyle.colors.a15p,
color: style.colors.a15p,
child: FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"sunSolid",
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
),
SizedBox(width: 8),
Text(
l10n.starting_soon,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
),
],
),
Row(
children: [
CounterDigitWidget((hour / 10).floor().toString()),
CounterDigitWidget((hour / 10).floor().toString(), style: style),
SizedBox(width: 4),
CounterDigitWidget(((hour % 10)).toString()),
CounterDigitWidget(((hour % 10)).toString(), style: style),
SizedBox(width: 8),
Text(
hourTxt,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
SizedBox(width: 8),
CounterDigitWidget((min / 10).floor().toString()),
CounterDigitWidget((min / 10).floor().toString(), style: style),
SizedBox(width: 4),
CounterDigitWidget(((min % 10)).toString()),
CounterDigitWidget(((min % 10)).toString(), style: style),
SizedBox(width: 8),
Text(
minTxt,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
SizedBox(width: 8),
CounterDigitWidget((sec / 10).floor().toString()),
CounterDigitWidget((sec / 10).floor().toString(), style: style),
SizedBox(width: 4),
CounterDigitWidget(((sec % 10)).toString()),
CounterDigitWidget(((sec % 10)).toString(), style: style),
SizedBox(width: 8),
Text(
secTxt,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
],

View File

@@ -16,11 +16,16 @@ class WelcomeWidget extends StatefulWidget {
final List<LessonCacheModel> lessons;
final DateTime now;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const WelcomeWidget(
this.l10n,
this.now,
this.student,
this.lessons, {
this.style,
super.key,
});
@@ -29,6 +34,8 @@ class WelcomeWidget extends StatefulWidget {
}
class _WelcomeWidgetState extends State<WelcomeWidget> {
FirkaStyle get style => widget.style ?? appStyle;
late ConfettiController _controllerCenter;
@override
@@ -56,25 +63,25 @@ class _WelcomeWidgetState extends State<WelcomeWidget> {
return FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"sunSolid",
color: appStyle.colors.accent,
color: style.colors.accent,
);
case Cycle.day:
return FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"parkSolidSchool",
color: appStyle.colors.accent,
color: style.colors.accent,
);
case Cycle.afternoon:
return FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
color: appStyle.colors.accent,
color: style.colors.accent,
);
case Cycle.night:
return FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
color: appStyle.colors.accent,
color: style.colors.accent,
);
}
}
@@ -161,15 +168,15 @@ class _WelcomeWidgetState extends State<WelcomeWidget> {
const SizedBox(height: 16.0),
Text(
headingText(getTitle(dayCycle)),
style: appStyle.fonts.H_H2.copyWith(
color: appStyle.colors.textPrimary,
style: style.fonts.H_H2.copyWith(
color: style.colors.textPrimary,
),
),
const SizedBox(height: 2.0),
Text(
getSubtitle(dayCycle),
style: appStyle.fonts.B_16R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.copyWith(
color: style.colors.textSecondary,
),
),
],

View File

@@ -1,295 +1,324 @@
import 'package:firka/app/app_state.dart';
import 'package:firka/core/extensions.dart';
import 'package:firka_common/core/grade_helper.dart';
import 'package:firka_common/data/models/grade_cache_model.dart';
import 'package:firka_common/data/models/homework_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/subject_cache_model.dart';
import 'package:firka_common/data/models/test_cache_model.dart';
import 'package:firka/ui/components/common_bottom_sheets.dart';
import 'package:firka_common/ui/components/firka_card.dart';
import 'package:firka_common/ui/components/grade.dart';
import 'package:firka/ui/shared/class_icon.dart';
import 'package:firka/ui/shared/firka_icon.dart';
import 'package:firka/ui/theme/style.dart';
import 'package:firka_common/data/util.dart';
import 'package:firka_common/ui/components/filled_circle.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:kreta_api/kreta_api.dart';
import 'package:majesticons_flutter/majesticons_flutter.dart';
class InfoCard extends StatelessWidget {
final void Function(BuildContext)? onTap;
final Widget icon;
final List<String> texts;
final List<Widget> right;
final List<TextStyle> textSyles = [
appStyle.fonts.B_16SB.apply(color: appStyle.colors.textPrimary),
appStyle.fonts.B_14R.apply(color: appStyle.colors.textSecondary),
];
InfoCard({
required this.icon,
required this.texts,
this.right = const [],
this.onTap,
super.key,
});
static Widget buildSubject(Color color, SubjectCacheModel subject) {
return FilledCircle(
diameter: 32,
color: color.withAlpha(38),
child: ClassIconWidget(subject: subject, color: color, size: 20),
);
}
factory InfoCard.test(TestCacheModel test) {
final color = appStyle.colors.accent;
final subject = test.lesson.loadAndGet()!.subject.loadAndGet()!;
return InfoCard(
icon: FilledCircle(
diameter: 36,
color: color.withAlpha(38),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: color,
size: 24,
),
),
texts: [
test.topic?.firstUpper() ?? test.method,
subject.name.firstUpper(),
],
right: [buildSubject(color, subject)],
onTap: (context) => showTestBottomSheet(context, initData, test),
);
}
factory InfoCard.testDesc(TestCacheModel test) {
if (test.topic == null) {
return InfoCard.test(test);
}
final subject = test.lesson.loadAndGet()!.subject.loadAndGet()!;
final color = appStyle.colors.accent;
return InfoCard(
icon: FilledCircle(
diameter: 36,
color: color.withAlpha(38),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: color,
size: 24,
),
),
texts: [test.topic!.firstUpper(), test.method.firstUpper()],
right: [buildSubject(color, subject)],
onTap: (context) => showTestBottomSheet(context, initData, test),
);
}
factory InfoCard.messageItem(MessageCacheModel item) {
return InfoCard(
icon: FilledCircle(
diameter: 36,
color: appStyle.colors.accent,
child: Text(
item.author[0],
style: appStyle.fonts.H_H2.apply(color: appStyle.colors.textPrimary),
),
),
texts: [item.title, item.author],
onTap: (context) => context.push('/message', extra: item),
);
}
factory InfoCard.omission(List<OmissionCacheModel> omissions) {
String title = "-";
Color color = appStyle.colors.accent;
FirkaIconType iconType = FirkaIconType.majesticons;
Object iconData = "check";
for (final state in [
(
OmissionState.pending,
appStyle.colors.warningAccent,
FirkaIconType.majesticons,
Majesticon.timerSolid,
),
(
OmissionState.unexcused,
appStyle.colors.errorAccent,
FirkaIconType.majesticons,
Majesticon.restrictedLine,
),
(
OmissionState.excused,
appStyle.colors.accent,
FirkaIconType.majesticonsLocal,
"check",
),
]) {
final count = omissions.where((o) => o.state == state.$1).length;
if (count == 0) {
continue;
}
title = initData.l10n.omissions_count(state.$1.name, count);
color = state.$2;
iconType = state.$3;
iconData = state.$4;
break;
}
return InfoCard(
icon: FilledCircle(
diameter: 36,
color: color.withAlpha(38),
child: FirkaIconWidget(iconType, iconData, color: color, size: 24),
),
texts: [
title,
DateFormat.MMMMd(
initData.l10n.localeName,
).format(omissions.first.createdAt).firstUpper(),
],
onTap: (context) =>
showOmissionBottomSheet(context, initData, title, omissions),
);
}
factory InfoCard.homework(HomeworkCacheModel homework) {
final subject = homework.subject.loadAndGet()!;
return InfoCard(
icon: FilledCircle(
diameter: 36,
color: appStyle.colors.accent.withAlpha(38),
child: homework.isDone
? FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"homeWithMark",
color: appStyle.colors.accent,
size: 24,
)
: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.homeSolid,
color: appStyle.colors.accent,
size: 24,
),
),
texts: [initData.l10n.homework, subject.name],
right: [buildSubject(appStyle.colors.accent, subject)],
onTap: (context) => showHomeworkBottomSheet(context, initData, homework),
);
}
factory InfoCard.gradeSubj(
GradeCacheModel grade, {
void Function(BuildContext)? onTap,
}) {
String? value = grade.numericValue == null ? grade.textValue : null;
return InfoCard(
icon: GradeWidget(grade),
texts: [
(value ?? grade.topic ?? grade.mode ?? grade.type).firstUpper(),
grade.subject.loadAndGet()!.name.firstUpper(),
],
right: [
buildSubject(
grade.numericValue != null
? getGradeColor(grade.numericValue!)
: appStyle.colors.accent,
grade.subject.loadAndGet()!,
),
],
onTap:
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
);
}
factory InfoCard.gradeGhost(
int gradeValue,
int gradeWeigth, {
void Function(BuildContext)? onTap,
}) {
return InfoCard(
icon: GradeWidget.gradeValue(gradeValue, gradeWeight: gradeWeigth),
texts: ["${initData.l10n.ghost_grade} ($gradeWeigth%)"],
right: [],
onTap: onTap,
);
}
factory InfoCard.gradeDesc(
GradeCacheModel grade, {
void Function(BuildContext)? onTap,
}) {
List<String> texts = [(grade.mode ?? grade.type).firstUpper()];
if (grade.topic != null) {
texts = [grade.topic!.firstUpper(), ...texts];
}
return InfoCard(
icon: GradeWidget(grade),
texts: texts,
right: [
buildSubject(appStyle.colors.accent, grade.subject.loadAndGet()!),
],
onTap:
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
);
}
@override
Widget build(BuildContext context) {
List<Text> children = [];
int i = 0;
for (var text in texts) {
children.add(
Text(text, style: textSyles[i], overflow: TextOverflow.ellipsis),
);
if (i < textSyles.length) {
i++;
}
}
return GestureDetector(
child: FirkaCard.single(
height: 68,
padding: EdgeInsets.symmetric(horizontal: 16),
margin: EdgeInsets.all(0),
child: Row(
spacing: 12,
children: [
icon,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
spacing: 2,
children: children,
),
),
...right,
],
),
),
onTap: () {
if (onTap == null) return;
onTap!.call(context);
},
);
}
}
import 'package:firka/app/app_state.dart';
import 'package:firka/core/extensions.dart';
import 'package:firka_common/core/grade_helper.dart';
import 'package:firka_common/data/models/grade_cache_model.dart';
import 'package:firka_common/data/models/homework_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/subject_cache_model.dart';
import 'package:firka_common/data/models/test_cache_model.dart';
import 'package:firka/ui/components/common_bottom_sheets.dart';
import 'package:firka_common/ui/components/firka_card.dart';
import 'package:firka_common/ui/components/grade.dart';
import 'package:firka/ui/shared/class_icon.dart';
import 'package:firka/ui/shared/firka_icon.dart';
import 'package:firka/ui/theme/style.dart';
import 'package:firka_common/data/util.dart';
import 'package:firka_common/ui/components/filled_circle.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
import 'package:kreta_api/kreta_api.dart';
import 'package:majesticons_flutter/majesticons_flutter.dart';
class InfoCard extends StatelessWidget {
final void Function(BuildContext)? onTap;
final Widget icon;
final List<String> texts;
final List<Widget> right;
/// Renders from this style instead of the global one, so a preview can show
/// a theme the user has not applied.
final FirkaStyle? style;
// a getter, not a field: a field initializer cannot read `style`
List<TextStyle> get textSyles {
final style = this.style ?? appStyle;
return [
style.fonts.B_16SB.apply(color: style.colors.textPrimary),
style.fonts.B_14R.apply(color: style.colors.textSecondary),
];
}
const InfoCard({
required this.icon,
required this.texts,
this.right = const [],
this.onTap,
this.style,
super.key,
});
static Widget buildSubject(Color color, SubjectCacheModel subject) {
return FilledCircle(
diameter: 32,
color: color.withAlpha(38),
child: ClassIconWidget(subject: subject, color: color, size: 20),
);
}
factory InfoCard.test(TestCacheModel test, {FirkaStyle? style}) {
final s = style ?? appStyle;
final color = s.colors.accent;
final subject = test.lesson.loadAndGet()!.subject.loadAndGet()!;
return InfoCard(
style: style,
icon: FilledCircle(
diameter: 36,
color: color.withAlpha(38),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: color,
size: 24,
),
),
texts: [
test.topic?.firstUpper() ?? test.method,
subject.name.firstUpper(),
],
right: [buildSubject(color, subject)],
onTap: (context) => showTestBottomSheet(context, initData, test),
);
}
factory InfoCard.testDesc(TestCacheModel test, {FirkaStyle? style}) {
final s = style ?? appStyle;
if (test.topic == null) {
return InfoCard.test(test, style: style);
}
final subject = test.lesson.loadAndGet()!.subject.loadAndGet()!;
final color = s.colors.accent;
return InfoCard(
style: style,
icon: FilledCircle(
diameter: 36,
color: color.withAlpha(38),
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: color,
size: 24,
),
),
texts: [test.topic!.firstUpper(), test.method.firstUpper()],
right: [buildSubject(color, subject)],
onTap: (context) => showTestBottomSheet(context, initData, test),
);
}
factory InfoCard.messageItem(MessageCacheModel item, {FirkaStyle? style}) {
final s = style ?? appStyle;
return InfoCard(
style: style,
icon: FilledCircle(
diameter: 36,
color: s.colors.accent,
child: Text(
item.author[0],
style: s.fonts.H_H2.apply(color: s.colors.textPrimary),
),
),
texts: [item.title, item.author],
onTap: (context) => context.push('/message', extra: item),
);
}
factory InfoCard.omission(List<OmissionCacheModel> omissions, {FirkaStyle? style}) {
final s = style ?? appStyle;
String title = "-";
Color color = s.colors.accent;
FirkaIconType iconType = FirkaIconType.majesticons;
Object iconData = "check";
for (final state in [
(
OmissionState.pending,
s.colors.warningAccent,
FirkaIconType.majesticons,
Majesticon.timerSolid,
),
(
OmissionState.unexcused,
s.colors.errorAccent,
FirkaIconType.majesticons,
Majesticon.restrictedLine,
),
(
OmissionState.excused,
s.colors.accent,
FirkaIconType.majesticonsLocal,
"check",
),
]) {
final count = omissions.where((o) => o.state == state.$1).length;
if (count == 0) {
continue;
}
title = initData.l10n.omissions_count(state.$1.name, count);
color = state.$2;
iconType = state.$3;
iconData = state.$4;
break;
}
return InfoCard(
style: style,
icon: FilledCircle(
diameter: 36,
color: color.withAlpha(38),
child: FirkaIconWidget(iconType, iconData, color: color, size: 24),
),
texts: [
title,
DateFormat.MMMMd(
initData.l10n.localeName,
).format(omissions.first.createdAt).firstUpper(),
],
onTap: (context) =>
showOmissionBottomSheet(context, initData, title, omissions),
);
}
factory InfoCard.homework(HomeworkCacheModel homework, {FirkaStyle? style}) {
final s = style ?? appStyle;
final subject = homework.subject.loadAndGet()!;
return InfoCard(
style: style,
icon: FilledCircle(
diameter: 36,
color: s.colors.accent.withAlpha(38),
child: homework.isDone
? FirkaIconWidget(
FirkaIconType.majesticonsLocal,
"homeWithMark",
color: s.colors.accent,
size: 24,
)
: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.homeSolid,
color: s.colors.accent,
size: 24,
),
),
texts: [initData.l10n.homework, subject.name],
right: [buildSubject(s.colors.accent, subject)],
onTap: (context) => showHomeworkBottomSheet(context, initData, homework),
);
}
factory InfoCard.gradeSubj(
GradeCacheModel grade, {
FirkaStyle? style,
void Function(BuildContext)? onTap,
}) {
final s = style ?? appStyle;
String? value = grade.numericValue == null ? grade.textValue : null;
return InfoCard(
style: style,
icon: GradeWidget(grade, style: style),
texts: [
(value ?? grade.topic ?? grade.mode ?? grade.type).firstUpper(),
grade.subject.loadAndGet()!.name.firstUpper(),
],
right: [
buildSubject(
grade.numericValue != null
? getGradeColor(grade.numericValue!, style: style)
: s.colors.accent,
grade.subject.loadAndGet()!,
),
],
onTap:
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
);
}
factory InfoCard.gradeGhost(
int gradeValue,
int gradeWeigth, {
FirkaStyle? style,
void Function(BuildContext)? onTap,
}) {
return InfoCard(
style: style,
icon: GradeWidget.gradeValue(
style: style,gradeValue, gradeWeight: gradeWeigth),
texts: ["${initData.l10n.ghost_grade} ($gradeWeigth%)"],
right: [],
onTap: onTap,
);
}
factory InfoCard.gradeDesc(
GradeCacheModel grade, {
FirkaStyle? style,
void Function(BuildContext)? onTap,
}) {
final s = style ?? appStyle;
List<String> texts = [(grade.mode ?? grade.type).firstUpper()];
if (grade.topic != null) {
texts = [grade.topic!.firstUpper(), ...texts];
}
return InfoCard(
style: style,
icon: GradeWidget(grade, style: style),
texts: texts,
right: [
buildSubject(s.colors.accent, grade.subject.loadAndGet()!),
],
onTap:
onTap ?? (context) => showGradeBottomSheet(context, initData, grade),
);
}
@override
Widget build(BuildContext context) {
List<Text> children = [];
int i = 0;
for (var text in texts) {
children.add(
Text(text, style: textSyles[i], overflow: TextOverflow.ellipsis),
);
if (i < textSyles.length) {
i++;
}
}
return GestureDetector(
child: FirkaCard.single(
style: style,
height: 68,
padding: EdgeInsets.symmetric(horizontal: 16),
margin: EdgeInsets.all(0),
child: Row(
spacing: 12,
children: [
icon,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
spacing: 2,
children: children,
),
),
...right,
],
),
),
onTap: () {
if (onTap == null) return;
onTap!.call(context);
},
);
}
}

View File

@@ -22,10 +22,21 @@ class LessonWidget extends StatelessWidget {
final LessonCacheModel lesson;
final bool active;
const LessonWidget(this.data, this.lesson, {this.active = false, super.key});
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const LessonWidget(
this.data,
this.lesson, {
this.active = false,
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
// we dont like events
assert(lesson.type != TimetableConsts.event);
final showTests = Settings.ttToastTestsAndHw.value;
@@ -38,19 +49,19 @@ class LessonWidget extends StatelessWidget {
final showLessonNos = Settings.ttToastLessonNo.value;
final isDismissed = lesson.type == "UresOra";
var accent = appStyle.colors.accent;
var secondary = appStyle.colors.secondary;
var bgColor = appStyle.colors.a15p;
var accent = style.colors.accent;
var secondary = style.colors.secondary;
var bgColor = style.colors.a15p;
if (isSubstituted) {
accent = appStyle.colors.warningAccent;
secondary = appStyle.colors.warningText;
bgColor = appStyle.colors.warning15p;
accent = style.colors.warningAccent;
secondary = style.colors.warningText;
bgColor = style.colors.warning15p;
}
if (isDismissed) {
accent = appStyle.colors.errorAccent;
secondary = appStyle.colors.errorText;
bgColor = appStyle.colors.error15p;
accent = style.colors.errorAccent;
secondary = style.colors.errorText;
bgColor = style.colors.error15p;
}
List<Widget> elements = [];
@@ -72,13 +83,14 @@ class LessonWidget extends StatelessWidget {
);
},
child: FirkaCard.single(
style: style,
height: 64,
borderColor: active ? appStyle.colors.accent : null,
borderColor: active ? style.colors.accent : null,
margin: EdgeInsets.all(0),
padding: EdgeInsets.only(left: 14, right: 16),
color: isDismissed
? appStyle.colors.cardTranslucent
: appStyle.colors.card,
? style.colors.cardTranslucent
: style.colors.card,
attached: showTests && test != null ? Attach.bottom : Attach.none,
shadow: !isDismissed,
child: Column(
@@ -103,7 +115,7 @@ class LessonWidget extends StatelessWidget {
),
Text(
lesson.dailyNth.toString(),
style: appStyle.fonts.B_14SB.apply(
style: style.fonts.B_14SB.apply(
color: secondary,
),
textAlign: TextAlign.center,
@@ -125,7 +137,7 @@ class LessonWidget extends StatelessWidget {
child: !showTests && test != null
? Transform.translate(
offset: Offset(4, -20),
child: BubbleTest(),
child: BubbleTest(style: style),
)
: SizedBox(),
),
@@ -142,18 +154,18 @@ class LessonWidget extends StatelessWidget {
children: [
Text(
subjectName,
style: appStyle.fonts.B_16SB.apply(
style: style.fonts.B_16SB.apply(
color: !isDismissed
? appStyle.colors.textPrimary
: appStyle.colors.textSecondary,
? style.colors.textPrimary
: style.colors.textSecondary,
),
overflow: TextOverflow.ellipsis,
),
showSubstitutions
? Text(
lesson.substituteTeacher!.shortenName(),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.apply(
color: style.colors.textSecondary,
),
)
: SizedBox(),
@@ -163,15 +175,15 @@ class LessonWidget extends StatelessWidget {
isDismissed
? Text(
data.l10n.class_dismissed,
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.apply(
color: style.colors.textSecondary,
),
)
: Flexible(
fit: FlexFit.loose,
child: Card(
shadowColor: Colors.transparent,
color: appStyle.colors.a15p,
color: style.colors.a15p,
margin: EdgeInsets.all(0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
@@ -182,8 +194,8 @@ class LessonWidget extends StatelessWidget {
),
child: Text(
roomName!,
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.secondary,
style: style.fonts.B_14R.apply(
color: style.colors.secondary,
),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
@@ -205,8 +217,8 @@ class LessonWidget extends StatelessWidget {
data.l10n,
FormatMode.hmm,
),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_14R.apply(
color: style.colors.textPrimary,
),
),
Text(
@@ -214,8 +226,8 @@ class LessonWidget extends StatelessWidget {
data.l10n,
FormatMode.hmm,
),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_14R.apply(
color: style.colors.textPrimary,
),
),
],
@@ -238,6 +250,7 @@ class LessonWidget extends StatelessWidget {
showTestBottomSheet(context, data, test);
},
child: FirkaCard.single(
style: style,
height: 48,
padding: EdgeInsets.symmetric(horizontal: 16),
margin: EdgeInsets.only(top: 4),
@@ -247,7 +260,7 @@ class LessonWidget extends StatelessWidget {
FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 20,
),
SizedBox(width: 8),
@@ -255,8 +268,8 @@ class LessonWidget extends StatelessWidget {
maxWidth: 160,
child: Text(
topic,
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
@@ -268,8 +281,8 @@ class LessonWidget extends StatelessWidget {
alignment: Alignment.centerRight,
child: Text(
method,
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.apply(
color: style.colors.textSecondary,
),
overflow: TextOverflow.ellipsis,
),

View File

@@ -20,34 +20,40 @@ class LessonBigWidget extends StatelessWidget {
final LessonCacheModel lesson;
final bool active;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const LessonBigWidget(
this.data,
this.lesson, {
this.active = false,
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
// we dont like events
assert(lesson.type != TimetableConsts.event);
final isSubstituted = lesson.substituteTeacher != null;
final isDismissed = lesson.type == "UresOra";
final test = lesson.test.loadAndGet();
var accent = appStyle.colors.accent;
var secondary = appStyle.colors.secondary;
var bgColor = appStyle.colors.a15p;
var accent = style.colors.accent;
var secondary = style.colors.secondary;
var bgColor = style.colors.a15p;
if (isSubstituted) {
accent = appStyle.colors.warningAccent;
secondary = appStyle.colors.warningText;
bgColor = appStyle.colors.warning15p;
accent = style.colors.warningAccent;
secondary = style.colors.warningText;
bgColor = style.colors.warning15p;
}
if (isDismissed) {
accent = appStyle.colors.errorAccent;
secondary = appStyle.colors.errorText;
bgColor = appStyle.colors.error15p;
accent = style.colors.errorAccent;
secondary = style.colors.errorText;
bgColor = style.colors.error15p;
}
var subjectName = lesson.subject.loadAndGet()!.name.firstUpper();
@@ -68,14 +74,14 @@ class LessonBigWidget extends StatelessWidget {
.timeLeft(initData.l10n)
: null) ??
lesson.start.format(data.l10n, FormatMode.hmm),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.apply(
color: style.colors.textSecondary,
),
),
Text(
lesson.end.format(initData.l10n, FormatMode.hmm),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.apply(
color: style.colors.textSecondary,
),
),
],
@@ -86,8 +92,8 @@ class LessonBigWidget extends StatelessWidget {
value:
timeNow().difference(lesson.start).inMilliseconds /
lesson.end.difference(lesson.start).inMilliseconds,
backgroundColor: appStyle.colors.a15p,
color: appStyle.colors.accent,
backgroundColor: style.colors.a15p,
color: style.colors.accent,
minHeight: 8,
),
),
@@ -100,7 +106,7 @@ class LessonBigWidget extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
color: appStyle.colors.background,
color: style.colors.background,
),
child: Row(
children: [
@@ -108,14 +114,14 @@ class LessonBigWidget extends StatelessWidget {
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
size: 12,
color: appStyle.colors.accent,
color: style.colors.accent,
),
SizedBox(width: 8),
Expanded(
child: Text(
test.topic ?? "",
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
@@ -136,13 +142,14 @@ class LessonBigWidget extends StatelessWidget {
);
},
child: FirkaCard.single(
style: style,
height: 104,
borderColor: active ? appStyle.colors.accent : null,
borderColor: active ? style.colors.accent : null,
margin: EdgeInsets.only(bottom: active ? 0 : 1),
padding: EdgeInsets.only(left: 16, right: 16),
color: isDismissed
? appStyle.colors.cardTranslucent
: appStyle.colors.card,
? style.colors.cardTranslucent
: style.colors.card,
shadow: !isDismissed,
child: Column(
spacing: 12,
@@ -164,7 +171,7 @@ class LessonBigWidget extends StatelessWidget {
),
Text(
lesson.dailyNth.toString(),
style: appStyle.fonts.B_14SB.apply(color: secondary),
style: style.fonts.B_14SB.apply(color: secondary),
textAlign: TextAlign.center,
),
],
@@ -193,18 +200,18 @@ class LessonBigWidget extends StatelessWidget {
children: [
Text(
subjectName,
style: appStyle.fonts.B_16SB.apply(
style: style.fonts.B_16SB.apply(
color: !isDismissed
? appStyle.colors.textPrimary
: appStyle.colors.textSecondary,
? style.colors.textPrimary
: style.colors.textSecondary,
),
overflow: TextOverflow.ellipsis,
),
if (isSubstituted)
Text(
lesson.substituteTeacher!.shortenName(),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.apply(
color: style.colors.textSecondary,
),
overflow: TextOverflow.ellipsis,
),
@@ -215,7 +222,7 @@ class LessonBigWidget extends StatelessWidget {
fit: FlexFit.loose,
child: Card(
shadowColor: Colors.transparent,
color: appStyle.colors.a15p,
color: style.colors.a15p,
margin: EdgeInsets.all(0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
@@ -224,8 +231,8 @@ class LessonBigWidget extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 6),
child: Text(
roomName ?? "",
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.secondary,
style: style.fonts.B_14R.apply(
color: style.colors.secondary,
),
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
@@ -247,8 +254,8 @@ class LessonBigWidget extends StatelessWidget {
data.l10n,
FormatMode.hmm,
),
style: appStyle.fonts.B_14R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_14R.apply(
color: style.colors.textPrimary,
),
),
],

View File

@@ -49,6 +49,7 @@ class _LessonSliderState extends State<LessonSlider> {
@override
Widget build(BuildContext context) {
final style = widget.style ?? appStyle;
final hasNewGrades = widget.newGrades.isNotEmpty;
final hasLessons = widget.lessons.isNotEmpty;
@@ -106,6 +107,7 @@ class _LessonSliderState extends State<LessonSlider> {
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: NewGradesWidget(
style: widget.style,
initData.l10n,
widget.newGrades,
onTap: widget.onNewGradesTap,
@@ -118,6 +120,7 @@ class _LessonSliderState extends State<LessonSlider> {
initData.l10n,
now,
widget.lessons,
style: widget.style,
),
),
...widget.lessons.map(
@@ -127,6 +130,7 @@ class _LessonSliderState extends State<LessonSlider> {
initData,
entry,
active: currentLesson == entry,
style: widget.style,
),
),
),
@@ -134,6 +138,7 @@ class _LessonSliderState extends State<LessonSlider> {
Padding(
padding: EdgeInsets.symmetric(horizontal: 5),
child: FirkaCard.single(
style: widget.style,
padding: EdgeInsets.all(16),
margin: EdgeInsets.only(bottom: 1),
child: Column(
@@ -144,12 +149,12 @@ class _LessonSliderState extends State<LessonSlider> {
children: [
FilledCircle(
diameter: 32,
color: appStyle.colors.a15p,
color: style.colors.a15p,
child: FirkaIconWidget(
FirkaIconType.majesticons,
Majesticon.moonSolid,
size: 20,
color: appStyle.colors.accent,
color: style.colors.accent,
),
),
SizedBox(width: 8),
@@ -157,8 +162,8 @@ class _LessonSliderState extends State<LessonSlider> {
widget.tomorrowTestAmount == 0
? initData.l10n.tt_no_classes_l2
: initData.l10n.get_ready,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
),
],
@@ -170,7 +175,7 @@ class _LessonSliderState extends State<LessonSlider> {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(14),
),
color: appStyle.colors.background,
color: style.colors.background,
),
child: Row(
children: [
@@ -178,7 +183,7 @@ class _LessonSliderState extends State<LessonSlider> {
FirkaIconType.majesticons,
Majesticon.editPen4Solid,
size: 12,
color: appStyle.colors.accent,
color: style.colors.accent,
),
SizedBox(width: 8),
Text(
@@ -187,8 +192,8 @@ class _LessonSliderState extends State<LessonSlider> {
: initData.l10n.tests_tomorrow(
widget.tomorrowTestAmount.toString(),
),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
),
],
@@ -231,8 +236,8 @@ class _LessonSliderState extends State<LessonSlider> {
FirkaIconType.majesticons,
Majesticon.shootingStarSolid,
color: centeredPageIndex == 0
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
? style.colors.accent
: style.colors.accent.withAlpha(128),
size: centeredPageIndex == 0 ? 16 : 12,
),
if (hasLessons) ...[
@@ -240,16 +245,16 @@ class _LessonSliderState extends State<LessonSlider> {
FirkaIconType.majesticonsLocal,
"sunSolid",
color: centeredPageIndex == offset
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
? style.colors.accent
: style.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),
? style.colors.accent
: style.colors.accent.withAlpha(128),
child: SizedBox(),
),
),
@@ -257,8 +262,8 @@ class _LessonSliderState extends State<LessonSlider> {
FirkaIconType.majesticons,
Majesticon.moonSolid,
color: centeredPageIndex == widget.lessons.length + 1 + offset
? appStyle.colors.accent
: appStyle.colors.accent.withAlpha(128),
? style.colors.accent
: style.colors.accent.withAlpha(128),
size: centeredPageIndex == widget.lessons.length + 1 + offset
? 16
: 12,
@@ -278,11 +283,16 @@ class LessonSlider extends StatefulWidget {
final List<GradeCacheModel> newGrades;
final VoidCallback? onNewGradesTap;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
LessonSlider(
Iterable<LessonCacheModel> lessons,
this.tomorrowTestAmount, {
this.newGrades = const [],
this.onNewGradesTap,
this.style,
super.key,
}) : lessons = lessons
.where(((l) => l.type != TimetableConsts.event))

View File

@@ -35,6 +35,7 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
with TickerProviderStateMixin {
late WebViewController _webViewController;
bool _isLoading = true;
bool _completingLogin = false;
AnimationController? _fadeAnimationController;
Animation<double>? _fadeAnimation;
late String _displayHost;
@@ -100,6 +101,7 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
if (uri.path == "/ellenorzo-student/prod/oauthredirect") {
var code = uri.queryParameters["code"]!;
setState(() => _completingLogin = true);
try {
var resp = await getAccessToken(code);
@@ -111,8 +113,15 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
if (!mounted) return NavigationDecision.prevent;
if (mounted) {
final router = appRouter;
Navigator.of(context).pop();
appRouter?.go('/home');
// swapping the pages while the sheet is still closing trips a debug-only navigator assertion
unawaited(
Future<void>.delayed(
const Duration(milliseconds: 400),
() => router?.go('/home'),
),
);
}
} catch (ex) {
if (ex is Error) {
@@ -163,10 +172,7 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
children: [
Padding(
padding: const EdgeInsets.only(left: 2),
child: const DaveMascot.icon(
width: 24,
height: 24,
),
child: const DaveMascot.icon(width: 24, height: 24),
),
const SizedBox(width: 8),
Expanded(
@@ -244,6 +250,17 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
),
),
),
if (_completingLogin)
Container(
color: appStyle.colors.background,
child: Center(
child: Image.asset(
"assets/images/logos/loading.gif",
width: 50,
height: 50,
),
),
),
],
),
),

View File

@@ -16,34 +16,40 @@ 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});
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
static Color stateToColor(OmissionCacheModel? o) {
return stateColor(o?.state);
const OmissionBar({super.key, this.previewSegments, this.style});
static Color stateToColor(OmissionCacheModel? o, [FirkaStyle? style]) {
return stateColor(o?.state, style);
}
static Color stateColor(OmissionState? state) {
static Color stateColor(OmissionState? state, [FirkaStyle? style]) {
final s = style ?? appStyle;
if (state == null) {
return appStyle.colors.a15p;
return s.colors.a15p;
}
switch (state) {
case OmissionState.excused:
return appStyle.colors.accent;
return s.colors.accent;
case OmissionState.unexcused:
return appStyle.colors.errorAccent;
return s.colors.errorAccent;
default:
return appStyle.colors.warningAccent;
return s.colors.warningAccent;
}
}
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
DateTime now = timeNow();
DateTime startOfTheYear = now.getFirstSchoolDay();
late final List<Color> segmentColors;
if (previewSegments != null) {
segmentColors = previewSegments!.map(stateColor).toList();
segmentColors = previewSegments!.map((s) => stateColor(s, style)).toList();
} else {
final dates = initData.client!.cache
.getTimeTable()
@@ -58,12 +64,12 @@ class OmissionBar extends StatelessWidget {
.groupList((o) => o.lesson.loadAndGet()!.start);
segmentColors = dates
.map((i) => stateToColor(omittedDates[i]?.firstOrNull))
.map((i) => stateToColor(omittedDates[i]?.firstOrNull, style))
.toList();
}
if (segmentColors.isEmpty) {
segmentColors.add(stateColor(null));
segmentColors.add(stateColor(null, style));
}
final bar = ClipRRect(
@@ -71,18 +77,14 @@ class OmissionBar extends StatelessWidget {
child: Row(
children: segmentColors
.map(
(color) => Expanded(
child: Container(
height: 12,
color: color,
),
),
(color) => Expanded(child: Container(height: 12, color: color)),
)
.toList(),
),
);
return FirkaCard.single(
style: style,
margin: EdgeInsets.zero,
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 8),
child: Column(
@@ -98,14 +100,14 @@ class OmissionBar extends StatelessWidget {
DateFormat.MMMM(
initData.l10n.localeName,
).format(startOfTheYear).firstUpper(),
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.copyWith(
color: style.colors.textSecondary,
),
),
Text(
initData.l10n.now,
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.copyWith(
color: style.colors.textSecondary,
),
),
],

View File

@@ -16,10 +16,15 @@ class TimeTableDayWidget extends StatelessWidget {
final List<LessonCacheModel> events;
final Future<void> Function()? onRefresh;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const TimeTableDayWidget(
this.lessons,
this.events, {
this.onRefresh,
this.style,
super.key,
});
@@ -63,12 +68,17 @@ class TimeTableDayWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
if (lessons.isEmpty) {
return RefreshIndicator(
onRefresh: onRefresh ?? () async {},
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.only(top: 70 + 16 + 20, left: 20, right: 20),
padding: const EdgeInsets.only(
top: 70 + 16 + 20,
left: 20,
right: 20,
),
children: [
SizedBox(
height: MediaQuery.sizeOf(context).height * 0.45,
@@ -76,21 +86,18 @@ class TimeTableDayWidget extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const DaveMascot(
width: 48,
height: 48,
),
const DaveMascot(width: 48, height: 48),
SizedBox(height: 12),
Text(
initData.l10n.tt_no_classes_l1,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
Text(
initData.l10n.tt_no_classes_l2,
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
if (events.isNotEmpty)
@@ -98,8 +105,8 @@ class TimeTableDayWidget extends StatelessWidget {
(event) => Center(
child: Text(
simplifyEventName(event.name),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textSecondary,
style: style.fonts.B_16R.apply(
color: style.colors.textSecondary,
),
),
),
@@ -116,12 +123,13 @@ class TimeTableDayWidget extends StatelessWidget {
for (final event in events) {
ttLessons.add(
FirkaCard.single(
style: style,
margin: EdgeInsets.zero,
padding: EdgeInsets.all(16),
child: Text(
simplifyEventName(event.name),
style: appStyle.fonts.B_16R.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16R.apply(
color: style.colors.textPrimary,
),
),
),
@@ -141,6 +149,7 @@ class TimeTableDayWidget extends StatelessWidget {
LessonWidget(
initData,
lesson,
style: this.style,
active: timeNow().isBetween(
i > 0 ? lessons[i - 1].end : lesson.start,
lesson.end,
@@ -155,23 +164,24 @@ class TimeTableDayWidget extends StatelessWidget {
var breakMins = nextLesson.start.difference(lesson.end).inMinutes;
ttLessons.add(
FirkaCard(
color: appStyle.colors.cardTranslucent,
style: style,
color: style.colors.cardTranslucent,
margin: EdgeInsets.all(0),
padding: EdgeInsets.symmetric(vertical: 11, horizontal: 16),
shadow: false,
left: [
Text(
initData.l10n.breakTxt,
style: appStyle.fonts.B_14SB.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14SB.copyWith(
color: style.colors.textSecondary,
),
),
],
right: [
Text(
"$breakMins ${breakMins > 1 ? initData.l10n.starting_min_plural : initData.l10n.starting_min}",
style: appStyle.fonts.B_14R.copyWith(
color: appStyle.colors.textSecondary,
style: style.fonts.B_14R.copyWith(
color: style.colors.textSecondary,
),
),
],

View File

@@ -33,10 +33,26 @@ ColorFilter? getDaveColorFilter([Color? targetColor]) {
final double m22 = 1.0 - m21;
return ColorFilter.matrix(<double>[
0.0, m01, m02, 0.0, 0.0,
0.0, m11, m12, 0.0, 0.0,
0.0, m21, m22, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0,
0.0,
m01,
m02,
0.0,
0.0,
0.0,
m11,
m12,
0.0,
0.0,
0.0,
m21,
m22,
0.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
]);
}
@@ -94,19 +110,14 @@ class DaveMascot extends StatelessWidget {
);
if (filter != null) {
image = ColorFiltered(
colorFilter: filter,
child: image,
);
image = ColorFiltered(colorFilter: filter, child: image);
}
return Container(
width: width,
height: height,
clipBehavior: Clip.antiAlias,
decoration: const ShapeDecoration(
shape: ContinuousRectangleBorder(),
),
decoration: const ShapeDecoration(shape: ContinuousRectangleBorder()),
child: image,
);
}
@@ -119,10 +130,7 @@ class DaveMascot extends StatelessWidget {
);
if (filter != null) {
svg = ColorFiltered(
colorFilter: filter,
child: svg,
);
svg = ColorFiltered(colorFilter: filter, child: svg);
}
return svg;

View File

@@ -0,0 +1,69 @@
import 'dart:io';
import 'package:firka/core/feedback_report.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('redactSecrets', () {
test('removes tokens, codes and e-mail addresses', () {
const text =
'Authorization: Bearer abc.def-123_456\n'
'jwt eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.sig\n'
'GET /cb?code=SECRET123&state=ok\n'
'user diak@example.com wrote';
final out = redactSecrets(text);
expect(out, isNot(contains('abc.def-123_456')));
expect(out, isNot(contains('eyJhbGciOiJIUzI1NiJ9')));
expect(out, isNot(contains('SECRET123')));
expect(out, isNot(contains('diak@example.com')));
expect(out, contains('state=ok'));
});
test('leaves ordinary log lines alone', () {
const line = '[2026-11-30 13:00:00.000] [Firka] [INFO] Home loaded';
expect(redactSecrets(line), line);
});
});
group('collectFeedbackLogs', () {
late Directory dir;
setUp(() => dir = Directory.systemTemp.createTempSync('firka_logs_'));
tearDown(() => dir.deleteSync(recursive: true));
test('joins the log files oldest first and skips other files', () async {
File('${dir.path}/2026_11_28.log').writeAsStringSync('old line');
File('${dir.path}/2026_11_30.log').writeAsStringSync('new line');
File('${dir.path}/default.isar').writeAsStringSync('database');
final logs = await collectFeedbackLogs(dir);
expect(logs.indexOf('old line'), lessThan(logs.indexOf('new line')));
expect(logs, contains('--- 2026_11_30.log ---'));
expect(logs, isNot(contains('database')));
});
test('keeps only the newest part of a long log', () async {
final long = List.generate(20000, (i) => 'line $i').join('\n');
File('${dir.path}/2026_11_30.log').writeAsStringSync(long);
final logs = await collectFeedbackLogs(dir);
expect(logs.length, lessThanOrEqualTo(feedbackLogLimit));
expect(logs, contains('line 19999'));
expect(logs, isNot(contains('line 0\n')));
});
test('puts the reported error on top, without secrets', () async {
File('${dir.path}/2026_11_30.log').writeAsStringSync('a line');
final logs = await collectFeedbackLogs(
dir,
error: 'Failed for diak@example.com',
);
expect(logs, startsWith('Hibaüzenet:\nFailed for [redacted]'));
expect(logs, contains('a line'));
});
});
}

View File

@@ -0,0 +1,67 @@
import 'package:firka/services/shake_detector.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
final start = DateTime(2026, 11, 30, 13);
DateTime at(int ms) => start.add(Duration(milliseconds: ms));
late int shakes;
late ShakeDetector detector;
setUp(() {
shakes = 0;
detector = ShakeDetector(() => shakes++);
});
/// a hard jolt: the pull is far from gravity
void jolt(int ms) => detector.handle(30, 20, 20, at(ms));
test('a phone lying still is not a shake', () {
for (var ms = 0; ms < 3000; ms += 20) {
detector.handle(0, 0, 9.81, at(ms));
}
expect(shakes, 0);
});
test('three hard jolts within a second are a shake', () {
jolt(0);
jolt(300);
jolt(600);
expect(shakes, 1);
});
test('two jolts are not enough', () {
jolt(0);
jolt(300);
expect(shakes, 0);
});
test('slow jolts are not a shake', () {
jolt(0);
jolt(700);
jolt(1400);
expect(shakes, 0);
});
test('samples of one jolt count once', () {
jolt(0);
jolt(20);
jolt(40);
jolt(60);
expect(shakes, 0);
});
test('it does not fire again right after a shake', () {
jolt(0);
jolt(300);
jolt(600);
jolt(900);
jolt(1200);
jolt(1500);
expect(shakes, 1);
jolt(4000);
jolt(4300);
jolt(4600);
expect(shakes, 2);
});
}

View File

@@ -1,48 +1,201 @@
import 'package:firka/ui/phone/screens/themes/builtin_theme_id.dart';
import 'package:firka/ui/phone/screens/themes/user_theme.dart';
import 'package:firka/ui/phone/screens/themes/widgets/theme_qr_card.dart';
import 'package:firka_common/ui/theme/core_theme.dart';
import 'package:firka_common/ui/theme/grade_theme.dart';
import 'package:firka_common/ui/theme/theme_binary_format.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
final _testGradeColors = [
resolveGrade(defaultGradeThemeId).light.grade1,
resolveGrade(defaultGradeThemeId).light.grade2,
resolveGrade(defaultGradeThemeId).light.grade3,
resolveGrade(defaultGradeThemeId).light.grade4,
resolveGrade(defaultGradeThemeId).light.grade5,
];
void main() {
group('Theme sharing binary format in firka', () {
test('encode and decode URL-safe base64 string for firkaCore', () {
final bytes = ThemeBinaryFormat.encodeCoreTheme(firkaCore);
group('theme sharing binary format in firka', () {
test('encode and decode url-safe base64 string for firkacore', () {
final bytes = ThemeBinaryFormat.encodeCoreTheme(
firkaCore,
gradeColors: _testGradeColors,
);
final b64 = ThemeBinaryFormat.toBase64(bytes);
expect(b64.isNotEmpty, isTrue);
final decodedBytes = ThemeBinaryFormat.fromBase64(b64);
final decoded = ThemeBinaryFormat.decode(decodedBytes);
final slots = decoded.toThemeSlots();
expect(slots.light[ThemeColorSlot.background], firkaCore.light.background);
expect(
slots.light[ThemeColorSlot.background],
firkaCore.light.background,
);
expect(slots.dark[ThemeColorSlot.background], firkaCore.dark.background);
expect(slots.light[ThemeColorSlot.accent], firkaCore.light.accent);
expect(slots.dark[ThemeColorSlot.accent], firkaCore.dark.accent);
});
test('builtin theme produces a share code', () {
final builtin = UserTheme.builtin(
'firka',
coreId: defaultCoreThemeId,
gradeId: defaultGradeThemeId,
);
expect(builtin.canShare, isTrue);
final code = builtin.shareCode;
expect(code.isNotEmpty, isTrue);
// the code round-trips back to valid binary data
final decoded = ThemeBinaryFormat.decodeFromBase64(code);
expect(decoded.gradeColors.length, 5);
final slots = decoded.toThemeSlots();
expect(slots.light[ThemeColorSlot.accent], firkaCore.light.accent);
});
test('custom theme without code cannot share', () {
final custom = UserTheme(
id: 'custom_1',
name: 'empty',
origin: ThemeOrigin.own,
swatch: const [Colors.red, Colors.white, Colors.black],
);
expect(custom.canShare, isFalse);
});
test('custom theme with code can share', () {
final bytes = ThemeBinaryFormat.encodeCoreTheme(
firkaCore,
gradeColors: _testGradeColors,
);
final code = ThemeBinaryFormat.toBase64(bytes);
final custom = UserTheme(
id: 'custom_2',
name: 'with code',
origin: ThemeOrigin.own,
swatch: const [Colors.red, Colors.white, Colors.black],
code: code,
);
expect(custom.canShare, isTrue);
expect(custom.shareCode, code);
});
test('share url includes name and code', () {
final bytes = ThemeBinaryFormat.encodeCoreTheme(
firkaCore,
gradeColors: _testGradeColors,
);
final code = ThemeBinaryFormat.toBase64(bytes);
final theme = UserTheme(
id: 'url_test',
name: 'Teszt Téma',
origin: ThemeOrigin.own,
swatch: const [Colors.red, Colors.white, Colors.black],
code: code,
);
final url = theme.shareUrl;
expect(url, contains('firka.app'));
expect(url, contains('d=$code'));
expect(url, contains('n='));
});
test('parse theme share payload from url', () {
final code = 'abc123';
final url = 'https://firka.app/?d=$code&n=My%20Theme';
final payload = url.parseThemeSharePayload();
expect(payload.code, code);
expect(payload.name, 'My Theme');
expect(payload.shareId, isEmpty);
});
test('an unpublished theme shares without a share id', () {
final theme = UserTheme(
id: 'unpublished',
name: 'Teszt',
origin: ThemeOrigin.own,
swatch: const [Colors.red, Colors.white, Colors.black],
code: 'abc123',
);
expect(theme.shareUrl, isNot(contains('&s=')));
});
test('a published theme carries both the code and the share id', () {
final theme = UserTheme(
id: 'published',
name: 'Teszt',
origin: ThemeOrigin.own,
swatch: const [Colors.red, Colors.white, Colors.black],
code: 'abc123',
shareId: 'f' * 32,
);
// the code imports with no network, the share id keeps it up to date
final payload = theme.shareUrl.parseThemeSharePayload();
expect(payload.code, 'abc123');
expect(payload.shareId, 'f' * 32);
expect(payload.name, 'Teszt');
});
test('an imported theme follows the share it came from', () {
final followed = UserTheme(
id: 'imported',
name: 'Teszt',
origin: ThemeOrigin.downloaded,
swatch: const [Colors.red, Colors.white, Colors.black],
code: 'abc123',
shareId: 'f' * 32,
);
expect(followed.followsShare, isTrue);
final pasted = UserTheme(
id: 'pasted',
name: 'Teszt',
origin: ThemeOrigin.downloaded,
swatch: const [Colors.red, Colors.white, Colors.black],
code: 'abc123',
);
expect(pasted.followsShare, isFalse);
});
test('sharing no longer freezes a theme', () {
final shared = UserTheme(
id: 'still_editable',
name: 'Teszt',
origin: ThemeOrigin.own,
swatch: const [Colors.red, Colors.white, Colors.black],
code: 'abc123',
shareId: 'f' * 32,
);
expect(shared.canEdit, isTrue);
expect(shared.canRename, isTrue);
});
test('parse theme share payload from plain code', () {
final code = 'abc123';
final payload = code.parseThemeSharePayload();
expect(payload.code, code);
expect(payload.name, isNull);
});
testWidgets('ThemeQrCard renders theme name and QR code', (tester) async {
final bytes = ThemeBinaryFormat.encodeCoreTheme(firkaCore);
final bytes = ThemeBinaryFormat.encodeCoreTheme(
firkaCore,
gradeColors: _testGradeColors,
);
final b64 = ThemeBinaryFormat.toBase64(bytes);
final userTheme = UserTheme(
id: 'test_theme',
name: 'Firka Green',
origin: ThemeOrigin.own,
swatch: const [
Color(0xFFA7DC22),
Colors.white,
Color(0xFF1E1E1E),
],
swatch: const [Color(0xFFA7DC22), Colors.white, Color(0xFF1E1E1E)],
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: ThemeQrCard(
theme: userTheme,
shareData: b64,
),
child: ThemeQrCard(theme: userTheme, shareData: b64),
),
),
),

View File

@@ -36,18 +36,20 @@ Color getGradeColor(
double t2 = 0.5,
double t3 = 0.5,
double t4 = 0.5,
FirkaStyle? style,
}) {
final colors = (style ?? appStyle).colors;
switch (roundGrade(grade, t1: t1, t2: t2, t3: t3, t4: t4)) {
case 2:
return appStyle.colors.grade2;
return colors.grade2;
case 3:
return appStyle.colors.grade3;
return colors.grade3;
case 4:
return appStyle.colors.grade4;
return colors.grade4;
case 5:
return appStyle.colors.grade5;
return colors.grade5;
default:
return appStyle.colors.grade1;
return colors.grade1;
}
}

View File

@@ -1,3 +1,4 @@
import 'isar_writes.dart';
import 'dart:collection';
import 'package:firka_common/data/database.dart';
@@ -108,23 +109,25 @@ 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();
});
await isarWrite(
() => 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() {

View File

@@ -0,0 +1,26 @@
import 'dart:async';
/// Serializes every Isar write in the app.
///
/// Isar throws if a sync write transaction is opened while an async one is
/// still in flight. The cache paths cannot simply become async to resolve
/// that: only the `*Sync` puts take `saveLinks`, so an async `putAll` stores
/// rows with empty IsarLinks and the cache reads back empty. The async
/// writers queue behind the sync ones here instead.
///
/// Sync writes that run inside a synchronous stretch of code (the DTO to
/// cache-model conversion, which creates missing subject rows) are covered by
/// wrapping that whole stretch, since it has no await points of its own.
Future<T> isarWrite<T>(FutureOr<T> Function() action) {
final completer = Completer<T>();
_tail = _tail.then((_) async {
try {
completer.complete(await action());
} catch (ex, st) {
completer.completeError(ex, st);
}
});
return completer.future;
}
Future<void> _tail = Future.value();

View File

@@ -16,5 +16,14 @@ class UserThemeModel {
late List<int> swatchArgb;
/// the whole theme as a share code: the slots, the grade colors and the
/// gradients. empty for themes made before codes were stored.
String code = "";
/// the server handle this theme is tied to, empty until it is shared or
/// imported. the owner keeps editing a shared theme and everyone holding
/// the link follows along, so this is also what a copy refetches by.
String shareId = "";
UserThemeModel();
}

View File

@@ -15,6 +15,10 @@ class FirkaCard extends StatelessWidget {
final Color? color;
final bool? isLightMode;
final double? rounding;
/// Renders from this style instead of the global one, so a preview can show
/// a theme the user has not applied.
final FirkaStyle? style;
final Widget child;
factory FirkaCard({
@@ -31,6 +35,7 @@ class FirkaCard extends StatelessWidget {
double? width,
bool? isLightMode,
double? rounding,
FirkaStyle? style,
}) {
final leftRow = Row(children: left);
@@ -53,6 +58,7 @@ class FirkaCard extends StatelessWidget {
shadow: shadow,
isLightMode: isLightMode,
rounding: rounding,
style: style,
child: extra == null ? alignedRow : Column(children: [alignedRow, extra]),
);
}
@@ -68,12 +74,14 @@ class FirkaCard extends StatelessWidget {
this.width,
this.isLightMode,
this.rounding,
this.style,
required this.child,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
final defaultRounding = rounding ?? 16.0;
final attachedRounding = 8.0;
final isLight =
@@ -88,7 +96,7 @@ class FirkaCard extends StatelessWidget {
shadows: shadow
? [
BoxShadow(
color: appStyle.colors.shadowColor,
color: style.colors.shadowColor,
offset: const Offset(0, 1),
blurRadius: isLight ? 2.0 : 0,
),
@@ -107,7 +115,7 @@ class FirkaCard extends StatelessWidget {
),
),
),
color: color ?? appStyle.colors.card,
color: color ?? style.colors.card,
),
child: child,
);

View File

@@ -7,7 +7,7 @@ import 'package:firka_common/ui/theme/style.dart';
import 'filled_circle.dart';
class GradeWidget extends StatelessWidget {
const GradeWidget(this.grade, {this.size = 36, super.key})
const GradeWidget(this.grade, {this.size = 36, this.style, super.key})
: gradeValue = null,
gradeWeight = null;
@@ -15,6 +15,7 @@ class GradeWidget extends StatelessWidget {
this.gradeValue, {
this.gradeWeight = 100,
this.size = 36,
this.style,
super.key,
}) : grade = null;
@@ -23,8 +24,13 @@ class GradeWidget extends StatelessWidget {
final int? gradeValue;
final int? gradeWeight;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
if (gradeValue != null && gradeValue != null) {
return _buildNumericCircle(gradeValue!, gradeWeight!);
}
@@ -32,19 +38,19 @@ class GradeWidget extends StatelessWidget {
final g = grade!;
if (g.numericValue == null) {
final gradeColor = appStyle.colors.accent;
final gradeColor = style.colors.accent;
return FilledCircle(
diameter: size,
color: gradeColor.withAlpha(38),
child: Text(
'❝❠',
style: appStyle.fonts.B_16SB.copyWith(color: gradeColor),
style: style.fonts.B_16SB.copyWith(color: gradeColor),
),
);
}
if (g.isInPercentage()) {
final gradeColor = appStyle.colors.accent;
final gradeColor = style.colors.accent;
return FilledCircle(
diameter: size,
color: gradeColor.withAlpha(38),
@@ -53,9 +59,9 @@ class GradeWidget extends StatelessWidget {
children: [
Text(
g.numericValue!.toString(),
style: appStyle.fonts.P_14.copyWith(color: gradeColor),
style: style.fonts.P_14.copyWith(color: gradeColor),
),
Text('%', style: appStyle.fonts.P_12.copyWith(color: gradeColor)),
Text('%', style: style.fonts.P_12.copyWith(color: gradeColor)),
],
),
);
@@ -65,8 +71,9 @@ class GradeWidget extends StatelessWidget {
}
Widget _buildNumericCircle(int value, int weight) {
final gradeColor = getGradeColor(value);
final textStyle = appStyle.fonts.H_H1.copyWith(
final style = this.style ?? appStyle;
final gradeColor = getGradeColor(value, style: style);
final textStyle = style.fonts.H_H1.copyWith(
color: gradeColor,
fontSize: size * 0.75,
);

View File

@@ -5,21 +5,26 @@ import 'package:firka_common/ui/theme/style.dart';
class CounterDigitWidget extends StatelessWidget {
final String c;
const CounterDigitWidget(this.c, {super.key});
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
const CounterDigitWidget(this.c, {this.style, super.key});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
return Container(
width: 18,
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
color: appStyle.colors.buttonSecondaryFill,
color: style.colors.buttonSecondaryFill,
),
padding: EdgeInsets.symmetric(vertical: 2),
child: Text(
c,
textAlign: TextAlign.center,
style: appStyle.fonts.H_16px.apply(color: appStyle.colors.textPrimary),
style: style.fonts.H_16px.apply(color: style.colors.textPrimary),
),
);
}

View File

@@ -12,16 +12,23 @@ class GradeSmallCard extends StatelessWidget {
final double? classAverage;
final SubjectCacheModel subject;
/// Renders from this style instead of the global one, so a preview can
/// show a theme the user has not applied.
final FirkaStyle? style;
GradeSmallCard(
this.studentAverage,
this.classAverage,
this.subject, {
this.style,
super.key,
});
@override
Widget build(BuildContext context) {
final style = this.style ?? appStyle;
return FirkaCard.single(
style: style,
height: 52,
padding: EdgeInsets.symmetric(horizontal: 16),
margin: EdgeInsets.all(0),
@@ -30,14 +37,14 @@ class GradeSmallCard extends StatelessWidget {
children: [
ClassIconWidget(
subject: subject,
color: appStyle.colors.accent,
color: style.colors.accent,
size: 20,
),
Expanded(
child: Text(
subject.name.firstUpper(),
style: appStyle.fonts.B_16SB.apply(
color: appStyle.colors.textPrimary,
style: style.fonts.B_16SB.apply(
color: style.colors.textPrimary,
),
overflow: TextOverflow.ellipsis,
),
@@ -49,15 +56,15 @@ class GradeSmallCard extends StatelessWidget {
decoration: ShapeDecoration(
color: Colors.transparent,
shape: RoundedRectangleBorder(
side: BorderSide(color: getGradeColor(classAverage!)),
side: BorderSide(color: getGradeColor(classAverage!, style: style)),
borderRadius: BorderRadius.circular(12),
),
),
child: Center(
child: Text(
classAverage!.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(classAverage!),
style: style.fonts.B_16R.apply(
color: getGradeColor(classAverage!, style: style),
),
),
),
@@ -67,7 +74,7 @@ class GradeSmallCard extends StatelessWidget {
width: 48,
height: 26,
decoration: ShapeDecoration(
color: getGradeColor(studentAverage!).withAlpha(38),
color: getGradeColor(studentAverage!, style: style).withAlpha(38),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
@@ -75,8 +82,8 @@ class GradeSmallCard extends StatelessWidget {
child: Center(
child: Text(
studentAverage!.toStringAsFixed(2),
style: appStyle.fonts.B_16R.apply(
color: getGradeColor(studentAverage!),
style: style.fonts.B_16R.apply(
color: getGradeColor(studentAverage!, style: style),
),
),
),

View File

@@ -25,46 +25,41 @@ enum ThemeColorSlot {
/// Decoded theme binary data.
class ThemeBinaryData {
/// Format version (e.g. 0).
/// format version, always [ThemeBinaryFormat.currentVersion].
final int version;
/// Ordered list of colors stored as raw bytes.
/// the 32 slot colors: the 16 light slots, then the 16 dark slots.
final List<Color> colors;
/// the five grade colors, grade 1 first.
final List<Color> gradeColors;
/// background gradient stops, empty when the theme has none.
final List<Color> gradientLight;
final List<Color> gradientDark;
const ThemeBinaryData({
required this.version,
required this.colors,
required this.gradeColors,
required this.gradientLight,
required this.gradientDark,
});
/// True if the payload contains both light (0..15) and dark (16..31) slots.
bool get isFullTheme => colors.length >= 32;
/// retrieves the color for [slot] in light mode.
Color lightSlot(ThemeColorSlot slot) => colors[slot.index];
/// Retrieves the color for [slot] in light mode, or null if out of range.
Color? lightSlot(ThemeColorSlot slot) {
final idx = slot.index;
return idx < colors.length ? colors[idx] : null;
}
/// Retrieves the color for [slot] in dark mode, or null if out of range.
Color? darkSlot(ThemeColorSlot slot) {
final idx = 16 + slot.index;
return idx < colors.length ? colors[idx] : null;
}
/// retrieves the color for [slot] in dark mode.
Color darkSlot(ThemeColorSlot slot) =>
colors[ThemeColorSlot.values.length + slot.index];
/// Extracts the full theme mapping for light and dark modes.
({Map<ThemeColorSlot, Color> light, Map<ThemeColorSlot, Color> dark}) toThemeSlots() {
final lightMap = <ThemeColorSlot, Color>{};
final darkMap = <ThemeColorSlot, Color>{};
for (final slot in ThemeColorSlot.values) {
final lColor = lightSlot(slot);
if (lColor != null) lightMap[slot] = lColor;
final dColor = darkSlot(slot) ?? lColor;
if (dColor != null) darkMap[slot] = dColor;
}
return (light: lightMap, dark: darkMap);
({Map<ThemeColorSlot, Color> light, Map<ThemeColorSlot, Color> dark})
toThemeSlots() {
return (
light: {for (final slot in ThemeColorSlot.values) slot: lightSlot(slot)},
dark: {for (final slot in ThemeColorSlot.values) slot: darkSlot(slot)},
);
}
@override
@@ -74,12 +69,22 @@ class ThemeBinaryData {
/// Binary encoder and decoder for Firka themes.
///
/// Format specification:
/// 1. Header: Varint storing the format version (e.g. `0x00` for version 0).
/// 2. Colors: Raw 32-bit ARGB bytes (4 bytes per color: Alpha, Red, Green, Blue).
/// format specification, one version only:
/// 1. header: varint storing the format version, [currentVersion].
/// 2. the 32 slot colors: 16 light, then 16 dark.
/// 3. the 5 grade colors, grade 1 first.
/// 4. the light background gradient: a varint stop count, then the stops.
/// 5. the dark background gradient, the same way.
///
/// a color is 32-bit argb, 4 bytes: alpha, red, green, blue.
class ThemeBinaryFormat {
/// Current binary format version.
static const int currentVersion = 0;
/// the only binary format version, anything else is refused.
static const int currentVersion = 1;
static const int gradeColorCount = 5;
/// more stops than the editor allows is not a theme.
static const int maxGradientStops = 16;
/// Encodes [value] into a standard unsigned LEB128 varint.
static void writeVarint(BytesBuilder builder, int value) {
@@ -96,7 +101,10 @@ class ThemeBinaryFormat {
/// Reads a standard unsigned LEB128 varint from [bytes] starting at [offset].
/// Returns a record of `(value, bytesRead)`.
static (int value, int bytesRead) readVarint(Uint8List bytes, [int offset = 0]) {
static (int value, int bytesRead) readVarint(
Uint8List bytes, [
int offset = 0,
]) {
var result = 0;
var shift = 0;
var index = offset;
@@ -112,94 +120,125 @@ class ThemeBinaryFormat {
throw const FormatException('Varint overflow');
}
}
throw const FormatException('Unexpected end of buffer while reading varint');
throw const FormatException(
'Unexpected end of buffer while reading varint',
);
}
/// Encodes a list of [colors] into the binary theme format.
///
/// Prepends [version] as a varint (default 0), followed by 4 raw bytes per
/// color in 32-bit ARGB order (Alpha, Red, Green, Blue).
static Uint8List encode({
required List<Color> colors,
int version = currentVersion,
}) {
final builder = BytesBuilder(copy: false);
// 1. Version as varint
writeVarint(builder, version);
// 2. Colors as raw bytes (4 bytes each: A, R, G, B)
for (final color in colors) {
final argb = color.toARGB32();
builder.addByte((argb >> 24) & 0xFF);
builder.addByte((argb >> 16) & 0xFF);
builder.addByte((argb >> 8) & 0xFF);
builder.addByte(argb & 0xFF);
}
return builder.takeBytes();
static void _writeColor(BytesBuilder builder, Color color) {
final argb = color.toARGB32();
builder.addByte((argb >> 24) & 0xFF);
builder.addByte((argb >> 16) & 0xFF);
builder.addByte((argb >> 8) & 0xFF);
builder.addByte(argb & 0xFF);
}
/// Decodes raw binary theme [bytes].
///
/// Reads the leading varint version and parses the subsequent raw bytes as
/// 32-bit ARGB colors (4 bytes per color).
/// decodes raw binary theme [bytes], throws a [FormatException] for anything
/// that is not a complete theme of the current version.
static ThemeBinaryData decode(Uint8List bytes) {
if (bytes.isEmpty) {
throw const FormatException('Cannot decode empty theme bytes');
}
// 1. Read version varint
final (version, headerLength) = readVarint(bytes, 0);
final colorByteLength = bytes.length - headerLength;
if (colorByteLength % 4 != 0) {
throw FormatException(
'Invalid color byte length ($colorByteLength). '
'Color bytes must be a multiple of 4.',
);
if (version != currentVersion) {
throw FormatException('Unsupported theme version $version');
}
final colorCount = colorByteLength ~/ 4;
final colors = <Color>[];
var offset = headerLength;
for (var i = 0; i < colorCount; i++) {
final offset = headerLength + (i * 4);
final a = bytes[offset];
final r = bytes[offset + 1];
final g = bytes[offset + 2];
final b = bytes[offset + 3];
colors.add(Color.fromARGB(a, r, g, b));
List<Color> readColors(int count) {
if (offset + count * 4 > bytes.length) {
throw const FormatException('Theme data ends too early');
}
final colors = <Color>[];
for (var i = 0; i < count; i++) {
colors.add(
Color.fromARGB(
bytes[offset],
bytes[offset + 1],
bytes[offset + 2],
bytes[offset + 3],
),
);
offset += 4;
}
return colors;
}
return ThemeBinaryData(version: version, colors: colors);
List<Color> readGradient() {
final (count, read) = readVarint(bytes, offset);
offset += read;
if (count > maxGradientStops) {
throw FormatException('Too many gradient stops ($count)');
}
return readColors(count);
}
final colors = readColors(ThemeColorSlot.values.length * 2);
final gradeColors = readColors(gradeColorCount);
final gradientLight = readGradient();
final gradientDark = readGradient();
if (offset != bytes.length) {
throw const FormatException('Unexpected data after the theme');
}
return ThemeBinaryData(
version: version,
colors: colors,
gradeColors: gradeColors,
gradientLight: gradientLight,
gradientDark: gradientDark,
);
}
/// Encodes a complete 32-color Firka theme (16 light slots + 16 dark slots).
/// encodes a complete theme: the 16 light and 16 dark slots, the grade
/// colors (grade 1 first) and the two background gradients.
static Uint8List encodeFullTheme({
required Map<ThemeColorSlot, Color> light,
required Map<ThemeColorSlot, Color> dark,
int version = currentVersion,
required List<Color> gradeColors,
List<Color> gradientLight = const [],
List<Color> gradientDark = const [],
}) {
final colors = <Color>[];
// Light slots (0..15)
for (final slot in ThemeColorSlot.values) {
colors.add(light[slot] ?? Colors.transparent);
if (gradeColors.length != gradeColorCount) {
throw ArgumentError.value(
gradeColors.length,
'gradeColors',
'A theme has $gradeColorCount grade colors',
);
}
if (gradientLight.length > maxGradientStops ||
gradientDark.length > maxGradientStops) {
throw ArgumentError('A gradient has at most $maxGradientStops stops');
}
// Dark slots (16..31)
final builder = BytesBuilder(copy: false);
writeVarint(builder, currentVersion);
for (final slot in ThemeColorSlot.values) {
colors.add(dark[slot] ?? light[slot] ?? Colors.transparent);
_writeColor(builder, light[slot] ?? Colors.transparent);
}
return encode(colors: colors, version: version);
for (final slot in ThemeColorSlot.values) {
_writeColor(builder, dark[slot] ?? light[slot] ?? Colors.transparent);
}
for (final color in gradeColors) {
_writeColor(builder, color);
}
for (final stops in [gradientLight, gradientDark]) {
writeVarint(builder, stops.length);
for (final color in stops) {
_writeColor(builder, color);
}
}
return builder.takeBytes();
}
/// Encodes a [CoreTheme] (both light and dark colors) into binary.
static Uint8List encodeCoreTheme(
CoreTheme theme, {
int version = currentVersion,
required List<Color> gradeColors,
List<Color> gradientLight = const [],
List<Color> gradientDark = const [],
}) {
Color getSlot(CoreThemeColors c, ThemeColorSlot slot) => switch (slot) {
ThemeColorSlot.accent => c.accent,
@@ -221,13 +260,20 @@ class ThemeBinaryFormat {
};
final lightMap = {
for (final slot in ThemeColorSlot.values) slot: getSlot(theme.light, slot),
for (final slot in ThemeColorSlot.values)
slot: getSlot(theme.light, slot),
};
final darkMap = {
for (final slot in ThemeColorSlot.values) slot: getSlot(theme.dark, slot),
};
return encodeFullTheme(light: lightMap, dark: darkMap, version: version);
return encodeFullTheme(
light: lightMap,
dark: darkMap,
gradeColors: gradeColors,
gradientLight: gradientLight,
gradientDark: gradientDark,
);
}
/// Encodes [bytes] to Base64 (URL-safe without padding by default).
@@ -246,16 +292,6 @@ class ThemeBinaryFormat {
return base64Url.decode(normalized);
}
/// Convenience method: Encodes [colors] directly into a URL-safe Base64 string.
static String encodeToBase64(
List<Color> colors, {
int version = currentVersion,
bool urlSafe = true,
}) {
final bytes = encode(colors: colors, version: version);
return toBase64(bytes, urlSafe: urlSafe);
}
/// Convenience method: Decodes a URL-safe Base64 string into [ThemeBinaryData].
static ThemeBinaryData decodeFromBase64(String encoded) {
final bytes = fromBase64(encoded);

Some files were not shown because too many files have changed in this diff Show More