11 Commits

Author SHA1 Message Date
zypherift
f953dbd49f fix: null-safe percentage detection 2026-03-05 09:22:28 +01:00
zypherift
01e7e559ba fix: maybe fixed percentages being calculated into the grade? pls review 2026-03-05 09:22:28 +01:00
b6bfef7715 update docs 2026-03-05 09:06:26 +01:00
bf75f72bcd update codegen lock 2026-03-05 09:01:11 +01:00
zypherift
b0cb020d76 feat: smoother graph using 3 weighted avarages :O 2026-03-05 08:40:50 +01:00
zypherift
4239ffa00c chore: stream home data cache-first then refresh 2026-03-05 08:40:50 +01:00
zypherift
427b6f8086 fix: snap grade calculator weights to common percentages 2026-03-05 08:40:50 +01:00
zypherift
fbd2351073 fix: flashbang on new screen pushes 2026-03-05 08:40:50 +01:00
zypherift
150e90d19b edit: replace spinner with dave 2026-03-05 08:40:50 +01:00
zypherift
a6cf8b13c6 edit: fine tune wall collision vibration 2026-03-05 08:40:50 +01:00
zypherift
d8ae8471ab edit: l10n 2026-03-05 08:40:45 +01:00
15 changed files with 167 additions and 143 deletions

View File

