added german translation and store stuff for app

This commit is contained in:
Jan Pleterski
2026-11-13 10:56:11 +01:00
parent d4bc01f202
commit 30708c73b1
47 changed files with 530 additions and 160 deletions
+34 -10
View File
@@ -1,16 +1,40 @@
# shooter_app # SDK Kovinar
A new Flutter project. Flutter app for the SDK Kovinar shooting club: target photo scoring (on-device TFLite detection),
live camera streams / spectator mode, training calendar with reminders, and club contacts.
## Getting Started - Android package: `si.sdkkovinar.app`
- Version: set in `pubspec.yaml` (`version: x.y.z+build`, bump the build number for every Play upload)
This project is a starting point for a Flutter application. ## Development
A few resources to get you started if this is your first Flutter project: ```sh
flutter pub get
flutter run
```
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) ## Club contacts
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the Contacts ship encrypted in `assets/club.enc` and unlock with the club code.
[online documentation](https://docs.flutter.dev/), which offers tutorials, Edit the plain data in `tool/club_data.json` (gitignored, never commit) and re-encrypt:
samples, guidance on mobile development, and a full API reference.
```sh
dart run tool/encrypt_club_data.dart
```
## Release (Google Play)
1. Create `android/key.properties` (gitignored) pointing at the upload keystore:
```properties
storePassword=...
keyPassword=...
keyAlias=upload
storeFile=/absolute/path/to/upload-keystore.jks
```
Release builds fail on purpose if this file is missing, so a debug-signed build can't be uploaded.
2. Bump `version` in `pubspec.yaml`.
3. `flutter build appbundle --release` → upload `build/app/outputs/bundle/release/app-release.aab`.
Keep a backup of the upload keystore and its passwords.
+8 -8
View File
@@ -19,7 +19,7 @@ android {
namespace = "si.sdkkovinar.app" namespace = "si.sdkkovinar.app"
compileSdk = flutter.compileSdkVersion compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973" // ✅ Keep only this line ndkVersion = "27.0.12077973"
compileOptions { compileOptions {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_11
@@ -52,19 +52,19 @@ android {
buildTypes { buildTypes {
release { release {
// Falls back to debug key only when key.properties is missing (local testing). signingConfig = signingConfigs.getByName("release")
signingConfig = if (keystorePropertiesFile.exists()) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
isMinifyEnabled = false isMinifyEnabled = false
isShrinkResources = false isShrinkResources = false
} }
} }
} }
// Never ship a debug-signed release (Play rejects it): fail release builds without the upload key.
gradle.taskGraph.whenReady {
if (!keystorePropertiesFile.exists() && allTasks.any { it.name.contains("Release") }) {
throw GradleException("android/key.properties missing — release builds need the upload keystore.")
}
}
dependencies { dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4") coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
+1 -3
View File
@@ -8,7 +8,6 @@
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!-- Added by the camera plugin; the app only takes photos (enableAudio: false) --> <!-- Added by the camera plugin; the app only takes photos (enableAudio: false) -->
<uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove"/> <uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove"/>
@@ -19,8 +18,7 @@
android:enableOnBackInvokedCallback="true" android:enableOnBackInvokedCallback="true"
android:usesCleartextTraffic="true" android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config">
android:localeConfig="@xml/locales_config">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Languages offered in Android 13+ Settings > Apps > SDK Kovinar > Language -->
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="sl"/>
<locale android:name="en"/>
</locale-config>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 437 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 452 KiB

+1 -1
View File
@@ -13,7 +13,7 @@
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>shooter_app</string> <string>SDK Kovinar</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
+7 -5
View File
@@ -248,8 +248,7 @@ class _BookScreenState extends State<BookScreen> with WidgetsBindingObserver {
_load(); _load();
} }
String get _locale => String get _locale => AppSettings.instance.dateLocale;
AppSettings.instance.language == 'Slovenian' ? 'sl_SI' : 'en_US';
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -1058,7 +1057,7 @@ class _Toggle extends StatelessWidget {
} }
/// One figure on a history card: small uppercase label over a bold number, /// One figure on a history card: small uppercase label over a bold number,
/// with an optional coloured note underneath. /// with an optional coloured note underneath (its row is kept even when empty).
class _CardFigure extends StatelessWidget { class _CardFigure extends StatelessWidget {
final String label; final String label;
final String value; final String value;
@@ -1087,12 +1086,15 @@ class _CardFigure extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
fontFeatures: const [FontFeature.tabularFigures()],
color: surf.textPrimary)), color: surf.textPrimary)),
if (note != null) // The note row is always there (blank without a note), so label and
Text(note!, // number line up across figures whether or not they have a note.
Text(note ?? ' ',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
fontFeatures: const [FontFeature.tabularFigures()],
color: noteColor)), color: noteColor)),
], ],
), ),
+3 -5
View File
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../models/contact.dart'; import '../models/contact.dart';
@@ -41,7 +40,6 @@ class _CalendarScreenState extends State<CalendarScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
initializeDateFormatting('sl_SI', null);
_backgroundColor = AppSettings.instance.backgroundColor; _backgroundColor = AppSettings.instance.backgroundColor;
_loadBulletColor(); _loadBulletColor();
_loadLanguage(); _loadLanguage();
@@ -54,7 +52,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
Future<void> _loadLanguage() async { Future<void> _loadLanguage() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
setState( setState(
() => _selectedLanguage = prefs.getString('language') ?? 'English'); () => _selectedLanguage = prefs.getString('language') ?? 'Slovenian');
} }
Future<void> _loadSelectedTargetColor() async { Future<void> _loadSelectedTargetColor() async {
@@ -644,7 +642,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
} }
Widget _buildDateBlock(DateTime date, int daysFromToday, Color color) { Widget _buildDateBlock(DateTime date, int daysFromToday, Color color) {
final locale = _selectedLanguage == 'Slovenian' ? 'sl_SI' : 'en_US'; final locale = AppSettings.dateLocaleFor(_selectedLanguage);
final relative = daysFromToday == 1 final relative = daysFromToday == 1
? _t('Tomorrow') ? _t('Tomorrow')
: _t('in {n} days').replaceAll('{n}', '$daysFromToday'); : _t('in {n} days').replaceAll('{n}', '$daysFromToday');
@@ -694,7 +692,7 @@ class _CalendarScreenState extends State<CalendarScreen> {
Widget _buildCalendarView(Color accentColor) { Widget _buildCalendarView(Color accentColor) {
final now = DateTime.now(); final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day); final today = DateTime(now.year, now.month, now.day);
final locale = _selectedLanguage == 'Slovenian' ? 'sl_SI' : 'en_US'; final locale = AppSettings.dateLocaleFor(_selectedLanguage);
final isLight = _isLightBackground(); final isLight = _isLightBackground();
final textPrimary = isLight ? Colors.black87 : Colors.white; final textPrimary = isLight ? Colors.black87 : Colors.white;
final textSecondary = isLight ? Colors.grey[700]! : Colors.grey[400]!; final textSecondary = isLight ? Colors.grey[700]! : Colors.grey[400]!;
+1 -1
View File
@@ -54,7 +54,7 @@ class _CameraScreenState extends State<CameraScreen> {
Future<void> _loadLanguage() async { Future<void> _loadLanguage() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
setState(() { setState(() {
_selectedLanguage = prefs.getString('language') ?? 'English'; _selectedLanguage = prefs.getString('language') ?? 'Slovenian';
}); });
} }
+11 -10
View File
@@ -128,7 +128,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
Future<void> _loadLanguage() async { Future<void> _loadLanguage() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
setState(() { setState(() {
_selectedLanguage = prefs.getString('language') ?? 'English'; _selectedLanguage = prefs.getString('language') ?? 'Slovenian';
}); });
} }
@@ -767,16 +767,17 @@ class _PreviewScreenState extends State<PreviewScreen> {
for (var folder in folders) { for (var folder in folders) {
final name = folder.path.split('/').last; final name = folder.path.split('/').last;
// Check for both English and Slovenian names // Numbering continues across languages (English, Slovenian, German names)
if (name.startsWith('Training') || name.startsWith('Trening')) { final training = RegExp(r'^(?:Training|Trening) (\d+)$').firstMatch(name);
final num = int.tryParse( if (training != null) {
name.replaceAll('Training ', '').replaceAll('Trening ', '')); final num = int.parse(training.group(1)!);
if (num != null && num >= trainingCount) trainingCount = num + 1; if (num >= trainingCount) trainingCount = num + 1;
} }
if (name.startsWith('Tournament') || name.startsWith('Tekmovanje')) { final tournament =
final num = int.tryParse( RegExp(r'^(?:Tournament|Tekmovanje|Wettkampf) (\d+)$').firstMatch(name);
name.replaceAll('Tournament ', '').replaceAll('Tekmovanje ', '')); if (tournament != null) {
if (num != null && num >= tournamentCount) tournamentCount = num + 1; final num = int.parse(tournament.group(1)!);
if (num >= tournamentCount) tournamentCount = num + 1;
} }
} }
+2
View File
@@ -148,6 +148,7 @@ class _SessionScreenState extends State<SessionScreen> {
/// "1 target" / "5 targets", with Slovenian dual and plural forms. /// "1 target" / "5 targets", with Slovenian dual and plural forms.
String targetCount(int n) { String targetCount(int n) {
final s = AppSettings.instance; final s = AppSettings.instance;
if (s.language == 'German') return n == 1 ? '1 Scheibe' : '$n Scheiben';
if (s.language != 'Slovenian') return n == 1 ? '1 target' : '$n targets'; if (s.language != 'Slovenian') return n == 1 ? '1 target' : '$n targets';
final mod = n % 100; final mod = n % 100;
final word = mod == 1 ? 'tarča' : mod == 2 ? 'tarči' : (mod == 3 || mod == 4) ? 'tarče' : 'tarč'; final word = mod == 1 ? 'tarča' : mod == 2 ? 'tarči' : (mod == 3 || mod == 4) ? 'tarče' : 'tarč';
@@ -157,6 +158,7 @@ String targetCount(int n) {
/// "1 shot" / "5 shots", with Slovenian dual and plural forms. /// "1 shot" / "5 shots", with Slovenian dual and plural forms.
String shotCount(int n) { String shotCount(int n) {
final s = AppSettings.instance; final s = AppSettings.instance;
if (s.language == 'German') return n == 1 ? '1 Schuss' : '$n Schüsse';
if (s.language != 'Slovenian') return n == 1 ? '1 shot' : '$n shots'; if (s.language != 'Slovenian') return n == 1 ? '1 shot' : '$n shots';
final mod = n % 100; final mod = n % 100;
final word = mod == 1 ? 'strel' : mod == 2 ? 'strela' : (mod == 3 || mod == 4) ? 'streli' : 'strelov'; final word = mod == 1 ? 'strel' : mod == 2 ? 'strela' : (mod == 3 || mod == 4) ? 'streli' : 'strelov';
+4 -12
View File
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import '../services/app_settings.dart'; import '../services/app_settings.dart';
import '../utils/translations.dart';
import '../services/notification_service.dart'; import '../services/notification_service.dart';
import '../theme/app_theme.dart'; import '../theme/app_theme.dart';
import '../utils/target_colors.dart'; import '../utils/target_colors.dart';
@@ -32,7 +33,6 @@ class SettingsScreen extends StatelessWidget {
GroupCard(children: [ GroupCard(children: [
SettingsTile( SettingsTile(
title: t(language['name']!), title: t(language['name']!),
subtitle: s.followSystemLanguage ? t('Automatic (phone language)') : null,
onTap: () => _pickLanguage(context), onTap: () => _pickLanguage(context),
), ),
]), ]),
@@ -211,19 +211,11 @@ class SettingsScreen extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
_SheetTitle(s.t('Select Language')), _SheetTitle(s.t('Select Language')),
SheetOption( // Each language in its own name, so it can be found from any language
label: '${s.t('Automatic (phone language)')} · ${s.t(AppSettings.systemLanguage)}',
selected: s.followSystemLanguage,
selectedColor: s.bulletColor,
onTap: () {
s.useSystemLanguage();
Navigator.pop(sheet);
},
),
for (final lang in AppSettings.languages) for (final lang in AppSettings.languages)
SheetOption( SheetOption(
label: s.t(lang['name']!), label: AppTranslations.translate(lang['name']!, lang['name']!),
selected: !s.followSystemLanguage && lang['name'] == s.language, selected: lang['name'] == s.language,
selectedColor: s.bulletColor, selectedColor: s.bulletColor,
onTap: () { onTap: () {
s.setLanguage(lang['name']!); s.setLanguage(lang['name']!);
+1 -1
View File
@@ -104,7 +104,7 @@ class _CameraStreamScreenState extends State<CameraStreamScreen>
final reloadOn = prefs.getBool('timerReloadEnabled') ?? false; final reloadOn = prefs.getBool('timerReloadEnabled') ?? false;
final waitOn = prefs.getBool('timerWaitEnabled') ?? false; final waitOn = prefs.getBool('timerWaitEnabled') ?? false;
setState(() { setState(() {
_selectedLanguage = prefs.getString('language') ?? 'English'; _selectedLanguage = prefs.getString('language') ?? 'Slovenian';
// Older versions allowed up to 10 // Older versions allowed up to 10
_numberOfBullets = (prefs.getInt('bulletCount') ?? AppSettings.maxBullets) _numberOfBullets = (prefs.getInt('bulletCount') ?? AppSettings.maxBullets)
.clamp(AppSettings.minBullets, AppSettings.maxBullets); .clamp(AppSettings.minBullets, AppSettings.maxBullets);
+1 -1
View File
@@ -71,7 +71,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
Future<void> _loadLanguage() async { Future<void> _loadLanguage() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
setState(() { setState(() {
_selectedLanguage = prefs.getString('language') ?? 'English'; _selectedLanguage = prefs.getString('language') ?? 'Slovenian';
}); });
} }
+18 -25
View File
@@ -27,7 +27,9 @@ class AppSettings extends ChangeNotifier {
static const List<Map<String, String>> languages = [ static const List<Map<String, String>> languages = [
{'name': 'English', 'flag': '🇬🇧'}, {'name': 'English', 'flag': '🇬🇧'},
{'name': 'Slovenian', 'flag': '🇸🇮'}, {'name': 'Slovenian', 'flag': '🇸🇮'},
{'name': 'German', 'flag': '🇩🇪'},
]; ];
static const String defaultLanguage = 'Slovenian';
static const Map<String, Color> bulletColors = { static const Map<String, Color> bulletColors = {
'Blue': Colors.blue, 'Blue': Colors.blue,
@@ -47,16 +49,18 @@ class AppSettings extends ChangeNotifier {
'Grey': Colors.grey, 'Grey': Colors.grey,
}; };
// 13 was dropped earlier; 21 and 31–34 were Christmas / Easter themes
static const Set<int> removedTargets = {13, 21, 31, 32, 33, 34};
static final List<String> targets = [ static final List<String> targets = [
defaultTarget, defaultTarget,
for (int i = 1; i <= 35; i++) for (int i = 1; i <= 35; i++)
if (i != 13) 'assets/targets/Target$i.jpg', // 13 was removed if (!removedTargets.contains(i)) 'assets/targets/Target$i.jpg',
]; ];
late SharedPreferences _prefs; late SharedPreferences _prefs;
String _language = 'English'; String _language = defaultLanguage;
bool _followSystemLanguage = false;
String _bulletColorName = 'Blue'; String _bulletColorName = 'Blue';
String _selectedTarget = defaultTarget; String _selectedTarget = defaultTarget;
int _reminderHours = 1; int _reminderHours = 1;
@@ -67,11 +71,14 @@ class AppSettings extends ChangeNotifier {
List<Contact>? _clubContacts; // null until the club code is entered List<Contact>? _clubContacts; // null until the club code is entered
String get language => _language; String get language => _language;
bool get followSystemLanguage => _followSystemLanguage;
// Phone language (or Android 13+ per-app language) mapped to our two languages /// intl locale for dates (month and day names) in [language].
static String get systemLanguage => static String dateLocaleFor(String language) => switch (language) {
WidgetsBinding.instance.platformDispatcher.locale.languageCode == 'sl' ? 'Slovenian' : 'English'; 'Slovenian' => 'sl_SI',
'German' => 'de_DE',
_ => 'en_US',
};
String get dateLocale => dateLocaleFor(_language);
String get bulletColorName => _bulletColorName; String get bulletColorName => _bulletColorName;
Color get bulletColor => bulletColors[_bulletColorName] ?? Colors.blue; Color get bulletColor => bulletColors[_bulletColorName] ?? Colors.blue;
String get selectedTarget => _selectedTarget; String get selectedTarget => _selectedTarget;
@@ -96,12 +103,12 @@ class AppSettings extends ChangeNotifier {
Future<void> load() async { Future<void> load() async {
_prefs = await SharedPreferences.getInstance(); _prefs = await SharedPreferences.getInstance();
// New installs follow the phone; an explicit earlier choice stays as it is // New installs start in Slovenian. Whoever had "automatic" keeps the language
// it last resolved to (saved under the same key).
final saved = _prefs.getString('language'); final saved = _prefs.getString('language');
_followSystemLanguage = _prefs.getBool('languageFollowsSystem') ?? saved == null; _language = languages.any((l) => l['name'] == saved) ? saved! : defaultLanguage;
_language = _followSystemLanguage ? systemLanguage : saved!;
await _prefs.setString('language', _language); // other screens read this key await _prefs.setString('language', _language); // other screens read this key
WidgetsBinding.instance.platformDispatcher.onLocaleChanged = _onSystemLocaleChanged; await _prefs.remove('languageFollowsSystem');
final color = _prefs.getString('bulletColor') ?? 'Blue'; final color = _prefs.getString('bulletColor') ?? 'Blue';
_bulletColorName = bulletColors.containsKey(color) ? color : 'Blue'; _bulletColorName = bulletColors.containsKey(color) ? color : 'Blue';
@@ -141,22 +148,8 @@ class AppSettings extends ChangeNotifier {
Future<void> setLanguage(String value) async { Future<void> setLanguage(String value) async {
_language = value; _language = value;
_followSystemLanguage = false;
notifyListeners(); notifyListeners();
await _prefs.setString('language', value); await _prefs.setString('language', value);
await _prefs.setBool('languageFollowsSystem', false);
}
Future<void> useSystemLanguage() async {
_followSystemLanguage = true;
_language = systemLanguage;
notifyListeners();
await _prefs.setString('language', _language);
await _prefs.setBool('languageFollowsSystem', true);
}
void _onSystemLocaleChanged() {
if (_followSystemLanguage && systemLanguage != _language) useSystemLanguage();
} }
Future<void> setBulletColor(String name) async { Future<void> setBulletColor(String name) async {
+17 -32
View File
@@ -63,33 +63,9 @@ class NotificationService {
AndroidFlutterLocalNotificationsPlugin>(); AndroidFlutterLocalNotificationsPlugin>();
await androidPlugin?.createNotificationChannel(_channel); await androidPlugin?.createNotificationChannel(_channel);
await requestPermissions(); await requestPermissions();
await _requestExactAlarmsOnce();
} catch (_) {} } catch (_) {}
} }
// Android 12+ needs "Alarms & reminders" access for on-time delivery.
// Ask once; without it we fall back to inexact alarms.
Future<void> _requestExactAlarmsOnce() async {
final android = _plugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();
if (android == null) return;
if (await android.canScheduleExactNotifications() ?? true) return;
final prefs = await SharedPreferences.getInstance();
if (prefs.getBool('exactAlarmAsked') ?? false) return;
await prefs.setBool('exactAlarmAsked', true);
await android.requestExactAlarmsPermission();
}
Future<AndroidScheduleMode> _scheduleMode() async {
final android = _plugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();
final canExact = await android?.canScheduleExactNotifications() ?? true;
return canExact
? AndroidScheduleMode.exactAllowWhileIdle
: AndroidScheduleMode.inexactAllowWhileIdle;
}
/// Fetches the calendar and reschedules all reminders. Call on app start /// Fetches the calendar and reschedules all reminders. Call on app start
/// and whenever notification settings change. /// and whenever notification settings change.
Future<void> rescheduleFromCalendar() async { Future<void> rescheduleFromCalendar() async {
@@ -140,9 +116,8 @@ class NotificationService {
final notifyDezuranje = prefs.getBool('notifyDezuranje') ?? true; final notifyDezuranje = prefs.getBool('notifyDezuranje') ?? true;
final notifySestanek = prefs.getBool('notifySestanek') ?? true; final notifySestanek = prefs.getBool('notifySestanek') ?? true;
final notifyTekma = prefs.getBool('notifyTekma') ?? true; final notifyTekma = prefs.getBool('notifyTekma') ?? true;
final isSlovenian = (prefs.getString('language') ?? 'English') == 'Slovenian'; final language = prefs.getString('language') ?? 'Slovenian';
final now = DateTime.now(); final now = DateTime.now();
final mode = await _scheduleMode();
await _plugin.cancelAll(); await _plugin.cancelAll();
@@ -166,23 +141,32 @@ class NotificationService {
await _scheduleNotification( await _scheduleNotification(
id: notifId++, id: notifId++,
title: event.summary ?? 'Event', title: event.summary ?? 'Event',
body: isSlovenian body: _startsIn(hours, language),
? (hours == 1 ? 'Začne se čez 1 uro' : 'Začne se čez $hours ur')
: (hours == 1 ? 'Starts in 1 hour' : 'Starts in $hours hours'),
scheduledDate: notifyAt, scheduledDate: notifyAt,
mode: mode,
); );
} }
} }
} catch (_) {} } catch (_) {}
} }
static String _startsIn(int hours, String language) {
switch (language) {
case 'Slovenian':
final mod = hours % 100;
final unit = mod == 1 ? 'uro' : mod == 2 ? 'uri' : (mod == 3 || mod == 4) ? 'ure' : 'ur';
return 'Začne se čez $hours $unit';
case 'German':
return hours == 1 ? 'Beginnt in 1 Stunde' : 'Beginnt in $hours Stunden';
default:
return hours == 1 ? 'Starts in 1 hour' : 'Starts in $hours hours';
}
}
Future<void> _scheduleNotification({ Future<void> _scheduleNotification({
required int id, required int id,
required String title, required String title,
required String body, required String body,
required DateTime scheduledDate, required DateTime scheduledDate,
required AndroidScheduleMode mode,
}) async { }) async {
final tzDate = tz.TZDateTime.from(scheduledDate, tz.local); final tzDate = tz.TZDateTime.from(scheduledDate, tz.local);
await _plugin.zonedSchedule( await _plugin.zonedSchedule(
@@ -191,7 +175,8 @@ class NotificationService {
body, body,
tzDate, tzDate,
_notifDetails, _notifDetails,
androidScheduleMode: mode, // Inexact: avoids the SCHEDULE_EXACT_ALARM permission (Play policy).
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
uiLocalNotificationDateInterpretation: uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime, UILocalNotificationDateInterpretation.absoluteTime,
); );
-5
View File
@@ -22,7 +22,6 @@ class TargetColors {
'assets/targets/Target18.jpg': Color(0xFF050608), // Very dark gray 'assets/targets/Target18.jpg': Color(0xFF050608), // Very dark gray
'assets/targets/Target19.jpg': Color(0xFFF68527), // Warm orange 'assets/targets/Target19.jpg': Color(0xFFF68527), // Warm orange
'assets/targets/Target20.jpg': Color(0xFFA9D9EF), // Light blue 'assets/targets/Target20.jpg': Color(0xFFA9D9EF), // Light blue
'assets/targets/Target21.jpg': Color(0xFFDA6868), // Muted red
'assets/targets/Target22.jpg': Color(0xFFFBFAF6), // Off-white 'assets/targets/Target22.jpg': Color(0xFFFBFAF6), // Off-white
'assets/targets/Target23.jpg': Color(0xFF000000), // Black 'assets/targets/Target23.jpg': Color(0xFF000000), // Black
'assets/targets/Target24.jpg': Color(0xFF646462), // Grey 'assets/targets/Target24.jpg': Color(0xFF646462), // Grey
@@ -32,10 +31,6 @@ class TargetColors {
'assets/targets/Target28.jpg': Color(0xFFFFFFFF), // White 'assets/targets/Target28.jpg': Color(0xFFFFFFFF), // White
'assets/targets/Target29.jpg': Color(0xFF180E27), // Dark purple 'assets/targets/Target29.jpg': Color(0xFF180E27), // Dark purple
'assets/targets/Target30.jpg': Color(0xFFFDFDFB), // Off-white 'assets/targets/Target30.jpg': Color(0xFFFDFDFB), // Off-white
'assets/targets/Target31.jpg': Color(0xFFC52736), // Red
'assets/targets/Target32.jpg': Color(0xFFFCF3EE), // Light cream
'assets/targets/Target33.jpg': Color(0xFFFCFCF3), // Very light off-white
'assets/targets/Target34.jpg': Color(0xFFFFFFFD), // Almost white
'assets/targets/Target35.jpg': Color(0xFFFFC5C4), // Light salmon 'assets/targets/Target35.jpg': Color(0xFFFFC5C4), // Light salmon
}; };
File diff suppressed because it is too large Load Diff
+30 -4
View File
@@ -1,4 +1,5 @@
import 'dart:math'; import 'dart:math';
import 'package:flutter/foundation.dart' show listEquals;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
enum ChartAxis { left, right, none } enum ChartAxis { left, right, none }
@@ -42,12 +43,37 @@ class ProgressChart extends StatefulWidget {
class _ProgressChartState extends State<ProgressChart> { class _ProgressChartState extends State<ProgressChart> {
int? _selected; int? _selected;
void _select(Offset position, Size size) { // Other data (another month/year, filter): the old selection means nothing there
@override
void didUpdateWidget(ProgressChart old) {
super.didUpdateWidget(old);
final same = listEquals(old.labels, widget.labels) &&
old.series.length == widget.series.length &&
[
for (var i = 0; i < widget.series.length; i++)
listEquals(old.series[i].values, widget.series[i].values)
].every((e) => e);
if (!same) _selected = null;
}
int? _indexAt(Offset position, Size size) {
final n = widget.labels.length; final n = widget.labels.length;
if (n == 0) return; if (n == 0) return null;
final plot = _ChartPainter.plotRect(size); final plot = _ChartPainter.plotRect(size);
final x = (position.dx - plot.left) / plot.width; final x = (position.dx - plot.left) / plot.width;
setState(() => _selected = (x * (n - 1)).round().clamp(0, n - 1)); return (x * (n - 1)).round().clamp(0, n - 1);
}
void _select(Offset position, Size size) {
final i = _indexAt(position, size);
if (i != null && i != _selected) setState(() => _selected = i);
}
// Tapping the selected point again hides the tooltip
void _toggle(Offset position, Size size) {
final i = _indexAt(position, size);
if (i == null) return;
setState(() => _selected = i == _selected ? null : i);
} }
@override @override
@@ -60,7 +86,7 @@ class _ProgressChartState extends State<ProgressChart> {
final size = Size(constraints.maxWidth, 190); final size = Size(constraints.maxWidth, 190);
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTapDown: (d) => _select(d.localPosition, size), onTapDown: (d) => _toggle(d.localPosition, size),
onHorizontalDragUpdate: (d) => _select(d.localPosition, size), onHorizontalDragUpdate: (d) => _select(d.localPosition, size),
child: CustomPaint( child: CustomPaint(
size: size, size: size,
+2 -2
View File
@@ -1,5 +1,5 @@
name: test1 name: sdk_kovinar
description: A new Flutter project. description: SDK Kovinar club app — target scoring, camera streams, training calendar and contacts.
publish_to: 'none' # This prevents publishing to pub.dev publish_to: 'none' # This prevents publishing to pub.dev
version: 1.3.0+6 version: 1.3.0+6
+145
View File
@@ -0,0 +1,145 @@
#!/usr/bin/env python3
"""Builds the Google Play graphics from the raw emulator screenshots.
python3 store/make_graphics.py
Needs chromium and ImageMagick (magick). Reads store/screenshots/raw/*.png,
writes store/out/: phone screenshots (1080x1920), feature graphic (1024x500)
and the 512x512 icon. Edit SLIDES to change captions or order.
"""
import html
import pathlib
import subprocess
import tempfile
ROOT = pathlib.Path(__file__).resolve().parent
RAW = ROOT / "screenshots" / "raw"
OUT = ROOT / "out"
ICON = ROOT.parent / "assets" / "Icon.png"
ACCENT = "#00BCD4" # the app's default hit colour (Cian)
# (raw screenshot, headline, subline, blur everything above this y in px or None)
SLIDES = [
("03_knjiga_leto.png", "Spremljaj svoj napredek",
"Povprečje, rekordi in graf napredka", None),
("04_seja.png", "Vsi streli na eni tarči",
"Cel trening na enem pogledu", None),
("10_kamera_ziva.png", "Tarča v živo z IP kamero",
"Spremljaj zadetke na telefonu, brez hoje do tarče", None),
("11_kamera_telefon.png", "Fotografiraj tarčo",
"Poravnaj jo v kvadrat, zadetke prešteje aplikacija", None),
("08_po_meri.png", "Tarča po tvojem okusu",
"Izberi slog tarče in barvo zadetkov", None),
("07_tarca.png", "Več kot ducat tarč",
"Od klasične do plamenov in valov", None),
("05_tekmovanja.png", "Treningi in tekmovanja",
"Ločena statistika za vadbo in tekme", None),
("06_barva_zadetkov.png", "Zadetki v tvoji barvi",
"15 barv, da so zadetki vedno dobro vidni", 1596),
]
BASE_CSS = """
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: %(w)dpx; height: %(h)dpx; overflow: hidden; }
body {
font-family: 'Noto Sans', 'Liberation Sans', sans-serif;
color: #fff;
background:
radial-gradient(ellipse 80%% 50%% at 50%% 0%%, rgba(0,188,212,.28), transparent 70%%),
linear-gradient(180deg, #1d2427 0%%, #121416 100%%);
}
.phone {
border-radius: 64px; padding: 14px; background: #0b0b0c;
box-shadow: 0 0 0 3px #3a3f44, 0 40px 80px rgba(0,0,0,.55);
}
.phone img { display: block; border-radius: 52px; width: 100%%; }
"""
def chromium_png(page: str, w: int, h: int, out: pathlib.Path, tmp: pathlib.Path):
src = tmp / (out.stem + ".html")
src.write_text(page, encoding="utf-8")
subprocess.run(
["chromium", "--headless=new", "--disable-gpu", "--hide-scrollbars",
"--force-device-scale-factor=1", f"--window-size={w},{h}",
f"--screenshot={out}", "--default-background-color=00000000",
src.as_uri()],
check=True, capture_output=True)
# Play wants opaque PNG/JPEG
subprocess.run(["magick", str(out), "-background", "#121416", "-alpha",
"remove", "-alpha", "off", str(out)], check=True)
def prepared(name: str, blur_above, tmp: pathlib.Path) -> pathlib.Path:
"""The raw shot, optionally with everything above y blurred (hides the club section)."""
src = RAW / name
if blur_above is None:
return src
out = tmp / name
subprocess.run(
["magick", str(src), "(", "+clone", "-crop", f"1080x{blur_above}+0+0",
"+repage", "-blur", "0x28", ")", "-geometry", "+0+0", "-composite",
str(out)], check=True)
return out
def slide(img: pathlib.Path, title: str, sub: str) -> str:
css = BASE_CSS % {"w": 1080, "h": 1920} + f"""
.cap {{ text-align: center; padding: 100px 70px 0; }}
.cap h1 {{ font-size: 76px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }}
.cap h1::after {{ content: ''; display: block; width: 90px; height: 8px;
border-radius: 4px; background: {ACCENT}; margin: 34px auto 0; }}
.cap p {{ margin-top: 30px; font-size: 38px; line-height: 1.35; color: #c4ccd0; }}
.phone {{ position: absolute; left: 50%; top: 470px; width: 630px;
transform: translateX(-50%); }}
"""
return f"""<!doctype html><html><head><meta charset="utf-8"><style>{css}</style></head>
<body><div class="cap"><h1>{html.escape(title)}</h1><p>{html.escape(sub)}</p></div>
<div class="phone"><img src="{img.as_uri()}"></div></body></html>"""
def feature(img: pathlib.Path, icon: pathlib.Path) -> str:
css = BASE_CSS % {"w": 1024, "h": 500} + f"""
body {{ background:
radial-gradient(circle at 78% 55%, rgba(30,144,255,.35), transparent 55%),
radial-gradient(ellipse at 0% 0%, rgba(0,188,212,.25), transparent 60%),
linear-gradient(120deg, #1d2427, #101214); }}
.left {{ position: absolute; left: 64px; top: 0; bottom: 0; width: 560px;
display: flex; flex-direction: column; justify-content: center; }}
.logo {{ width: 96px; height: 96px; border-radius: 24px; background: #fff;
padding: 10px; margin-bottom: 26px; }}
.logo img {{ width: 100%; height: 100%; }}
h1 {{ font-size: 66px; font-weight: 800; letter-spacing: -1px; line-height: 1; }}
h1 span {{ color: {ACCENT}; }}
p {{ margin-top: 18px; font-size: 27px; line-height: 1.35; color: #c4ccd0; }}
.phone {{ position: absolute; right: 70px; top: 46px; width: 290px;
border-radius: 40px; padding: 8px; transform: rotate(6deg); }}
.phone img {{ border-radius: 32px; }}
"""
return f"""<!doctype html><html><head><meta charset="utf-8"><style>{css}</style></head>
<body><div class="left"><div class="logo"><img src="{icon.as_uri()}"></div>
<h1>SDK <span>Kovinar</span></h1>
<p>Strelski dnevnik: rezultati, napredek in tarče po tvoji meri.</p></div>
<div class="phone"><img src="{img.as_uri()}"></div></body></html>"""
def main():
OUT.mkdir(exist_ok=True)
with tempfile.TemporaryDirectory() as t:
tmp = pathlib.Path(t)
for i, (name, title, sub, blur) in enumerate(SLIDES, 1):
img = prepared(name, blur, tmp)
out = OUT / f"phone_{i:02d}_{pathlib.Path(name).stem}.png"
chromium_png(slide(img, title, sub), 1080, 1920, out, tmp)
print("wrote", out.relative_to(ROOT.parent))
out = OUT / "feature_graphic.png"
chromium_png(feature(RAW / "09_val_modra.png", ICON), 1024, 500, out, tmp)
print("wrote", out.relative_to(ROOT.parent))
icon = OUT / "icon_512.png"
subprocess.run(["magick", str(ICON), "-resize", "512x512", "-background",
"white", "-alpha", "remove", "-alpha", "off", str(icon)], check=True)
print("wrote", icon.relative_to(ROOT.parent))
if __name__ == "__main__":
main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

+1 -1
View File
@@ -7,7 +7,7 @@
// Re-run after editing contacts or to change the club code, then rebuild the app. // Re-run after editing contacts or to change the club code, then rebuild the app.
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:test1/services/club_crypto.dart'; import 'package:sdk_kovinar/services/club_crypto.dart';
const _input = 'tool/club_data.json'; const _input = 'tool/club_data.json';
const _output = 'assets/club.enc'; const _output = 'assets/club.enc';