@@ -1,35 +1,19 @@
# Flutter telepítése
A firka androidra való lebuildeléséhez kötelező a saját Flutter fork használata, illetve minden más fajta --release buildhez is.
A Flutter telepítéséhez a dokumentáció [itt](https://docs.flutter.dev/get-started/install) található.
A Flutter zip letöltése helyett a custom engine-t cloneold le ([https://git.firka.app/firka/flutter/](https://git.firka.app/firka/flutter/))
# Brotli
A firka brotlival compresseli a libflutter-t buildelés közben ezért szükséges a projekt
buildeléséhez hogy a brotli a PATH-ben legyen
## Windows
- Töltsd le a `brotli-x64-windows-static.zip`-et a [google/brotli github repoból](https://github.com/google/brotli/releases/latest)
- Csomagold ki valahol (pl. C:\Users\\<username>\dev\brotli)
- Add hozzá a mappát ahova kicsomagoltad (C:\Users\\<username>\dev\brotli) a PATH-hez
- Ne felejtsd el újraindítani az IDE-det illetve parancssorodat utánna hogy frissüljön a PATH
## Linux/MacOS
Telepítsd fel a brotli packaget a distro-d package managerével
A projekt jelenleg a 3.41.2-es Flutter SDK-t használja.
# Keystore
[Secrets dokumentáció](secrets/README.md)
# Flutter l10n
# Fileok generálása
Flutter l10n fileok generálása
Flutter l10n és egyéb fileok generálása
```shell
Flutter gen-l10n --template-arb-file app_hu.arb
$ cd firka # vagy firka_wear
$ dart run scripts/codegen.dart
```
# Android debug build
@@ -42,20 +26,10 @@ $ Flutter build apk --debug --target-platform android-arm,android-arm64,android-
# Android release build
A release buildhez közelező egy keystore használata, illetve a saját Flutter engineünk használata.
A release buildhez közelező egy keystore használata.
## Custom Flutter engine setupolása
## Release appbundle buildelése (firka és firka_wear)
```shell
$ git clone https://git.firka.app/firka/flutter
$ cd flutter
$ . dev/tools/envsetup.sh
$ gclient sync -D
$ ./dev/tools/build_release.sh
```
## Release apk buildelése
```shell
$ ./tools/linux/build_apk.sh main
$ ./build.sh
```

View File

@@ -1,41 +1,24 @@
# Installing flutter
# Installing Flutter
To build firka you will have to use our custom Flutter fork,
and to make a release build you will have to use our custom
flutter engine.
The documentation for installing flutter can be found [here](https://docs.flutter.dev/get-started/install).
Instead of downloading the regular flutter zip, clone it from ([https://git.firka.app/firka/flutter/](https://git.firka.app/firka/flutter/)).
# Brotli
Firka uses brotli to compress libflutter during the build process to make the app smaller,
so building Firka requires you to have brotli in your path
## Windows
- Download `brotli-x64-windows-static.zip` from [google/brotli](https://github.com/google/brotli/releases/latest)
- Extract it to somewhere like C:\Users\\<username>\dev\brotli
- Add the directory (ex. C:\Users\\<username>\dev\brotli) to your PATH
- Don't forget to restart your IDE or terminal sessions for the PATH variable to update
## Linux/MacOS
Install it using your distro's package manager
Flutter installation documentation can be found [here](https://docs.flutter.dev/get-started/install).
The project currently uses Flutter SDK 3.41.2.
# Keystore
[Secrets docs](secrets/README_en.md)
[Secrets documentation](secrets/README.md)
# Flutter l10n
# Generating files
Generating flutter l10n files
Generating Flutter l10n and other files
```shell
flutter gen-l10n --template-arb-file app_hu.arb
$ cd firka # or firka_wear
$ dart run scripts/codegen.dart
```
# Android debug build
The dev build doesn't require using a custom keystore
The dev build does not require using a keystore
```shell
$ cd firka
$ flutter build apk --debug --target-platform android-arm,android-arm64,android-x64
@@ -43,20 +26,10 @@ $ flutter build apk --debug --target-platform android-arm,android-arm64,android-
# Android release build
The release build requires using a custom keystore and our custom flutter fork
The release build requires using a keystore.
## Setting up our flutter engine fork
## Building the release appbundle (firka and firka_wear)
```shell
$ git clone https://git.firka.app/firka/flutter
$ cd flutter
$ . dev/tools/envsetup.sh
$ gclient sync -D
$ ./dev/tools/build_release.sh
$ ./build.sh
```
## Building the release apk
```shell
$ ./tools/linux/build_apk.sh main
```

View File

@@ -1,15 +1,15 @@
icons:
"flutter_launcher_icons.yaml": "c600507ca0df7cebd0f708124842512a14ed3d597b779176200d6ba25b1335b1"
"pubspec.yaml": "cc5c8123f956bca34e25cec666ccc13fe5b7bdec06e217a58e1fa0ee58dedc20"
"pubspec.yaml": "a6ae0bd67a2b6226bec2dfd55437b3db2b7ca4a03f315c1a0a8c2f4b505c7c87"
"assets/images/logos/colored_logo.webp": "4b4fa99d144fe6694aa4487ba1b26aeecafae41e3c877836cd7da28d61a77983"
"assets/images/logos/monochrome_logo.png": "188d2b0a64c70323b09bcee721663d6698fb557066f20ddaec97bba6869c1c6c"
"assets/images/logos/colored_logo_without_mustache.png": "d11cff9f38985885873bfdd2d84e61f8fab03803eada94d4caac1545ef3685f3"
"assets/images/logos/colored_logo_only_mustache.png": "bad6220c11bdfb1dfe04e5173bd2ebedd3999689d4b3a68fc63dc520c96dd33b"
l10n:
"l10n.yml": "a57bc304cac4a2b0235593586f17f400a5165d67fc9aadeaa11893cfa36ee082"
"lib/l10n/app_de.arb": "9cd5913be1e3bc3ed6c088ef448d5ce2924a6290b7dd6006d1af624c5e9a2503"
"lib/l10n/app_hu.arb": "17077ec76b68ed03796a264b99e4dba9e6ddd532e27a92d8fb237ea6f211f757"
"lib/l10n/app_en.arb": "cbad6dd2485a983e399cce97371c19089b9110d30536488c14a7ea709c7b6ead"
"lib/l10n/app_de.arb": "ecfbf13bd33be9d27a2b54bfd8fb61e46c1a1dce905869d3f30cd05b4aecf258"
"lib/l10n/app_en.arb": "8bb0064984deb02eefaec24c13ee019eb38758e115b678ce85335fd4d1b6b6d9"
"lib/l10n/app_hu.arb": "2d2c568a3767a5b0bcfde7d27f221fd74b653256bbe41789756c78422a159e4d"
isar:
"lib/data/models/app_settings_model.dart": "5eb5af345f1347f104257f0999763650fe2673f9da1754bd12d3f756fe5c9723"
"lib/data/models/generic_cache_model.dart": "79151d0467fb5d40c532eaaa08ad7c7e24a34304199280fbf49cf6e5adcce6bc"

View File

@@ -16,6 +16,7 @@ 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/watch_sync_helper.dart';
import 'package:firka/ui/theme/style.dart';
import 'package:firka/ui/phone/pages/extras/main_wear_pair.dart';
import 'package:firka/l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@@ -34,6 +35,23 @@ class _InitializationScreenState extends State<InitializationScreen> {
const Duration(seconds: 20),
);
ThemeData _buildTheme(FirkaStyle style) {
return ThemeData(
scaffoldBackgroundColor: style.colors.background,
canvasColor: style.colors.background,
bottomSheetTheme: const BottomSheetThemeData(
backgroundColor: Colors.transparent,
),
colorScheme: ColorScheme.fromSeed(
seedColor: style.colors.accent,
brightness: style.isLight ? Brightness.light : Brightness.dark,
background: style.colors.background,
surface: style.colors.card,
),
useMaterial3: false,
);
}
@override
Widget build(BuildContext context) {
return FutureBuilder<AppInitialization>(
@@ -180,40 +198,47 @@ class _InitializationScreenState extends State<InitializationScreen> {
BlocProvider<ReauthCubit>.value(value: reauthCubit),
BlocProvider<HomeRefreshCubit>.value(value: homeRefreshCubit),
],
child: MaterialApp.router(
title: 'Firka',
key: const ValueKey('firkaApp'),
routerConfig: _router!,
theme: ThemeData(
primarySwatch: Colors.lightGreen,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
builder: (context, child) {
return BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, themeState) {
final isLight = themeState.isLightMode;
final overlay = SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: isLight
? Brightness.dark
: Brightness.light,
statusBarBrightness: isLight
? Brightness.light
: Brightness.dark,
systemStatusBarContrastEnforced: false,
);
child: BlocBuilder<ThemeCubit, ThemeState>(
builder: (context, themeState) {
final isLight = themeState.isLightMode;
final overlay = SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness:
isLight ? Brightness.dark : Brightness.light,
statusBarBrightness:
isLight ? Brightness.light : Brightness.dark,
systemStatusBarContrastEnforced: false,
);
SystemChrome.setSystemUIOverlayStyle(overlay);
final themeMode =
isLight ? ThemeMode.light : ThemeMode.dark;
final fallbackBg = isLight
? lightStyle.colors.background
: darkStyle.colors.background;
SystemChrome.setSystemUIOverlayStyle(overlay);
return MaterialApp.router(
title: 'Firka',
key: const ValueKey('firkaApp'),
routerConfig: _router!,
theme: _buildTheme(lightStyle),
darkTheme: _buildTheme(darkStyle),
themeMode: themeMode,
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
builder: (context, child) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: overlay,
child: child ?? const SizedBox.shrink(),
child: ColoredBox(
color: fallbackBg,
child: child ?? const SizedBox.shrink(),
),
);
},
);

View File

@@ -1,10 +1,17 @@
import 'package:kreta_api/kreta_api.dart';
bool _isPercentageGrade(Grade grade) {
final name = grade.valueType.name?.toLowerCase() ?? '';
return name.contains('szazalek') || name.contains('percent');
}
double calculateAverage(List<Grade> sortedGrades) {
double totalWeight = 0.0;
double weightedSum = 0.0;
for (final grade in sortedGrades) {
if (_isPercentageGrade(grade)) continue;
final value = grade.numericValue;
final weight = grade.weightPercentage;

View File

@@ -322,6 +322,11 @@ class WidgetCacheHelper {
var sum = 0.0;
for (var grade in grades) {
final name = grade.valueType.name?.toLowerCase() ?? '';
final isPercentage =
name.contains('szazalek') || name.contains('percent');
if (isPercentage) continue;
if (grade.numericValue != null) {
var weight = (grade.weightPercentage ?? 100) / 100.0;
weightTotal += weight;

View File

@@ -1048,9 +1048,13 @@ class _GradeCalculatorSheetContent extends StatefulWidget {
class _GradeCalculatorSheetContentState
extends State<_GradeCalculatorSheetContent> {
int selectedGrade = 3;
int weightPercent = 100;
int weightIndex = 1; // 0-based index into _snapPoints
final List<(int grade, int weight)> entries = [];
static const _snapPoints = [50, 100, 200, 300, 500];
int get weightPercent => _snapPoints[weightIndex];
@override
Widget build(BuildContext context) {
return Column(
@@ -1184,11 +1188,12 @@ class _GradeCalculatorSheetContentState
trackHeight: 8,
),
child: Slider(
value: weightPercent.toDouble(),
min: 1,
max: 500,
divisions: 499,
onChanged: (v) => setState(() => weightPercent = v.round()),
value: weightIndex.toDouble(),
min: 0,
max: (_snapPoints.length - 1).toDouble(),
divisions: _snapPoints.length - 1,
label: '${weightPercent}%',
onChanged: (v) => setState(() => weightIndex = v.round()),
),
),
),

View File

@@ -146,18 +146,6 @@ class _HomeGradesScreen extends FirkaState<HomeGradesScreen> {
double avg = double.nan;
if (subjectGrades.isNotEmpty) {
for (var grade in subjectGrades) {
if (grade.valueType.name == "Szazalekos") {
grade.valueType = NameUidDesc(
uid: "1,Osztalyzat",
name: "Osztalyzat",
description: "",
);
if (grade.numericValue != null) {
grade.numericValue = percentageToGrade(grade.numericValue!);
}
}
}
avg = grades!.response!.getAverageBySubject(subject);
}

View File

@@ -55,7 +55,7 @@ class _HomeMainScreen extends FirkaState<HomeMainScreen> {
}
}
Future<void> fetchData({bool cacheOnly = true}) async {
Future<void> fetchData({bool cacheOnly = false}) async {
final midnight = now.getMidnight();
var lessonsFetched = 0;

View File

@@ -69,6 +69,7 @@ class _LoginScreenState extends FirkaState<LoginScreen> {
"assets/images/carousel_dark/slide3.webp",
"assets/images/carousel_dark/slide4.webp",
"assets/images/logos/colored_logo.webp",
"assets/images/logos/loading.gif",
];
try {
await ImagePreloader.preloadMultipleAssets(FirkaBundle(), imagePaths);
@@ -816,32 +817,42 @@ class _FloatingCardsSlideState extends State<_FloatingCardsSlide>
double vx = _velocities[i].dx;
double vy = _velocities[i].dy;
// capture incoming velocity components before any bounce damping
final double preVx = vx;
final double preVy = vy;
double impactSpeed = 0.0; // normal to the wall
bool hit = false;
if (pos.dx < minX) {
pos = Offset(minX, pos.dy);
vx = vx.abs() * _bounceDamping;
impactSpeed = math.max(impactSpeed, preVx.abs());
hit = true;
} else if (pos.dx > maxX) {
pos = Offset(maxX, pos.dy);
vx = -vx.abs() * _bounceDamping;
impactSpeed = math.max(impactSpeed, preVx.abs());
hit = true;
}
if (pos.dy < minY) {
pos = Offset(pos.dx, minY);
vy = vy.abs() * _bounceDamping;
impactSpeed = math.max(impactSpeed, preVy.abs());
hit = true;
} else if (pos.dy > maxY) {
pos = Offset(pos.dx, maxY);
vy = -vy.abs() * _bounceDamping;
impactSpeed = math.max(impactSpeed, preVy.abs());
hit = true;
}
_velocities[i] = _clampVel(Offset(vx, vy));
_positions[i] = pos;
if (hit && _velocities[i].distance > _vibrateSpeedThreshold) {
// vibrate only when the component toward the wall exceeded threshold
if (hit && impactSpeed > _vibrateSpeedThreshold) {
wallHitThisTick = true;
}
}

View File

@@ -33,6 +33,10 @@ class _GradeChartState extends State<GradeChart> {
double totalWeight = 0;
for (final g in grades) {
if (g.subject.uid != subjectUid) continue;
final name = g.valueType.name?.toLowerCase() ?? '';
final isPercentage =
name.contains('szazalek') || name.contains('percent');
if (isPercentage) continue;
final v = g.numericValue;
final w = g.weightPercentage;
if (v != null && w != null) {
@@ -93,6 +97,27 @@ class _GradeChartState extends State<GradeChart> {
}
}
List<FlSpot> _smoothSpots(List<FlSpot> input) {
if (input.length < 3) return input;
final smoothed = <FlSpot>[];
for (var i = 0; i < input.length; i++) {
if (i == 0 || i == input.length - 1) {
smoothed.add(input[i]);
continue;
}
final prev = input[i - 1].y;
final curr = input[i].y;
final next = input[i + 1].y;
final blended = (0.25 * prev) + (0.5 * curr) + (0.25 * next);
smoothed.add(FlSpot(input[i].x, blended));
}
return smoothed;
}
@override
void didUpdateWidget(covariant GradeChart oldWidget) {
super.didUpdateWidget(oldWidget);
@@ -213,8 +238,10 @@ class _GradeChartState extends State<GradeChart> {
}
LineChartData avgData() {
var firstX = spots.first.x;
var lastX = spots.last.x;
final smoothedSpots = _smoothSpots(spots);
var firstX = smoothedSpots.first.x;
var lastX = smoothedSpots.last.x;
if (firstX == lastX) {
lastX = firstX + 1;
}
@@ -359,12 +386,12 @@ class _GradeChartState extends State<GradeChart> {
lineBarsData: [
LineChartBarData(
spots: spots,
spots: smoothedSpots,
isCurved: true,
curveSmoothness: 0.35,
curveSmoothness: 0.5,
showingIndicators: _touchedIndex != null ? [_touchedIndex!] : [],
gradient: LinearGradient(
colors: [for (final s in spots) colorForY(s.y)],
colors: [for (final s in smoothedSpots) colorForY(s.y)],
),
barWidth: 5,
isStrokeCapRound: true,
@@ -373,7 +400,8 @@ class _GradeChartState extends State<GradeChart> {
show: true,
gradient: LinearGradient(
colors: [
for (final s in spots) colorForY(s.y).withValues(alpha: 0.1),
for (final s in smoothedSpots)
colorForY(s.y).withValues(alpha: 0.1),
],
),
),

View File

@@ -276,15 +276,10 @@ class _LoginWebviewWidgetState extends FirkaState<LoginWebviewWidget>
child: Container(
color: appStyle.colors.background,
child: Center(
child: SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
strokeWidth: 3,
valueColor: AlwaysStoppedAnimation<Color>(
appStyle.colors.accent,
),
),
child: Image.asset(
"assets/images/logos/loading.gif",
width: 50,
height: 50,
),
),
),

View File

@@ -81,6 +81,7 @@ flutter:
- .env
- assets/images/logos/colored_logo.webp
- assets/images/logos/dave.svg
- assets/images/logos/loading.gif
- assets/images/carousel/
- assets/images/carousel_dark/
- assets/images/icons/

View File

@@ -86,6 +86,14 @@ extension GradeListExtension on List<Grade> {
for (var grade in this) {
if (grade.subject.uid == subject.uid) {
final name = grade.valueType.name?.toLowerCase() ?? '';
final isPercentage =
name.contains('szazalek') || name.contains('percent');
if (isPercentage) {
continue;
}
if (grade.numericValue != null) {
var weight = (grade.weightPercentage ?? 100) / 100.0;
weightTotal += weight;
@@ -95,6 +103,10 @@ extension GradeListExtension on List<Grade> {
}
}
if (weightTotal == 0) {
return double.nan;
}
return sum / weightTotal;
}
}