Compare commits
7 Commits
main
...
30708c73b1
| Author | SHA1 | Date | |
|---|---|---|---|
| 30708c73b1 | |||
| d4bc01f202 | |||
| d3927aac8a | |||
| df85d36c75 | |||
| 9d9e0c77f2 | |||
| 3b50cb0fe9 | |||
| 9a65ff7ad4 |
@@ -43,3 +43,6 @@ app.*.map.json
|
|||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
/android/app/release
|
/android/app/release
|
||||||
|
|
||||||
|
# Plain club data (contacts) — encrypted into assets/club.enc, never commit
|
||||||
|
/tool/club_data.json
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
- build/**
|
||||||
|
- android/**
|
||||||
|
- ios/**
|
||||||
|
- linux/**
|
||||||
|
include: package:flutter_lints/flutter.yaml
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import java.util.Properties
|
||||||
|
import java.io.FileInputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
id("kotlin-android")
|
id("kotlin-android")
|
||||||
@@ -5,11 +8,18 @@ plugins {
|
|||||||
id("dev.flutter.flutter-gradle-plugin")
|
id("dev.flutter.flutter-gradle-plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Upload key for Google Play. android/key.properties is gitignored — never commit it.
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
val keystorePropertiesFile = rootProject.file("key.properties")
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.example.shooter_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
|
||||||
@@ -22,23 +32,39 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.example.shooter_app"
|
applicationId = "si.sdkkovinar.app"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 33
|
targetSdk = 36
|
||||||
versionCode = flutter.versionCode
|
versionCode = flutter.versionCode
|
||||||
versionName = flutter.versionName
|
versionName = flutter.versionName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
create("release") {
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keyAlias = keystoreProperties["keyAlias"] as String
|
||||||
|
keyPassword = keystoreProperties["keyPassword"] as String
|
||||||
|
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||||
|
storePassword = keystoreProperties["storePassword"] as String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
signingConfig = signingConfigs.getByName("debug")
|
signingConfig = signingConfigs.getByName("release")
|
||||||
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,28 +0,0 @@
|
|||||||
# TensorFlow Lite
|
|
||||||
-keep class org.tensorflow.** { *; }
|
|
||||||
-dontwarn org.tensorflow.**
|
|
||||||
|
|
||||||
# TFLite GPU Delegate
|
|
||||||
-keep class org.tensorflow.lite.gpu.** { *; }
|
|
||||||
-dontwarn org.tensorflow.lite.gpu.**
|
|
||||||
|
|
||||||
# TFLite Support Libraries
|
|
||||||
-keep class org.tensorflow.lite.support.** { *; }
|
|
||||||
-dontwarn org.tensorflow.lite.support.**
|
|
||||||
|
|
||||||
# Prevent R8 stripping
|
|
||||||
-keep class com.google.** { *; }
|
|
||||||
-dontwarn com.google.**
|
|
||||||
|
|
||||||
# Keep your YOLO model loader class if needed
|
|
||||||
-keep class your.package.name.YOLODetect { *; }
|
|
||||||
|
|
||||||
# Flutter Local Notifications
|
|
||||||
-keep class com.dexterous.** { *; }
|
|
||||||
-dontwarn com.dexterous.**
|
|
||||||
|
|
||||||
# Timezone
|
|
||||||
-keep class com.jakewharton.threetenabp.** { *; }
|
|
||||||
-dontwarn com.jakewharton.threetenabp.**
|
|
||||||
-keep class org.threeten.** { *; }
|
|
||||||
-dontwarn org.threeten.**
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
|
||||||
@@ -6,22 +7,21 @@
|
|||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
<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"/>
|
||||||
|
<!-- Added by the camera plugin; the app only takes photos (enableAudio: false) -->
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" tools:node="remove"/>
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="SDK Muta"
|
android:label="SDK Kovinar"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:enableOnBackInvokedCallback="true"
|
android:enableOnBackInvokedCallback="true"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:requestLegacyExternalStorage="true"
|
|
||||||
android:preserveLegacyExternalStorage="true"
|
|
||||||
android:networkSecurityConfig="@xml/network_security_config">
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
uses-cleartext-traffic="true"
|
|
||||||
android:usesCleartextTraffic="true"
|
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:taskAffinity=""
|
android:taskAffinity=""
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.example.shooter_app
|
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
|
|
||||||
class MainActivity : FlutterActivity()
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.example.test1
|
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
|
|
||||||
class MainActivity : FlutterActivity()
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package si.sdkkovinar.app
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
|
import android.net.NetworkRequest
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
class MainActivity : FlutterActivity() {
|
||||||
|
private val connectivity by lazy {
|
||||||
|
getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
}
|
||||||
|
private var wifiCallback: ConnectivityManager.NetworkCallback? = null
|
||||||
|
|
||||||
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
|
super.configureFlutterEngine(flutterEngine)
|
||||||
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "si.sdkkovinar.app/network")
|
||||||
|
.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"bindToWifi" -> result.success(bindToWifi())
|
||||||
|
"unbind" -> {
|
||||||
|
unbind()
|
||||||
|
result.success(null)
|
||||||
|
}
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The range Wi-Fi has no internet, so Android routes traffic over mobile data
|
||||||
|
// and the cameras' local IPs become unreachable. Pin this app's traffic to
|
||||||
|
// Wi-Fi (other apps keep using mobile data). Returns true if bound right away.
|
||||||
|
private fun bindToWifi(): Boolean {
|
||||||
|
if (wifiCallback == null) {
|
||||||
|
val request = NetworkRequest.Builder()
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||||
|
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
|
.build()
|
||||||
|
val callback = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
connectivity.bindProcessToNetwork(network)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
if (connectivity.boundNetworkForProcess == network) {
|
||||||
|
connectivity.bindProcessToNetwork(null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connectivity.registerNetworkCallback(request, callback)
|
||||||
|
wifiCallback = callback
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
val wifi = connectivity.allNetworks.firstOrNull {
|
||||||
|
connectivity.getNetworkCapabilities(it)
|
||||||
|
?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true
|
||||||
|
} ?: return false
|
||||||
|
return connectivity.bindProcessToNetwork(wifi)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unbind() {
|
||||||
|
wifiCallback?.let { connectivity.unregisterNetworkCallback(it) }
|
||||||
|
wifiCallback = null
|
||||||
|
connectivity.bindProcessToNetwork(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
unbind()
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,32 @@ subprojects {
|
|||||||
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
|
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
|
||||||
project.layout.buildDirectory.value(newSubprojectBuildDir)
|
project.layout.buildDirectory.value(newSubprojectBuildDir)
|
||||||
}
|
}
|
||||||
|
// Plugins such as tflite_flutter set a Java target but no Kotlin target, so on a
|
||||||
|
// newer JDK Kotlin picks a default that fails Gradle's JVM target validation.
|
||||||
|
// Keep each module's Kotlin target in line with its own Java target.
|
||||||
|
subprojects {
|
||||||
|
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||||
|
val javaTaskName = name.replace("Kotlin", "JavaWithJavac")
|
||||||
|
val projectTasks = project.tasks
|
||||||
|
compilerOptions.jvmTarget.set(
|
||||||
|
project.provider {
|
||||||
|
(projectTasks.findByName(javaTaskName) as? JavaCompile)
|
||||||
|
?.targetCompatibility
|
||||||
|
?.let { org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(it) }
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Older plugins such as tflite_flutter pin a low compileSdk, which fails the AAR
|
||||||
|
// metadata check against current AndroidX. compileSdk only affects which APIs a
|
||||||
|
// module compiles against, not runtime behavior, so raise it for those modules.
|
||||||
|
subprojects {
|
||||||
|
afterEvaluate {
|
||||||
|
extensions.findByType<com.android.build.gradle.LibraryExtension>()?.let { android ->
|
||||||
|
if ((android.compileSdk ?: 0) < 36) android.compileSdk = 36
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
subprojects {
|
subprojects {
|
||||||
project.evaluationDependsOn(":app")
|
project.evaluationDependsOn(":app")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
# This builtInKotlin flag was added automatically by Flutter migrator
|
||||||
|
android.builtInKotlin=false
|
||||||
|
# This newDsl flag was added automatically by Flutter migrator
|
||||||
|
android.newDsl=false
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ pluginManagement {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||||
id("com.android.application") version "8.7.0" apply false
|
id("com.android.application") version "8.13.0" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
|
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{"v":1,"salt":"FY2tFQDBCelhcwVb7N8zCQ==","nonce":"PYsMaiSSFEy65Sfq","cipher":"TR7WZBCpsG+eh5lAR5D4lHN0EWnfd1DkX4U8D5oF6+ypG/0lshVCcnb+AFYEqZdi9lT8jjTl6N0NN8NNsqTLIE74UgHzTy2nKwvd5ICZwhi18isU2wqYxx3yZOfgL0E1GJemuTp+fDVQB2RtmMurwp6KJBzx7e6AHZ7Jy5I+n++H/an+2SZryTuDiWbwADUTmL5zqkBSIHJbz/4tc61hAMVD7mDC82NqmKJqUPOGtsWQRI7OXCvGnHal/GMk6m1kLZrvuk4A8P3c1j+kbpvz+wkioHj50sC0jFyK899j3ZS4BWKcR+QFhjV1VVGkIKLw2ecevc1KHiC6Z1MX2PTQspBz/z/89/O83P2TL57UGBAHyXR90E4w9hR7l4GlOPYMzIT4t6eIe+B5dcSnbTtbryrNj4tvxgnOmjVVdjfBate+YinIGPazJJlX9K7uggtrjf4B6GL4eKvGWCqeuXhlLaqVdf3C584WzWatIxMkGRXNFAtarNNHq3mBAPQIEev9Td7TqdosRJgCp0tEAN0zU4NGWjiuqBV+C/ao9YtI4RUHk+wppbZYaK+IvLdL5u2BhxL62KD/dqb+3cjT52WFwSduwTVqDawwtwWDBIF0q7MviFtIGKdQZw53uH7A09V/Gh+GlH0gsrgth3g8AkIZh30esUhfLLlqfk8XTyeiszSkDTNIFvy4U4fAhO+MVmn/zKEiIf0HpXZRonAarpgEHq8uu44owPutrLAl3W5/2F7LoNWL2IIqVHPFFYPIPntW/I4BuMupBRMyDb2fm98NBfW6Go7bl1vRVIOOSPfyrTY2H8Ro/kihNfCuiUunpwFE3Wc0vOpEb0IzWXzS1F1xKRi5hC5sjEYLHsIJ1bS8hbdb9LV4mq+Hfvh/f9QvyIKubiBTElUeiHDMNNgmyUkZE2I2RPX7YDZb4Sho8bZLi/JgoIhGvZpT045XrRcRohwUkajNxNO8/LYj6+y2eeATdUwK3UrW8UiHaNHdbIvkv3/Q9+taPbMPrjcu9KoVUChr14eTecoDRHhqjVkUbGonKGBVnhgw/a7r1EuFS0vqZlYVFK5Y7uJdQqgCN7knX/U2XH0TMOuuVGVN3oGIjxfFkAAs4qb3tYsaKOeDtT4hqaPWQFE1zhc4u0ESqngjL0rucK67wV0sd1SK35X3bxQ0izvTmKBmSMfc7Ni7FrddwOsWDM9ZkjVrf0291FVOmmqrYjYm9+wFcir6G8jvG7zbTlbCvf5mVNzf1VZGGmu3jCSIESWGEVcUR3BriAbBvdD68XlU4zIuA/d9YEiTU7QSZWrzJkyH3e5xeOmK+HCFW+ex1O4JYSWX4VFE2gY3x04aqmGbQ+Shu4prJOGDVFep9CHURJsu8NSeIIkMQa8x4YR3Yh+TXp4SrZzUGZ+RawYidMZ8sovgAyW7+m86zfUocMQcxHf0DmbMBAISMabtquFSlN9aRW67z8GTof/y0Y4wjEU3Q8vobkUdIIrcVlWb2S/pE9xj9NwWE2Q/oDZPQscKinSb/BleUfzPie72u77qy+tqXmA/0Hn2QINs21g8tk1bmcTGe3pqTxAIdJd3E5mmerr0gI2sT+Wr1bucuZjKh/1ndARTG6zhpbxLsDZNG8LaBCqKoGcWdvdCteR+XamWEMud9z/KTZ7FjC0tO+tIi6sEubhyUbyXF12VmANPpOSKVM3zRCT67rbzQBjKz++ucdxmIAf1kAJ1Pmm1/kgmwIW+XV05teO4Uuzdb9ZfwU07iYGZqPViEtKDKEwJcz97DsMsub9Mo1IzBaocfmczxj++1mHmIAqiJJSqzyeXehZATNl9JiTjv2TJ4GF02wjAfWNCYcJz6elQedu4HKaK1EsrRh9MZGBWkC9OiguyUPkYh9cNtNMGqLV971IkSXA/GZohRdG8wyURqVMxpEbMYCCnOt5CTcMWmjZbY+U5vLtns0e0Pws5eyyHONpI43mKB5sLBraNP1A1hGeAraHKNAFXIujjZEFPzDtl6o/ktDGbkh6gqE9Sb9D7Xi9MS9pLbQuc7mldiJbOzHDxfBdhwfhcfG6e01NLrjuWeRv/iI3tCxbt4Y5KaQrVdziRUqjk2b7oKJ69enI4BnBEie4Otxrraxb692TSeU4df1krAnDOHr+eiMixUR4EwojMaNvczV3i6q9t7KG9CkFVy6X0Pbdj1tQBXUk9fHnscP9KZbnGN3yJKNWtHAxozegQeoneWTTfwgDpJd4MhzB/+ZuJUI0kyrU465K1Kg7hAQETa/bLu/B7rGpk3PS9TFu7rqPJyL5kM6uH6ShXHR9bUzRIBFQ/PjKuOSE/8GBvWqGpo5ROabGEtmPLEZdIuS9peeWCNhGXO5Lou14cKnTCa6GBirFMi2fJAmZTTVdreXVjHYcUoDrbM4XSojKf4jxKROzi+eT7QIhKy2ValqIwsCSHljkd/2ugwGUT8v7HVvuM5aLazVrRo4NlWVrSgd63D69PUPMfhxsqBtXDSEIJHlpPObzwvvRkJs9AlbEB+MT3uum9bI7fcUqzUpt1ohSA2NB+eJUckF1huUwoJ5h0QP5bDwstAK20wm5Cr9wOAi/MoGJslqVjYkoX12uZHLCXtYvew9Y5DynQen9TfJxekwg2vpadJnhS99hJXuFpnVA6EvKhxO8IMOQfj8zzxLjLbS3jIznrFxU5sfQHb1uCVrvxU+PMyCACWmq3ag4t9kw5GPBwAKYpRmQOCIXt5ABrPRT85UGwo6qNmPbhehdaTcUM/pYI8b+BM3fRx+zOrxjIjxM67JACsmreouprJNgkG298hHtwF435cysSCPq4lzdzV04+hMYa9rfe0hnCQQ3k15xI9BcumlEBZFbvL545PWYN0Zg/GmRTJaVRxIynB3HAJw/ekR0QfZViIwr6/JWELNvO2coknEYjU5e4B/uw6Lut2qeh8BabQUDv5ZmsV8/c1u+IP4kd8GB1DGob6AzAbaFVctKzPRt3X+w6BuJ3fJfaE53BBWkWq3WVSegI7ZlkADjAFOWtQ7yW+ATf0IF/k9BhtpEGRPS5fPSfwh3Ptkf0/PcrtMQPqb1wgjzy+tl3o9CWfwvJW3hu8ac=","mac":"3aZYxqTeZujIHc58JnsVyg=="}
|
||||||
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 136 KiB |
@@ -1,176 +0,0 @@
|
|||||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
||||||
width="100%" viewBox="0 0 832 832" enable-background="new 0 0 832 832" xml:space="preserve">
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M217.385040,640.634888
|
|
||||||
C167.371597,596.268005 135.726517,541.600220 122.004700,476.575897
|
|
||||||
C120.362053,468.791779 119.680847,460.809143 118.293297,452.964630
|
|
||||||
C117.746704,449.874481 119.037468,448.979736 121.666008,448.977570
|
|
||||||
C143.829102,448.959259 165.992279,448.989624 188.155212,448.926971
|
|
||||||
C191.644348,448.917114 192.750092,450.959106 193.207932,453.864044
|
|
||||||
C197.968811,484.071350 208.669083,512.087463 225.487534,537.543823
|
|
||||||
C260.541687,590.601685 309.220367,623.665039 371.859955,635.771423
|
|
||||||
C373.328674,636.055237 374.787415,636.595581 376.258148,636.623108
|
|
||||||
C379.651733,636.686707 380.333496,638.606079 380.326355,641.533630
|
|
||||||
C380.273529,663.196899 380.204651,684.861206 380.380432,706.523193
|
|
||||||
C380.419128,711.290527 378.009888,711.674622 374.391205,711.179443
|
|
||||||
C327.438385,704.754150 284.132416,688.766541 244.939484,661.929932
|
|
||||||
C235.439224,655.424683 226.393066,648.348389 217.385040,640.634888
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M380.315796,138.009048
|
|
||||||
C380.315613,156.666809 380.196991,174.828186 380.405334,192.985779
|
|
||||||
C380.451416,197.002670 378.977386,198.602676 375.229797,199.226151
|
|
||||||
C335.021332,205.915405 299.223267,222.398804 268.394043,248.973557
|
|
||||||
C227.854797,283.918365 202.418610,327.743378 193.373978,380.728607
|
|
||||||
C192.710037,384.618042 191.495758,386.456116 187.107422,386.412689
|
|
||||||
C165.950577,386.203247 144.790512,386.328552 123.631622,386.305786
|
|
||||||
C121.848953,386.303894 119.952629,386.654358 118.105957,385.126953
|
|
||||||
C119.237549,371.494934 121.871552,358.007690 125.292259,344.674927
|
|
||||||
C139.522827,289.208862 167.430298,241.700974 209.076218,202.450302
|
|
||||||
C250.204315,163.687637 298.698975,138.912613 354.109436,127.776833
|
|
||||||
C361.426575,126.306313 368.881775,125.535194 376.239319,124.247482
|
|
||||||
C379.124939,123.742447 380.322876,124.656189 380.293793,127.515274
|
|
||||||
C380.259888,130.846863 380.304565,134.179245 380.315796,138.009048
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M585.821289,656.872925
|
|
||||||
C548.639404,683.801758 507.704041,700.996277 462.908630,709.058960
|
|
||||||
C458.167999,709.912231 453.382751,710.520142 448.614227,711.214783
|
|
||||||
C445.480774,711.671204 443.593689,710.956299 443.612610,707.120056
|
|
||||||
C443.721161,685.124817 443.705811,663.128479 443.617004,641.133057
|
|
||||||
C443.604034,637.914429 444.969086,637.012329 447.979034,636.501038
|
|
||||||
C484.623535,630.276062 517.888550,616.048584 547.155457,593.115906
|
|
||||||
C592.754639,557.385681 620.489868,510.765808 630.524475,453.708771
|
|
||||||
C631.162720,450.079681 632.684509,448.942596 636.058655,448.952362
|
|
||||||
C657.387817,449.014221 678.717224,448.964172 700.046387,449.024506
|
|
||||||
C705.170715,449.039001 705.935547,450.048218 705.135437,455.553528
|
|
||||||
C701.971558,477.322327 697.174194,498.695526 689.552612,519.381042
|
|
||||||
C673.613708,562.640137 648.921448,600.160706 615.603210,631.988220
|
|
||||||
C606.323730,640.852417 596.531738,649.141724 585.821289,656.872925
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M543.106384,152.777008
|
|
||||||
C623.864807,194.497498 675.672546,259.028137 698.780090,346.557220
|
|
||||||
C701.664368,357.482635 703.416565,368.647156 705.113098,379.808838
|
|
||||||
C705.972534,385.462982 705.255066,386.301849 699.637939,386.307220
|
|
||||||
C678.483643,386.327515 657.328979,386.246948 636.175415,386.367004
|
|
||||||
C632.515503,386.387756 631.252441,385.312256 630.465210,381.477020
|
|
||||||
C611.099548,287.129395 554.752502,227.317871 461.961639,201.788712
|
|
||||||
C457.494659,200.559738 452.832184,200.043533 448.263397,199.181366
|
|
||||||
C445.693939,198.696503 443.598297,198.054764 443.615936,194.581528
|
|
||||||
C443.730072,172.095444 443.680511,149.608551 443.709625,127.121956
|
|
||||||
C443.710663,126.324203 443.973877,125.526787 444.240295,124.019760
|
|
||||||
C478.926300,127.755081 511.672424,137.272491 543.106384,152.777008
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M701.000000,400.778809
|
|
||||||
C723.485535,400.781036 745.472717,400.925323 767.455505,400.679413
|
|
||||||
C772.544128,400.622498 774.256897,402.306488 774.059509,407.255646
|
|
||||||
C773.780884,414.239410 773.761230,421.255371 774.102234,428.234528
|
|
||||||
C774.338745,433.077240 772.593079,434.455170 767.814636,434.443237
|
|
||||||
C714.183533,434.309387 660.552002,434.383759 606.920532,434.387543
|
|
||||||
C570.777588,434.390106 534.634644,434.374756 498.491730,434.354248
|
|
||||||
C491.790222,434.350464 491.779114,434.321625 491.763947,427.753906
|
|
||||||
C491.748566,421.091644 491.746674,414.429291 491.760223,407.767029
|
|
||||||
C491.774384,400.795593 491.785461,400.786346 498.632294,400.783600
|
|
||||||
C544.268982,400.765198 589.905640,400.744354 635.542358,400.738556
|
|
||||||
C657.194885,400.735809 678.847473,400.764465 701.000000,400.778809
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M394.777466,672.000000
|
|
||||||
C394.776855,616.021362 394.775238,560.542725 394.776672,505.064087
|
|
||||||
C394.776855,497.793488 394.784149,497.790741 401.856598,497.780914
|
|
||||||
C407.687683,497.772827 413.518890,497.750397 419.349854,497.773285
|
|
||||||
C429.261841,497.812164 428.328613,496.935669 428.334534,506.517517
|
|
||||||
C428.361725,550.500610 428.347656,594.483643 428.344940,638.466736
|
|
||||||
C428.342194,683.449402 428.338684,728.432129 428.326843,773.414795
|
|
||||||
C428.325104,780.044495 428.302979,780.049255 421.686462,780.049927
|
|
||||||
C414.689178,780.050598 407.684692,779.846741 400.697113,780.104919
|
|
||||||
C396.084534,780.275330 394.677429,778.487915 394.696930,773.960876
|
|
||||||
C394.842468,740.141113 394.776855,706.320435 394.777466,672.000000
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M394.780304,122.000160
|
|
||||||
C394.780304,101.836891 394.773376,82.173622 394.786804,62.510368
|
|
||||||
C394.791473,55.707291 394.814545,55.700260 401.803131,55.690872
|
|
||||||
C408.635284,55.681694 415.483154,55.971924 422.294312,55.593998
|
|
||||||
C427.205994,55.321468 428.454407,57.120087 428.440277,61.853291
|
|
||||||
C428.289581,112.344139 428.346466,162.835602 428.344055,213.326889
|
|
||||||
C428.342163,252.486801 428.341461,291.646729 428.329010,330.806641
|
|
||||||
C428.326935,337.320618 428.300354,337.328125 421.669769,337.337067
|
|
||||||
C414.171082,337.347198 406.670898,337.253967 399.174469,337.384735
|
|
||||||
C395.948486,337.440979 394.707306,336.154388 394.750397,332.963135
|
|
||||||
C394.849396,325.632660 394.734802,318.299561 394.736145,310.967529
|
|
||||||
C394.747528,248.145081 394.765411,185.322617 394.780304,122.000160
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M109.999901,400.740662
|
|
||||||
C181.795898,400.739990 253.091904,400.739319 324.387909,400.742310
|
|
||||||
C331.320068,400.742584 331.332153,400.752899 331.343597,407.525208
|
|
||||||
C331.355713,414.688080 331.146423,421.858337 331.413605,429.011169
|
|
||||||
C331.569092,433.173920 330.074554,434.435059 325.972107,434.415558
|
|
||||||
C298.820374,434.286438 271.667572,434.380585 244.515137,434.382446
|
|
||||||
C182.214432,434.386749 119.913734,434.382141 57.613033,434.374512
|
|
||||||
C49.791779,434.373535 49.788113,434.354919 49.774273,426.342194
|
|
||||||
C49.762764,419.679016 49.974655,413.006439 49.680656,406.355988
|
|
||||||
C49.482746,401.879120 51.266327,400.643585 55.529621,400.684052
|
|
||||||
C73.518280,400.854736 91.509567,400.747375 109.999901,400.740662
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M355.006714,289.079895
|
|
||||||
C314.542847,307.902771 288.356110,338.559448 276.091980,381.015442
|
|
||||||
C274.888428,385.182037 273.095215,386.842010 268.864868,386.370209
|
|
||||||
C266.231445,386.076508 263.534729,386.212646 260.874268,386.331818
|
|
||||||
C257.080597,386.501678 256.319031,384.836212 257.247894,381.392822
|
|
||||||
C273.855225,319.828796 312.712891,280.391144 374.326569,263.599457
|
|
||||||
C380.012299,262.049927 380.234985,262.392334 380.309387,268.251495
|
|
||||||
C380.459137,280.039276 380.432434,279.958344 369.353027,283.609314
|
|
||||||
C364.617004,285.169952 360.018280,287.147278 355.006714,289.079895
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M530.844788,522.827209
|
|
||||||
C507.250580,548.878845 478.829315,565.771240 443.768250,573.063721
|
|
||||||
C443.768250,567.065430 443.631561,561.955872 443.824524,556.858826
|
|
||||||
C443.924438,554.220093 446.501617,554.235901 448.316559,553.728210
|
|
||||||
C477.592224,545.538330 501.883942,529.704346 521.112183,506.177460
|
|
||||||
C533.607300,490.888947 542.482056,473.665497 547.554810,454.587372
|
|
||||||
C548.635681,450.522400 550.318359,448.476959 554.665283,448.970612
|
|
||||||
C558.553711,449.412201 562.612244,448.140808 566.989685,450.238983
|
|
||||||
C561.468018,477.622711 549.265564,501.550690 530.844788,522.827209
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M321.429260,525.557129
|
|
||||||
C337.614563,538.831970 355.341278,548.432312 375.303497,553.634033
|
|
||||||
C378.937042,554.580811 380.806030,556.076660 380.342194,560.065674
|
|
||||||
C379.868652,564.138123 380.930969,568.329590 379.559998,572.810181
|
|
||||||
C371.784576,572.006714 364.506714,569.613953 357.468445,566.874451
|
|
||||||
C305.258423,546.553284 271.903625,509.263031 257.610077,455.037445
|
|
||||||
C256.168457,449.568359 256.639526,449.089569 262.330505,448.970734
|
|
||||||
C273.943176,448.728271 273.961517,448.722382 277.490479,459.732086
|
|
||||||
C285.826874,485.740204 300.358704,507.617676 321.429260,525.557129
|
|
||||||
z"/>
|
|
||||||
<path fill="#000000" opacity="1.000000" stroke="none"
|
|
||||||
d="
|
|
||||||
M478.263367,293.780090
|
|
||||||
C468.371307,288.450684 458.355194,284.368042 447.821228,281.748016
|
|
||||||
C444.510101,280.924408 443.492584,279.381256 443.613556,276.231689
|
|
||||||
C443.777985,271.950439 443.654541,267.658112 443.654541,262.501068
|
|
||||||
C470.685822,267.855408 493.812103,279.232391 514.055847,296.378204
|
|
||||||
C541.776123,319.856445 559.376709,349.468872 567.201355,385.734680
|
|
||||||
C561.265930,386.723236 555.849548,386.557587 550.500671,385.988373
|
|
||||||
C548.103027,385.733246 548.268616,382.943359 547.763672,381.134033
|
|
||||||
C540.945984,356.703400 528.606750,335.492645 510.620270,317.629517
|
|
||||||
C501.116150,308.190613 490.407288,300.304352 478.263367,293.780090
|
|
||||||
z"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 9.7 KiB |
@@ -1,305 +0,0 @@
|
|||||||
<?xml version="1.0" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
|
||||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
|
||||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="1200.000000pt" height="1200.000000pt" viewBox="0 0 1200.000000 1200.000000"
|
|
||||||
preserveAspectRatio="xMidYMid meet">
|
|
||||||
|
|
||||||
<g transform="translate(0.000000,1200.000000) scale(0.100000,-0.100000)"
|
|
||||||
fill="#000000" stroke="none">
|
|
||||||
<path d="M5690 11129 c-1618 -101 -3089 -960 -3983 -2324 -1118 -1707 -1114
|
|
||||||
-3907 10 -5615 772 -1173 1991 -1982 3363 -2234 1190 -218 2415 -9 3461 590
|
|
||||||
1414 809 2363 2232 2559 3838 63 520 48 1033 -46 1546 -273 1484 -1193 2779
|
|
||||||
-2513 3534 -860 493 -1864 727 -2851 665z m810 -44 c1443 -151 2716 -868 3584
|
|
||||||
-2020 199 -263 344 -500 501 -820 288 -585 439 -1126 507 -1810 19 -193 16
|
|
||||||
-720 -6 -920 -71 -662 -237 -1232 -526 -1805 -440 -870 -1112 -1589 -1960
|
|
||||||
-2097 -163 -97 -547 -286 -725 -356 -1125 -441 -2339 -473 -3480 -92 -1534
|
|
||||||
512 -2743 1728 -3243 3265 -115 354 -185 686 -228 1085 -25 224 -25 756 0 980
|
|
||||||
54 500 159 934 333 1380 70 177 258 562 356 725 508 848 1227 1520 2097 1960
|
|
||||||
636 321 1312 502 2030 544 136 8 621 -4 760 -19z"/>
|
|
||||||
<path d="M5988 10916 c-21 -18 -38 -38 -38 -45 0 -14 27 -15 35 -1 16 27 25 3
|
|
||||||
25 -70 0 -79 0 -80 25 -80 l25 0 0 115 c0 132 -6 139 -72 81z"/>
|
|
||||||
<path d="M5675 10549 c-1290 -97 -2468 -731 -3271 -1760 -751 -962 -1082
|
|
||||||
-2211 -908 -3429 65 -460 207 -921 414 -1345 227 -465 503 -849 879 -1226 459
|
|
||||||
-458 962 -790 1551 -1022 399 -157 774 -248 1240 -299 151 -16 699 -16 850 0
|
|
||||||
585 64 1074 202 1565 442 467 228 845 499 1221 874 196 196 295 309 439 502
|
|
||||||
942 1255 1166 2923 589 4380 -342 866 -936 1605 -1704 2119 -672 451 -1413
|
|
||||||
705 -2225 765 -160 11 -478 11 -640 -1z m646 -29 c609 -47 1173 -201 1699
|
|
||||||
-465 1131 -567 1977 -1579 2331 -2790 317 -1083 210 -2266 -296 -3275 -541
|
|
||||||
-1079 -1496 -1907 -2636 -2283 -914 -303 -1914 -303 -2828 0 -586 193 -1135
|
|
||||||
512 -1608 934 -577 515 -1031 1209 -1276 1950 -302 913 -303 1914 -1 2826 228
|
|
||||||
691 633 1334 1157 1839 766 739 1753 1183 2807 1263 157 12 498 12 651 1z"/>
|
|
||||||
<path d="M5955 10355 c-14 -13 -25 -29 -25 -35 0 -16 47 -12 54 6 8 21 50 14
|
|
||||||
54 -10 3 -11 -12 -34 -36 -60 -95 -99 -94 -116 3 -116 68 0 75 2 75 20 0 17
|
|
||||||
-7 20 -40 20 -22 0 -40 3 -40 6 0 4 18 26 40 50 31 33 40 52 40 78 0 64 -78
|
|
||||||
89 -125 41z"/>
|
|
||||||
<path d="M5705 9980 c-566 -50 -1040 -186 -1527 -437 -1077 -556 -1847 -1580
|
|
||||||
-2082 -2769 -229 -1158 67 -2350 814 -3274 419 -519 986 -939 1600 -1188 1339
|
|
||||||
-542 2857 -318 3985 586 745 597 1258 1454 1429 2387 48 266 60 408 60 720 0
|
|
||||||
328 -13 475 -70 766 -285 1461 -1377 2651 -2814 3065 -178 51 -455 106 -650
|
|
||||||
129 -158 19 -599 28 -745 15z m750 -45 c919 -112 1725 -509 2370 -1167 628
|
|
||||||
-639 1000 -1417 1112 -2323 24 -197 24 -683 0 -880 -116 -933 -508 -1732
|
|
||||||
-1169 -2380 -648 -636 -1452 -1016 -2363 -1117 -158 -17 -642 -17 -800 0 -543
|
|
||||||
60 -1058 223 -1520 481 -681 381 -1254 976 -1608 1671 -594 1167 -567 2562 72
|
|
||||||
3705 381 681 976 1254 1671 1608 425 216 929 364 1385 406 66 6 136 13 155 15
|
|
||||||
84 10 573 -4 695 -19z"/>
|
|
||||||
<path d="M5946 9798 c-9 -12 -16 -26 -16 -30 0 -14 33 -9 51 8 21 19 49 12 49
|
|
||||||
-11 0 -8 -9 -20 -20 -27 -26 -17 -25 -31 2 -43 27 -12 35 -40 18 -60 -16 -19
|
|
||||||
-46 -19 -54 0 -7 19 -46 20 -46 1 0 -20 48 -56 75 -56 12 0 34 9 49 21 33 26
|
|
||||||
36 81 6 102 -18 13 -19 16 -5 27 20 17 19 53 -3 73 -28 25 -87 22 -106 -5z"/>
|
|
||||||
<path d="M5805 9439 c-1522 -84 -2826 -1194 -3159 -2689 -401 -1802 704 -3605
|
|
||||||
2499 -4075 468 -123 989 -142 1479 -54 1091 196 2053 947 2511 1960 695 1536
|
|
||||||
187 3329 -1210 4276 -430 291 -915 478 -1433 553 -128 18 -440 42 -517 38 -16
|
|
||||||
0 -93 -4 -170 -9z m570 -44 c635 -70 1212 -305 1735 -708 134 -104 471 -441
|
|
||||||
576 -577 411 -531 644 -1111 715 -1780 7 -63 12 -209 12 -325 0 -300 -28 -537
|
|
||||||
-98 -821 -306 -1244 -1314 -2228 -2570 -2509 -522 -117 -1078 -106 -1600 30
|
|
||||||
-482 126 -932 358 -1322 682 -118 98 -345 325 -443 443 -324 391 -564 864
|
|
||||||
-685 1353 -71 290 -98 515 -98 822 0 307 27 532 98 822 121 489 361 962 685
|
|
||||||
1353 98 118 325 345 443 443 579 481 1254 744 2032 791 102 6 383 -4 520 -19z"/>
|
|
||||||
<path d="M6038 9262 c-24 -5 -118 -140 -118 -170 0 -22 3 -23 48 -21 42 3 47
|
|
||||||
1 50 -19 4 -29 42 -31 42 -2 0 11 7 20 15 20 8 0 15 9 15 20 0 11 -7 20 -15
|
|
||||||
20 -11 0 -15 18 -17 78 -3 67 -5 77 -20 74z m-18 -112 c0 -36 -2 -40 -25 -40
|
|
||||||
-14 0 -25 5 -25 11 0 11 38 69 46 69 2 0 4 -18 4 -40z"/>
|
|
||||||
<path d="M5840 8869 c-1028 -50 -1973 -686 -2425 -1632 -189 -395 -277 -787
|
|
||||||
-277 -1232 0 -445 88 -837 277 -1232 504 -1054 1588 -1697 2749 -1632 1035 58
|
|
||||||
1946 660 2415 1598 278 555 363 1218 236 1847 -158 785 -665 1488 -1368 1899
|
|
||||||
-487 284 -1023 412 -1607 384z m330 -29 c419 -28 750 -118 1122 -307 435 -219
|
|
||||||
819 -564 1090 -978 93 -141 207 -363 271 -525 224 -568 253 -1219 81 -1812
|
|
||||||
-308 -1061 -1219 -1859 -2311 -2022 -262 -40 -574 -40 -837 0 -1003 150 -1864
|
|
||||||
840 -2230 1786 -254 657 -255 1387 -1 2042 397 1029 1363 1741 2462 1815 171
|
|
||||||
12 193 12 353 1z"/>
|
|
||||||
<path d="M5945 8674 c-3 -26 -9 -52 -11 -59 -7 -18 24 -27 46 -12 39 23 79
|
|
||||||
-33 50 -69 -16 -18 -46 -18 -54 1 -7 18 -46 20 -46 3 0 -21 14 -36 43 -47 59
|
|
||||||
-23 107 13 107 80 0 44 -25 69 -69 69 -26 0 -32 4 -29 18 2 12 15 18 46 20 34
|
|
||||||
3 42 7 42 23 0 17 -7 19 -59 19 l-59 0 -7 -46z"/>
|
|
||||||
<path d="M5825 8350 c-309 -26 -571 -98 -850 -235 -681 -332 -1162 -974 -1289
|
|
||||||
-1720 -82 -479 -9 -975 209 -1420 232 -476 604 -848 1080 -1081 570 -278 1202
|
|
||||||
-316 1806 -109 57 20 172 69 254 110 474 231 849 606 1081 1080 165 338 237
|
|
||||||
652 237 1030 0 378 -72 692 -237 1030 -341 697 -1004 1183 -1766 1295 -152 22
|
|
||||||
-390 31 -525 20z m504 -45 c996 -144 1792 -917 1965 -1909 98 -562 -25 -1164
|
|
||||||
-336 -1643 -372 -573 -956 -948 -1633 -1049 -165 -24 -475 -24 -640 0 -1033
|
|
||||||
154 -1827 948 -1981 1981 -24 165 -24 475 0 640 75 506 305 963 662 1321 388
|
|
||||||
388 887 621 1444 674 124 11 386 4 519 -15z"/>
|
|
||||||
<path d="M5959 8161 c-26 -26 -29 -36 -29 -94 0 -83 23 -117 79 -117 48 0 71
|
|
||||||
24 71 73 0 51 -31 81 -76 74 -38 -6 -37 -7 -24 27 10 26 45 36 52 15 2 -6 15
|
|
||||||
-9 28 -7 l25 3 -27 28 c-35 35 -62 34 -99 -2z m69 -103 c30 -30 -1 -94 -33
|
|
||||||
-68 -15 13 -21 61 -8 73 10 11 28 8 41 -5z"/>
|
|
||||||
<path d="M5739 7785 c-677 -110 -1226 -572 -1438 -1210 -74 -223 -85 -298 -85
|
|
||||||
-570 0 -272 11 -347 85 -570 178 -534 600 -956 1134 -1134 223 -74 298 -85
|
|
||||||
570 -85 272 0 347 11 570 85 534 178 956 600 1134 1134 74 223 85 298 85 570
|
|
||||||
0 212 -2 252 -22 345 -158 730 -691 1264 -1417 1420 -130 28 -483 37 -616 15z
|
|
||||||
m341 -169 c0 -7 -16 -43 -35 -80 -19 -37 -35 -78 -35 -91 0 -37 -11 -55 -32
|
|
||||||
-55 -19 0 -20 4 -14 46 3 26 19 71 35 100 l29 54 -49 0 c-42 0 -49 3 -49 20 0
|
|
||||||
18 7 20 75 20 57 0 75 -3 75 -14z m175 -381 c433 -91 792 -405 936 -820 50
|
|
||||||
-145 64 -235 64 -410 0 -175 -14 -265 -64 -410 -125 -359 -422 -655 -781 -778
|
|
||||||
-140 -48 -232 -62 -405 -62 -173 0 -265 14 -405 62 -360 123 -660 423 -783
|
|
||||||
783 -48 140 -62 232 -62 405 0 173 14 265 62 405 123 360 423 660 783 783 66
|
|
||||||
23 175 48 265 61 64 9 313 -2 390 -19z m-1675 -1124 c0 -5 -16 -35 -35 -67
|
|
||||||
-20 -33 -37 -77 -41 -106 -6 -43 -9 -48 -31 -48 -24 0 -25 2 -19 38 4 20 19
|
|
||||||
63 35 95 l28 57 -49 0 c-41 0 -48 3 -48 20 0 18 7 20 80 20 44 0 80 -4 80 -9z
|
|
||||||
m3010 -6 c0 -8 -13 -35 -30 -61 -16 -26 -34 -71 -40 -100 -9 -44 -15 -54 -32
|
|
||||||
-54 -18 0 -20 5 -15 38 4 32 24 84 55 145 2 4 -19 7 -47 7 -44 0 -51 3 -51 20
|
|
||||||
0 18 7 20 80 20 64 0 80 -3 80 -15z m-1510 -1505 c0 -11 -11 -37 -24 -58 -14
|
|
||||||
-20 -30 -59 -37 -87 -6 -27 -13 -56 -15 -62 -6 -22 -44 -15 -44 7 0 31 37 130
|
|
||||||
56 151 16 18 15 19 -34 19 -49 0 -52 2 -52 25 0 24 2 25 75 25 69 0 75 -2 75
|
|
||||||
-20z"/>
|
|
||||||
<path d="M5801 7194 c-498 -84 -904 -493 -986 -994 -118 -732 449 -1400 1190
|
|
||||||
-1400 664 0 1205 541 1205 1205 0 669 -546 1210 -1215 1204 -60 -1 -148 -7
|
|
||||||
-194 -15z m259 -134 c24 -24 25 -38 5 -67 -13 -18 -13 -22 0 -33 9 -7 15 -29
|
|
||||||
15 -51 0 -44 -27 -69 -75 -69 -48 0 -75 25 -75 69 0 22 6 44 15 51 14 12 14
|
|
||||||
15 0 30 -34 38 0 90 60 90 22 0 43 -8 55 -20z m124 -376 c235 -61 437 -263
|
|
||||||
502 -504 24 -89 24 -263 0 -350 -54 -197 -190 -362 -372 -454 -104 -52 -182
|
|
||||||
-69 -309 -69 -127 0 -205 17 -309 70 -140 69 -250 180 -320 319 -52 104 -69
|
|
||||||
182 -69 309 0 127 17 205 69 309 105 209 296 349 529 387 67 11 204 2 279 -17z
|
|
||||||
m-1076 -581 c16 -22 15 -58 -2 -72 -13 -11 -12 -15 5 -32 26 -26 24 -65 -7
|
|
||||||
-96 -21 -21 -32 -24 -62 -19 -65 10 -94 74 -53 115 17 17 18 21 5 32 -23 19
|
|
||||||
-14 71 16 87 30 15 80 8 98 -15z m1910 0 c16 -22 15 -58 -2 -72 -13 -11 -12
|
|
||||||
-15 5 -32 24 -24 24 -60 0 -90 -14 -18 -29 -24 -61 -24 -32 0 -47 6 -61 24
|
|
||||||
-24 30 -24 66 0 90 17 17 18 21 5 32 -23 19 -14 71 16 87 30 15 80 8 98 -15z
|
|
||||||
m-958 -953 c24 -24 25 -38 5 -67 -13 -18 -13 -22 0 -33 9 -7 15 -29 15 -51 0
|
|
||||||
-44 -27 -69 -75 -69 -48 0 -75 25 -75 69 0 22 6 44 15 51 14 12 14 15 0 30
|
|
||||||
-19 21 -19 40 1 68 20 29 85 31 114 2z"/>
|
|
||||||
<path d="M5982 7018 c2 -15 10 -23 23 -23 13 0 21 8 23 23 3 18 -1 22 -23 22
|
|
||||||
-22 0 -26 -4 -23 -22z"/>
|
|
||||||
<path d="M5980 6935 c-18 -21 -3 -55 25 -55 15 0 26 7 30 20 7 23 -10 50 -30
|
|
||||||
50 -7 0 -18 -7 -25 -15z"/>
|
|
||||||
<path d="M5893 6650 c-236 -43 -428 -211 -509 -445 -24 -70 -28 -95 -28 -200
|
|
||||||
0 -105 4 -130 28 -200 70 -204 212 -347 415 -419 77 -27 98 -30 206 -30 108 0
|
|
||||||
129 3 206 30 203 72 345 215 415 419 24 70 28 95 28 200 0 105 -4 130 -28 200
|
|
||||||
-70 203 -214 349 -412 417 -92 32 -231 44 -321 28z m195 -528 c89 -64 76 -200
|
|
||||||
-24 -247 -130 -61 -259 96 -175 213 44 63 136 78 199 34z"/>
|
|
||||||
<path d="M5026 6073 c-4 -9 -1 -23 7 -30 18 -18 51 5 41 30 -8 22 -40 22 -48
|
|
||||||
0z"/>
|
|
||||||
<path d="M5027 5984 c-15 -16 -7 -53 14 -59 27 -9 42 6 37 36 -3 24 -36 38
|
|
||||||
-51 23z"/>
|
|
||||||
<path d="M6933 6074 c-3 -8 1 -22 9 -30 19 -19 52 3 42 29 -8 21 -43 22 -51 1z"/>
|
|
||||||
<path d="M6934 5976 c-11 -29 0 -51 26 -51 21 0 25 5 25 30 0 24 -5 31 -23 33
|
|
||||||
-13 2 -24 -3 -28 -12z"/>
|
|
||||||
<path d="M5982 5108 c2 -15 10 -23 23 -23 13 0 21 8 23 23 3 18 -1 22 -23 22
|
|
||||||
-22 0 -26 -4 -23 -22z"/>
|
|
||||||
<path d="M5980 5025 c-18 -21 -3 -55 25 -55 15 0 26 7 30 20 7 23 -10 50 -30
|
|
||||||
50 -7 0 -18 -7 -25 -15z"/>
|
|
||||||
<path d="M3924 6120 c-37 -15 -54 -50 -54 -112 0 -71 15 -104 52 -117 55 -19
|
|
||||||
98 15 98 78 0 45 -33 75 -76 68 -38 -6 -37 -7 -24 27 11 29 26 33 49 12 9 -8
|
|
||||||
24 -11 34 -7 18 7 18 7 0 28 -22 26 -51 34 -79 23z m44 -122 c17 -17 15 -53
|
|
||||||
-3 -68 -31 -26 -60 13 -44 58 9 24 29 28 47 10z"/>
|
|
||||||
<path d="M8044 6120 c-38 -15 -54 -50 -54 -117 0 -50 4 -67 23 -89 48 -55 127
|
|
||||||
-25 127 48 0 52 -30 82 -75 75 -29 -5 -32 -3 -27 19 5 29 39 42 55 21 7 -9 19
|
|
||||||
-12 30 -8 18 7 18 7 0 28 -22 26 -51 34 -79 23z m44 -122 c17 -17 15 -67 -3
|
|
||||||
-74 -22 -9 -45 14 -45 46 0 40 23 53 48 28z"/>
|
|
||||||
<path d="M5951 4034 c-16 -20 -21 -41 -21 -85 0 -69 13 -103 47 -118 34 -16
|
|
||||||
47 -14 77 10 20 16 26 29 26 60 0 54 -30 83 -77 76 -28 -5 -34 -3 -29 9 3 9 6
|
|
||||||
19 6 24 0 17 34 20 51 4 12 -10 23 -13 33 -7 14 8 14 11 0 31 -23 33 -86 31
|
|
||||||
-113 -4z m78 -98 c7 -8 11 -27 9 -43 -2 -22 -8 -28 -28 -28 -20 0 -26 6 -28
|
|
||||||
28 -6 53 20 76 47 43z"/>
|
|
||||||
<path d="M3357 6113 c-3 -5 -8 -32 -12 -61 l-7 -52 49 2 48 3 0 -34 c0 -43
|
|
||||||
-29 -65 -49 -38 -14 18 -56 24 -56 7 0 -24 41 -50 78 -50 51 0 77 28 77 82 0
|
|
||||||
47 -34 82 -72 75 -17 -3 -23 0 -23 14 0 16 8 19 45 19 38 0 45 3 45 20 0 18
|
|
||||||
-7 20 -59 20 -33 0 -62 -3 -64 -7z"/>
|
|
||||||
<path d="M8541 6070 c-16 -73 -16 -72 34 -64 41 6 46 4 54 -17 18 -49 -20 -87
|
|
||||||
-53 -54 -9 9 -25 15 -37 13 l-21 -3 22 -27 c46 -59 140 -22 140 54 0 39 -43
|
|
||||||
82 -76 75 -18 -3 -24 0 -24 14 0 16 8 19 45 19 38 0 45 3 45 20 0 18 -7 20
|
|
||||||
-59 20 l-59 0 -11 -50z"/>
|
|
||||||
<path d="M5943 3468 c-6 -35 -9 -65 -6 -68 2 -2 17 1 34 7 36 14 56 8 64 -18
|
|
||||||
16 -49 -23 -81 -56 -48 -20 20 -49 20 -49 -1 0 -5 9 -19 20 -30 47 -47 130 -6
|
|
||||||
130 65 0 44 -29 75 -71 75 -24 0 -30 3 -25 16 3 9 6 18 6 20 0 2 18 4 40 4 33
|
|
||||||
0 40 3 40 20 0 18 -7 20 -59 20 l-58 0 -10 -62z"/>
|
|
||||||
<path d="M2831 6048 c-28 -40 -51 -82 -51 -95 0 -21 4 -23 50 -23 43 0 50 -3
|
|
||||||
50 -20 0 -13 7 -20 20 -20 13 0 20 7 20 20 0 11 7 20 15 20 8 0 15 9 15 20 0
|
|
||||||
11 -7 20 -15 20 -12 0 -15 15 -15 75 0 67 -2 75 -19 75 -13 0 -37 -25 -70 -72z
|
|
||||||
m46 -75 c-3 -2 -17 -3 -31 -1 l-26 3 27 40 28 40 3 -39 c2 -21 1 -40 -1 -43z"/>
|
|
||||||
<path d="M9110 6045 c-27 -41 -50 -83 -50 -95 0 -17 6 -20 50 -20 43 0 50 -3
|
|
||||||
50 -20 0 -13 7 -20 20 -20 13 0 20 7 20 20 0 11 7 20 15 20 8 0 15 9 15 20 0
|
|
||||||
11 -7 20 -15 20 -12 0 -15 15 -15 75 0 68 -2 75 -20 75 -13 0 -36 -24 -70 -75z
|
|
||||||
m50 -35 c0 -36 -2 -40 -25 -40 -14 0 -25 3 -25 6 0 9 41 74 46 74 2 0 4 -18 4
|
|
||||||
-40z"/>
|
|
||||||
<path d="M5970 2905 c-27 -41 -50 -83 -50 -95 0 -17 6 -20 50 -20 45 0 50 -2
|
|
||||||
50 -23 0 -16 6 -23 20 -24 15 -1 20 4 20 23 0 15 6 24 15 24 8 0 15 9 15 20 0
|
|
||||||
11 -7 20 -15 20 -12 0 -15 15 -15 75 0 68 -2 75 -20 75 -13 0 -36 -24 -70 -75z
|
|
||||||
m50 -35 c0 -38 -2 -40 -30 -40 l-30 0 26 40 c15 22 28 40 30 40 2 0 4 -18 4
|
|
||||||
-40z"/>
|
|
||||||
<path d="M2273 6120 c-12 -5 -27 -18 -33 -30 -15 -28 13 -39 40 -15 21 19 50
|
|
||||||
14 50 -10 0 -8 -9 -20 -20 -27 -26 -17 -25 -31 3 -43 27 -12 30 -53 5 -68 -13
|
|
||||||
-9 -21 -7 -36 6 -20 18 -52 23 -52 8 0 -5 8 -19 19 -32 23 -29 81 -31 111 -4
|
|
||||||
27 24 27 79 0 98 -18 13 -19 16 -5 27 18 15 20 50 3 73 -16 20 -57 29 -85 17z"/>
|
|
||||||
<path d="M9680 6123 c-24 -9 -50 -35 -50 -50 0 -18 36 -17 44 2 8 21 42 19 51
|
|
||||||
-2 4 -12 -1 -24 -14 -35 -24 -19 -27 -38 -6 -38 22 0 38 -36 25 -60 -13 -24
|
|
||||||
-33 -26 -54 -5 -18 19 -46 20 -46 2 0 -17 28 -43 57 -51 26 -8 78 16 87 39 12
|
|
||||||
32 6 64 -14 78 -18 13 -19 16 -5 27 43 36 -19 113 -75 93z"/>
|
|
||||||
<path d="M5955 2406 c-26 -26 -26 -46 1 -46 8 0 17 7 20 15 8 20 43 19 51 -2
|
|
||||||
4 -10 -2 -23 -15 -34 -28 -22 -28 -32 1 -44 27 -12 30 -53 4 -69 -15 -9 -22
|
|
||||||
-7 -35 9 -18 22 -52 22 -52 1 0 -44 94 -62 130 -26 26 26 26 75 0 93 -18 13
|
|
||||||
-19 16 -5 27 35 29 10 86 -42 96 -26 5 -37 1 -58 -20z"/>
|
|
||||||
<path d="M1697 6102 c-21 -24 -22 -52 -1 -52 9 0 24 10 33 22 22 27 51 18 51
|
|
||||||
-15 0 -13 -12 -34 -26 -48 -31 -28 -84 -98 -84 -111 0 -4 36 -8 80 -8 73 0 80
|
|
||||||
2 80 20 0 17 -7 20 -46 20 l-47 0 47 50 c51 55 58 88 26 120 -26 26 -90 27
|
|
||||||
-113 2z"/>
|
|
||||||
<path d="M10212 6104 c-27 -18 -30 -54 -4 -54 9 0 23 9 30 20 15 25 38 26 51
|
|
||||||
2 12 -22 -1 -44 -59 -107 -64 -69 -62 -75 30 -75 73 0 80 2 80 20 0 17 -7 20
|
|
||||||
-46 20 l-47 0 47 50 c49 52 56 81 30 118 -18 27 -78 30 -112 6z"/>
|
|
||||||
<path d="M5973 1860 c-19 -8 -43 -38 -43 -54 0 -14 48 -5 54 10 9 23 50 14 54
|
|
||||||
-12 2 -13 -16 -42 -53 -83 -75 -84 -73 -91 20 -91 68 0 75 2 75 20 0 17 -7 20
|
|
||||||
-40 20 -22 0 -40 3 -40 6 0 4 18 26 40 50 31 33 40 52 40 78 0 54 -48 79 -107
|
|
||||||
56z"/>
|
|
||||||
<path d="M1158 6086 c-21 -18 -38 -38 -38 -45 0 -14 27 -15 35 -1 16 27 25 3
|
|
||||||
25 -70 0 -79 0 -80 25 -80 l25 0 0 115 c0 132 -6 139 -72 81z"/>
|
|
||||||
<path d="M10818 6086 c-21 -18 -38 -38 -38 -45 0 -14 27 -15 35 -1 16 27 25 3
|
|
||||||
25 -70 0 -79 0 -80 25 -80 l25 0 0 115 c0 132 -6 139 -72 81z"/>
|
|
||||||
<path d="M5988 1256 c-21 -18 -38 -38 -38 -45 0 -14 27 -15 35 -1 16 27 25 3
|
|
||||||
25 -70 0 -79 0 -80 25 -80 l25 0 0 115 c0 132 -6 139 -72 81z"/>
|
|
||||||
<path d="M10760 1064 c0 -3 5 -14 10 -25 14 -25 52 -24 75 1 22 25 11 39 -17
|
|
||||||
21 -14 -9 -23 -10 -31 -2 -12 12 -37 15 -37 5z"/>
|
|
||||||
<path d="M8445 993 c-33 -9 -65 -45 -65 -74 0 -28 17 -51 51 -69 33 -18 22
|
|
||||||
-32 -23 -28 -42 3 -43 2 -46 -30 l-3 -32 50 0 c64 0 98 13 112 44 17 37 4 71
|
|
||||||
-37 95 -42 25 -36 46 11 37 29 -6 33 -4 39 20 4 14 5 28 3 31 -8 7 -71 12 -92
|
|
||||||
6z"/>
|
|
||||||
<path d="M9395 993 c-56 -15 -85 -87 -47 -118 9 -7 28 -23 42 -35 l25 -20 -49
|
|
||||||
2 c-46 2 -50 0 -57 -24 -9 -35 -5 -38 52 -38 62 0 97 14 110 44 17 37 4 71
|
|
||||||
-37 95 -42 25 -36 46 11 37 29 -6 33 -4 39 20 4 14 5 28 3 31 -8 7 -71 12 -92
|
|
||||||
6z"/>
|
|
||||||
<path d="M9815 992 c-35 -12 -52 -26 -74 -62 -46 -77 -9 -170 69 -170 85 0
|
|
||||||
130 46 130 133 0 61 -11 82 -51 96 -35 12 -44 12 -74 3z m53 -94 c4 -49 -12
|
|
||||||
-78 -43 -78 -30 0 -41 33 -25 75 22 58 63 60 68 3z"/>
|
|
||||||
<path d="M10770 987 c-69 -24 -75 -98 -10 -132 42 -22 37 -35 -14 -35 -36 0
|
|
||||||
-45 -4 -49 -22 -9 -33 -1 -38 59 -38 48 0 60 4 85 29 16 16 29 37 29 47 0 9
|
|
||||||
-18 34 -40 54 -22 20 -40 40 -40 45 0 4 16 5 35 2 32 -5 37 -3 46 20 5 14 8
|
|
||||||
28 6 30 -12 11 -76 11 -107 0z"/>
|
|
||||||
<path d="M11395 993 c-31 -7 -73 -52 -86 -90 -25 -76 14 -143 83 -143 82 0
|
|
||||||
128 52 128 142 -1 49 -15 73 -54 88 -28 10 -38 11 -71 3z m53 -95 c4 -48 -12
|
|
||||||
-78 -43 -78 -29 0 -38 24 -25 70 18 62 63 68 68 8z"/>
|
|
||||||
<path d="M8567 968 c-8 -27 -1 -38 24 -38 21 0 20 -6 -1 -128 l-8 -43 37 3
|
|
||||||
c35 3 36 4 43 53 15 109 17 115 42 115 23 0 36 17 36 46 0 11 -18 14 -84 14
|
|
||||||
-77 0 -84 -2 -89 -22z"/>
|
|
||||||
<path d="M8765 968 c-2 -13 -9 -52 -15 -88 -6 -36 -13 -77 -16 -92 -5 -26 -3
|
|
||||||
-28 29 -28 33 0 36 2 42 40 8 50 19 51 31 3 8 -35 12 -38 47 -41 42 -4 43 0
|
|
||||||
21 53 -15 37 -15 38 10 64 14 15 26 39 26 52 0 43 -28 59 -103 59 -61 0 -67
|
|
||||||
-2 -72 -22z m101 -39 c10 -16 -23 -46 -36 -33 -6 6 -8 18 -4 27 7 19 29 22 40
|
|
||||||
6z"/>
|
|
||||||
<path d="M8974 953 c-3 -21 -12 -69 -20 -106 -8 -38 -14 -73 -14 -78 0 -5 35
|
|
||||||
-9 79 -9 73 0 79 2 85 23 9 36 8 37 -40 37 -54 0 -57 23 -3 28 36 4 49 15 49
|
|
||||||
45 0 13 -8 17 -35 17 -19 0 -35 5 -35 10 0 6 18 10 39 10 38 0 51 11 51 46 0
|
|
||||||
11 -17 14 -75 14 l-74 0 -7 -37z"/>
|
|
||||||
<path d="M9165 978 c-2 -7 -9 -47 -15 -88 -6 -41 -13 -87 -16 -102 l-6 -28 75
|
|
||||||
0 c59 0 76 3 81 16 14 35 7 44 -35 44 -41 0 -41 0 -35 32 3 18 9 56 13 85 l6
|
|
||||||
53 -32 0 c-17 0 -33 -6 -36 -12z"/>
|
|
||||||
<path d="M9530 987 c0 -2 -9 -52 -20 -112 -11 -60 -20 -110 -20 -112 0 -2 15
|
|
||||||
-3 34 -3 32 0 35 2 41 41 8 48 26 47 38 -4 9 -35 11 -37 49 -37 28 0 39 4 36
|
|
||||||
13 -3 6 -13 36 -22 65 l-18 53 36 44 c20 24 36 46 36 49 0 3 -17 6 -37 6 -35
|
|
||||||
0 -41 -4 -66 -48 l-28 -47 4 48 5 47 -34 0 c-19 0 -34 -1 -34 -3z"/>
|
|
||||||
<path d="M10056 973 c-2 -10 -10 -52 -16 -93 -6 -41 -13 -85 -16 -97 -4 -22
|
|
||||||
-1 -23 58 -23 112 0 175 56 164 145 -7 61 -41 85 -121 85 -52 0 -65 -3 -69
|
|
||||||
-17z m102 -45 c15 -15 16 -63 2 -89 -6 -11 -21 -19 -36 -19 -23 0 -25 3 -20
|
|
||||||
30 3 17 9 44 12 60 6 31 22 38 42 18z"/>
|
|
||||||
<path d="M10277 897 c-24 -134 -24 -139 16 -135 29 3 32 6 35 41 4 48 23 44
|
|
||||||
35 -6 8 -35 11 -37 47 -37 l38 0 -16 49 c-15 49 -15 50 7 68 29 23 32 80 6 99
|
|
||||||
-11 9 -45 14 -85 14 l-67 0 -16 -93z m113 23 c0 -11 -2 -20 -4 -20 -2 0 -11
|
|
||||||
-3 -20 -6 -11 -4 -16 0 -16 13 0 23 8 33 27 33 7 0 13 -9 13 -20z"/>
|
|
||||||
<path d="M10491 927 c-16 -92 -14 -124 9 -147 38 -38 146 -20 165 28 6 17 35
|
|
||||||
160 35 175 0 4 -15 7 -33 7 l-34 0 -13 -72 c-17 -96 -18 -98 -47 -98 -26 0
|
|
||||||
-26 1 -20 60 4 33 10 72 13 85 6 23 3 25 -29 25 l-35 0 -11 -63z"/>
|
|
||||||
<path d="M10906 968 c-9 -35 -8 -38 20 -38 19 0 24 -4 21 -17 -3 -10 -8 -36
|
|
||||||
-11 -58 -4 -22 -9 -52 -12 -67 -5 -26 -3 -28 30 -28 39 0 38 -2 54 115 6 45
|
|
||||||
10 50 35 53 19 2 27 9 27 22 0 10 4 21 9 24 9 6 16 -30 27 -141 l7 -73 44 0
|
|
||||||
44 0 54 113 53 112 -36 3 c-40 4 -45 -1 -68 -73 -25 -75 -32 -74 -40 4 l-7 71
|
|
||||||
-122 0 c-119 0 -123 -1 -129 -22z"/>
|
|
||||||
<path d="M8786 603 c-3 -16 -10 -57 -16 -93 -6 -36 -13 -75 -15 -87 -5 -20 -1
|
|
||||||
-23 29 -23 36 0 46 12 46 56 0 41 28 28 35 -16 7 -39 8 -40 46 -40 21 0 39 2
|
|
||||||
39 3 0 2 -9 30 -20 62 -22 63 -22 61 29 123 l34 43 -44 -3 c-40 -3 -46 -7 -67
|
|
||||||
-45 -23 -43 -48 -59 -38 -25 21 70 21 72 -17 72 -31 0 -36 -4 -41 -27z"/>
|
|
||||||
<path d="M9031 604 c-55 -46 -64 -142 -18 -184 32 -30 107 -27 146 6 55 46 64
|
|
||||||
133 19 182 -31 33 -106 31 -147 -4z m99 -44 c19 -35 -13 -110 -46 -110 -34 0
|
|
||||||
-38 76 -6 113 20 22 39 22 52 -3z"/>
|
|
||||||
<path d="M9240 603 c0 -15 5 -66 11 -115 l12 -88 43 0 44 0 44 95 c65 140 65
|
|
||||||
137 21 133 -36 -3 -38 -5 -62 -70 -14 -37 -29 -65 -34 -62 -5 3 -9 34 -9 70
|
|
||||||
l0 64 -35 0 c-31 0 -35 -3 -35 -27z"/>
|
|
||||||
<path d="M9456 533 c-10 -54 -20 -106 -23 -115 -3 -15 2 -18 31 -18 40 0 36
|
|
||||||
-9 61 129 19 107 20 101 -18 101 l-33 0 -18 -97z"/>
|
|
||||||
<path d="M9557 537 c-24 -130 -23 -137 12 -137 24 0 29 5 35 31 3 17 6 42 6
|
|
||||||
55 0 39 18 27 30 -18 6 -24 13 -49 15 -55 7 -20 73 -16 79 5 7 25 36 182 36
|
|
||||||
198 0 20 -56 18 -64 -2 -3 -9 -6 -34 -6 -57 -1 -38 -2 -40 -15 -24 -7 11 -17
|
|
||||||
36 -20 58 -7 38 -8 39 -49 39 l-43 0 -16 -93z"/>
|
|
||||||
<path d="M9807 527 c-26 -58 -47 -109 -47 -116 0 -6 15 -11 34 -11 26 0 36 5
|
|
||||||
41 20 4 13 15 20 31 20 17 0 24 -5 24 -20 0 -17 7 -20 39 -20 l39 0 -5 43 c-2
|
|
||||||
23 -7 74 -11 112 l-7 70 -46 3 -46 3 -46 -104z m79 -35 c-13 -12 -18 9 -10 45
|
|
||||||
l8 38 4 -39 c2 -21 1 -41 -2 -44z"/>
|
|
||||||
<path d="M10024 616 c-3 -7 -13 -59 -23 -115 l-18 -101 32 0 c35 0 45 13 45
|
|
||||||
56 0 38 18 28 30 -16 10 -37 13 -40 45 -40 40 0 39 -1 23 51 -10 35 -9 42 9
|
|
||||||
62 35 38 37 64 9 92 -21 21 -34 25 -86 25 -42 0 -62 -4 -66 -14z m93 -52 c3
|
|
||||||
-9 0 -20 -8 -25 -21 -13 -29 -11 -29 9 0 33 26 44 37 16z"/>
|
|
||||||
<path d="M10306 618 c-2 -7 -11 -49 -21 -93 -9 -44 -19 -90 -22 -102 -5 -21
|
|
||||||
-1 -23 30 -23 l36 0 6 55 c4 30 11 55 16 55 5 0 9 -25 9 -55 0 -54 1 -55 29
|
|
||||||
-55 25 0 31 6 46 48 24 64 39 78 31 27 -4 -22 -9 -48 -12 -57 -4 -15 1 -18 29
|
|
||||||
-18 l34 0 17 104 c9 58 16 110 16 116 0 7 -17 10 -47 8 l-48 -3 -21 -62 c-11
|
|
||||||
-35 -24 -60 -27 -56 -4 3 -7 33 -7 65 l0 58 -45 0 c-28 0 -47 -5 -49 -12z"/>
|
|
||||||
<path d="M10585 618 c-9 -31 -25 -122 -25 -148 0 -46 31 -70 90 -70 81 0 107
|
|
||||||
38 125 178 l7 52 -34 0 -34 0 -12 -77 c-13 -82 -29 -110 -58 -99 -17 7 -17 30
|
|
||||||
2 139 6 36 6 37 -25 37 -17 0 -33 -6 -36 -12z"/>
|
|
||||||
<path d="M10806 614 c-11 -29 -6 -44 15 -44 23 0 23 -2 3 -127 l-7 -43 35 0
|
|
||||||
35 0 14 83 c12 73 16 82 37 85 19 3 42 35 42 58 0 2 -38 4 -84 4 -67 0 -85 -3
|
|
||||||
-90 -16z"/>
|
|
||||||
<path d="M11020 610 c-6 -11 -26 -57 -46 -102 -19 -46 -38 -89 -41 -95 -4 -9
|
|
||||||
6 -13 32 -13 28 0 38 5 42 20 4 14 14 20 34 20 22 0 29 -5 29 -20 0 -16 7 -20
|
|
||||||
36 -20 l37 0 -7 78 c-14 155 -13 152 -62 152 -33 0 -46 -5 -54 -20z m50 -85
|
|
||||||
c0 -22 -16 -42 -26 -33 -2 3 -1 19 2 36 7 36 24 33 24 -3z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 337 KiB |
|
Before Width: | Height: | Size: 437 KiB |
|
Before Width: | Height: | Size: 374 KiB |
|
Before Width: | Height: | Size: 381 KiB |
|
Before Width: | Height: | Size: 449 KiB |
|
Before Width: | Height: | Size: 452 KiB |
@@ -0,0 +1,3 @@
|
|||||||
|
description: This file stores settings for Dart & Flutter DevTools.
|
||||||
|
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||||
|
extensions:
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
<string>Shooter App</string>
|
<string>SDK Kovinar</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,13 +1,20 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart'; // Import for SystemChrome
|
import 'package:flutter/services.dart'; // Import for SystemChrome
|
||||||
|
import 'package:intl/date_symbol_data_local.dart';
|
||||||
import 'screens/home_screen.dart';
|
import 'screens/home_screen.dart';
|
||||||
import 'services/notification_service.dart';
|
import 'services/notification_service.dart';
|
||||||
|
import 'services/app_settings.dart';
|
||||||
|
import 'theme/app_theme.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await AppSettings.instance.load();
|
||||||
|
await initializeDateFormatting(); // Slovenian month/day names for every screen
|
||||||
try {
|
try {
|
||||||
await NotificationService().initialize();
|
await NotificationService().initialize();
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
// Refresh reminders in the background so they don't depend on opening the calendar
|
||||||
|
NotificationService().rescheduleFromCalendar();
|
||||||
|
|
||||||
// Lock orientation to portrait only
|
// Lock orientation to portrait only
|
||||||
await SystemChrome.setPreferredOrientations([
|
await SystemChrome.setPreferredOrientations([
|
||||||
@@ -21,43 +28,47 @@ void main() async {
|
|||||||
statusBarColor: Colors.grey[900],
|
statusBarColor: Colors.grey[900],
|
||||||
systemNavigationBarColor: Colors.grey[900],
|
systemNavigationBarColor: Colors.grey[900],
|
||||||
systemNavigationBarIconBrightness: Brightness.light,
|
systemNavigationBarIconBrightness: Brightness.light,
|
||||||
|
// No grey scrim behind 3-button navigation; we paint the strip ourselves
|
||||||
|
systemNavigationBarContrastEnforced: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'SDK Muta',
|
title: 'SDK Kovinar',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: AppTheme.light(),
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
|
darkTheme: AppTheme.dark(),
|
||||||
useMaterial3: true,
|
|
||||||
),
|
|
||||||
darkTheme: ThemeData(
|
|
||||||
colorScheme: ColorScheme.fromSeed(
|
|
||||||
seedColor: Colors.blue,
|
|
||||||
brightness: Brightness.dark,
|
|
||||||
),
|
|
||||||
useMaterial3: true,
|
|
||||||
dialogTheme: DialogThemeData(
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
builder: (context, child) {
|
builder: (context, child) {
|
||||||
final originalTextScaler = MediaQuery.of(context).textScaler;
|
final originalTextScaler = MediaQuery.of(context).textScaler;
|
||||||
final clampedScale = originalTextScaler.clamp(minScaleFactor: 0.8, maxScaleFactor: 1.2);
|
final clampedScale =
|
||||||
|
originalTextScaler.clamp(minScaleFactor: 0.8, maxScaleFactor: 1.2);
|
||||||
|
// Edge-to-edge (Android 15+) ignores the navigation bar color, so paint
|
||||||
|
// the system bar strip ourselves on every screen, matching our bars.
|
||||||
|
final systemBar = MediaQuery.viewPaddingOf(context).bottom;
|
||||||
return MediaQuery(
|
return MediaQuery(
|
||||||
data: MediaQuery.of(context).copyWith(
|
data: MediaQuery.of(context).copyWith(
|
||||||
textScaler: clampedScale,
|
textScaler: clampedScale,
|
||||||
),
|
),
|
||||||
child: child!,
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
child!,
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
height: systemBar,
|
||||||
|
child: IgnorePointer(child: ColoredBox(color: AppTheme.bar)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
home: const HomeScreen(),
|
home: const HomeScreen(),
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/// Which cameras exist: shooting positions (lanes 1–6) × locations (strelišča).
|
||||||
|
/// Each position can have a camera at several locations, e.g. "Kovinar" and "Doma".
|
||||||
|
class CameraSetup {
|
||||||
|
static const int maxPositions = 6;
|
||||||
|
static const int firstPort = 9081;
|
||||||
|
|
||||||
|
final List<String> locations;
|
||||||
|
final int positions;
|
||||||
|
final Map<int, Map<String, String>> ips; // position (1-based) → location → ip:port
|
||||||
|
final String? activeLocation; // last chosen, used by screens that show one location
|
||||||
|
final String? clubLocation; // added by the club code, removed when access is removed
|
||||||
|
|
||||||
|
const CameraSetup({
|
||||||
|
this.locations = const [],
|
||||||
|
this.positions = maxPositions,
|
||||||
|
this.ips = const {},
|
||||||
|
this.activeLocation,
|
||||||
|
this.clubLocation,
|
||||||
|
});
|
||||||
|
|
||||||
|
String ipFor(int position, String location) => ips[position]?[location] ?? '';
|
||||||
|
|
||||||
|
/// Locations with a camera at [position], in the user's location order.
|
||||||
|
Map<String, String> camerasAt(int position) => {
|
||||||
|
for (final l in locations)
|
||||||
|
if (ipFor(position, l).isNotEmpty) l: ipFor(position, l),
|
||||||
|
};
|
||||||
|
|
||||||
|
int camerasIn(String location) => [
|
||||||
|
for (int p = 1; p <= positions; p++)
|
||||||
|
if (ipFor(p, location).isNotEmpty) p,
|
||||||
|
].length;
|
||||||
|
|
||||||
|
CameraSetup copyWith({
|
||||||
|
List<String>? locations,
|
||||||
|
int? positions,
|
||||||
|
Map<int, Map<String, String>>? ips,
|
||||||
|
String? activeLocation,
|
||||||
|
String? clubLocation,
|
||||||
|
bool clearClubLocation = false,
|
||||||
|
}) {
|
||||||
|
return CameraSetup(
|
||||||
|
locations: locations ?? this.locations,
|
||||||
|
positions: positions ?? this.positions,
|
||||||
|
ips: ips ?? this.ips,
|
||||||
|
activeLocation: activeLocation ?? this.activeLocation,
|
||||||
|
clubLocation: clearClubLocation ? null : (clubLocation ?? this.clubLocation),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Deep copy of [ips] for editing.
|
||||||
|
Map<int, Map<String, String>> ipsCopy() => {for (final e in ips.entries) e.key: {...e.value}};
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'locations': locations,
|
||||||
|
'positions': positions,
|
||||||
|
'ips': {for (final e in ips.entries) '${e.key}': e.value},
|
||||||
|
'activeLocation': activeLocation,
|
||||||
|
'clubLocation': clubLocation,
|
||||||
|
};
|
||||||
|
|
||||||
|
factory CameraSetup.fromJson(Map<String, dynamic> json) => CameraSetup(
|
||||||
|
locations: [for (final l in json['locations'] as List? ?? []) l as String],
|
||||||
|
positions: (json['positions'] as int? ?? maxPositions).clamp(1, maxPositions),
|
||||||
|
ips: {
|
||||||
|
for (final e in (json['ips'] as Map<String, dynamic>? ?? {}).entries)
|
||||||
|
int.parse(e.key): {for (final i in (e.value as Map).entries) i.key as String: i.value as String},
|
||||||
|
},
|
||||||
|
activeLocation: json['activeLocation'] as String?,
|
||||||
|
clubLocation: json['clubLocation'] as String?,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
class Contact {
|
||||||
|
final String firstName;
|
||||||
|
final String lastName;
|
||||||
|
final String phone;
|
||||||
|
final String email;
|
||||||
|
|
||||||
|
const Contact({
|
||||||
|
required this.firstName,
|
||||||
|
required this.lastName,
|
||||||
|
required this.phone,
|
||||||
|
required this.email,
|
||||||
|
});
|
||||||
|
|
||||||
|
String get fullName => '$firstName $lastName';
|
||||||
|
|
||||||
|
factory Contact.fromJson(Map<String, dynamic> json) => Contact(
|
||||||
|
firstName: json['firstName'] ?? '',
|
||||||
|
lastName: json['lastName'] ?? '',
|
||||||
|
phone: json['phone'] ?? '',
|
||||||
|
email: json['email'] ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -7,6 +7,9 @@ import 'yolo_detector.dart';
|
|||||||
import 'preview_screen.dart';
|
import 'preview_screen.dart';
|
||||||
import '../utils/translations.dart';
|
import '../utils/translations.dart';
|
||||||
import '../utils/target_colors.dart';
|
import '../utils/target_colors.dart';
|
||||||
|
import '../services/app_settings.dart';
|
||||||
|
import '../widgets/camera_sheet.dart';
|
||||||
|
import '../widgets/help_sheet.dart';
|
||||||
|
|
||||||
class CameraScreen extends StatefulWidget {
|
class CameraScreen extends StatefulWidget {
|
||||||
const CameraScreen({super.key});
|
const CameraScreen({super.key});
|
||||||
@@ -26,9 +29,10 @@ class _CameraScreenState extends State<CameraScreen> {
|
|||||||
String _selectedLanguage = 'English';
|
String _selectedLanguage = 'English';
|
||||||
late Color _backgroundColor;
|
late Color _backgroundColor;
|
||||||
|
|
||||||
// Brightness and contrast controls
|
// Real camera controls (they change the photo itself)
|
||||||
double _brightness = 0.0; // -1.0 to 1.0
|
double _exposure = 0, _minExposure = 0, _maxExposure = 0;
|
||||||
double _contrast = 1.0; // 0.0 to 2.0
|
double _zoom = 1, _minZoom = 1, _maxZoom = 1;
|
||||||
|
bool _torch = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -40,24 +44,9 @@ class _CameraScreenState extends State<CameraScreen> {
|
|||||||
_loadBulletColor(); // 👈
|
_loadBulletColor(); // 👈
|
||||||
_loadLanguage();
|
_loadLanguage();
|
||||||
_loadSelectedTargetColor();
|
_loadSelectedTargetColor();
|
||||||
_loadBrightnessContrast();
|
|
||||||
YOLODetector.create().then((detector) => _yoloDetector = detector);
|
YOLODetector.create().then((detector) => _yoloDetector = detector);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadBrightnessContrast() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
setState(() {
|
|
||||||
_brightness = prefs.getDouble('brightness') ?? 0.0;
|
|
||||||
_contrast = prefs.getDouble('contrast') ?? 1.0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _saveBrightnessContrast() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
await prefs.setDouble('brightness', _brightness);
|
|
||||||
await prefs.setDouble('contrast', _contrast);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _t(String key) {
|
String _t(String key) {
|
||||||
return AppTranslations.translate(key, _selectedLanguage);
|
return AppTranslations.translate(key, _selectedLanguage);
|
||||||
}
|
}
|
||||||
@@ -65,13 +54,14 @@ 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';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadSelectedTargetColor() async {
|
Future<void> _loadSelectedTargetColor() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
final selectedTarget =
|
||||||
|
prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||||
setState(() {
|
setState(() {
|
||||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
||||||
});
|
});
|
||||||
@@ -122,12 +112,12 @@ Color _getColorFromName(String colorName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _loadBulletCount() async {
|
Future<void> _loadBulletCount() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
setState(() {
|
setState(() {
|
||||||
_numberOfBullets = prefs.getInt('bulletCount') ?? 5; // Load stored bullet count, default to 5
|
// Older versions allowed up to 10
|
||||||
|
_numberOfBullets = (prefs.getInt('bulletCount') ?? AppSettings.maxBullets)
|
||||||
|
.clamp(AppSettings.minBullets, AppSettings.maxBullets);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +136,13 @@ Color _getColorFromName(String colorName) {
|
|||||||
enableAudio: false,
|
enableAudio: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
_initializeControllerFuture = _controller!.initialize();
|
_initializeControllerFuture = _controller!.initialize().then((_) async {
|
||||||
|
// Ranges differ per phone; read them once the camera is ready
|
||||||
|
_minExposure = await _controller!.getMinExposureOffset();
|
||||||
|
_maxExposure = await _controller!.getMaxExposureOffset();
|
||||||
|
_minZoom = await _controller!.getMinZoomLevel();
|
||||||
|
_maxZoom = (await _controller!.getMaxZoomLevel()).clamp(_minZoom, 8.0);
|
||||||
|
});
|
||||||
if (mounted) setState(() {});
|
if (mounted) setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,250 +194,132 @@ Color _getColorFromName(String colorName) {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error taking picture: $e');
|
debugPrint('Error taking picture: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to show the dialog for selecting the number of bullets
|
|
||||||
void _showBulletDialog() {
|
void _showBulletDialog() {
|
||||||
showDialog(
|
showCameraSheet(
|
||||||
context: context,
|
context,
|
||||||
builder: (BuildContext context) {
|
builder: (sheet) => StatefulBuilder(
|
||||||
return Dialog(
|
builder: (context, setSheetState) => Column(
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(24.0), // Increased padding for better spacing
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
CameraSheetHeader(
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
title: _t('Select the number of bullets'),
|
||||||
child: Text(
|
subtitle:
|
||||||
_t('Select the number of bullets'),
|
'${AppSettings.minBullets} – ${AppSettings.maxBullets}'),
|
||||||
textAlign: TextAlign.center,
|
SheetStepper(
|
||||||
style: const TextStyle(
|
value: _numberOfBullets,
|
||||||
color: Colors.white,
|
min: AppSettings.minBullets,
|
||||||
fontSize: 20,
|
max: AppSettings.maxBullets,
|
||||||
fontWeight: FontWeight.bold,
|
accent: _bulletColor,
|
||||||
),
|
onChanged: (n) {
|
||||||
),
|
_selectBulletCount(n);
|
||||||
),
|
setSheetState(() {});
|
||||||
Center(
|
|
||||||
child: Wrap(
|
|
||||||
alignment: WrapAlignment.center,
|
|
||||||
spacing: 12,
|
|
||||||
runSpacing: 12,
|
|
||||||
children: List.generate(5, (index) {
|
|
||||||
final bulletNum = index + 1;
|
|
||||||
final isSelected = _numberOfBullets == bulletNum;
|
|
||||||
return ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
_selectBulletCount(bulletNum);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor:
|
|
||||||
isSelected ? _bulletColor : Colors.grey[800],
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
child: Text(
|
],
|
||||||
'$bulletNum',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight:
|
|
||||||
isSelected ? FontWeight.bold : FontWeight.normal,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showHelpDialog() {
|
||||||
|
showHelpSheet(context, accent: _bulletColor, t: _t, items: const [
|
||||||
|
(Icons.crop_square, 'Align the target inside the square frame.'),
|
||||||
|
(
|
||||||
|
Icons.camera_alt,
|
||||||
|
'Camera button: take a photo. Bullets are detected and you can check and save the result.'
|
||||||
|
),
|
||||||
|
(Icons.filter_5_rounded, 'Number bottom left: shots per target (1–5).'),
|
||||||
|
(Icons.tune, 'Settings icon: exposure, zoom and flashlight.'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showCameraControls() {
|
||||||
|
showCameraSheet(
|
||||||
|
context,
|
||||||
|
builder: (sheet) => StatefulBuilder(
|
||||||
|
builder: (context, setSheetState) {
|
||||||
|
Future<void> apply(
|
||||||
|
VoidCallback change, Future<void> Function() camera) async {
|
||||||
|
setState(change);
|
||||||
|
setSheetState(() {});
|
||||||
|
try {
|
||||||
|
await camera();
|
||||||
|
} catch (_) {} // control not supported on this phone
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
CameraSheetHeader(
|
||||||
|
title: _t('Image Settings'),
|
||||||
|
trailing: TextButton.icon(
|
||||||
|
style: TextButton.styleFrom(foregroundColor: Colors.white70),
|
||||||
|
icon: const Icon(Icons.restart_alt_rounded, size: 18),
|
||||||
|
label: Text(_t('Reset')),
|
||||||
|
onPressed: () => apply(() {
|
||||||
|
_exposure = 0;
|
||||||
|
_zoom = _minZoom;
|
||||||
|
}, () async {
|
||||||
|
await _controller!.setExposureOffset(0);
|
||||||
|
await _controller!.setZoomLevel(_minZoom);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (_maxExposure > _minExposure)
|
||||||
|
SheetSlider(
|
||||||
|
icon: Icons.exposure_rounded,
|
||||||
|
label: _t('Exposure'),
|
||||||
|
valueText:
|
||||||
|
'${_exposure >= 0 ? '+' : ''}${_exposure.toStringAsFixed(1)}',
|
||||||
|
value: _exposure,
|
||||||
|
min: _minExposure,
|
||||||
|
max: _maxExposure,
|
||||||
|
accent: _bulletColor,
|
||||||
|
onChanged: (v) => apply(() => _exposure = v,
|
||||||
|
() => _controller!.setExposureOffset(v)),
|
||||||
|
),
|
||||||
|
if (_maxZoom > _minZoom)
|
||||||
|
SheetSlider(
|
||||||
|
icon: Icons.zoom_in_rounded,
|
||||||
|
label: _t('Zoom'),
|
||||||
|
valueText: '${_zoom.toStringAsFixed(1)}×',
|
||||||
|
value: _zoom,
|
||||||
|
min: _minZoom,
|
||||||
|
max: _maxZoom,
|
||||||
|
accent: _bulletColor,
|
||||||
|
onChanged: (v) => apply(
|
||||||
|
() => _zoom = v, () => _controller!.setZoomLevel(v)),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: SheetToggle(
|
||||||
|
icon: _torch
|
||||||
|
? Icons.flashlight_on_rounded
|
||||||
|
: Icons.flashlight_off_rounded,
|
||||||
|
label: _t('Flashlight'),
|
||||||
|
active: _torch,
|
||||||
|
accent: _bulletColor,
|
||||||
|
onTap: () => apply(
|
||||||
|
() => _torch = !_torch,
|
||||||
|
() => _controller!
|
||||||
|
.setFlashMode(_torch ? FlashMode.torch : FlashMode.off),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _showHelpDialog() {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return Dialog(
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(24.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_t('Help'),
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
_buildHelpItem(Icons.camera_alt, _t('Tap camera button to capture and detect bullets')),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
_buildHelpItem(Icons.filter_9_plus, _t('Bottom left number: Set expected bullet count (1-5)')),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
_buildHelpItem(Icons.brightness_6, _t('Sun icon: Adjust brightness and contrast for better visibility')),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
_buildHelpItem(Icons.crop_square, _t('Align target inside the square frame')),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Center(
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: _bulletColor,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
),
|
|
||||||
child: Text(_t('Got it!')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildHelpItem(IconData icon, String text) {
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Icon(icon, color: _bulletColor, size: 20),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
text,
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showBrightnessContrastDialog() {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return StatefulBuilder(
|
|
||||||
builder: (context, setDialogState) {
|
|
||||||
return Dialog(
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(24.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_t('Brightness & Contrast'),
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
// Brightness slider
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'${_t('Brightness')}: ${(_brightness * 100).toInt()}',
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
|
||||||
),
|
|
||||||
Slider(
|
|
||||||
value: _brightness,
|
|
||||||
min: -1.0,
|
|
||||||
max: 1.0,
|
|
||||||
divisions: 40,
|
|
||||||
activeColor: _bulletColor,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_brightness = value;
|
|
||||||
});
|
|
||||||
setDialogState(() {});
|
|
||||||
_saveBrightnessContrast();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
// Contrast slider
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'${_t('Contrast')}: ${(_contrast * 100).toInt()}%',
|
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 16),
|
|
||||||
),
|
|
||||||
Slider(
|
|
||||||
value: _contrast,
|
|
||||||
min: 0.5,
|
|
||||||
max: 2.0,
|
|
||||||
divisions: 30,
|
|
||||||
activeColor: _bulletColor,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_contrast = value;
|
|
||||||
});
|
|
||||||
setDialogState(() {});
|
|
||||||
_saveBrightnessContrast();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_brightness = 0.0;
|
|
||||||
_contrast = 1.0;
|
|
||||||
});
|
|
||||||
setDialogState(() {});
|
|
||||||
_saveBrightnessContrast();
|
|
||||||
},
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.grey[800],
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
),
|
|
||||||
child: Text(_t('Reset')),
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: _bulletColor,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
),
|
|
||||||
child: Text(_t('Done')),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the bullet count and save it
|
|
||||||
void _selectBulletCount(int number) {
|
void _selectBulletCount(int number) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_numberOfBullets = number; // Update the selected number
|
_numberOfBullets = number; // Update the selected number
|
||||||
@@ -477,7 +355,7 @@ Color _getColorFromName(String colorName) {
|
|||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.help_outline, color: Colors.white),
|
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
|
||||||
onPressed: _showHelpDialog,
|
onPressed: _showHelpDialog,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
@@ -519,8 +397,9 @@ Color _getColorFromName(String colorName) {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.brightness_6, color: Colors.white, size: 24),
|
icon:
|
||||||
onPressed: _showBrightnessContrastDialog,
|
const Icon(Icons.tune, color: Colors.white, size: 24),
|
||||||
|
onPressed: _showCameraControls,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import '../utils/translations.dart';
|
|
||||||
|
|
||||||
class CameraSelectionDialog extends StatefulWidget {
|
|
||||||
final List<Map<String, dynamic>> availableCameras;
|
|
||||||
final String selectedLanguage;
|
|
||||||
|
|
||||||
const CameraSelectionDialog({
|
|
||||||
super.key,
|
|
||||||
required this.availableCameras,
|
|
||||||
required this.selectedLanguage,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<CameraSelectionDialog> createState() => _CameraSelectionDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CameraSelectionDialogState extends State<CameraSelectionDialog> {
|
|
||||||
late List<bool> _selectedCameras;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_selectedCameras = List.generate(widget.availableCameras.length, (_) => false);
|
|
||||||
}
|
|
||||||
|
|
||||||
String _t(String key) {
|
|
||||||
return AppTranslations.translate(key, widget.selectedLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
title: Text(
|
|
||||||
_t('Select Cameras to Spectate'),
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
content: SizedBox(
|
|
||||||
width: double.maxFinite,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_t('Choose 1-6 cameras'),
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Flexible(
|
|
||||||
child: ListView.builder(
|
|
||||||
shrinkWrap: true,
|
|
||||||
itemCount: widget.availableCameras.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final camera = widget.availableCameras[index];
|
|
||||||
final cameraIndex = camera['index'] as int;
|
|
||||||
final cameraIp = camera['ip'] as String;
|
|
||||||
|
|
||||||
return CheckboxListTile(
|
|
||||||
title: Text(
|
|
||||||
"${_t('Camera')} $cameraIndex",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
cameraIp,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
value: _selectedCameras[index],
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_selectedCameras[index] = value ?? false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
activeColor: Colors.grey[800],
|
|
||||||
checkColor: Colors.white,
|
|
||||||
tileColor: Colors.grey[850],
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 12,
|
|
||||||
vertical: 4,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: Text(
|
|
||||||
_t('Cancel'),
|
|
||||||
style: const TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
TextButton(
|
|
||||||
onPressed: _selectedCameras.contains(true)
|
|
||||||
? () {
|
|
||||||
final selectedCameras = <Map<String, dynamic>>[];
|
|
||||||
for (int i = 0; i < _selectedCameras.length; i++) {
|
|
||||||
if (_selectedCameras[i]) {
|
|
||||||
selectedCameras.add(widget.availableCameras[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Navigator.pop(context, selectedCameras);
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Text(
|
|
||||||
_t('View Cameras'),
|
|
||||||
style: TextStyle(
|
|
||||||
color: _selectedCameras.contains(true)
|
|
||||||
? Colors.white
|
|
||||||
: Colors.grey[600],
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../models/camera_setup.dart';
|
||||||
|
import '../services/app_settings.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
import '../widgets/section.dart';
|
||||||
|
import '../widgets/text_prompt.dart';
|
||||||
|
|
||||||
|
/// Locations (strelišča), number of positions, and the camera IP of every
|
||||||
|
/// position at every location.
|
||||||
|
class CameraSettingsScreen extends StatelessWidget {
|
||||||
|
const CameraSettingsScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListenableBuilder(
|
||||||
|
listenable: AppSettings.instance,
|
||||||
|
builder: (context, _) {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final t = s.t;
|
||||||
|
final setup = s.cameras;
|
||||||
|
final surf = Surfaces.current;
|
||||||
|
const firstPort = CameraSetup.firstPort;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: s.backgroundColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(t('Cameras'), style: const TextStyle(color: Colors.white)),
|
||||||
|
backgroundColor: AppTheme.bar,
|
||||||
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
// Keep the last row clear of the system gesture bar (edge-to-edge)
|
||||||
|
padding: EdgeInsets.fromLTRB(16, 4, 16, 24 + MediaQuery.paddingOf(context).bottom),
|
||||||
|
children: [
|
||||||
|
SectionHeader(t('Locations')),
|
||||||
|
GroupCard(children: [
|
||||||
|
for (final location in setup.locations)
|
||||||
|
SettingsTile(
|
||||||
|
leading: Icon(
|
||||||
|
location == setup.clubLocation ? Icons.verified_rounded : Icons.place_rounded,
|
||||||
|
color: location == setup.clubLocation ? Colors.green : s.bulletColor,
|
||||||
|
),
|
||||||
|
title: location,
|
||||||
|
subtitle: location == setup.clubLocation ? t('Added with the club code') : null,
|
||||||
|
value: t('{n} cameras').replaceAll('{n}', '${setup.camerasIn(location)}'),
|
||||||
|
onTap: () => _editLocation(context, location),
|
||||||
|
),
|
||||||
|
SettingsTile(
|
||||||
|
leading: Icon(Icons.add_rounded, color: surf.textSecondary),
|
||||||
|
title: t('Add location'),
|
||||||
|
onTap: () => _addLocation(context),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
SectionHeader(t('Positions')),
|
||||||
|
GroupCard(children: [
|
||||||
|
SettingsTile(
|
||||||
|
title: t('Number of positions'),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.remove_rounded),
|
||||||
|
color: surf.textPrimary,
|
||||||
|
onPressed: setup.positions > 1 ? () => s.setPositionCount(setup.positions - 1) : null,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 28,
|
||||||
|
child: Text(
|
||||||
|
'${setup.positions}',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: surf.textPrimary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.add_rounded),
|
||||||
|
color: surf.textPrimary,
|
||||||
|
onPressed: setup.positions < CameraSetup.maxPositions
|
||||||
|
? () => s.setPositionCount(setup.positions + 1)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
for (final location in setup.locations) ...[
|
||||||
|
SectionHeader(location),
|
||||||
|
GroupCard(children: [
|
||||||
|
SettingsTile(
|
||||||
|
leading: Icon(Icons.bolt_rounded, color: s.bulletColor),
|
||||||
|
title: t('Set all cameras from one IP'),
|
||||||
|
subtitle: t('Ports {from}–{to}')
|
||||||
|
.replaceAll('{from}', '$firstPort')
|
||||||
|
.replaceAll('{to}', '${firstPort + setup.positions - 1}'),
|
||||||
|
onTap: () => _editHost(context, location),
|
||||||
|
),
|
||||||
|
for (int p = 1; p <= setup.positions; p++)
|
||||||
|
SettingsTile(
|
||||||
|
title: '${t('Camera')} $p',
|
||||||
|
value: setup.ipFor(p, location).isEmpty ? '—' : setup.ipFor(p, location),
|
||||||
|
onTap: () => _editCamera(context, p, location),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _addLocation(BuildContext context) async {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final name = await showTextPrompt(context, title: s.t('Add location'), hint: s.t('e.g. Home'));
|
||||||
|
if (name == null || name.isEmpty) return;
|
||||||
|
if (!await s.addLocation(name) && context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(s.t('This location already exists'))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _editLocation(BuildContext context, String location) async {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final name = await showTextPrompt(
|
||||||
|
context,
|
||||||
|
title: s.t('Location'),
|
||||||
|
initial: location,
|
||||||
|
resetLabel: s.t('Delete'),
|
||||||
|
onReset: () => s.removeLocation(location),
|
||||||
|
);
|
||||||
|
if (name != null && name.isNotEmpty && name != location) await s.renameLocation(location, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _editHost(BuildContext context, String location) async {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final first = s.cameras.ipFor(1, location);
|
||||||
|
final host = await showTextPrompt(
|
||||||
|
context,
|
||||||
|
title: '${s.t('Set all cameras from one IP')} · $location',
|
||||||
|
initial: first.split(':').first,
|
||||||
|
hint: '192.168.0.10',
|
||||||
|
keyboardType: TextInputType.url,
|
||||||
|
);
|
||||||
|
if (host != null && host.isNotEmpty) s.setLocationHost(location, host);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _editCamera(BuildContext context, int position, String location) async {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final ip = await showTextPrompt(
|
||||||
|
context,
|
||||||
|
title: '${s.t('Camera')} $position · $location',
|
||||||
|
initial: s.cameras.ipFor(position, location),
|
||||||
|
hint: '192.168.0.10:${CameraSetup.firstPort + position - 1}',
|
||||||
|
keyboardType: TextInputType.url,
|
||||||
|
resetLabel: s.t('Remove'),
|
||||||
|
onReset: () => s.setCameraIp(position, location, ''),
|
||||||
|
);
|
||||||
|
if (ip != null && ip.isNotEmpty) s.setCameraIp(position, location, ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,118 +4,102 @@ import 'calendar_screen.dart';
|
|||||||
import 'settings_screen.dart';
|
import 'settings_screen.dart';
|
||||||
import 'target_screen.dart';
|
import 'target_screen.dart';
|
||||||
import '../widgets/bottom_nav.dart';
|
import '../widgets/bottom_nav.dart';
|
||||||
//import 'login_screen.dart';
|
|
||||||
import 'camera_screen.dart';
|
import 'camera_screen.dart';
|
||||||
import 'spectator_screen.dart';
|
import 'spectator_screen.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import '../services/app_settings.dart';
|
||||||
import '../utils/translations.dart';
|
import '../theme/app_theme.dart';
|
||||||
import '../utils/target_colors.dart';
|
|
||||||
|
enum AppTab { book, shooting, camera, calendar, settings }
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
const HomeScreen({super.key});
|
const HomeScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_HomeScreenState createState() => _HomeScreenState();
|
State<HomeScreen> createState() => _HomeScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HomeScreenState extends State<HomeScreen> {
|
class _HomeScreenState extends State<HomeScreen> {
|
||||||
int _selectedIndex = 1; // Default to Shooting Screen
|
AppTab _selected = AppTab.shooting;
|
||||||
String _selectedLanguage = 'English';
|
|
||||||
String _selectedTarget = 'assets/target.png';
|
|
||||||
late Color _backgroundColor;
|
|
||||||
|
|
||||||
static final List<Widget> _pages = <Widget>[
|
static const Map<AppTab, String> _titles = {
|
||||||
BookScreen(),
|
AppTab.book: 'Book',
|
||||||
TargetScreen(),
|
AppTab.shooting: 'Shooting',
|
||||||
Placeholder(), // Placeholder for Scan - optional
|
AppTab.camera: 'Camera',
|
||||||
CalendarScreen(),
|
AppTab.calendar: 'Calendar',
|
||||||
SettingsScreen(),
|
AppTab.settings: 'Settings',
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Map<AppTab, IconData> _icons = {
|
||||||
|
AppTab.book: Icons.book,
|
||||||
|
AppTab.shooting: Icons.my_location,
|
||||||
|
AppTab.camera: Icons.camera_alt,
|
||||||
|
AppTab.calendar: Icons.calendar_today,
|
||||||
|
AppTab.settings: Icons.settings,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Calendar is only shown to club members (see Settings > Club code)
|
||||||
|
List<AppTab> get _visibleTabs => [
|
||||||
|
for (final tab in AppTab.values)
|
||||||
|
if (tab != AppTab.calendar || AppSettings.instance.clubUnlocked) tab,
|
||||||
];
|
];
|
||||||
|
|
||||||
final List<String> _pageTitles = [
|
Widget _page(AppTab tab) {
|
||||||
'Book',
|
switch (tab) {
|
||||||
'Shooting',
|
case AppTab.book:
|
||||||
'Scan',
|
return const BookScreen();
|
||||||
'Calendar',
|
case AppTab.shooting:
|
||||||
'Settings'
|
case AppTab.camera: // camera opens as its own route, never shown here
|
||||||
];
|
return const TargetScreen();
|
||||||
|
case AppTab.calendar:
|
||||||
@override
|
return const CalendarScreen();
|
||||||
void initState() {
|
case AppTab.settings:
|
||||||
super.initState();
|
return const SettingsScreen();
|
||||||
// Initialize with default target background color
|
}
|
||||||
_backgroundColor = TargetColors.getBackgroundColor('assets/target.png');
|
|
||||||
_loadLanguage();
|
|
||||||
_loadSelectedTarget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String _t(String key) {
|
void _onTabTapped(AppTab tab) {
|
||||||
return AppTranslations.translate(key, _selectedLanguage);
|
if (tab == AppTab.camera) {
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadLanguage() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
setState(() {
|
|
||||||
_selectedLanguage = prefs.getString('language') ?? 'English';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadSelectedTarget() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
final selectedTarget =
|
|
||||||
prefs.getString('selectedTarget') ?? 'assets/target.png';
|
|
||||||
setState(() {
|
|
||||||
_selectedTarget = selectedTarget;
|
|
||||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
|
||||||
if (index == 2) {
|
|
||||||
_openCameraScan();
|
_openCameraScan();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() => _selected = tab);
|
||||||
_selectedIndex = index;
|
|
||||||
});
|
|
||||||
// Reload language when switching screens to pick up any changes from Settings
|
|
||||||
_loadLanguage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//void _logout() {
|
// When returning from the camera screen, always land on the Shooting tab
|
||||||
// Navigator.of(context).pushAndRemoveUntil(
|
|
||||||
// MaterialPageRoute(builder: (context) => const LoginScreen()),
|
|
||||||
// (Route<dynamic> route) => false,
|
|
||||||
// );
|
|
||||||
//}
|
|
||||||
|
|
||||||
// When opening the camera screen, ensure the shooting screen is always selected after returning
|
|
||||||
void _openCameraScan() async {
|
void _openCameraScan() async {
|
||||||
// Navigate to CameraScreen
|
|
||||||
await Navigator.of(context).push(
|
await Navigator.of(context).push(
|
||||||
MaterialPageRoute(builder: (context) => const CameraScreen()),
|
MaterialPageRoute(builder: (context) => const CameraScreen()),
|
||||||
);
|
);
|
||||||
|
setState(() => _selected = AppTab.shooting);
|
||||||
// After returning, ensure that Shooting screen (index 1) is selected
|
|
||||||
setState(() {
|
|
||||||
_selectedIndex = 1;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return ListenableBuilder(
|
||||||
|
listenable: AppSettings.instance,
|
||||||
|
builder: (context, _) {
|
||||||
|
final settings = AppSettings.instance;
|
||||||
|
final tabs = _visibleTabs;
|
||||||
|
if (!tabs.contains(_selected)) _selected = AppTab.settings; // calendar was just locked
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
_t(_pageTitles[_selectedIndex]),
|
settings.t(_titles[_selected]!),
|
||||||
style: const TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.grey[900],
|
backgroundColor: AppTheme.bar,
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
scrolledUnderElevation: 0, // For Material 3 (Flutter 3.7+)
|
scrolledUnderElevation: 0, // For Material 3 (Flutter 3.7+)
|
||||||
actions: [
|
actions: [
|
||||||
if (_selectedIndex == 1)
|
if (_selected == AppTab.book)
|
||||||
|
IconButton(
|
||||||
|
tooltip: settings.t('Help'),
|
||||||
|
icon: const Icon(Icons.info_outline_rounded, color: Colors.white),
|
||||||
|
onPressed: () => showBookHelp(context),
|
||||||
|
),
|
||||||
|
if (_selected == AppTab.shooting)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.visibility_rounded, color: Colors.white),
|
icon: const Icon(Icons.visibility_rounded, color: Colors.white),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -123,34 +107,29 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => SpectatorScreen(
|
builder: (context) => SpectatorScreen(
|
||||||
selectedLanguage: _selectedLanguage,
|
selectedLanguage: settings.language,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Padding(
|
],
|
||||||
padding: const EdgeInsets.only(right: 16.0),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
'V1.1',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.grey[400],
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
backgroundColor: settings.backgroundColor,
|
||||||
|
body: _page(_selected),
|
||||||
|
bottomNavigationBar: BottomNavBar(
|
||||||
|
selectedIndex: tabs.indexOf(_selected),
|
||||||
|
onItemTapped: (i) => _onTabTapped(tabs[i]),
|
||||||
|
items: [
|
||||||
|
for (final tab in tabs)
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(_icons[tab]),
|
||||||
|
label: settings.t(_titles[tab]!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
backgroundColor: _backgroundColor,
|
);
|
||||||
body: _pages[_selectedIndex],
|
},
|
||||||
bottomNavigationBar: BottomNavBar(
|
|
||||||
selectedIndex: _selectedIndex,
|
|
||||||
onItemTapped: _onItemTapped,
|
|
||||||
selectedLanguage: _selectedLanguage,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,232 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:google_sign_in/google_sign_in.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import '../widgets/input_field.dart';
|
|
||||||
import 'home_screen.dart';
|
|
||||||
import 'register_screen.dart';
|
|
||||||
|
|
||||||
class LoginScreen extends StatefulWidget {
|
|
||||||
const LoginScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<LoginScreen> createState() => _LoginScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _LoginScreenState extends State<LoginScreen> {
|
|
||||||
final usernameController = TextEditingController();
|
|
||||||
final passwordController = TextEditingController();
|
|
||||||
bool rememberMe = false;
|
|
||||||
|
|
||||||
final GoogleSignIn _googleSignIn = GoogleSignIn(
|
|
||||||
clientId: 'YOUR_WEB_CLIENT_ID_HERE',
|
|
||||||
scopes: ['email'],
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_checkAutoLogin();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _checkAutoLogin() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
final isRemembered = prefs.getBool('rememberMe') ?? false;
|
|
||||||
final googleUser = prefs.getString('googleUser');
|
|
||||||
|
|
||||||
if (isRemembered) {
|
|
||||||
final savedUsername = prefs.getString('loginUsername') ?? prefs.getString('username');
|
|
||||||
final savedPassword = prefs.getString('password');
|
|
||||||
if (savedUsername != null && savedPassword != null) {
|
|
||||||
usernameController.text = savedUsername;
|
|
||||||
passwordController.text = savedPassword;
|
|
||||||
setState(() => rememberMe = true);
|
|
||||||
}
|
|
||||||
} else if (googleUser != null) {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _saveLoginDetails(String username, String password) async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
await prefs.setString('loginUsername', username); // Ensures login uses latest username
|
|
||||||
await prefs.setString('password', password);
|
|
||||||
|
|
||||||
if (rememberMe) {
|
|
||||||
await prefs.setBool('rememberMe', true);
|
|
||||||
} else {
|
|
||||||
await prefs.remove('rememberMe');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void login() async {
|
|
||||||
String username = usernameController.text.trim();
|
|
||||||
String password = passwordController.text.trim();
|
|
||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
String? savedUsername = prefs.getString('loginUsername') ?? prefs.getString('username'); // Get the latest username
|
|
||||||
String? savedPassword = prefs.getString('password'); // Get the saved password
|
|
||||||
|
|
||||||
if (savedUsername == username && savedPassword == password) {
|
|
||||||
await _saveLoginDetails(username, password);
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Invalid username or password')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> googleLogin() async {
|
|
||||||
try {
|
|
||||||
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
|
|
||||||
if (googleUser != null) {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
await prefs.setString('googleUser', googleUser.displayName ?? 'Google User');
|
|
||||||
await prefs.setString('googleEmail', googleUser.email);
|
|
||||||
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const HomeScreen()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Google Sign-In Failed: $error')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
body: Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Image.asset(
|
|
||||||
'assets/logo.png',
|
|
||||||
width: 1000,
|
|
||||||
height: 150,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40),
|
|
||||||
InputField(
|
|
||||||
hintText: 'Username',
|
|
||||||
icon: Icons.person,
|
|
||||||
controller: usernameController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
InputField(
|
|
||||||
hintText: 'Password',
|
|
||||||
icon: Icons.lock,
|
|
||||||
obscureText: true,
|
|
||||||
controller: passwordController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Remember Me Checkbox - Centered
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Checkbox(
|
|
||||||
value: rememberMe,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
rememberMe = value ?? false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
activeColor: Colors.grey[800],
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
'Remember Me',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black87,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
/// Login Button
|
|
||||||
ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.grey[800],
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
minimumSize: const Size.fromHeight(50),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: login,
|
|
||||||
child: const Text('Login', style: TextStyle(fontSize: 18)),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Horizontal Line with "or"
|
|
||||||
Row(
|
|
||||||
children: const [
|
|
||||||
Expanded(
|
|
||||||
child: Divider(color: Colors.grey, thickness: 1),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
child: Text("or", style: TextStyle(color: Colors.grey, fontSize: 16)),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Divider(color: Colors.grey, thickness: 1),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Google Sign-In Button (Styled same as Login)
|
|
||||||
ElevatedButton.icon(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.grey[800], // Match Login Button
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
minimumSize: const Size.fromHeight(50),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: googleLogin,
|
|
||||||
icon: const Icon(Icons.g_mobiledata, size: 30), // Google Icon
|
|
||||||
label: const Text('Sign in with Google', style: TextStyle(fontSize: 18)),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
/// Register Text (Styled in Blue)
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const RegisterScreen()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
"Don't have an account? Register",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.grey, // Better visibility
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,248 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_mjpeg/flutter_mjpeg.dart';
|
|
||||||
import '../utils/translations.dart';
|
|
||||||
|
|
||||||
class MultiCameraScreen extends StatefulWidget {
|
|
||||||
final List<Map<String, dynamic>> cameras;
|
|
||||||
final String selectedLanguage;
|
|
||||||
|
|
||||||
const MultiCameraScreen({
|
|
||||||
super.key,
|
|
||||||
required this.cameras,
|
|
||||||
required this.selectedLanguage,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MultiCameraScreen> createState() => _MultiCameraScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MultiCameraScreenState extends State<MultiCameraScreen> {
|
|
||||||
int? _fullscreenIndex; // null = grid view, index = fullscreen camera
|
|
||||||
|
|
||||||
String _t(String key) {
|
|
||||||
return AppTranslations.translate(key, widget.selectedLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate grid columns based on camera count
|
|
||||||
int get _crossAxisCount {
|
|
||||||
final count = widget.cameras.length;
|
|
||||||
if (count == 1) return 1;
|
|
||||||
if (count <= 4) return 2;
|
|
||||||
return 3; // 5-6 cameras
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(
|
|
||||||
_fullscreenIndex == null
|
|
||||||
? _t('Multi-Camera View')
|
|
||||||
: "${_t('Camera')} ${widget.cameras[_fullscreenIndex!]['index']}",
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
||||||
onPressed: () {
|
|
||||||
if (_fullscreenIndex != null) {
|
|
||||||
setState(() {
|
|
||||||
_fullscreenIndex = null; // Exit fullscreen first
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Navigator.pop(context); // Exit screen
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
body: _fullscreenIndex == null
|
|
||||||
? _buildGridView()
|
|
||||||
: _buildFullscreenView(_fullscreenIndex!),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildGridView() {
|
|
||||||
return GridView.builder(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
itemCount: widget.cameras.length,
|
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: _crossAxisCount,
|
|
||||||
mainAxisSpacing: 8,
|
|
||||||
crossAxisSpacing: 8,
|
|
||||||
childAspectRatio: 4 / 3, // 4:3 aspect ratio for camera feeds
|
|
||||||
),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return _buildCameraCell(index);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildCameraCell(int index) {
|
|
||||||
final camera = widget.cameras[index];
|
|
||||||
final cameraIndex = camera['index'] as int;
|
|
||||||
final cameraIp = camera['ip'] as String;
|
|
||||||
|
|
||||||
final streamUrl = cameraIp.startsWith(RegExp(r"https?://"))
|
|
||||||
? cameraIp
|
|
||||||
: "http://$cameraIp";
|
|
||||||
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
_fullscreenIndex = index; // Enter fullscreen
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(color: Colors.grey[700]!, width: 1),
|
|
||||||
),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
// MJPEG Stream
|
|
||||||
Mjpeg(
|
|
||||||
stream: streamUrl,
|
|
||||||
isLive: true,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
error: (context, error, stackTrace) {
|
|
||||||
return _buildErrorWidget(cameraIndex);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// Camera label overlay
|
|
||||||
Positioned(
|
|
||||||
top: 8,
|
|
||||||
left: 8,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black.withValues(alpha: 0.6),
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
"${_t('Camera')} $cameraIndex",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildFullscreenView(int index) {
|
|
||||||
final camera = widget.cameras[index];
|
|
||||||
final cameraIndex = camera['index'] as int;
|
|
||||||
final cameraIp = camera['ip'] as String;
|
|
||||||
|
|
||||||
final streamUrl = cameraIp.startsWith(RegExp(r"https?://"))
|
|
||||||
? cameraIp
|
|
||||||
: "http://$cameraIp";
|
|
||||||
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
_fullscreenIndex = null; // Exit fullscreen, return to grid
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: Mjpeg(
|
|
||||||
stream: streamUrl,
|
|
||||||
isLive: true,
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
error: (context, error, stackTrace) {
|
|
||||||
return _buildErrorWidget(cameraIndex);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Back indicator overlay
|
|
||||||
Positioned(
|
|
||||||
bottom: 16,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Center(
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black.withValues(alpha: 0.6),
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.touch_app, color: Colors.white, size: 16),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
_t('Tap to return to grid'),
|
|
||||||
style:
|
|
||||||
const TextStyle(color: Colors.white, fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Camera label
|
|
||||||
Positioned(
|
|
||||||
top: 16,
|
|
||||||
left: 16,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black.withValues(alpha: 0.6),
|
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
"${_t('Camera')} $cameraIndex",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildErrorWidget(int cameraIndex) {
|
|
||||||
return Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.videocam_off, color: Colors.red, size: 32),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
"${_t('Camera')} $cameraIndex\n${_t('Stream unavailable')}",
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white70,
|
|
||||||
fontSize: 11,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../utils/target_colors.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
import 'package:flutter/services.dart' show rootBundle;
|
import 'package:flutter/services.dart' show rootBundle;
|
||||||
import 'package:image/image.dart' as img;
|
import 'package:image/image.dart' as img;
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
@@ -10,89 +12,6 @@ import 'dart:math';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import '../utils/translations.dart';
|
import '../utils/translations.dart';
|
||||||
|
|
||||||
// DEBUG: Set to true to show scoring rings visualization
|
|
||||||
const bool _DEBUG_SHOW_SCORING_RINGS = false;
|
|
||||||
|
|
||||||
class ScoringRingsPainter extends CustomPainter {
|
|
||||||
final Offset center;
|
|
||||||
final double scaleX;
|
|
||||||
final double scaleY;
|
|
||||||
final double targetScaleFactorX;
|
|
||||||
final double targetScaleFactorY;
|
|
||||||
|
|
||||||
ScoringRingsPainter({
|
|
||||||
required this.center,
|
|
||||||
required this.scaleX,
|
|
||||||
required this.scaleY,
|
|
||||||
required this.targetScaleFactorX,
|
|
||||||
required this.targetScaleFactorY,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
// Colors for each ring (10 to 1)
|
|
||||||
final List<Color> ringColors = [
|
|
||||||
Colors.red, // 10
|
|
||||||
Colors.orange, // 9
|
|
||||||
Colors.yellow, // 8
|
|
||||||
Colors.lime, // 7
|
|
||||||
Colors.green, // 6
|
|
||||||
Colors.cyan, // 5
|
|
||||||
Colors.blue, // 4
|
|
||||||
Colors.indigo, // 3
|
|
||||||
Colors.purple, // 2
|
|
||||||
Colors.pink, // 1
|
|
||||||
];
|
|
||||||
|
|
||||||
// Scoring rings distances from center (in default 1200x1200 space)
|
|
||||||
// Must match the rings in _generatePositionForScore
|
|
||||||
final List<double> rings = [14, 68, 123, 177, 232, 286, 342, 397, 455, 510];
|
|
||||||
|
|
||||||
// The canvas is already positioned at the image location
|
|
||||||
// Center should be scaled by target scale factors first (default 1200x1200 to actual target size)
|
|
||||||
// then by display scale factors (target image to screen)
|
|
||||||
final scaledCenter = Offset(
|
|
||||||
center.dx * targetScaleFactorX,
|
|
||||||
center.dy * targetScaleFactorY,
|
|
||||||
);
|
|
||||||
final displayCenter = Offset(
|
|
||||||
scaledCenter.dx * scaleX,
|
|
||||||
scaledCenter.dy * scaleY,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Draw each scoring ring with a different color
|
|
||||||
for (int i = 0; i < rings.length; i++) {
|
|
||||||
final paint = Paint()
|
|
||||||
..color = ringColors[i].withValues(alpha: 0.5)
|
|
||||||
..style = PaintingStyle.stroke
|
|
||||||
..strokeWidth = 2;
|
|
||||||
|
|
||||||
final ringRadius = rings[i];
|
|
||||||
// Scale by target scale factors (default 1200x1200 to actual target size)
|
|
||||||
// then by display scale factors (target image to screen)
|
|
||||||
final scaledRadiusX = ringRadius * targetScaleFactorX * scaleX;
|
|
||||||
final scaledRadiusY = ringRadius * targetScaleFactorY * scaleY;
|
|
||||||
final scaledRadius = (scaledRadiusX + scaledRadiusY) / 2;
|
|
||||||
canvas.drawCircle(displayCenter, scaledRadius, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw center point
|
|
||||||
final centerPaint = Paint()
|
|
||||||
..color = Colors.red
|
|
||||||
..style = PaintingStyle.fill;
|
|
||||||
canvas.drawCircle(displayCenter, 4, centerPaint);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(ScoringRingsPainter oldDelegate) {
|
|
||||||
return center != oldDelegate.center ||
|
|
||||||
scaleX != oldDelegate.scaleX ||
|
|
||||||
scaleY != oldDelegate.scaleY ||
|
|
||||||
targetScaleFactorX != oldDelegate.targetScaleFactorX ||
|
|
||||||
targetScaleFactorY != oldDelegate.targetScaleFactorY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PreviewScreen extends StatefulWidget {
|
class PreviewScreen extends StatefulWidget {
|
||||||
final String imagePath;
|
final String imagePath;
|
||||||
final List<DetectionResult> detections;
|
final List<DetectionResult> detections;
|
||||||
@@ -120,7 +39,6 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
img.Image? _realImageDecoded;
|
img.Image? _realImageDecoded;
|
||||||
img.Image? _targetImageDecoded;
|
img.Image? _targetImageDecoded;
|
||||||
Future<img.Image?>? _targetImageFuture;
|
Future<img.Image?>? _targetImageFuture;
|
||||||
Offset? _targetImageCenterForScoring;
|
|
||||||
|
|
||||||
Uint8List? _cachedTargetImage;
|
Uint8List? _cachedTargetImage;
|
||||||
Uint8List? _cachedRealImage;
|
Uint8List? _cachedRealImage;
|
||||||
@@ -134,8 +52,6 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
double _scaleFactorX = 1.0;
|
double _scaleFactorX = 1.0;
|
||||||
double _scaleFactorY = 1.0;
|
double _scaleFactorY = 1.0;
|
||||||
img.Image? _defaultTargetDecoded; // Default target for reference dimensions
|
img.Image? _defaultTargetDecoded; // Default target for reference dimensions
|
||||||
Offset?
|
|
||||||
_scaledTargetCenterForScoring; // Scaled center for scoring with display target
|
|
||||||
|
|
||||||
int? _highlightedBulletIndex;
|
int? _highlightedBulletIndex;
|
||||||
|
|
||||||
@@ -191,7 +107,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error loading current folder info: $e");
|
debugPrint("Error loading current folder info: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,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';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,138 +172,18 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
if (_defaultTargetDecoded == null || _targetImageDecoded == null) {
|
if (_defaultTargetDecoded == null || _targetImageDecoded == null) {
|
||||||
_scaleFactorX = 1.0;
|
_scaleFactorX = 1.0;
|
||||||
_scaleFactorY = 1.0;
|
_scaleFactorY = 1.0;
|
||||||
_scaledTargetCenterForScoring = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_scaleFactorX = _targetImageDecoded!.width / _defaultTargetDecoded!.width;
|
_scaleFactorX = _targetImageDecoded!.width / _defaultTargetDecoded!.width;
|
||||||
_scaleFactorY = _targetImageDecoded!.height / _defaultTargetDecoded!.height;
|
_scaleFactorY = _targetImageDecoded!.height / _defaultTargetDecoded!.height;
|
||||||
|
|
||||||
// Scale the center point for scoring
|
|
||||||
if (_targetImageCenterForScoring != null) {
|
|
||||||
_scaledTargetCenterForScoring = Offset(
|
|
||||||
_targetImageCenterForScoring!.dx * _scaleFactorX,
|
|
||||||
_targetImageCenterForScoring!.dy * _scaleFactorY,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
"📏 Scale factors calculated: X=$_scaleFactorX, Y=$_scaleFactorY");
|
"📏 Scale factors calculated: X=$_scaleFactorX, Y=$_scaleFactorY");
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getBackgroundColorForTarget(String targetPath) {
|
// One source of truth for target colors (utils/target_colors.dart)
|
||||||
// Map each target to its background color (extracted from first pixel of each image)
|
Color _getBackgroundColorForTarget(String targetPath) =>
|
||||||
switch (targetPath) {
|
TargetColors.getBackgroundColor(targetPath);
|
||||||
case 'assets/target.png':
|
|
||||||
return const Color(0xFFFFFFFF); // White
|
|
||||||
|
|
||||||
case 'assets/targets/Target1.jpg':
|
|
||||||
return const Color(0xFFE8ECD5); // Light beige
|
|
||||||
|
|
||||||
case 'assets/targets/Target2.jpg':
|
|
||||||
return const Color(0xFFC1DF87); // Light green
|
|
||||||
|
|
||||||
case 'assets/targets/Target3.jpg':
|
|
||||||
return const Color(0xFFFEFEFE); // Off-white
|
|
||||||
|
|
||||||
case 'assets/targets/Target4.jpg':
|
|
||||||
return const Color(0xFFD42931); // Red
|
|
||||||
|
|
||||||
case 'assets/targets/Target5.jpg':
|
|
||||||
return const Color(0xFF02050A); // Very dark blue/black
|
|
||||||
|
|
||||||
case 'assets/targets/Target6.jpg':
|
|
||||||
return const Color(0xFFF3E7D1); // Light beige
|
|
||||||
|
|
||||||
case 'assets/targets/Target7.jpg':
|
|
||||||
return const Color(0xFFFFD454); // Bright yellow
|
|
||||||
|
|
||||||
case 'assets/targets/Target8.jpg':
|
|
||||||
return const Color(0xFF1E5E81); // Dark teal blue
|
|
||||||
|
|
||||||
case 'assets/targets/Target9.jpg':
|
|
||||||
return const Color(0xFFFEFEFC); // Off-white
|
|
||||||
|
|
||||||
case 'assets/targets/Target10.jpg':
|
|
||||||
return const Color(0xFF98926E); // Olive green
|
|
||||||
|
|
||||||
case 'assets/targets/Target11.jpg':
|
|
||||||
return const Color(0xFF13132B); // Dark blue
|
|
||||||
|
|
||||||
case 'assets/targets/Target12.jpg':
|
|
||||||
return const Color(0xFFF5F4EF); // Off-white
|
|
||||||
|
|
||||||
case 'assets/targets/Target13.jpg':
|
|
||||||
return const Color(0xFF174AA5); // Blue
|
|
||||||
|
|
||||||
case 'assets/targets/Target14.jpg':
|
|
||||||
return const Color(0xFFFEE05E); // Light yellow
|
|
||||||
|
|
||||||
case 'assets/targets/Target15.jpg':
|
|
||||||
return const Color(0xFFFFFFFF); // White
|
|
||||||
|
|
||||||
case 'assets/targets/Target16.jpg':
|
|
||||||
return const Color(0xFF000000); // Black
|
|
||||||
|
|
||||||
case 'assets/targets/Target17.jpg':
|
|
||||||
return const Color(0xFF21304D); // Dark blue
|
|
||||||
|
|
||||||
case 'assets/targets/Target18.jpg':
|
|
||||||
return const Color(0xFF050608); // Very dark gray
|
|
||||||
|
|
||||||
case 'assets/targets/Target19.jpg':
|
|
||||||
return const Color(0xFFF68527); // Warm orange
|
|
||||||
|
|
||||||
case 'assets/targets/Target20.jpg':
|
|
||||||
return const Color(0xFFA9D9EF); // Light blue
|
|
||||||
|
|
||||||
case 'assets/targets/Target21.jpg':
|
|
||||||
return const Color(0xFFDA6868); // Muted red
|
|
||||||
|
|
||||||
case 'assets/targets/Target22.jpg':
|
|
||||||
return const Color(0xFFFBFAF6); // Off-white
|
|
||||||
|
|
||||||
case 'assets/targets/Target23.jpg':
|
|
||||||
return const Color(0xFF000000); // Black
|
|
||||||
|
|
||||||
case 'assets/targets/Target24.jpg':
|
|
||||||
return const Color(0xFFb7b7b7); // Gray
|
|
||||||
|
|
||||||
case 'assets/targets/Target25.jpg':
|
|
||||||
return const Color(0xFF040308); // Very dark gray
|
|
||||||
|
|
||||||
case 'assets/targets/Target26.jpg':
|
|
||||||
return const Color(0xFF161C2C); // Dark blue-gray
|
|
||||||
|
|
||||||
case 'assets/targets/Target27.jpg':
|
|
||||||
return const Color(0xFF28A5DF); // Blue
|
|
||||||
|
|
||||||
case 'assets/targets/Target28.jpg':
|
|
||||||
return const Color(0xFFFFFFFF); // White
|
|
||||||
|
|
||||||
case 'assets/targets/Target29.jpg':
|
|
||||||
return const Color(0xFF180E27); // Dark purple
|
|
||||||
|
|
||||||
case 'assets/targets/Target30.jpg':
|
|
||||||
return const Color(0xFFFDFDFB); // Off-white
|
|
||||||
|
|
||||||
case 'assets/targets/Target31.jpg':
|
|
||||||
return const Color(0xFFC52736); // Red
|
|
||||||
|
|
||||||
case 'assets/targets/Target32.jpg':
|
|
||||||
return const Color(0xFFFCF3EE); // Light cream
|
|
||||||
|
|
||||||
case 'assets/targets/Target33.jpg':
|
|
||||||
return const Color(0xFFFCFCF3); // Very light off-white
|
|
||||||
|
|
||||||
case 'assets/targets/Target34.jpg':
|
|
||||||
return const Color(0xFFFFFFFD); // Almost white
|
|
||||||
|
|
||||||
case 'assets/targets/Target35.jpg':
|
|
||||||
return const Color(0xFFFFC5C4); // Light salmon
|
|
||||||
|
|
||||||
default:
|
|
||||||
return Colors.grey[900]!; // Fallback to dark gray
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadBulletColor() async {
|
Future<void> _loadBulletColor() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@@ -476,15 +272,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
Future<img.Image?> _loadAndDecodeTargetImage() async {
|
Future<img.Image?> _loadAndDecodeTargetImage() async {
|
||||||
final byteData = await rootBundle.load(targetAssetPath);
|
final byteData = await rootBundle.load(targetAssetPath);
|
||||||
final bytes = byteData.buffer.asUint8List();
|
final bytes = byteData.buffer.asUint8List();
|
||||||
final tempDir = await getTemporaryDirectory();
|
return img.decodeImage(bytes);
|
||||||
final targetFile = File('${tempDir.path}/target.png');
|
|
||||||
await targetFile.writeAsBytes(bytes);
|
|
||||||
final decoded = img.decodeImage(bytes);
|
|
||||||
if (decoded != null) {
|
|
||||||
_targetImageCenterForScoring =
|
|
||||||
Offset(decoded.width / 2, decoded.height / 2 - 1);
|
|
||||||
}
|
|
||||||
return decoded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _runDetectionAndMapping() async {
|
Future<void> _runDetectionAndMapping() async {
|
||||||
@@ -578,109 +366,6 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _manualScoreEntry() {
|
|
||||||
final missingCount = widget.bulletCount - _mappedBullets.length;
|
|
||||||
final controllers =
|
|
||||||
List.generate(missingCount, (_) => TextEditingController());
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return Dialog(
|
|
||||||
backgroundColor: Colors.grey[900],
|
|
||||||
shape:
|
|
||||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(24.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
_t('Enter Missing Bullet Scores'),
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxHeight: 300),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: List.generate(missingCount, (index) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
|
||||||
child: TextField(
|
|
||||||
controller: controllers[index],
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText:
|
|
||||||
'${_t('Bullet Score')} ${_mappedBullets.length + index + 1}',
|
|
||||||
labelStyle:
|
|
||||||
const TextStyle(color: Colors.white54),
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey[800],
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
borderSide: BorderSide.none,
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
borderSide: BorderSide(color: _bulletColor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () {
|
|
||||||
final scores = controllers
|
|
||||||
.map((c) => int.tryParse(c.text.trim()) ?? 0)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
for (final score in scores) {
|
|
||||||
final offset = _generatePositionForScore(score);
|
|
||||||
// Scale position from default coordinate system to display target size
|
|
||||||
final scaledOffset = Offset(
|
|
||||||
offset.dx * _scaleFactorX,
|
|
||||||
offset.dy * _scaleFactorY,
|
|
||||||
);
|
|
||||||
_mappedBullets.add(scaledOffset);
|
|
||||||
_manualBulletScores.add(score);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: _bulletColor,
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Text(_t('Add Bullets')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showMissingBulletDialog(int bulletNum) {
|
void _showMissingBulletDialog(int bulletNum) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -871,7 +556,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
|
|
||||||
await _performSave(lastFolder, false);
|
await _performSave(lastFolder, false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error saving to last folder: $e");
|
debugPrint("Error saving to last folder: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,7 +583,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
|
|
||||||
await _performSave(selectedFolder, isTournament);
|
await _performSave(selectedFolder, isTournament);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error saving target data: $e");
|
debugPrint("Error saving target data: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -940,6 +625,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
final targetData = {
|
final targetData = {
|
||||||
'date': dateString,
|
'date': dateString,
|
||||||
'totalScore': _totalScore,
|
'totalScore': _totalScore,
|
||||||
|
'bulletCount': widget.bulletCount, // shots fired; missed ones are absent from 'bullets'
|
||||||
'bullets': bulletsInDefaultCoordinates,
|
'bullets': bulletsInDefaultCoordinates,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -948,15 +634,17 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
await jsonFile.writeAsString(jsonEncode(targetData));
|
await jsonFile.writeAsString(jsonEncode(targetData));
|
||||||
|
|
||||||
// Close preview and signal refresh
|
// Close preview and signal refresh
|
||||||
|
if (!mounted) return;
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error performing save: $e");
|
debugPrint("Error performing save: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEditController() {
|
Widget _buildEditController() {
|
||||||
if (!_isEditMode || _selectedBulletIndexInEdit == null)
|
if (!_isEditMode || _selectedBulletIndexInEdit == null) {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
|
||||||
return Positioned(
|
return Positioned(
|
||||||
bottom: 20,
|
bottom: 20,
|
||||||
@@ -1079,22 +767,24 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nextTraining = '$trainingWord $trainingCount';
|
final String nextTraining = '$trainingWord $trainingCount';
|
||||||
final String nextTournament = '$tournamentWord $tournamentCount';
|
final String nextTournament = '$tournamentWord $tournamentCount';
|
||||||
|
|
||||||
|
if (!mounted) return null;
|
||||||
return showDialog<String>(
|
return showDialog<String>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
@@ -1273,8 +963,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
int get _totalScore {
|
int get _totalScore {
|
||||||
// Score is based on the default target coordinate system (1200x1200)
|
// Score is based on the default target coordinate system (1200x1200)
|
||||||
// since bullets were mapped to that system and then scaled for display
|
// since bullets were mapped to that system and then scaled for display
|
||||||
|
// Manual bullets are appended after the detected ones and scored below,
|
||||||
|
// so take only the detected ones here (at most the remaining shot slots).
|
||||||
|
final detected = _mappedBullets.length - _manualBulletScores.length;
|
||||||
final autoScore = _mappedBullets
|
final autoScore = _mappedBullets
|
||||||
.take(widget.bulletCount - _manualBulletScores.length)
|
.take(min(detected, widget.bulletCount - _manualBulletScores.length))
|
||||||
.map((b) {
|
.map((b) {
|
||||||
// Scale bullet back to default coordinate system for scoring
|
// Scale bullet back to default coordinate system for scoring
|
||||||
final defaultTargetBullet = Offset(
|
final defaultTargetBullet = Offset(
|
||||||
@@ -1349,7 +1042,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
children: [
|
children: [
|
||||||
// Training/Tournament Banner
|
// Training/Tournament Banner
|
||||||
Container(
|
Container(
|
||||||
color: Colors.grey[300],
|
color: Surfaces.current.card,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 16, vertical: 10),
|
horizontal: 16, vertical: 10),
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -1359,9 +1052,9 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
_currentFolderName.isNotEmpty
|
_currentFolderName.isNotEmpty
|
||||||
? _currentFolderName
|
? _currentFolderName
|
||||||
: 'No training selected',
|
: _t('No training selected'),
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: Surfaces.current.textPrimary,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
@@ -1371,8 +1064,8 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
if (_currentDate.isNotEmpty)
|
if (_currentDate.isNotEmpty)
|
||||||
Text(
|
Text(
|
||||||
_currentDate,
|
_currentDate,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.black,
|
color: Surfaces.current.textPrimary,
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1467,24 +1160,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
// DEBUG: Show scoring rings in both modes to verify alignment
|
|
||||||
if (_DEBUG_SHOW_SCORING_RINGS)
|
|
||||||
Positioned(
|
|
||||||
left: offsetX,
|
|
||||||
top: offsetY,
|
|
||||||
width: displayWidth,
|
|
||||||
height: displayHeight,
|
|
||||||
child: CustomPaint(
|
|
||||||
painter: ScoringRingsPainter(
|
|
||||||
center: fixedRingTargetCenter,
|
|
||||||
scaleX: scaleX,
|
|
||||||
scaleY: scaleY,
|
|
||||||
targetScaleFactorX: _scaleFactorX,
|
|
||||||
targetScaleFactorY: _scaleFactorY,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_mode == PreviewMode.mappedTarget)
|
if (_mode == PreviewMode.mappedTarget)
|
||||||
..._mappedBullets
|
..._mappedBullets
|
||||||
.asMap()
|
.asMap()
|
||||||
@@ -1543,14 +1219,15 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
if (_mappedBullets.isNotEmpty)
|
// Shown even with no detections, so missed shots can be scored by hand
|
||||||
|
if (widget.bulletCount > 0)
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
// Score buttons for detected and missing bullets
|
// Score buttons for detected and missing bullets
|
||||||
@@ -1636,7 +1313,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
Container(
|
Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[300],
|
color: Surfaces.current.card,
|
||||||
borderRadius:
|
borderRadius:
|
||||||
const BorderRadius
|
const BorderRadius
|
||||||
.only(
|
.only(
|
||||||
@@ -1649,11 +1326,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${index + 1}',
|
'${index + 1}',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontWeight:
|
fontWeight:
|
||||||
FontWeight.bold,
|
FontWeight.bold,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.black87,
|
color: Surfaces.current.textPrimary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1728,7 +1405,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
Container(
|
Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[300],
|
color: Surfaces.current.card,
|
||||||
borderRadius:
|
borderRadius:
|
||||||
const BorderRadius
|
const BorderRadius
|
||||||
.only(
|
.only(
|
||||||
@@ -1741,11 +1418,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
'$bulletNum',
|
'$bulletNum',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontWeight:
|
fontWeight:
|
||||||
FontWeight.bold,
|
FontWeight.bold,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.black87,
|
color: Surfaces.current.textPrimary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1791,109 +1468,73 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
// Room for the save button, which sticks up out of the bottom bar
|
||||||
|
const SizedBox(height: 40),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
_buildEditController(),
|
_buildEditController(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: Column(
|
// Same layout as the camera screen: number on the left, round white
|
||||||
mainAxisSize: MainAxisSize.min,
|
// main action docked in the notch, secondary icons on the right.
|
||||||
children: [
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||||
// Top bar - Total Score
|
floatingActionButton: FloatingActionButton(
|
||||||
Container(
|
backgroundColor: Colors.white,
|
||||||
color: Colors.grey[300],
|
onPressed: _saveToLastFolder,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
tooltip: _t("Save"),
|
||||||
child: Row(
|
child: const Icon(Icons.save, color: Colors.black),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.track_changes, size: 20, color: Colors.black),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
_t("Total score:"),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 13,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
),
|
||||||
),
|
bottomNavigationBar: BottomAppBar(
|
||||||
const SizedBox(width: 12),
|
|
||||||
Text(
|
|
||||||
"$_totalScore",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Bottom bar - Action Buttons
|
|
||||||
BottomAppBar(
|
|
||||||
color: Colors.grey[900],
|
color: Colors.grey[900],
|
||||||
padding: EdgeInsets.zero,
|
shape: const CircularNotchedRectangle(),
|
||||||
|
notchMargin: 8.0,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 60,
|
height: 60,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
// Plus button (left, no background)
|
// Left - total score
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Center(
|
child: Padding(
|
||||||
child: IconButton(
|
padding: const EdgeInsets.only(left: 16),
|
||||||
icon: Stack(
|
child: Column(
|
||||||
alignment: Alignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.folder, color: Colors.white, size: 24),
|
Text(
|
||||||
Positioned(
|
_t('Total').toUpperCase(),
|
||||||
bottom: 0,
|
style: const TextStyle(
|
||||||
right: 0,
|
fontSize: 10,
|
||||||
child: Container(
|
fontWeight: FontWeight.bold,
|
||||||
decoration: const BoxDecoration(
|
letterSpacing: 1.2,
|
||||||
color: Colors.white,
|
color: Colors.white54,
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(2),
|
),
|
||||||
child: const Icon(Icons.add, color: Colors.grey, size: 10),
|
Text(
|
||||||
|
'$_totalScore',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
height: 1.1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Center space for FAB
|
||||||
|
const SizedBox(width: 80),
|
||||||
|
// Right - save to another folder, edit mode
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.create_new_folder_outlined, color: Colors.white, size: 24),
|
||||||
onPressed: _saveTargetDataWithDialog,
|
onPressed: _saveTargetDataWithDialog,
|
||||||
|
tooltip: _t("Save to folder"),
|
||||||
),
|
),
|
||||||
),
|
IconButton(
|
||||||
),
|
|
||||||
// Save button (center with white background)
|
|
||||||
Expanded(
|
|
||||||
child: Center(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
child: SizedBox(
|
|
||||||
width: 60,
|
|
||||||
height: 40,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: _saveToLastFolder,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: const Icon(Icons.save,
|
|
||||||
color: Colors.black, size: 20),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Edit button (right)
|
|
||||||
Expanded(
|
|
||||||
child: Center(
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_isEditMode ? Icons.check : Icons.edit,
|
_isEditMode ? Icons.check : Icons.edit,
|
||||||
color: _isEditMode ? Colors.red : Colors.white,
|
color: _isEditMode ? Colors.red : Colors.white,
|
||||||
@@ -1907,14 +1548,14 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
},
|
},
|
||||||
tooltip: _isEditMode ? _t("Done Editing") : _t("Edit Mode"),
|
tooltip: _isEditMode ? _t("Done Editing") : _t("Edit Mode"),
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,180 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import '../widgets/input_field.dart';
|
|
||||||
import 'login_screen.dart';
|
|
||||||
|
|
||||||
class RegisterScreen extends StatefulWidget {
|
|
||||||
const RegisterScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<RegisterScreen> createState() => _RegisterScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RegisterScreenState extends State<RegisterScreen> {
|
|
||||||
final usernameController = TextEditingController();
|
|
||||||
final emailController = TextEditingController();
|
|
||||||
final passwordController = TextEditingController();
|
|
||||||
final confirmPasswordController = TextEditingController();
|
|
||||||
|
|
||||||
Future<void> register() async {
|
|
||||||
String username = usernameController.text.trim();
|
|
||||||
String email = emailController.text.trim();
|
|
||||||
String password = passwordController.text.trim();
|
|
||||||
String confirmPassword = confirmPasswordController.text.trim();
|
|
||||||
|
|
||||||
if (username.isEmpty || email.isEmpty || password.isEmpty || confirmPassword.isEmpty) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('All fields are required')),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(email)) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Invalid email format')),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (password != confirmPassword) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Passwords do not match')),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
|
|
||||||
// Check if the username or email is already taken
|
|
||||||
String? existingUser = prefs.getString(username);
|
|
||||||
String? existingEmail = prefs.getString(email);
|
|
||||||
if (existingUser != null || existingEmail != null) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Username or Email already exists. Choose another.')),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save user credentials in SharedPreferences
|
|
||||||
await prefs.setString(username, password);
|
|
||||||
await prefs.setString(email, username); // Store email linked to the username
|
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Registration Successful! Please Login')),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Redirect to Login Screen
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const LoginScreen()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.white,
|
|
||||||
body: Center(
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
padding: const EdgeInsets.all(24),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
/// Logo
|
|
||||||
Image.asset(
|
|
||||||
'assets/logo.png',
|
|
||||||
width: 1000,
|
|
||||||
height: 150,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40),
|
|
||||||
|
|
||||||
/// Username Field
|
|
||||||
InputField(
|
|
||||||
hintText: 'Username',
|
|
||||||
icon: Icons.person,
|
|
||||||
controller: usernameController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Email Field
|
|
||||||
InputField(
|
|
||||||
hintText: 'Email',
|
|
||||||
icon: Icons.email,
|
|
||||||
controller: emailController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Password Field
|
|
||||||
InputField(
|
|
||||||
hintText: 'Password',
|
|
||||||
icon: Icons.lock,
|
|
||||||
obscureText: true,
|
|
||||||
controller: passwordController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Confirm Password Field
|
|
||||||
InputField(
|
|
||||||
hintText: 'Confirm Password',
|
|
||||||
icon: Icons.lock,
|
|
||||||
obscureText: true,
|
|
||||||
controller: confirmPasswordController,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
|
|
||||||
/// Register Button
|
|
||||||
ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.grey[800], // Match Login Button
|
|
||||||
foregroundColor: Colors.white,
|
|
||||||
minimumSize: const Size.fromHeight(50),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: register,
|
|
||||||
child: const Text('Register', style: TextStyle(fontSize: 18)),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Horizontal Line with "or" (optional, in case Google Sign-Up is added)
|
|
||||||
Row(
|
|
||||||
children: const [
|
|
||||||
Expanded(
|
|
||||||
child: Divider(color: Colors.grey, thickness: 1),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
child: Text("or", style: TextStyle(color: Colors.grey, fontSize: 16)),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Divider(color: Colors.grey, thickness: 1),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
|
|
||||||
/// Login Navigation (Styled in Blue)
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const LoginScreen()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
"Already have an account? Login",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
color: Colors.grey, // Styled for better visibility
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import '../services/app_settings.dart';
|
||||||
|
import '../services/target_repository.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
import '../widgets/section.dart';
|
||||||
|
import 'target_view.dart';
|
||||||
|
|
||||||
|
/// One training or tournament: its stats, its targets, and edit/delete actions.
|
||||||
|
class SessionScreen extends StatefulWidget {
|
||||||
|
final Session session;
|
||||||
|
|
||||||
|
const SessionScreen({super.key, required this.session});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SessionScreen> createState() => _SessionScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SessionScreenState extends State<SessionScreen> {
|
||||||
|
late Session _session = widget.session;
|
||||||
|
|
||||||
|
Future<void> _reload() async {
|
||||||
|
final sessions = await TargetRepository.loadSessions();
|
||||||
|
final updated = sessions.where((s) => s.name == _session.name);
|
||||||
|
if (!mounted) return;
|
||||||
|
if (updated.isEmpty) {
|
||||||
|
Navigator.pop(context); // session no longer exists
|
||||||
|
} else {
|
||||||
|
setState(() => _session = updated.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _openTargets(List<TargetRecord> targets) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => TargetViewScreen(
|
||||||
|
jsonFiles: [for (final t in targets) t.file],
|
||||||
|
refreshFolders: _reload,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _edit() async {
|
||||||
|
final result = await showEditSessionDialog(context, _session);
|
||||||
|
if (result == null) return;
|
||||||
|
final ok = await TargetRepository.updateSession(_session, name: result.name, isTournament: result.isTournament);
|
||||||
|
if (!mounted) return;
|
||||||
|
if (!ok) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text(AppSettings.instance.t('A folder with this name already exists'))),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_session = Session(name: result.name, isTournament: result.isTournament, date: _session.date, targets: _session.targets);
|
||||||
|
_reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _delete() async {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final message = '${s.t('Are you sure you want to delete the folder')} "${_session.name}" ${s.t('and all of its contents?')}';
|
||||||
|
if (await confirmDelete(context, message) != true) return;
|
||||||
|
await TargetRepository.deleteSession(_session);
|
||||||
|
if (mounted) Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _deleteTarget(TargetRecord target) async {
|
||||||
|
if (await confirmDelete(context, AppSettings.instance.t('Are you sure you want to delete this file?')) != true) return;
|
||||||
|
await TargetRepository.deleteTarget(target);
|
||||||
|
_reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListenableBuilder(
|
||||||
|
listenable: AppSettings.instance,
|
||||||
|
builder: (context, _) {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final t = s.t;
|
||||||
|
final surf = Surfaces.current;
|
||||||
|
final session = _session;
|
||||||
|
final stats = ShooterStats.of([session]);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: s.backgroundColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(session.name, style: const TextStyle(color: Colors.white)),
|
||||||
|
backgroundColor: AppTheme.bar,
|
||||||
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
|
scrolledUnderElevation: 0,
|
||||||
|
actions: [
|
||||||
|
IconButton(icon: const Icon(Icons.edit), tooltip: t('Edit'), onPressed: _edit),
|
||||||
|
IconButton(icon: const Icon(Icons.delete, color: Colors.red), tooltip: t('Delete'), onPressed: _delete),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
// Keep the last row clear of the system gesture bar (edge-to-edge)
|
||||||
|
padding: EdgeInsets.fromLTRB(16, 4, 16, 24 + MediaQuery.paddingOf(context).bottom),
|
||||||
|
children: [
|
||||||
|
SectionHeader(
|
||||||
|
'${session.isTournament ? t('Tournament') : t('Training')} · ${DateFormat('d. M. yyyy').format(session.date)}',
|
||||||
|
),
|
||||||
|
StatGrid(tiles: [
|
||||||
|
StatTile(label: t('Total'), value: '${session.totalScore}', caption: targetCount(session.targets.length)),
|
||||||
|
StatTile(
|
||||||
|
label: t('Average per shot'),
|
||||||
|
value: stats.averagePerShot?.toStringAsFixed(2) ?? '–',
|
||||||
|
caption: shotCount(stats.shots),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
SectionHeader(t('Targets')),
|
||||||
|
if (session.targets.isEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Text(t('No targets in this folder'), style: TextStyle(color: surf.textSecondary)),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
GroupCard(children: [
|
||||||
|
for (int i = 0; i < session.targets.length; i++)
|
||||||
|
SettingsTile(
|
||||||
|
title: '${t('Target')} ${i + 1}',
|
||||||
|
subtitle: '${DateFormat('HH:mm').format(session.targets[i].shotAt)} · ${shotCount(session.targets[i].shots)}',
|
||||||
|
onTap: () => _openTargets([session.targets[i]]),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${session.targets[i].score}',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: surf.textPrimary),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.delete, color: Colors.red, size: 20),
|
||||||
|
onPressed: () => _deleteTarget(session.targets[i]),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "1 target" / "5 targets", with Slovenian dual and plural forms.
|
||||||
|
String targetCount(int n) {
|
||||||
|
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';
|
||||||
|
final mod = n % 100;
|
||||||
|
final word = mod == 1 ? 'tarča' : mod == 2 ? 'tarči' : (mod == 3 || mod == 4) ? 'tarče' : 'tarč';
|
||||||
|
return '$n $word';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "1 shot" / "5 shots", with Slovenian dual and plural forms.
|
||||||
|
String shotCount(int n) {
|
||||||
|
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';
|
||||||
|
final mod = n % 100;
|
||||||
|
final word = mod == 1 ? 'strel' : mod == 2 ? 'strela' : (mod == 3 || mod == 4) ? 'streli' : 'strelov';
|
||||||
|
return '$n $word';
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool?> confirmDelete(BuildContext context, String message) {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
return showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialog) => AlertDialog(
|
||||||
|
title: Text(s.t('Confirm Deletion')),
|
||||||
|
content: Text(message),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialog, false),
|
||||||
|
child: Text(s.t('Cancel'), style: const TextStyle(color: Colors.white70)),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
style: FilledButton.styleFrom(backgroundColor: Colors.red[700]),
|
||||||
|
onPressed: () => Navigator.pop(dialog, true),
|
||||||
|
child: Text(s.t('Yes, delete')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class SessionEdit {
|
||||||
|
final String name;
|
||||||
|
final bool isTournament;
|
||||||
|
|
||||||
|
const SessionEdit(this.name, this.isTournament);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rename a session and choose training/tournament.
|
||||||
|
Future<SessionEdit?> showEditSessionDialog(BuildContext context, Session session) {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final controller = TextEditingController(text: session.name);
|
||||||
|
var isTournament = session.isTournament;
|
||||||
|
|
||||||
|
return showDialog<SessionEdit>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialog) => StatefulBuilder(
|
||||||
|
builder: (context, setDialogState) => AlertDialog(
|
||||||
|
title: Text(s.t('Folder Settings')),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
TextField(
|
||||||
|
controller: controller,
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
cursorColor: s.bulletColor,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.white10,
|
||||||
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide.none),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(color: s.bulletColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
SwitchListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: Text(s.t('Tournament'), style: const TextStyle(color: Colors.white)),
|
||||||
|
secondary: Icon(Icons.emoji_events, color: isTournament ? s.bulletColor : Colors.white54),
|
||||||
|
value: isTournament,
|
||||||
|
activeTrackColor: s.bulletColor,
|
||||||
|
onChanged: (v) => setDialogState(() => isTournament = v),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialog),
|
||||||
|
child: Text(s.t('Cancel'), style: const TextStyle(color: Colors.white70)),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
style: FilledButton.styleFrom(backgroundColor: s.bulletColor),
|
||||||
|
onPressed: () {
|
||||||
|
final name = controller.text.trim();
|
||||||
|
if (name.isEmpty || name.contains('/')) return;
|
||||||
|
Navigator.pop(dialog, SessionEdit(name, isTournament));
|
||||||
|
},
|
||||||
|
child: Text(s.t('Save')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_mjpeg/flutter_mjpeg.dart';
|
import 'package:flutter_mjpeg/flutter_mjpeg.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import '../utils/translations.dart';
|
import '../utils/translations.dart';
|
||||||
|
import '../services/wifi_binding.dart';
|
||||||
|
|
||||||
class SpectatorScreen extends StatefulWidget {
|
class SpectatorScreen extends StatefulWidget {
|
||||||
final String selectedLanguage;
|
final String selectedLanguage;
|
||||||
@@ -16,22 +17,32 @@ class SpectatorScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SpectatorScreenState extends State<SpectatorScreen> {
|
class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||||
List<bool> _selectedCameras = List.generate(6, (_) => true); // All selected by default
|
final List<bool> _selectedCameras = List.generate(6, (_) => true); // All selected by default
|
||||||
List<bool> _enabledCameras = List.generate(6, (_) => false); // Which cameras have IPs configured
|
List<bool> _enabledCameras = List.generate(6, (_) => false); // Which cameras have IPs configured
|
||||||
List<Map<String, dynamic>> _cameras = [];
|
List<Map<String, dynamic>> _cameras = [];
|
||||||
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
||||||
|
late final Future<void> _wifiReady;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_wifiReady = WifiBinding.acquire();
|
||||||
_loadCameras();
|
_loadCameras();
|
||||||
_loadBulletColor();
|
_loadBulletColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
WifiBinding.release();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
String _t(String key) {
|
String _t(String key) {
|
||||||
return AppTranslations.translate(key, widget.selectedLanguage);
|
return AppTranslations.translate(key, widget.selectedLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadCameras() async {
|
Future<void> _loadCameras() async {
|
||||||
|
await _wifiReady; // streams must start after traffic is pinned to Wi-Fi
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
List<Map<String, dynamic>> cameras = [];
|
List<Map<String, dynamic>> cameras = [];
|
||||||
List<bool> enabledCameras = List.generate(6, (_) => false);
|
List<bool> enabledCameras = List.generate(6, (_) => false);
|
||||||
|
|||||||
@@ -1,153 +1,133 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import '../services/app_settings.dart';
|
||||||
import 'stream_screen.dart'; // Import the camera stream screen
|
import '../theme/app_theme.dart';
|
||||||
import '../utils/translations.dart';
|
import 'camera_settings_screen.dart';
|
||||||
import '../utils/target_colors.dart';
|
import 'stream_screen.dart';
|
||||||
|
|
||||||
class TargetScreen extends StatefulWidget {
|
/// Shooting: one tile per position. A position with cameras at several
|
||||||
|
/// locations asks where we are shooting before opening the stream.
|
||||||
|
class TargetScreen extends StatelessWidget {
|
||||||
const TargetScreen({super.key});
|
const TargetScreen({super.key});
|
||||||
|
|
||||||
@override
|
void _openPosition(BuildContext context, int position) {
|
||||||
State<TargetScreen> createState() => _TargetScreenState();
|
final s = AppSettings.instance;
|
||||||
|
final cameras = s.cameras.camerasAt(position);
|
||||||
|
if (cameras.isEmpty) {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (_) => const CameraSettingsScreen()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (cameras.length == 1) {
|
||||||
|
_openStream(context, position, cameras.keys.first, cameras.values.first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
builder: (sheet) => SafeArea(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
s.t('Where are we shooting?'),
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${s.t('Camera')} $position',
|
||||||
|
style: const TextStyle(color: Colors.white54, fontSize: 12),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
for (final entry in cameras.entries)
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(Icons.place_rounded, color: s.bulletColor),
|
||||||
|
title: Text(entry.key, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600)),
|
||||||
|
subtitle: Text(entry.value, style: const TextStyle(color: Colors.white54)),
|
||||||
|
trailing: entry.key == s.cameras.activeLocation
|
||||||
|
? Icon(Icons.check_rounded, color: s.bulletColor)
|
||||||
|
: const Icon(Icons.chevron_right, color: Colors.white38),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(sheet);
|
||||||
|
_openStream(context, position, entry.key, entry.value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TargetScreenState extends State<TargetScreen> {
|
void _openStream(BuildContext context, int position, String location, String ip) {
|
||||||
List<bool> _cameraButtonsEnabled =
|
AppSettings.instance.setActiveLocation(location);
|
||||||
List.generate(6, (_) => false); // Initially, all buttons are disabled
|
Navigator.push(
|
||||||
String _selectedLanguage = 'English';
|
context,
|
||||||
late Color _backgroundColor;
|
MaterialPageRoute(
|
||||||
|
builder: (_) => CameraStreamScreen(cameraIndex: position, ip: ip, location: location),
|
||||||
@override
|
),
|
||||||
void initState() {
|
);
|
||||||
super.initState();
|
|
||||||
// Initialize with default target background color
|
|
||||||
_backgroundColor = TargetColors.getBackgroundColor('assets/target.png');
|
|
||||||
_loadLanguage();
|
|
||||||
_loadSelectedTargetColor();
|
|
||||||
_loadCameraData();
|
|
||||||
}
|
|
||||||
|
|
||||||
String _t(String key) {
|
|
||||||
return AppTranslations.translate(key, _selectedLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadLanguage() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
setState(() {
|
|
||||||
_selectedLanguage = prefs.getString('language') ?? 'English';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadSelectedTargetColor() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
|
||||||
setState(() {
|
|
||||||
_backgroundColor = TargetColors.getBackgroundColor(selectedTarget);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Load the camera IPs from SharedPreferences and update button status
|
|
||||||
Future<void> _loadCameraData() async {
|
|
||||||
final prefs = await SharedPreferences.getInstance();
|
|
||||||
final List<String> defaultIPs = [
|
|
||||||
'192.168.0.134:9081',
|
|
||||||
'192.168.0.134:9082',
|
|
||||||
'192.168.0.134:9083',
|
|
||||||
'192.168.0.134:9084',
|
|
||||||
'192.168.0.134:9085',
|
|
||||||
'192.168.0.134:9086',
|
|
||||||
];
|
|
||||||
|
|
||||||
List<bool> cameraDataStatus = List.generate(6, (index) {
|
|
||||||
String key = 'cameraIP_${index + 1}';
|
|
||||||
|
|
||||||
if (!prefs.containsKey(key)) {
|
|
||||||
prefs.setString(key, defaultIPs[index]);
|
|
||||||
return true; // Default set
|
|
||||||
}
|
|
||||||
|
|
||||||
String? ip = prefs.getString(key);
|
|
||||||
return ip != null && ip.isNotEmpty && ip != 'Not Set';
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!mounted) return;
|
|
||||||
setState(() {
|
|
||||||
_cameraButtonsEnabled = cameraDataStatus;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return ListenableBuilder(
|
||||||
backgroundColor: _backgroundColor,
|
listenable: AppSettings.instance,
|
||||||
body: Padding(
|
builder: (context, _) {
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
final s = AppSettings.instance;
|
||||||
child: Column(
|
final setup = s.cameras;
|
||||||
children: [
|
|
||||||
Expanded(
|
return GridView.builder(
|
||||||
child: Column(
|
padding: const EdgeInsets.fromLTRB(24, 32, 24, 32),
|
||||||
children: [
|
itemCount: setup.positions,
|
||||||
// Camera grid (6 cameras)
|
|
||||||
Expanded(
|
|
||||||
child: GridView.builder(
|
|
||||||
itemCount: 6,
|
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 2,
|
crossAxisCount: 2,
|
||||||
mainAxisSpacing: 16,
|
mainAxisSpacing: 16,
|
||||||
crossAxisSpacing: 16,
|
crossAxisSpacing: 16,
|
||||||
childAspectRatio: 1,
|
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, i) {
|
||||||
final isEnabled = _cameraButtonsEnabled[index];
|
final position = i + 1;
|
||||||
return GestureDetector(
|
final locations = setup.camerasAt(position).keys.toList();
|
||||||
onTap: isEnabled
|
final enabled = locations.isNotEmpty;
|
||||||
? () {
|
final surf = Surfaces.current;
|
||||||
Navigator.push(
|
|
||||||
context,
|
return Material(
|
||||||
MaterialPageRoute(
|
color: enabled ? Colors.grey[900] : surf.card,
|
||||||
builder: (context) =>
|
|
||||||
CameraStreamScreen(cameraIndex: index + 1),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: isEnabled ? Colors.grey[900] : Colors.grey[300],
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
child: InkWell(
|
||||||
padding: const EdgeInsets.all(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
onTap: () => _openPosition(context, position),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons.videocam_rounded,
|
enabled ? Icons.videocam_rounded : Icons.videocam_off_rounded,
|
||||||
color: isEnabled ? Colors.white : Colors.grey[500],
|
color: enabled ? Colors.white : surf.textSecondary,
|
||||||
size: 36,
|
size: 36,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text(
|
Text(
|
||||||
"${_t('Camera')} ${index + 1}",
|
'${s.t('Camera')} $position',
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isEnabled ? Colors.white : Colors.grey[600],
|
color: enabled ? Colors.white : surf.textSecondary,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
enabled ? locations.join(' · ') : s.t('Not set up'),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(fontSize: 12, color: enabled ? Colors.white60 : surf.textSecondary),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
import 'package:flutter/services.dart' show rootBundle;
|
import 'package:flutter/services.dart' show rootBundle;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:image/image.dart' as img;
|
import 'package:image/image.dart' as img;
|
||||||
@@ -25,10 +26,11 @@ class TargetViewScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TargetViewScreenState extends State<TargetViewScreen> {
|
class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||||
int _currentIndex = 0;
|
final int _currentIndex = 0;
|
||||||
List<Offset> _bullets = [];
|
List<Offset> _bullets = [];
|
||||||
List<Offset> _scaledBullets = []; // Bullets scaled to display target size
|
List<Offset> _scaledBullets = []; // Bullets scaled to display target size
|
||||||
int _totalScore = 0;
|
int _totalScore = 0;
|
||||||
|
Map<int, int> _folderChartScores = {};
|
||||||
Offset? _targetCenter;
|
Offset? _targetCenter;
|
||||||
Uint8List? _targetImageBytes;
|
Uint8List? _targetImageBytes;
|
||||||
img.Image? _targetImageDecoded;
|
img.Image? _targetImageDecoded;
|
||||||
@@ -69,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';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,9 +86,9 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
_backgroundColor = _getBackgroundColorForTarget(selectedTarget);
|
_backgroundColor = _getBackgroundColorForTarget(selectedTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _getBackgroundColorForTarget(String targetPath) {
|
// One source of truth for target colors (utils/target_colors.dart)
|
||||||
return TargetColors.getBackgroundColor(targetPath);
|
Color _getBackgroundColorForTarget(String targetPath) =>
|
||||||
}
|
TargetColors.getBackgroundColor(targetPath);
|
||||||
|
|
||||||
Future<void> _loadBulletColor() async {
|
Future<void> _loadBulletColor() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@@ -142,7 +144,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
img.Image? defaultTargetDecoded = img.decodeImage(defaultBytes);
|
img.Image? defaultTargetDecoded = img.decodeImage(defaultBytes);
|
||||||
|
|
||||||
if (defaultTargetDecoded == null) {
|
if (defaultTargetDecoded == null) {
|
||||||
print("Failed to decode default target image.");
|
debugPrint("Failed to decode default target image.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +160,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
_targetImageDecoded = img.decodeImage(displayBytes);
|
_targetImageDecoded = img.decodeImage(displayBytes);
|
||||||
|
|
||||||
if (_targetImageDecoded == null) {
|
if (_targetImageDecoded == null) {
|
||||||
print("Failed to decode display target image.");
|
debugPrint("Failed to decode display target image.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,9 +258,24 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
.map((b) => _scoreForBullet(b, _targetCenter!))
|
.map((b) => _scoreForBullet(b, _targetCenter!))
|
||||||
.fold(0, (sum, score) => sum + score);
|
.fold(0, (sum, score) => sum + score);
|
||||||
|
|
||||||
|
// Pre-compute folder chart scores to avoid sync file reads in build
|
||||||
|
if (widget.isCombinedView) {
|
||||||
|
final chartScores = <int, int>{};
|
||||||
|
for (int i = 0; i < widget.jsonFiles.length; i++) {
|
||||||
|
final data = jsonDecode(await widget.jsonFiles[i].readAsString());
|
||||||
|
final bullets = (data['bullets'] as List?) ?? [];
|
||||||
|
int s = 0;
|
||||||
|
for (final b in bullets) {
|
||||||
|
s += _scoreForBullet(Offset(b['x'].toDouble(), b['y'].toDouble()), _targetCenter!);
|
||||||
|
}
|
||||||
|
chartScores[i + 1] = s;
|
||||||
|
}
|
||||||
|
_folderChartScores = chartScores;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error loading JSON or image: $e");
|
debugPrint("Error loading JSON or image: $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,13 +293,15 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
try {
|
try {
|
||||||
final file = File(_targetFilePath);
|
final file = File(_targetFilePath);
|
||||||
await file.delete();
|
await file.delete();
|
||||||
|
widget.refreshFolders();
|
||||||
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Target deleted')),
|
const SnackBar(content: Text('Target deleted')),
|
||||||
);
|
);
|
||||||
widget.refreshFolders();
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error deleting target: $e");
|
debugPrint("Error deleting target: $e");
|
||||||
|
if (!mounted) return;
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Failed to delete target')),
|
const SnackBar(content: Text('Failed to delete target')),
|
||||||
);
|
);
|
||||||
@@ -294,18 +313,38 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: _backgroundColor,
|
backgroundColor: _backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Row(
|
// Score on top, where it is read first; the date sits in the bottom bar
|
||||||
|
// Same look as the SKUPAJ total on the preview screen
|
||||||
|
title: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.calendar_today, size: 20, color: Colors.white),
|
Text(
|
||||||
const SizedBox(width: 8),
|
_t('Total score').replaceAll(':', '').toUpperCase(),
|
||||||
Text(_date, style: const TextStyle(color: Colors.white)),
|
style: const TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
letterSpacing: 1.5,
|
||||||
|
color: Colors.white54,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"$_totalScore",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 26,
|
||||||
|
height: 1.1,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.grey[900],
|
backgroundColor: Colors.grey[900],
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
actions: [
|
actions: [
|
||||||
|
// The combined view shows a whole session; deleting would remove an
|
||||||
|
// arbitrary one of its targets. Sessions are deleted from the Book list.
|
||||||
|
if (!widget.isCombinedView)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.delete),
|
icon: const Icon(Icons.delete),
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
@@ -470,7 +509,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -500,36 +539,23 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
// Total score
|
// Date
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.track_changes,
|
const Icon(Icons.calendar_today,
|
||||||
size: 20, color: Colors.white),
|
size: 20, color: Colors.white),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
Text(
|
||||||
_t('Total score'),
|
// Saved targets store dd/MM/yyyy; show it the Slovenian way
|
||||||
|
_date.replaceAll('/', '.'),
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 16,
|
||||||
color: Colors.white54,
|
fontWeight: FontWeight.w600,
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"$_totalScore",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
// Chart toggle button
|
// Chart toggle button
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -565,26 +591,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildFolderChartView() {
|
Widget _buildFolderChartView() {
|
||||||
// Calculate target scores from all files
|
final Map<int, int> targetScores = _folderChartScores;
|
||||||
// Each file represents one target at position (fileIndex + 1)
|
|
||||||
final Map<int, int> targetScores = {};
|
|
||||||
|
|
||||||
for (int fileIdx = 0; fileIdx < widget.jsonFiles.length; fileIdx++) {
|
|
||||||
final file = widget.jsonFiles[fileIdx];
|
|
||||||
final targetPosition = fileIdx + 1; // T1, T2, T3, etc.
|
|
||||||
|
|
||||||
final data = jsonDecode(file.readAsStringSync());
|
|
||||||
final bullets = (data['bullets'] as List?) ?? [];
|
|
||||||
|
|
||||||
// Sum scores for this target
|
|
||||||
int targetScore = 0;
|
|
||||||
for (int j = 0; j < bullets.length; j++) {
|
|
||||||
final bullet = Offset(bullets[j]['x'].toDouble(), bullets[j]['y'].toDouble());
|
|
||||||
final score = _scoreForBullet(bullet, _targetCenter ?? Offset.zero);
|
|
||||||
targetScore += score;
|
|
||||||
}
|
|
||||||
targetScores[targetPosition] = targetScore;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetScores.isEmpty) {
|
if (targetScores.isEmpty) {
|
||||||
return Center(
|
return Center(
|
||||||
@@ -711,7 +718,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
Container(
|
Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[300],
|
color: Surfaces.current.card,
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topLeft: Radius.circular(16),
|
topLeft: Radius.circular(16),
|
||||||
topRight: Radius.circular(16),
|
topRight: Radius.circular(16),
|
||||||
@@ -722,10 +729,10 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
fit: BoxFit.scaleDown,
|
fit: BoxFit.scaleDown,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${count}x',
|
'${count}x',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.black87,
|
color: Surfaces.current.textPrimary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -804,7 +811,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
Container(
|
Container(
|
||||||
height: 30,
|
height: 30,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey[300],
|
color: Surfaces.current.card,
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topLeft: Radius.circular(16),
|
topLeft: Radius.circular(16),
|
||||||
topRight: Radius.circular(16),
|
topRight: Radius.circular(16),
|
||||||
@@ -813,10 +820,10 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${index + 1}',
|
'${index + 1}',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color: Colors.black87,
|
color: Surfaces.current.textPrimary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ class YOLODetector {
|
|||||||
final inputShape = inputTensor.shape;
|
final inputShape = inputTensor.shape;
|
||||||
inputHeight = inputShape[1];
|
inputHeight = inputShape[1];
|
||||||
inputWidth = inputShape[2];
|
inputWidth = inputShape[2];
|
||||||
|
|
||||||
print("📐 Model input shape: $inputShape");
|
|
||||||
print("📦 Model input type: ${inputTensor.type}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<DetectionResult>> detect(File imageFile) async {
|
Future<List<DetectionResult>> detect(File imageFile) async {
|
||||||
@@ -66,8 +63,6 @@ class YOLODetector {
|
|||||||
final numDetections = outputShape[1];
|
final numDetections = outputShape[1];
|
||||||
final outputBuffer = List.generate(1, (_) =>
|
final outputBuffer = List.generate(1, (_) =>
|
||||||
List.generate(numDetections, (_) => List.filled(6, 0.0)));
|
List.generate(numDetections, (_) => List.filled(6, 0.0)));
|
||||||
|
|
||||||
print("🚀 Running inference...");
|
|
||||||
_interpreter.run(inputBuffer, outputBuffer);
|
_interpreter.run(inputBuffer, outputBuffer);
|
||||||
|
|
||||||
final rawDetections = outputBuffer[0];
|
final rawDetections = outputBuffer[0];
|
||||||
@@ -102,8 +97,6 @@ class YOLODetector {
|
|||||||
classId,
|
classId,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
print("🎯 Detections found: ${results.length}");
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,325 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:isolate';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import '../models/camera_setup.dart';
|
||||||
|
import '../models/contact.dart';
|
||||||
|
import 'club_crypto.dart';
|
||||||
|
import '../utils/target_colors.dart';
|
||||||
|
import '../utils/translations.dart';
|
||||||
|
|
||||||
|
/// Single source of truth for user settings. Loaded once in main(); widgets
|
||||||
|
/// rebuild via ListenableBuilder(listenable: AppSettings.instance, ...).
|
||||||
|
///
|
||||||
|
/// Writes the same SharedPreferences keys the rest of the app already reads,
|
||||||
|
/// so screens can migrate to this class one at a time.
|
||||||
|
class AppSettings extends ChangeNotifier {
|
||||||
|
AppSettings._();
|
||||||
|
static final AppSettings instance = AppSettings._();
|
||||||
|
|
||||||
|
static const String defaultTarget = 'assets/target.png';
|
||||||
|
// Shots per target, same limit for camera and stream capture
|
||||||
|
static const int minBullets = 1;
|
||||||
|
static const int maxBullets = 5;
|
||||||
|
static const List<int> reminderHourOptions = [1, 2, 3, 6, 12, 24, 48];
|
||||||
|
|
||||||
|
static const List<Map<String, String>> languages = [
|
||||||
|
{'name': 'English', 'flag': '🇬🇧'},
|
||||||
|
{'name': 'Slovenian', 'flag': '🇸🇮'},
|
||||||
|
{'name': 'German', 'flag': '🇩🇪'},
|
||||||
|
];
|
||||||
|
static const String defaultLanguage = 'Slovenian';
|
||||||
|
|
||||||
|
static const Map<String, Color> bulletColors = {
|
||||||
|
'Blue': Colors.blue,
|
||||||
|
'Green': Colors.green,
|
||||||
|
'Yellow': Colors.yellow,
|
||||||
|
'Purple': Colors.purple,
|
||||||
|
'Cyan': Colors.cyan,
|
||||||
|
'Teal': Colors.teal,
|
||||||
|
'Indigo': Colors.indigo,
|
||||||
|
'Pink': Colors.pink,
|
||||||
|
'Lime': Colors.lime,
|
||||||
|
'Mint': Colors.greenAccent,
|
||||||
|
'Orange': Colors.orange,
|
||||||
|
'Violet': Colors.deepPurpleAccent,
|
||||||
|
'Amber': Colors.amber,
|
||||||
|
'Brown': Colors.brown,
|
||||||
|
'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 = [
|
||||||
|
defaultTarget,
|
||||||
|
for (int i = 1; i <= 35; i++)
|
||||||
|
if (!removedTargets.contains(i)) 'assets/targets/Target$i.jpg',
|
||||||
|
];
|
||||||
|
|
||||||
|
late SharedPreferences _prefs;
|
||||||
|
|
||||||
|
String _language = defaultLanguage;
|
||||||
|
String _bulletColorName = 'Blue';
|
||||||
|
String _selectedTarget = defaultTarget;
|
||||||
|
int _reminderHours = 1;
|
||||||
|
bool _notifyDezuranje = true;
|
||||||
|
bool _notifySestanek = true;
|
||||||
|
bool _notifyTekma = true;
|
||||||
|
CameraSetup _cameras = const CameraSetup();
|
||||||
|
List<Contact>? _clubContacts; // null until the club code is entered
|
||||||
|
|
||||||
|
String get language => _language;
|
||||||
|
|
||||||
|
/// intl locale for dates (month and day names) in [language].
|
||||||
|
static String dateLocaleFor(String language) => switch (language) {
|
||||||
|
'Slovenian' => 'sl_SI',
|
||||||
|
'German' => 'de_DE',
|
||||||
|
_ => 'en_US',
|
||||||
|
};
|
||||||
|
String get dateLocale => dateLocaleFor(_language);
|
||||||
|
String get bulletColorName => _bulletColorName;
|
||||||
|
Color get bulletColor => bulletColors[_bulletColorName] ?? Colors.blue;
|
||||||
|
String get selectedTarget => _selectedTarget;
|
||||||
|
Color get backgroundColor => TargetColors.getBackgroundColor(_selectedTarget);
|
||||||
|
bool get isLightBackground => backgroundColor.computeLuminance() > 0.4;
|
||||||
|
int get reminderHours => _reminderHours;
|
||||||
|
bool get notifyDezuranje => _notifyDezuranje;
|
||||||
|
bool get notifySestanek => _notifySestanek;
|
||||||
|
bool get notifyTekma => _notifyTekma;
|
||||||
|
CameraSetup get cameras => _cameras;
|
||||||
|
|
||||||
|
/// Calendar, reminders and contacts are for club members only.
|
||||||
|
bool get clubUnlocked => _clubContacts != null;
|
||||||
|
List<Contact> get clubContacts => _clubContacts ?? const [];
|
||||||
|
|
||||||
|
String t(String key) => AppTranslations.translate(key, _language);
|
||||||
|
|
||||||
|
String targetName(String path) {
|
||||||
|
if (path == defaultTarget) return t('Default Target');
|
||||||
|
return t(path.replaceAll('assets/targets/', '').replaceAll('.jpg', ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> load() async {
|
||||||
|
_prefs = await SharedPreferences.getInstance();
|
||||||
|
// 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');
|
||||||
|
_language = languages.any((l) => l['name'] == saved) ? saved! : defaultLanguage;
|
||||||
|
await _prefs.setString('language', _language); // other screens read this key
|
||||||
|
await _prefs.remove('languageFollowsSystem');
|
||||||
|
|
||||||
|
final color = _prefs.getString('bulletColor') ?? 'Blue';
|
||||||
|
_bulletColorName = bulletColors.containsKey(color) ? color : 'Blue';
|
||||||
|
|
||||||
|
_selectedTarget = _prefs.getString('selectedTarget') ?? defaultTarget;
|
||||||
|
if (!targets.contains(_selectedTarget)) {
|
||||||
|
// Target no longer shipped: fall back so screens reading prefs don't load a missing image
|
||||||
|
_selectedTarget = defaultTarget;
|
||||||
|
await _prefs.setString('selectedTarget', defaultTarget);
|
||||||
|
}
|
||||||
|
_reminderHours = _prefs.getInt('notificationHours_single') ?? 1;
|
||||||
|
_notifyDezuranje = _prefs.getBool('notifyDezuranje') ?? true;
|
||||||
|
_notifySestanek = _prefs.getBool('notifySestanek') ?? true;
|
||||||
|
_notifyTekma = _prefs.getBool('notifyTekma') ?? true;
|
||||||
|
|
||||||
|
final clubData = _prefs.getString('clubData');
|
||||||
|
if (clubData != null) {
|
||||||
|
_clubContacts = _parseContacts(clubData);
|
||||||
|
_refreshClubData(); // picks up contact changes shipped in an app update
|
||||||
|
}
|
||||||
|
|
||||||
|
final setup = _prefs.getString('cameraSetup');
|
||||||
|
if (setup != null) {
|
||||||
|
_cameras = CameraSetup.fromJson(jsonDecode(setup) as Map<String, dynamic>);
|
||||||
|
} else {
|
||||||
|
// Before locations existed: the six single IPs become location "Kovinar"
|
||||||
|
final old = {
|
||||||
|
for (int p = 1; p <= CameraSetup.maxPositions; p++)
|
||||||
|
if ((_prefs.getString('cameraIP_$p') ?? '').isNotEmpty) p: {'Kovinar': _prefs.getString('cameraIP_$p')!},
|
||||||
|
};
|
||||||
|
if (old.isNotEmpty) {
|
||||||
|
_cameras = CameraSetup(locations: const ['Kovinar'], ips: old, activeLocation: 'Kovinar');
|
||||||
|
await _saveCameras();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setLanguage(String value) async {
|
||||||
|
_language = value;
|
||||||
|
notifyListeners();
|
||||||
|
await _prefs.setString('language', value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setBulletColor(String name) async {
|
||||||
|
_bulletColorName = name;
|
||||||
|
notifyListeners();
|
||||||
|
await _prefs.setString('bulletColor', name);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setTarget(String path) async {
|
||||||
|
_selectedTarget = path;
|
||||||
|
notifyListeners();
|
||||||
|
await _prefs.setString('selectedTarget', path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setReminderHours(int hours) async {
|
||||||
|
_reminderHours = hours;
|
||||||
|
notifyListeners();
|
||||||
|
await _prefs.setInt('notificationHours_single', hours);
|
||||||
|
await _prefs.setStringList('notificationHours', [hours.toString()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setNotifyDezuranje(bool v) => _setNotify('notifyDezuranje', v, () => _notifyDezuranje = v);
|
||||||
|
Future<void> setNotifySestanek(bool v) => _setNotify('notifySestanek', v, () => _notifySestanek = v);
|
||||||
|
Future<void> setNotifyTekma(bool v) => _setNotify('notifyTekma', v, () => _notifyTekma = v);
|
||||||
|
|
||||||
|
Future<void> _setNotify(String key, bool value, VoidCallback apply) async {
|
||||||
|
apply();
|
||||||
|
notifyListeners();
|
||||||
|
await _prefs.setBool(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _setCameras(CameraSetup next) async {
|
||||||
|
_cameras = next;
|
||||||
|
notifyListeners();
|
||||||
|
await _saveCameras();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also fills the old cameraIP_1…6 keys (last chosen location) for screens
|
||||||
|
// that still read them, like the spectator view.
|
||||||
|
Future<void> _saveCameras() async {
|
||||||
|
await _prefs.setString('cameraSetup', jsonEncode(_cameras.toJson()));
|
||||||
|
for (int p = 1; p <= CameraSetup.maxPositions; p++) {
|
||||||
|
final at = p <= _cameras.positions ? _cameras.camerasAt(p) : <String, String>{};
|
||||||
|
final ip = at[_cameras.activeLocation] ?? (at.isEmpty ? '' : at.values.first);
|
||||||
|
await _prefs.setString('cameraIP_$p', ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> addLocation(String name) async {
|
||||||
|
if (name.isEmpty || _cameras.locations.contains(name)) return false;
|
||||||
|
await _setCameras(_cameras.copyWith(locations: [..._cameras.locations, name]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> renameLocation(String from, String to) async {
|
||||||
|
if (to.isEmpty || (to != from && _cameras.locations.contains(to))) return false;
|
||||||
|
final ips = _cameras.ipsCopy();
|
||||||
|
for (final m in ips.values) {
|
||||||
|
if (m.containsKey(from)) m[to] = m.remove(from)!;
|
||||||
|
}
|
||||||
|
await _setCameras(CameraSetup(
|
||||||
|
locations: [for (final l in _cameras.locations) l == from ? to : l],
|
||||||
|
positions: _cameras.positions,
|
||||||
|
ips: ips,
|
||||||
|
activeLocation: _cameras.activeLocation == from ? to : _cameras.activeLocation,
|
||||||
|
clubLocation: _cameras.clubLocation == from ? to : _cameras.clubLocation,
|
||||||
|
));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> removeLocation(String name) async {
|
||||||
|
final ips = _cameras.ipsCopy();
|
||||||
|
for (final m in ips.values) {
|
||||||
|
m.remove(name);
|
||||||
|
}
|
||||||
|
await _setCameras(CameraSetup(
|
||||||
|
locations: [for (final l in _cameras.locations) if (l != name) l],
|
||||||
|
positions: _cameras.positions,
|
||||||
|
ips: ips,
|
||||||
|
activeLocation: _cameras.activeLocation == name ? null : _cameras.activeLocation,
|
||||||
|
clubLocation: _cameras.clubLocation == name ? null : _cameras.clubLocation,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setPositionCount(int count) =>
|
||||||
|
_setCameras(_cameras.copyWith(positions: count.clamp(1, CameraSetup.maxPositions)));
|
||||||
|
|
||||||
|
Future<void> setCameraIp(int position, String location, String ip) {
|
||||||
|
final ips = _cameras.ipsCopy();
|
||||||
|
(ips[position] ??= {})[location] = ip.trim();
|
||||||
|
return _setCameras(_cameras.copyWith(ips: ips));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Points every position of [location] at one host with consecutive ports (9081, 9082, ...).
|
||||||
|
Future<void> setLocationHost(String location, String host) {
|
||||||
|
final ips = _cameras.ipsCopy();
|
||||||
|
for (int p = 1; p <= _cameras.positions; p++) {
|
||||||
|
(ips[p] ??= {})[location] = '$host:${CameraSetup.firstPort + p - 1}';
|
||||||
|
}
|
||||||
|
return _setCameras(_cameras.copyWith(ips: ips));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setActiveLocation(String location) => _setCameras(_cameras.copyWith(activeLocation: location));
|
||||||
|
|
||||||
|
// Club data may carry the club's cameras: {"cameras": {"location": "Kovinar", "ips": [...]}}
|
||||||
|
Future<void> _applyClubCameras(String plaintext) async {
|
||||||
|
final data = (jsonDecode(plaintext) as Map<String, dynamic>)['cameras'] as Map<String, dynamic>?;
|
||||||
|
if (data == null) return;
|
||||||
|
final location = data['location'] as String;
|
||||||
|
final clubIps = [for (final ip in data['ips'] as List) ip as String];
|
||||||
|
final ips = _cameras.ipsCopy();
|
||||||
|
for (int i = 0; i < clubIps.length && i < CameraSetup.maxPositions; i++) {
|
||||||
|
(ips[i + 1] ??= {})[location] = clubIps[i];
|
||||||
|
}
|
||||||
|
await _setCameras(_cameras.copyWith(
|
||||||
|
locations: _cameras.locations.contains(location) ? null : [location, ..._cameras.locations],
|
||||||
|
positions: clubIps.length.clamp(_cameras.positions, CameraSetup.maxPositions),
|
||||||
|
ips: ips,
|
||||||
|
activeLocation: _cameras.activeLocation ?? location,
|
||||||
|
clubLocation: location,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decrypts the bundled club data with [code]. Returns false if the code is wrong.
|
||||||
|
Future<bool> unlockClub(String code) async {
|
||||||
|
final encrypted = await _loadClubAsset();
|
||||||
|
if (encrypted == null) return false; // asset missing: run tool/encrypt_club_data.dart
|
||||||
|
|
||||||
|
// Key derivation is deliberately slow; keep it off the UI thread
|
||||||
|
final plaintext = await Isolate.run(() => ClubCrypto.decrypt(encrypted, code));
|
||||||
|
if (plaintext == null) return false;
|
||||||
|
|
||||||
|
_clubContacts = _parseContacts(plaintext);
|
||||||
|
notifyListeners();
|
||||||
|
await _applyClubCameras(plaintext);
|
||||||
|
await _prefs.setString('clubData', plaintext);
|
||||||
|
await _prefs.setString('clubCode', code);
|
||||||
|
await _prefs.setString('clubDataSource', encrypted);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> lockClub() async {
|
||||||
|
_clubContacts = null;
|
||||||
|
notifyListeners();
|
||||||
|
final clubLocation = _cameras.clubLocation;
|
||||||
|
if (clubLocation != null) await removeLocation(clubLocation);
|
||||||
|
await _prefs.remove('clubData');
|
||||||
|
await _prefs.remove('clubCode');
|
||||||
|
await _prefs.remove('clubDataSource');
|
||||||
|
}
|
||||||
|
|
||||||
|
/// If the bundled club.enc changed since unlocking (new app version), decrypt
|
||||||
|
/// it again with the saved code. A changed club code locks the phone again.
|
||||||
|
Future<void> _refreshClubData() async {
|
||||||
|
final encrypted = await _loadClubAsset();
|
||||||
|
final code = _prefs.getString('clubCode');
|
||||||
|
if (encrypted == null || encrypted == _prefs.getString('clubDataSource')) return;
|
||||||
|
if (code == null || !await unlockClub(code)) await lockClub();
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String?> _loadClubAsset() async {
|
||||||
|
try {
|
||||||
|
return await rootBundle.loadString('assets/club.enc');
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<Contact> _parseContacts(String json) {
|
||||||
|
final list = (jsonDecode(json) as Map<String, dynamic>)['contacts'] as List;
|
||||||
|
return list.map((c) => Contact.fromJson(c as Map<String, dynamic>)).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'package:cryptography/cryptography.dart';
|
||||||
|
|
||||||
|
/// Encrypts/decrypts the club data (contacts) with the club code as the key,
|
||||||
|
/// so the data can ship inside the public app but is unreadable without the code.
|
||||||
|
///
|
||||||
|
/// No Flutter imports: also used by tool/encrypt_club_data.dart.
|
||||||
|
/// File format (assets/club.enc): JSON {v, salt, nonce, cipher, mac}, base64 values.
|
||||||
|
class ClubCrypto {
|
||||||
|
static const int _iterations = 100000;
|
||||||
|
static final _aes = AesGcm.with256bits();
|
||||||
|
|
||||||
|
/// Codes are compared ignoring case and surrounding spaces.
|
||||||
|
static String normalize(String code) => code.trim().toLowerCase();
|
||||||
|
|
||||||
|
static Future<SecretKey> _deriveKey(String code, List<int> salt) {
|
||||||
|
return Pbkdf2(macAlgorithm: Hmac.sha256(), iterations: _iterations, bits: 256)
|
||||||
|
.deriveKeyFromPassword(password: normalize(code), nonce: salt);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<String> encrypt(String plaintext, String code) async {
|
||||||
|
final salt = SecretKeyData.random(length: 16).bytes;
|
||||||
|
final key = await _deriveKey(code, salt);
|
||||||
|
final box = await _aes.encrypt(utf8.encode(plaintext), secretKey: key);
|
||||||
|
return jsonEncode({
|
||||||
|
'v': 1,
|
||||||
|
'salt': base64Encode(salt),
|
||||||
|
'nonce': base64Encode(box.nonce),
|
||||||
|
'cipher': base64Encode(box.cipherText),
|
||||||
|
'mac': base64Encode(box.mac.bytes),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the plaintext, or null if the code is wrong.
|
||||||
|
static Future<String?> decrypt(String encrypted, String code) async {
|
||||||
|
final data = jsonDecode(encrypted) as Map<String, dynamic>;
|
||||||
|
final key = await _deriveKey(code, base64Decode(data['salt']));
|
||||||
|
final box = SecretBox(
|
||||||
|
base64Decode(data['cipher']),
|
||||||
|
nonce: base64Decode(data['nonce']),
|
||||||
|
mac: Mac(base64Decode(data['mac'])),
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
return utf8.decode(await _aes.decrypt(box, secretKey: key));
|
||||||
|
} on SecretBoxAuthenticationError {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import 'package:timezone/timezone.dart' as tz;
|
|||||||
import 'package:timezone/data/latest.dart' as tz;
|
import 'package:timezone/data/latest.dart' as tz;
|
||||||
import 'package:flutter_timezone/flutter_timezone.dart';
|
import 'package:flutter_timezone/flutter_timezone.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import '../services/app_settings.dart';
|
||||||
import '../services/google_calendar_service.dart';
|
import '../services/google_calendar_service.dart';
|
||||||
|
|
||||||
class NotificationService {
|
class NotificationService {
|
||||||
@@ -65,6 +66,27 @@ class NotificationService {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetches the calendar and reschedules all reminders. Call on app start
|
||||||
|
/// and whenever notification settings change.
|
||||||
|
Future<void> rescheduleFromCalendar() async {
|
||||||
|
if (!AppSettings.instance.clubUnlocked) {
|
||||||
|
await cancelAll(); // reminders are a club-member feature
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final service = GoogleCalendarService();
|
||||||
|
try {
|
||||||
|
final now = DateTime.now();
|
||||||
|
final events = await service.getEvents(
|
||||||
|
startDate: now,
|
||||||
|
endDate: now.add(const Duration(days: 365)),
|
||||||
|
);
|
||||||
|
await scheduleEventNotifications(events);
|
||||||
|
} catch (_) {
|
||||||
|
} finally {
|
||||||
|
service.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> requestPermissions() async {
|
Future<bool> requestPermissions() async {
|
||||||
final android = _plugin.resolvePlatformSpecificImplementation<
|
final android = _plugin.resolvePlatformSpecificImplementation<
|
||||||
AndroidFlutterLocalNotificationsPlugin>();
|
AndroidFlutterLocalNotificationsPlugin>();
|
||||||
@@ -94,7 +116,7 @@ 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();
|
||||||
|
|
||||||
await _plugin.cancelAll();
|
await _plugin.cancelAll();
|
||||||
@@ -104,9 +126,11 @@ class NotificationService {
|
|||||||
if (event.startTime == null) continue;
|
if (event.startTime == null) continue;
|
||||||
|
|
||||||
final summary = (event.summary ?? '').toLowerCase();
|
final summary = (event.summary ?? '').toLowerCase();
|
||||||
final isCompetition = summary.contains('liga') || summary.contains('tekmovanje');
|
// Same classification as the calendar screen; skip anything else
|
||||||
final isSestanek = summary.contains('sestanek');
|
final isCompetition = summary.contains('liga') || summary.contains('tekmovanje') || summary.contains('tekma');
|
||||||
final isDezuranje = !isCompetition && !isSestanek;
|
final isSestanek = !isCompetition && summary.contains('sestanek');
|
||||||
|
final isDezuranje = !isCompetition && !isSestanek && summary.contains('dežurstvo');
|
||||||
|
if (!isCompetition && !isSestanek && !isDezuranje) continue;
|
||||||
|
|
||||||
if (isCompetition && !notifyTekma) continue;
|
if (isCompetition && !notifyTekma) continue;
|
||||||
if (isSestanek && !notifySestanek) continue;
|
if (isSestanek && !notifySestanek) continue;
|
||||||
@@ -117,9 +141,7 @@ 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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -127,25 +149,17 @@ class NotificationService {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> scheduleTestNotification() async {
|
static String _startsIn(int hours, String language) {
|
||||||
try {
|
switch (language) {
|
||||||
await initialize();
|
case 'Slovenian':
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final mod = hours % 100;
|
||||||
final isSlovenian = (prefs.getString('language') ?? 'English') == 'Slovenian';
|
final unit = mod == 1 ? 'uro' : mod == 2 ? 'uri' : (mod == 3 || mod == 4) ? 'ure' : 'ur';
|
||||||
await _plugin.show(
|
return 'Začne se čez $hours $unit';
|
||||||
9999,
|
case 'German':
|
||||||
isSlovenian ? 'Testno obvestilo' : 'Test Notification',
|
return hours == 1 ? 'Beginnt in 1 Stunde' : 'Beginnt in $hours Stunden';
|
||||||
isSlovenian ? 'Obvestila delujejo!' : 'Notifications are working!',
|
default:
|
||||||
_notifDetails,
|
return hours == 1 ? 'Starts in 1 hour' : 'Starts in $hours hours';
|
||||||
);
|
}
|
||||||
final in10s = DateTime.now().add(const Duration(seconds: 10));
|
|
||||||
await _scheduleNotification(
|
|
||||||
id: 9998,
|
|
||||||
title: isSlovenian ? 'Načrtovano testno obvestilo' : 'Scheduled Test',
|
|
||||||
body: isSlovenian ? 'Načrtovana obvestila delujejo!' : 'Scheduled notifications are working!',
|
|
||||||
scheduledDate: in10s,
|
|
||||||
);
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _scheduleNotification({
|
Future<void> _scheduleNotification({
|
||||||
@@ -161,6 +175,7 @@ class NotificationService {
|
|||||||
body,
|
body,
|
||||||
tzDate,
|
tzDate,
|
||||||
_notifDetails,
|
_notifDetails,
|
||||||
|
// Inexact: avoids the SCHEDULE_EXACT_ALARM permission (Play policy).
|
||||||
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
|
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
|
||||||
uiLocalNotificationDateInterpretation:
|
uiLocalNotificationDateInterpretation:
|
||||||
UILocalNotificationDateInterpretation.absoluteTime,
|
UILocalNotificationDateInterpretation.absoluteTime,
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
|
|
||||||
class SharedPrefsService {
|
|
||||||
static Future<void> saveCameraIPs(List<String> cameraIPs) async {
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
for (int i = 0; i < 6; i++) {
|
|
||||||
prefs.setString('camera_$i', cameraIPs[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<List<String>> loadCameraIPs() async {
|
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
||||||
return List.generate(6, (index) => prefs.getString('camera_$index') ?? '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,302 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
|
/// One saved target (a JSON file written by the preview screen).
|
||||||
|
class TargetRecord {
|
||||||
|
final File file;
|
||||||
|
final DateTime shotAt;
|
||||||
|
final int score;
|
||||||
|
final int shots;
|
||||||
|
|
||||||
|
const TargetRecord(
|
||||||
|
{required this.file,
|
||||||
|
required this.shotAt,
|
||||||
|
required this.score,
|
||||||
|
required this.shots});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A folder of targets: one training or tournament.
|
||||||
|
class Session {
|
||||||
|
final String name;
|
||||||
|
final bool isTournament;
|
||||||
|
final DateTime date;
|
||||||
|
final List<TargetRecord> targets; // oldest first
|
||||||
|
|
||||||
|
const Session(
|
||||||
|
{required this.name,
|
||||||
|
required this.isTournament,
|
||||||
|
required this.date,
|
||||||
|
required this.targets});
|
||||||
|
|
||||||
|
int get totalScore => targets.fold(0, (sum, t) => sum + t.score);
|
||||||
|
int get shots => targets.fold(0, (sum, t) => sum + t.shots);
|
||||||
|
double? get averagePerShot => shots == 0 ? null : totalScore / shots;
|
||||||
|
List<File> get files => [for (final t in targets) t.file];
|
||||||
|
|
||||||
|
/// The same session limited to targets with [shots] bullets (null = all).
|
||||||
|
Session onlyShots(int? shots) => shots == null
|
||||||
|
? this
|
||||||
|
: Session(name: name, isTournament: isTournament, date: date, targets: [
|
||||||
|
for (final t in targets)
|
||||||
|
if (t.shots == shots) t,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Aggregates over any set of sessions (trainings or tournaments of one format).
|
||||||
|
class ShooterStats {
|
||||||
|
static const int trendWindow = 5;
|
||||||
|
|
||||||
|
final int sessions;
|
||||||
|
final int targets;
|
||||||
|
final int shots;
|
||||||
|
final Session? bestSession; // highest average per shot
|
||||||
|
final double? averageTarget;
|
||||||
|
final double? averagePerShot;
|
||||||
|
final double? trend; // last sessions minus the ones before them, per shot
|
||||||
|
|
||||||
|
const ShooterStats._({
|
||||||
|
required this.sessions,
|
||||||
|
required this.targets,
|
||||||
|
required this.shots,
|
||||||
|
required this.bestSession,
|
||||||
|
required this.averageTarget,
|
||||||
|
required this.averagePerShot,
|
||||||
|
required this.trend,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// [sessions] newest first, as [TargetRepository.loadSessions] returns them.
|
||||||
|
factory ShooterStats.of(List<Session> sessions) {
|
||||||
|
final all = [for (final s in sessions) ...s.targets];
|
||||||
|
final shots = all.fold(0, (sum, t) => sum + t.shots);
|
||||||
|
final total = all.fold(0, (sum, t) => sum + t.score);
|
||||||
|
final mean = all.isEmpty ? null : total / all.length;
|
||||||
|
|
||||||
|
Session? bestSession;
|
||||||
|
for (final s in sessions) {
|
||||||
|
final avg = s.averagePerShot;
|
||||||
|
if (avg != null &&
|
||||||
|
(bestSession == null || avg > bestSession.averagePerShot!)) {
|
||||||
|
bestSession = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ShooterStats._(
|
||||||
|
sessions: sessions.length,
|
||||||
|
targets: all.length,
|
||||||
|
shots: shots,
|
||||||
|
bestSession: bestSession,
|
||||||
|
averageTarget: mean,
|
||||||
|
averagePerShot: shots == 0 ? null : total / shots,
|
||||||
|
trend: _trend(sessions),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Average per shot of the newest sessions minus the same number before them
|
||||||
|
static double? _trend(List<Session> newestFirst) {
|
||||||
|
final scored = newestFirst.where((s) => s.shots > 0).toList();
|
||||||
|
final n = min(trendWindow, scored.length ~/ 2);
|
||||||
|
if (n == 0) return null;
|
||||||
|
double avg(Iterable<Session> list) =>
|
||||||
|
list.fold(0, (a, s) => a + s.totalScore) /
|
||||||
|
list.fold(0, (a, s) => a + s.shots);
|
||||||
|
return avg(scored.take(n)) - avg(scored.skip(n).take(n));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads and edits the saved targets under `<documents>/saved_images/<session>/`.
|
||||||
|
///
|
||||||
|
/// Score and shots of every target are cached in `<documents>/target_index.json`,
|
||||||
|
/// keyed by the file's path with its size and last change, so loading reads one
|
||||||
|
/// file instead of every target. A new, edited or renamed target no longer
|
||||||
|
/// matches its entry and is read again; entries of deleted files are dropped.
|
||||||
|
class TargetRepository {
|
||||||
|
static Map<String, dynamic>? _index; // path in saved_images -> entry
|
||||||
|
|
||||||
|
static Future<Directory> _root() async {
|
||||||
|
final dir = Directory(
|
||||||
|
'${(await getApplicationDocumentsDirectory()).path}/saved_images');
|
||||||
|
if (!await dir.exists()) await dir.create(recursive: true);
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<File> _indexFile() async => File(
|
||||||
|
'${(await getApplicationDocumentsDirectory()).path}/target_index.json');
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>> _loadIndex() async {
|
||||||
|
if (_index != null) return _index!;
|
||||||
|
try {
|
||||||
|
final file = await _indexFile();
|
||||||
|
_index = await file.exists()
|
||||||
|
? jsonDecode(await file.readAsString()) as Map<String, dynamic>
|
||||||
|
: {};
|
||||||
|
} catch (_) {
|
||||||
|
_index = {}; // unreadable: rebuild it from the targets
|
||||||
|
}
|
||||||
|
return _index!;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sessions, newest first.
|
||||||
|
static Future<List<Session>> loadSessions() async {
|
||||||
|
final sessions = <Session>[];
|
||||||
|
final index = await _loadIndex();
|
||||||
|
final seen = <String>{};
|
||||||
|
var changed = false;
|
||||||
|
|
||||||
|
for (final folder in await _folders()) {
|
||||||
|
final targets = <TargetRecord>[];
|
||||||
|
for (final file in folder.targetFiles) {
|
||||||
|
final key = '${folder.name}/${file.uri.pathSegments.last}';
|
||||||
|
seen.add(key);
|
||||||
|
final stat = file.statSync();
|
||||||
|
final stamp = '${stat.size}:${stat.modified.millisecondsSinceEpoch}';
|
||||||
|
final cached = index[key];
|
||||||
|
TargetRecord? record;
|
||||||
|
if (cached is Map && cached['stamp'] == stamp) {
|
||||||
|
record = TargetRecord(
|
||||||
|
file: file,
|
||||||
|
shotAt: _timeFromFileName(file) ?? stat.modified,
|
||||||
|
score: cached['score'] as int,
|
||||||
|
shots: cached['shots'] as int,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
record = await _readTarget(file);
|
||||||
|
if (record != null) {
|
||||||
|
index[key] = {
|
||||||
|
'stamp': stamp,
|
||||||
|
'score': record.score,
|
||||||
|
'shots': record.shots
|
||||||
|
};
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (record != null) targets.add(record);
|
||||||
|
}
|
||||||
|
targets.sort((a, b) => a.shotAt.compareTo(b.shotAt));
|
||||||
|
sessions.add(Session(
|
||||||
|
name: folder.name,
|
||||||
|
isTournament: folder.isTournament,
|
||||||
|
date: folder.date,
|
||||||
|
targets: targets,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
final before = index.length;
|
||||||
|
index.removeWhere((key, _) => !seen.contains(key));
|
||||||
|
if (changed || index.length != before) {
|
||||||
|
try {
|
||||||
|
await (await _indexFile()).writeAsString(jsonEncode(index));
|
||||||
|
} catch (_) {
|
||||||
|
// Only a cache: the next load reads the targets again
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sessions.sort((a, b) => b.date.compareTo(a.date));
|
||||||
|
return sessions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cheap pass over the folders: metadata + file names, no target files read
|
||||||
|
static Future<List<_FolderInfo>> _folders() async {
|
||||||
|
final root = await _root();
|
||||||
|
final result = <_FolderInfo>[];
|
||||||
|
for (final folder in root.listSync().whereType<Directory>()) {
|
||||||
|
final meta = await _readMetadata(folder);
|
||||||
|
final files = [
|
||||||
|
for (final f in folder.listSync().whereType<File>())
|
||||||
|
if (f.path.endsWith('.json') && !f.path.endsWith('metadata.json')) f,
|
||||||
|
];
|
||||||
|
final fileTimes =
|
||||||
|
files.map(_timeFromFileName).whereType<DateTime>().toList()..sort();
|
||||||
|
result.add(_FolderInfo(
|
||||||
|
name: folder.path.split('/').last,
|
||||||
|
isTournament: meta['isTournament'] == true,
|
||||||
|
date: DateTime.tryParse(meta['createdAt'] ?? '') ??
|
||||||
|
(fileTimes.isNotEmpty
|
||||||
|
? fileTimes.first
|
||||||
|
: folder.statSync().changed),
|
||||||
|
targetFiles: files,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>> _readMetadata(Directory folder) async {
|
||||||
|
final file = File('${folder.path}/metadata.json');
|
||||||
|
if (!await file.exists()) return {};
|
||||||
|
try {
|
||||||
|
return jsonDecode(await file.readAsString()) as Map<String, dynamic>;
|
||||||
|
} catch (_) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<TargetRecord?> _readTarget(File file) async {
|
||||||
|
try {
|
||||||
|
final data =
|
||||||
|
jsonDecode(await file.readAsString()) as Map<String, dynamic>;
|
||||||
|
final score = data['totalScore'];
|
||||||
|
return TargetRecord(
|
||||||
|
file: file,
|
||||||
|
shotAt: _timeFromFileName(file) ?? file.statSync().modified,
|
||||||
|
score: score is int ? score : 0,
|
||||||
|
// Older saves have no bulletCount: fall back to the detected bullets
|
||||||
|
shots: data['bulletCount'] as int? ??
|
||||||
|
(data['bullets'] as List?)?.length ??
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
} catch (_) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// File names look like target_2026-10-26_17-5-3.json (see preview_screen _performSave)
|
||||||
|
static DateTime? _timeFromFileName(File file) {
|
||||||
|
final match = RegExp(r'target_(\d+)-(\d+)-(\d+)_(\d+)-(\d+)-(\d+)\.json$')
|
||||||
|
.firstMatch(file.path);
|
||||||
|
if (match == null) return null;
|
||||||
|
final p = [for (int i = 1; i <= 6; i++) int.parse(match.group(i)!)];
|
||||||
|
return DateTime(p[0], p[1], p[2], p[3], p[4], p[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Renames a session and/or changes its type. Returns false if the new name is taken.
|
||||||
|
static Future<bool> updateSession(Session session,
|
||||||
|
{required String name, required bool isTournament}) async {
|
||||||
|
final root = await _root();
|
||||||
|
var folder = Directory('${root.path}/${session.name}');
|
||||||
|
if (name != session.name) {
|
||||||
|
final target = Directory('${root.path}/$name');
|
||||||
|
if (await target.exists()) return false;
|
||||||
|
folder = await folder.rename(target.path);
|
||||||
|
}
|
||||||
|
final metaFile = File('${folder.path}/metadata.json');
|
||||||
|
final meta = await _readMetadata(folder);
|
||||||
|
await metaFile.writeAsString(jsonEncode({
|
||||||
|
'isTournament': isTournament,
|
||||||
|
'createdAt': meta['createdAt'] ?? session.date.toIso8601String(),
|
||||||
|
}));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> deleteSession(Session session) async {
|
||||||
|
final folder = Directory('${(await _root()).path}/${session.name}');
|
||||||
|
if (await folder.exists()) await folder.delete(recursive: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<void> deleteTarget(TargetRecord target) async {
|
||||||
|
if (await target.file.exists()) await target.file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FolderInfo {
|
||||||
|
final String name;
|
||||||
|
final bool isTournament;
|
||||||
|
final DateTime date;
|
||||||
|
final List<File> targetFiles;
|
||||||
|
|
||||||
|
const _FolderInfo(
|
||||||
|
{required this.name,
|
||||||
|
required this.isTournament,
|
||||||
|
required this.date,
|
||||||
|
required this.targetFiles});
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
/// Routes the app's traffic over Wi-Fi while camera screens are open, so the
|
||||||
|
/// cameras stay reachable when the range Wi-Fi has no internet and Android
|
||||||
|
/// would otherwise prefer mobile data. Other apps are not affected.
|
||||||
|
class WifiBinding {
|
||||||
|
static const _channel = MethodChannel('si.sdkkovinar.app/network');
|
||||||
|
static int _users = 0;
|
||||||
|
|
||||||
|
/// Call from initState; await before connecting to a camera.
|
||||||
|
static Future<void> acquire() async {
|
||||||
|
_users++;
|
||||||
|
if (_users > 1 || !Platform.isAndroid) return;
|
||||||
|
try {
|
||||||
|
await _channel.invokeMethod('bindToWifi');
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Call from dispose.
|
||||||
|
static Future<void> release() async {
|
||||||
|
if (_users == 0) return;
|
||||||
|
_users--;
|
||||||
|
if (_users > 0 || !Platform.isAndroid) return;
|
||||||
|
try {
|
||||||
|
await _channel.invokeMethod('unbind');
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../services/app_settings.dart';
|
||||||
|
|
||||||
|
/// Shared colors and component styles. Prefer these over hardcoded
|
||||||
|
/// Colors.grey[...] so screens look alike and can be restyled in one place.
|
||||||
|
class AppTheme {
|
||||||
|
static final Color bar = Colors.grey[900]!; // app bar, bottom nav, sheets
|
||||||
|
static final Color sheet = Colors.grey[900]!;
|
||||||
|
|
||||||
|
static ThemeData light() {
|
||||||
|
return ThemeData(
|
||||||
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
|
||||||
|
useMaterial3: true,
|
||||||
|
bottomSheetTheme: BottomSheetThemeData(
|
||||||
|
backgroundColor: sheet,
|
||||||
|
showDragHandle: true,
|
||||||
|
dragHandleColor: Colors.white24,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
dialogTheme: DialogThemeData(
|
||||||
|
backgroundColor: sheet,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
|
titleTextStyle: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
|
||||||
|
contentTextStyle: const TextStyle(color: Colors.white70, fontSize: 14),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ThemeData dark() {
|
||||||
|
return light().copyWith(
|
||||||
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue, brightness: Brightness.dark),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Card and text colors that stay readable on the current target background
|
||||||
|
/// (which can be anything from white to red to black).
|
||||||
|
class Surfaces {
|
||||||
|
final Color card;
|
||||||
|
final Color divider;
|
||||||
|
final Color textPrimary;
|
||||||
|
final Color textSecondary;
|
||||||
|
|
||||||
|
const Surfaces._({
|
||||||
|
required this.card,
|
||||||
|
required this.divider,
|
||||||
|
required this.textPrimary,
|
||||||
|
required this.textSecondary,
|
||||||
|
});
|
||||||
|
|
||||||
|
static Surfaces get current => AppSettings.instance.isLightBackground
|
||||||
|
? Surfaces._(
|
||||||
|
card: Colors.grey[300]!, // same grey as calendar cards
|
||||||
|
divider: Colors.grey[400]!,
|
||||||
|
textPrimary: Colors.black87,
|
||||||
|
textSecondary: Colors.black54,
|
||||||
|
)
|
||||||
|
: Surfaces._(
|
||||||
|
card: Colors.grey[850]!,
|
||||||
|
divider: Colors.grey[700]!,
|
||||||
|
textPrimary: Colors.white,
|
||||||
|
textSecondary: Colors.white60,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@ class TargetColors {
|
|||||||
'assets/targets/Target10.jpg': Color(0xFF98926E), // Olive green
|
'assets/targets/Target10.jpg': Color(0xFF98926E), // Olive green
|
||||||
'assets/targets/Target11.jpg': Color(0xFF13132B), // Dark blue
|
'assets/targets/Target11.jpg': Color(0xFF13132B), // Dark blue
|
||||||
'assets/targets/Target12.jpg': Color(0xFFF5F4EF), // Off-white
|
'assets/targets/Target12.jpg': Color(0xFFF5F4EF), // Off-white
|
||||||
'assets/targets/Target13.jpg': Color(0xFF174AA5), // Blue
|
|
||||||
'assets/targets/Target14.jpg': Color(0xFFFEE05E), // Light yellow
|
'assets/targets/Target14.jpg': Color(0xFFFEE05E), // Light yellow
|
||||||
'assets/targets/Target15.jpg': Color(0xFFFFFFFF), // White
|
'assets/targets/Target15.jpg': Color(0xFFFFFFFF), // White
|
||||||
'assets/targets/Target16.jpg': Color(0xFF000000), // Black
|
'assets/targets/Target16.jpg': Color(0xFF000000), // Black
|
||||||
@@ -23,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
|
||||||
@@ -33,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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class BarTab {
|
||||||
|
final String label;
|
||||||
|
final IconData icon;
|
||||||
|
|
||||||
|
const BarTab(this.label, this.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tab strip that continues the dark app bar (Koledar/Stiki, Knjiga filters).
|
||||||
|
/// The selected tab is a white pill; [trailing] sits at the right end.
|
||||||
|
class BarTabs extends StatelessWidget {
|
||||||
|
final List<BarTab> tabs;
|
||||||
|
final int selected;
|
||||||
|
final ValueChanged<int> onSelect;
|
||||||
|
final Widget? trailing;
|
||||||
|
|
||||||
|
const BarTabs({
|
||||||
|
super.key,
|
||||||
|
required this.tabs,
|
||||||
|
required this.selected,
|
||||||
|
required this.onSelect,
|
||||||
|
this.trailing,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
color: AppTheme.bar,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
for (int i = 0; i < tabs.length; i++) ...[
|
||||||
|
if (i > 0) const SizedBox(width: 6),
|
||||||
|
Expanded(child: _tab(tabs[i], i == selected, () => onSelect(i))),
|
||||||
|
],
|
||||||
|
if (trailing != null) trailing!,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _tab(BarTab tab, bool active, VoidCallback onTap) {
|
||||||
|
final color = active ? Colors.black : Colors.grey[400];
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: active ? Colors.white : Colors.transparent,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(tab.icon, color: color, size: 18),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
tab.label,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: color),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,29 +1,30 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../utils/translations.dart';
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
class BottomNavBar extends StatelessWidget {
|
class BottomNavBar extends StatelessWidget {
|
||||||
final int selectedIndex;
|
final int selectedIndex;
|
||||||
final Function(int) onItemTapped;
|
final ValueChanged<int> onItemTapped;
|
||||||
final String selectedLanguage;
|
final List<BottomNavigationBarItem> items;
|
||||||
|
|
||||||
const BottomNavBar({
|
const BottomNavBar({
|
||||||
super.key,
|
super.key,
|
||||||
required this.selectedIndex,
|
required this.selectedIndex,
|
||||||
required this.onItemTapped,
|
required this.onItemTapped,
|
||||||
required this.selectedLanguage,
|
required this.items,
|
||||||
});
|
});
|
||||||
|
|
||||||
String _t(String key) {
|
|
||||||
return AppTranslations.translate(key, selectedLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
// Paint the gesture-bar strip below the nav too (edge-to-edge since targetSdk 35),
|
||||||
|
// otherwise the target background color shows through as a thin line.
|
||||||
|
return ColoredBox(
|
||||||
|
color: AppTheme.bar,
|
||||||
|
child: SafeArea(
|
||||||
|
top: false,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 80,
|
height: 80,
|
||||||
child: BottomNavigationBar(
|
child: BottomNavigationBar(
|
||||||
backgroundColor: Colors.grey[900],
|
backgroundColor: AppTheme.bar,
|
||||||
currentIndex: selectedIndex,
|
currentIndex: selectedIndex,
|
||||||
onTap: onItemTapped,
|
onTap: onItemTapped,
|
||||||
showSelectedLabels: true,
|
showSelectedLabels: true,
|
||||||
@@ -33,16 +34,10 @@ Widget build(BuildContext context) {
|
|||||||
unselectedFontSize: 12,
|
unselectedFontSize: 12,
|
||||||
selectedItemColor: Colors.white,
|
selectedItemColor: Colors.white,
|
||||||
unselectedItemColor: Colors.white70,
|
unselectedItemColor: Colors.white70,
|
||||||
items: [
|
items: items,
|
||||||
BottomNavigationBarItem(icon: const Icon(Icons.book), label: _t("Book")),
|
),
|
||||||
BottomNavigationBarItem(icon: const Icon(Icons.my_location), label: _t("Shooting")),
|
|
||||||
BottomNavigationBarItem(icon: const Icon(Icons.camera_alt), label: _t("Camera")),
|
|
||||||
BottomNavigationBarItem(icon: const Icon(Icons.calendar_today), label: _t("Calendar")),
|
|
||||||
BottomNavigationBarItem(icon: const Icon(Icons.settings), label: _t("Settings")),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,236 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// Bottom sheet used by every menu on the camera stream: the live image stays
|
||||||
|
/// visible and undimmed above it, so changes can be judged immediately.
|
||||||
|
Future<T?> showCameraSheet<T>(BuildContext context,
|
||||||
|
{required WidgetBuilder builder}) {
|
||||||
|
return showModalBottomSheet<T>(
|
||||||
|
context: context,
|
||||||
|
barrierColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.grey[900],
|
||||||
|
isScrollControlled:
|
||||||
|
true, // tall content (timer) may use more than half the screen
|
||||||
|
builder: (sheet) => SafeArea(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints:
|
||||||
|
BoxConstraints(maxHeight: MediaQuery.sizeOf(sheet).height * 0.75),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 0, 20, 16),
|
||||||
|
child: builder(sheet),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Title (+ optional subtitle) on the left, optional action on the right.
|
||||||
|
class CameraSheetHeader extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String? subtitle;
|
||||||
|
final IconData? icon;
|
||||||
|
final Color? iconColor;
|
||||||
|
final Widget? trailing;
|
||||||
|
|
||||||
|
const CameraSheetHeader({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.icon,
|
||||||
|
this.iconColor,
|
||||||
|
this.trailing,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 14),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (icon != null) ...[
|
||||||
|
Icon(icon, color: iconColor ?? Colors.white, size: 22),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(title,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
if (subtitle != null)
|
||||||
|
Text(subtitle!,
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Colors.white54, fontSize: 12)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (trailing != null) trailing!,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Icon, label, slider and current value in one row.
|
||||||
|
class SheetSlider extends StatelessWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final String label;
|
||||||
|
final String valueText;
|
||||||
|
final double value;
|
||||||
|
final double min;
|
||||||
|
final double max;
|
||||||
|
final Color accent;
|
||||||
|
final ValueChanged<double> onChanged;
|
||||||
|
|
||||||
|
const SheetSlider({super.key,
|
||||||
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
required this.valueText,
|
||||||
|
required this.value,
|
||||||
|
required this.min,
|
||||||
|
required this.max,
|
||||||
|
required this.accent,
|
||||||
|
required this.onChanged,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Icon(icon, color: Colors.white54, size: 20),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
SizedBox(
|
||||||
|
width: 72,
|
||||||
|
child: Text(label,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 13)),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Slider(
|
||||||
|
value: value.clamp(min, max),
|
||||||
|
min: min,
|
||||||
|
max: max,
|
||||||
|
activeColor: accent,
|
||||||
|
inactiveColor: Colors.white24,
|
||||||
|
onChanged: onChanged,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 46,
|
||||||
|
child: Text(
|
||||||
|
valueText,
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white70,
|
||||||
|
fontSize: 13,
|
||||||
|
fontFeatures: [FontFeature.tabularFigures()]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wide button that shows an on/off state with the accent color.
|
||||||
|
class SheetToggle extends StatelessWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final String label;
|
||||||
|
final bool active;
|
||||||
|
final Color accent;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
const SheetToggle({super.key,
|
||||||
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
required this.active,
|
||||||
|
required this.accent,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: active
|
||||||
|
? accent.withValues(alpha: 0.18)
|
||||||
|
: Colors.white.withValues(alpha: 0.06),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
side:
|
||||||
|
BorderSide(color: active ? accent : Colors.transparent, width: 1.5),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
onTap: onTap,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 10),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 18, color: active ? accent : Colors.white70),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: active ? Colors.white : Colors.white70),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Big number with − / + buttons, used for the bullet count.
|
||||||
|
class SheetStepper extends StatelessWidget {
|
||||||
|
final int value;
|
||||||
|
final int min;
|
||||||
|
final int max;
|
||||||
|
final Color accent;
|
||||||
|
final ValueChanged<int> onChanged;
|
||||||
|
|
||||||
|
const SheetStepper({
|
||||||
|
super.key,
|
||||||
|
required this.value,
|
||||||
|
required this.min,
|
||||||
|
required this.max,
|
||||||
|
required this.accent,
|
||||||
|
required this.onChanged,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Widget button(IconData icon, bool enabled, int next) => IconButton(
|
||||||
|
onPressed: enabled ? () => onChanged(next) : null,
|
||||||
|
icon: Icon(icon, color: Colors.white, size: 28),
|
||||||
|
style: IconButton.styleFrom(
|
||||||
|
backgroundColor:
|
||||||
|
Colors.white.withValues(alpha: enabled ? 0.12 : 0.04),
|
||||||
|
shape: const CircleBorder(),
|
||||||
|
minimumSize: const Size(56, 56),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
button(Icons.remove, value > min, value - 1),
|
||||||
|
SizedBox(
|
||||||
|
width: 120,
|
||||||
|
child: Text(
|
||||||
|
'$value',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 56, fontWeight: FontWeight.bold, color: accent),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
button(Icons.add, value < max, value + 1),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// Help bottom sheet: one icon + sentence per control, close button at the end.
|
||||||
|
/// Shared by Knjiga, camera and stream so their info buttons look the same.
|
||||||
|
void showHelpSheet(
|
||||||
|
BuildContext context, {
|
||||||
|
required List<(IconData, String)> items,
|
||||||
|
required Color accent,
|
||||||
|
required String Function(String) t,
|
||||||
|
}) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (sheet) => SafeArea(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.fromLTRB(24, 8, 24, 16),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(t('Help'),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
for (final (icon, text) in items)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 14),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Icon(icon, color: accent, size: 20),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Text(t(text),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white, fontSize: 14, height: 1.3)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: FilledButton(
|
||||||
|
style: FilledButton.styleFrom(backgroundColor: accent),
|
||||||
|
onPressed: () => Navigator.pop(sheet),
|
||||||
|
child: Text(t('Close')),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,258 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'camera_sheet.dart';
|
||||||
|
|
||||||
|
enum ImageFilterType { none, greyscale, invert, highContrast }
|
||||||
|
|
||||||
|
/// Live-image adjustments for one camera stream. Saved per camera, because
|
||||||
|
/// lighting differs from lane to lane.
|
||||||
|
class ImageAdjustments {
|
||||||
|
final ImageFilterType filter;
|
||||||
|
final double brightness; // -1 … 1
|
||||||
|
final double contrast; // 0.5 … 2
|
||||||
|
final int quarterTurns; // 0–3, for cameras mounted sideways
|
||||||
|
|
||||||
|
const ImageAdjustments({
|
||||||
|
this.filter = ImageFilterType.none,
|
||||||
|
this.brightness = 0,
|
||||||
|
this.contrast = 1,
|
||||||
|
this.quarterTurns = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageAdjustments copyWith({
|
||||||
|
ImageFilterType? filter,
|
||||||
|
double? brightness,
|
||||||
|
double? contrast,
|
||||||
|
int? quarterTurns,
|
||||||
|
}) {
|
||||||
|
return ImageAdjustments(
|
||||||
|
filter: filter ?? this.filter,
|
||||||
|
brightness: brightness ?? this.brightness,
|
||||||
|
contrast: contrast ?? this.contrast,
|
||||||
|
quarterTurns: quarterTurns ?? this.quarterTurns,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Keeps rotation, resets the picture itself.
|
||||||
|
ImageAdjustments resetPicture() =>
|
||||||
|
copyWith(filter: ImageFilterType.none, brightness: 0, contrast: 1);
|
||||||
|
|
||||||
|
// Older versions stored one global setting; use it until a camera has its own
|
||||||
|
static Future<ImageAdjustments> load(String camera) async {
|
||||||
|
final p = await SharedPreferences.getInstance();
|
||||||
|
final filter =
|
||||||
|
p.getInt('filter_cam$camera') ?? p.getInt('selectedFilter') ?? 0;
|
||||||
|
return ImageAdjustments(
|
||||||
|
filter: ImageFilterType
|
||||||
|
.values[filter.clamp(0, ImageFilterType.values.length - 1)],
|
||||||
|
brightness: p.getDouble('brightness_cam$camera') ??
|
||||||
|
p.getDouble('brightness') ??
|
||||||
|
0,
|
||||||
|
contrast:
|
||||||
|
p.getDouble('contrast_cam$camera') ?? p.getDouble('contrast') ?? 1,
|
||||||
|
quarterTurns: p.getInt('rotation_cam$camera') ?? 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> save(String camera) async {
|
||||||
|
final p = await SharedPreferences.getInstance();
|
||||||
|
await p.setInt('filter_cam$camera', filter.index);
|
||||||
|
await p.setDouble('brightness_cam$camera', brightness);
|
||||||
|
await p.setDouble('contrast_cam$camera', contrast);
|
||||||
|
await p.setInt('rotation_cam$camera', quarterTurns);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Filter first, then contrast around mid-grey and brightness on top.
|
||||||
|
ColorFilter get colorFilter {
|
||||||
|
const lum = [0.2126, 0.7152, 0.0722];
|
||||||
|
final List<double> base = switch (filter) {
|
||||||
|
ImageFilterType.greyscale || ImageFilterType.highContrast => [
|
||||||
|
...lum, 0, 0, //
|
||||||
|
...lum, 0, 0,
|
||||||
|
...lum, 0, 0,
|
||||||
|
0, 0, 0, 1, 0,
|
||||||
|
],
|
||||||
|
ImageFilterType.invert => [
|
||||||
|
-1, 0, 0, 0, 255, //
|
||||||
|
0, -1, 0, 0, 255,
|
||||||
|
0, 0, -1, 0, 255,
|
||||||
|
0, 0, 0, 1, 0,
|
||||||
|
],
|
||||||
|
ImageFilterType.none => [
|
||||||
|
1, 0, 0, 0, 0, //
|
||||||
|
0, 1, 0, 0, 0,
|
||||||
|
0, 0, 1, 0, 0,
|
||||||
|
0, 0, 0, 1, 0,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
// High contrast makes dark holes stand out on a light target
|
||||||
|
final c = contrast * (filter == ImageFilterType.highContrast ? 2.2 : 1);
|
||||||
|
final m = [...base];
|
||||||
|
for (final row in [0, 5, 10]) {
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
m[row + i] *= c;
|
||||||
|
}
|
||||||
|
m[row + 4] = m[row + 4] * c + 128 * (1 - c) + brightness * 255;
|
||||||
|
}
|
||||||
|
return ColorFilter.matrix(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Bottom sheet that leaves the live image visible, so every change is seen immediately.
|
||||||
|
Future<void> showImageSettingsSheet(
|
||||||
|
BuildContext context, {
|
||||||
|
required ImageAdjustments initial,
|
||||||
|
required String settingsId,
|
||||||
|
required String cameraLabel,
|
||||||
|
required Color accent,
|
||||||
|
required String Function(String) t,
|
||||||
|
required ValueChanged<ImageAdjustments> onChanged,
|
||||||
|
}) {
|
||||||
|
var value = initial;
|
||||||
|
return showCameraSheet(
|
||||||
|
context,
|
||||||
|
builder: (sheet) => StatefulBuilder(
|
||||||
|
builder: (context, setSheetState) {
|
||||||
|
void update(ImageAdjustments next) {
|
||||||
|
setSheetState(() => value = next);
|
||||||
|
onChanged(next);
|
||||||
|
next.save(settingsId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
CameraSheetHeader(
|
||||||
|
title: t('Image Settings'),
|
||||||
|
subtitle: '$cameraLabel · ${t('Saved for this camera')}',
|
||||||
|
trailing: TextButton.icon(
|
||||||
|
style: TextButton.styleFrom(foregroundColor: Colors.white70),
|
||||||
|
icon: const Icon(Icons.restart_alt_rounded, size: 18),
|
||||||
|
label: Text(t('Reset')),
|
||||||
|
onPressed: () => update(value.resetPicture()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
for (final (f, icon, label) in [
|
||||||
|
(ImageFilterType.none, Icons.image_outlined, 'None'),
|
||||||
|
(
|
||||||
|
ImageFilterType.greyscale,
|
||||||
|
Icons.filter_b_and_w_rounded,
|
||||||
|
'Greyscale'
|
||||||
|
),
|
||||||
|
(
|
||||||
|
ImageFilterType.highContrast,
|
||||||
|
Icons.contrast_rounded,
|
||||||
|
'High contrast'
|
||||||
|
),
|
||||||
|
(
|
||||||
|
ImageFilterType.invert,
|
||||||
|
Icons.invert_colors_rounded,
|
||||||
|
'Invert'
|
||||||
|
),
|
||||||
|
]) ...[
|
||||||
|
if (f != ImageFilterType.none) const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: _FilterTile(
|
||||||
|
icon: icon,
|
||||||
|
label: t(label),
|
||||||
|
selected: value.filter == f,
|
||||||
|
accent: accent,
|
||||||
|
onTap: () => update(value.copyWith(filter: f)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
SheetSlider(
|
||||||
|
icon: Icons.brightness_6_rounded,
|
||||||
|
label: t('Brightness'),
|
||||||
|
valueText:
|
||||||
|
'${value.brightness >= 0 ? '+' : ''}${(value.brightness * 100).round()}',
|
||||||
|
value: value.brightness,
|
||||||
|
min: -1,
|
||||||
|
max: 1,
|
||||||
|
accent: accent,
|
||||||
|
onChanged: (v) => update(value.copyWith(brightness: v)),
|
||||||
|
),
|
||||||
|
SheetSlider(
|
||||||
|
icon: Icons.tonality_rounded,
|
||||||
|
label: t('Contrast'),
|
||||||
|
valueText: '${(value.contrast * 100).round()} %',
|
||||||
|
value: value.contrast,
|
||||||
|
min: 0.5,
|
||||||
|
max: 2,
|
||||||
|
accent: accent,
|
||||||
|
onChanged: (v) => update(value.copyWith(contrast: v)),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
SheetToggle(
|
||||||
|
icon: Icons.rotate_90_degrees_cw_rounded,
|
||||||
|
label: '${t('Rotate')} · ${value.quarterTurns * 90}°',
|
||||||
|
active: value.quarterTurns != 0,
|
||||||
|
accent: accent,
|
||||||
|
onTap: () => update(
|
||||||
|
value.copyWith(quarterTurns: (value.quarterTurns + 1) % 4)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FilterTile extends StatelessWidget {
|
||||||
|
final IconData icon;
|
||||||
|
final String label;
|
||||||
|
final bool selected;
|
||||||
|
final Color accent;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
const _FilterTile({
|
||||||
|
required this.icon,
|
||||||
|
required this.label,
|
||||||
|
required this.selected,
|
||||||
|
required this.accent,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Material(
|
||||||
|
color: selected
|
||||||
|
? accent.withValues(alpha: 0.18)
|
||||||
|
: Colors.white.withValues(alpha: 0.06),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
side:
|
||||||
|
BorderSide(color: selected ? accent : Colors.transparent, width: 2),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
onTap: onTap,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 4),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Icon(icon, color: selected ? accent : Colors.white70, size: 26),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: selected ? Colors.white : Colors.white70,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class InputField extends StatelessWidget {
|
|
||||||
final String hintText;
|
|
||||||
final IconData icon;
|
|
||||||
final bool obscureText;
|
|
||||||
final TextEditingController controller;
|
|
||||||
|
|
||||||
const InputField({
|
|
||||||
super.key,
|
|
||||||
required this.hintText,
|
|
||||||
required this.icon,
|
|
||||||
this.obscureText = false,
|
|
||||||
required this.controller,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return TextField(
|
|
||||||
controller: controller,
|
|
||||||
obscureText: obscureText,
|
|
||||||
style: const TextStyle(color: Colors.grey), // Text inside input field is gray
|
|
||||||
decoration: InputDecoration(
|
|
||||||
prefixIcon: Icon(icon, color: Colors.grey), // Icons inside input field are gray
|
|
||||||
hintText: hintText,
|
|
||||||
hintStyle: const TextStyle(color: Colors.grey), // Placeholder text is gray
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey[300], // Light gray background for inputs
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
borderSide: BorderSide.none, // No border
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,268 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
import 'package:flutter/foundation.dart' show listEquals;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
enum ChartAxis { left, right, none }
|
||||||
|
|
||||||
|
/// One line on the chart. Each series has its own scale, so values of very
|
||||||
|
/// different size (average per shot vs. session total) can share the chart.
|
||||||
|
/// [axis] says which side labels its scale.
|
||||||
|
class ChartSeries {
|
||||||
|
final String name;
|
||||||
|
final Color color;
|
||||||
|
final List<double> values; // one per label
|
||||||
|
final int decimals;
|
||||||
|
final ChartAxis axis;
|
||||||
|
|
||||||
|
const ChartSeries(this.name, this.color, this.values,
|
||||||
|
{this.decimals = 2, this.axis = ChartAxis.none});
|
||||||
|
|
||||||
|
String format(double v) => v.toStringAsFixed(decimals);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Line chart: 2px lines, 8px points, three faint gridlines, up to one labelled
|
||||||
|
/// axis per side. Tap (or drag) to show every series' value at the nearest point.
|
||||||
|
class ProgressChart extends StatefulWidget {
|
||||||
|
final List<String> labels; // shown in the tooltip and under the first/last point
|
||||||
|
final List<ChartSeries> series; // legend and tooltip order
|
||||||
|
final Color textColor;
|
||||||
|
final Color gridColor;
|
||||||
|
|
||||||
|
const ProgressChart({
|
||||||
|
super.key,
|
||||||
|
required this.labels,
|
||||||
|
required this.series,
|
||||||
|
required this.textColor,
|
||||||
|
required this.gridColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ProgressChart> createState() => _ProgressChartState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProgressChartState extends State<ProgressChart> {
|
||||||
|
int? _selected;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
if (n == 0) return null;
|
||||||
|
final plot = _ChartPainter.plotRect(size);
|
||||||
|
final x = (position.dx - plot.left) / plot.width;
|
||||||
|
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
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final size = Size(constraints.maxWidth, 190);
|
||||||
|
return GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTapDown: (d) => _toggle(d.localPosition, size),
|
||||||
|
onHorizontalDragUpdate: (d) => _select(d.localPosition, size),
|
||||||
|
child: CustomPaint(
|
||||||
|
size: size,
|
||||||
|
painter: _ChartPainter(
|
||||||
|
labels: widget.labels,
|
||||||
|
series: widget.series,
|
||||||
|
textColor: widget.textColor,
|
||||||
|
gridColor: widget.gridColor,
|
||||||
|
selected: _selected,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
// Legend, centred under the graph
|
||||||
|
Wrap(
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
spacing: 16,
|
||||||
|
runSpacing: 4,
|
||||||
|
children: [
|
||||||
|
for (final s in widget.series)
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 14,
|
||||||
|
height: 3,
|
||||||
|
decoration: BoxDecoration(color: s.color, borderRadius: BorderRadius.circular(2)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(s.name, style: TextStyle(fontSize: 12, color: widget.textColor)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChartPainter extends CustomPainter {
|
||||||
|
static const double axis = 34; // room for y labels on each side
|
||||||
|
static const double pad = 10; // keeps end points inside the plot
|
||||||
|
static const double top = 34; // room for the tooltip
|
||||||
|
static const double bottom = 20; // room for x labels
|
||||||
|
|
||||||
|
static Rect plotRect(Size size) =>
|
||||||
|
Rect.fromLTRB(axis + pad, top, size.width - axis - pad, size.height - bottom);
|
||||||
|
|
||||||
|
final List<String> labels;
|
||||||
|
final List<ChartSeries> series;
|
||||||
|
final Color textColor;
|
||||||
|
final Color gridColor;
|
||||||
|
final int? selected;
|
||||||
|
|
||||||
|
_ChartPainter({
|
||||||
|
required this.labels,
|
||||||
|
required this.series,
|
||||||
|
required this.textColor,
|
||||||
|
required this.gridColor,
|
||||||
|
required this.selected,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Min and max of a series, widened so a flat line sits in the middle
|
||||||
|
static (double, double) _range(List<double> values, double minSpan) {
|
||||||
|
var lo = values.reduce(min);
|
||||||
|
var hi = values.reduce(max);
|
||||||
|
if (hi - lo < minSpan) {
|
||||||
|
final mid = (hi + lo) / 2;
|
||||||
|
lo = mid - minSpan / 2;
|
||||||
|
hi = mid + minSpan / 2;
|
||||||
|
}
|
||||||
|
return (lo, hi);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
if (labels.isEmpty || series.isEmpty) return;
|
||||||
|
final plot = plotRect(size);
|
||||||
|
final n = labels.length;
|
||||||
|
final ranges = [
|
||||||
|
for (final s in series) _range(s.values, s.values.reduce(max).abs() * 0.1 + 0.2),
|
||||||
|
];
|
||||||
|
|
||||||
|
double xAt(int i) => n == 1 ? plot.center.dx : plot.left + plot.width * i / (n - 1);
|
||||||
|
double yAt(double v, (double, double) r) => plot.bottom - plot.height * (v - r.$1) / (r.$2 - r.$1);
|
||||||
|
|
||||||
|
// Gridlines + y labels in each axis series' colour
|
||||||
|
final grid = Paint()
|
||||||
|
..color = gridColor
|
||||||
|
..strokeWidth = 1;
|
||||||
|
for (final f in [0.0, 0.5, 1.0]) {
|
||||||
|
final y = plot.bottom - plot.height * f;
|
||||||
|
canvas.drawLine(Offset(axis, y), Offset(size.width - axis, y), grid);
|
||||||
|
for (int k = 0; k < series.length; k++) {
|
||||||
|
if (series[k].axis == ChartAxis.none) continue;
|
||||||
|
final right = series[k].axis == ChartAxis.right;
|
||||||
|
final r = ranges[k];
|
||||||
|
final v = r.$1 + (r.$2 - r.$1) * f;
|
||||||
|
final text = series[k].decimals == 0 ? v.round().toString() : v.toStringAsFixed(1);
|
||||||
|
_text(canvas, text, Offset(right ? size.width : 0, y - 7), 11, series[k].color, alignRight: right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// x labels: first and last only
|
||||||
|
_text(canvas, labels.first, Offset(plot.left - pad, plot.bottom + 5), 11, textColor);
|
||||||
|
if (n > 1) {
|
||||||
|
_text(canvas, labels.last, Offset(plot.right + pad, plot.bottom + 5), 11, textColor, alignRight: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lines, last series first so the main one stays on top
|
||||||
|
for (int k = series.length - 1; k >= 0; k--) {
|
||||||
|
final s = series[k];
|
||||||
|
final r = ranges[k];
|
||||||
|
final path = Path()..moveTo(xAt(0), yAt(s.values[0], r));
|
||||||
|
for (int i = 1; i < n; i++) {
|
||||||
|
path.lineTo(xAt(i), yAt(s.values[i], r));
|
||||||
|
}
|
||||||
|
canvas.drawPath(
|
||||||
|
path,
|
||||||
|
Paint()
|
||||||
|
..color = s.color
|
||||||
|
..strokeWidth = 2
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeJoin = StrokeJoin.round,
|
||||||
|
);
|
||||||
|
// Points with a surface ring so they read on top of the line
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
final isSel = i == selected;
|
||||||
|
final p = Offset(xAt(i), yAt(s.values[i], r));
|
||||||
|
canvas.drawCircle(p, isSel ? 6 : 4.5, Paint()..color = Colors.white);
|
||||||
|
canvas.drawCircle(p, isSel ? 4.5 : 3.5, Paint()..color = s.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tooltip for the selected point: label, then each value in its colour
|
||||||
|
if (selected != null) {
|
||||||
|
final i = selected!;
|
||||||
|
canvas.drawLine(Offset(xAt(i), plot.top), Offset(xAt(i), plot.bottom), grid);
|
||||||
|
final tp = TextPainter(
|
||||||
|
text: TextSpan(
|
||||||
|
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white),
|
||||||
|
children: [
|
||||||
|
TextSpan(text: labels[i]),
|
||||||
|
for (final s in series)
|
||||||
|
TextSpan(
|
||||||
|
text: ' ${s.format(s.values[i])}',
|
||||||
|
style: TextStyle(color: Color.lerp(s.color, Colors.white, 0.35)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
)..layout(maxWidth: size.width - 16);
|
||||||
|
final w = tp.width + 16;
|
||||||
|
final left = (xAt(i) - w / 2).clamp(0.0, size.width - w);
|
||||||
|
canvas.drawRRect(
|
||||||
|
RRect.fromRectAndRadius(Rect.fromLTWH(left, 2, w, 24), const Radius.circular(6)),
|
||||||
|
Paint()..color = Colors.grey[900]!,
|
||||||
|
);
|
||||||
|
tp.paint(canvas, Offset(left + 8, 2 + (24 - tp.height) / 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _text(Canvas canvas, String text, Offset at, double size, Color color, {bool alignRight = false}) {
|
||||||
|
final tp = TextPainter(
|
||||||
|
text: TextSpan(text: text, style: TextStyle(fontSize: size, color: color)),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
)..layout();
|
||||||
|
tp.paint(canvas, alignRight ? at.translate(-tp.width, 0) : at);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(_ChartPainter old) =>
|
||||||
|
old.labels != labels ||
|
||||||
|
old.series != series ||
|
||||||
|
old.selected != selected ||
|
||||||
|
old.textColor != textColor;
|
||||||
|
}
|
||||||
@@ -0,0 +1,248 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
|
/// Small uppercase label above a group, e.g. "OBVESTILA".
|
||||||
|
class SectionHeader extends StatelessWidget {
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
const SectionHeader(this.label, {super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(4, 20, 4, 8),
|
||||||
|
child: Text(
|
||||||
|
label.toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
letterSpacing: 1.4,
|
||||||
|
color: Surfaces.current.textSecondary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Rounded group of rows with thin dividers between them.
|
||||||
|
class GroupCard extends StatelessWidget {
|
||||||
|
final List<Widget> children;
|
||||||
|
|
||||||
|
const GroupCard({super.key, required this.children});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = Surfaces.current;
|
||||||
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
child: Material(
|
||||||
|
color: s.card,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
for (int i = 0; i < children.length; i++) ...[
|
||||||
|
if (i > 0) Divider(height: 1, thickness: 1, indent: 16, color: s.divider),
|
||||||
|
children[i],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One settings row: title (+ optional subtitle) on the left, current value and
|
||||||
|
/// a chevron on the right. Pass [trailing] to replace value + chevron (e.g. a Switch).
|
||||||
|
class SettingsTile extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String? subtitle;
|
||||||
|
final Widget? leading;
|
||||||
|
final String? value;
|
||||||
|
final Widget? valueLeading;
|
||||||
|
final Widget? trailing;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
|
const SettingsTile({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.leading,
|
||||||
|
this.value,
|
||||||
|
this.valueLeading,
|
||||||
|
this.trailing,
|
||||||
|
this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = Surfaces.current;
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(minHeight: 52),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
if (leading != null) ...[leading!, const SizedBox(width: 12)],
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(title, style: TextStyle(fontSize: 15, color: s.textPrimary)),
|
||||||
|
if (subtitle != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 2),
|
||||||
|
child: Text(subtitle!, style: TextStyle(fontSize: 12, color: s.textSecondary)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (trailing != null)
|
||||||
|
trailing!
|
||||||
|
else ...[
|
||||||
|
if (valueLeading != null) ...[valueLeading!, const SizedBox(width: 8)],
|
||||||
|
if (value != null)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 170),
|
||||||
|
child: Text(
|
||||||
|
value!,
|
||||||
|
style: TextStyle(fontSize: 14, color: s.textSecondary),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (onTap != null) Icon(Icons.chevron_right, color: s.textSecondary),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Settings row with a switch on the right; tapping the row toggles it.
|
||||||
|
class SettingsSwitchTile extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final bool value;
|
||||||
|
final ValueChanged<bool> onChanged;
|
||||||
|
final Color activeColor;
|
||||||
|
|
||||||
|
const SettingsSwitchTile({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.value,
|
||||||
|
required this.onChanged,
|
||||||
|
required this.activeColor,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SettingsTile(
|
||||||
|
title: title,
|
||||||
|
onTap: () => onChanged(!value),
|
||||||
|
trailing: SizedBox(
|
||||||
|
height: 32,
|
||||||
|
child: FittedBox(
|
||||||
|
child: Switch(
|
||||||
|
value: value,
|
||||||
|
onChanged: onChanged,
|
||||||
|
activeTrackColor: activeColor,
|
||||||
|
activeThumbColor: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Row used inside dark bottom-sheet pickers, with a check on the selected one.
|
||||||
|
class SheetOption extends StatelessWidget {
|
||||||
|
final String label;
|
||||||
|
final Widget? leading;
|
||||||
|
final bool selected;
|
||||||
|
final Color selectedColor;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
const SheetOption({
|
||||||
|
super.key,
|
||||||
|
required this.label,
|
||||||
|
this.leading,
|
||||||
|
required this.selected,
|
||||||
|
required this.selectedColor,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
onTap: onTap,
|
||||||
|
leading: leading,
|
||||||
|
title: Text(
|
||||||
|
label,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: selected ? FontWeight.bold : FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: selected ? Icon(Icons.check_rounded, color: selectedColor) : null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Headline number with a small label above and an optional caption below.
|
||||||
|
class StatTile extends StatelessWidget {
|
||||||
|
final String label;
|
||||||
|
final String value;
|
||||||
|
final String? caption;
|
||||||
|
|
||||||
|
const StatTile({super.key, required this.label, required this.value, this.caption});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = Surfaces.current;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 12, 12),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(label, style: TextStyle(fontSize: 12, color: s.textSecondary)),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(value, style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: s.textPrimary)),
|
||||||
|
if (caption != null)
|
||||||
|
Text(caption!, style: TextStyle(fontSize: 11, color: s.textSecondary), maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Grid of [StatTile]s, two per row, on one card.
|
||||||
|
class StatGrid extends StatelessWidget {
|
||||||
|
final List<StatTile> tiles;
|
||||||
|
|
||||||
|
const StatGrid({super.key, required this.tiles});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final s = Surfaces.current;
|
||||||
|
final rows = <Widget>[];
|
||||||
|
for (int i = 0; i < tiles.length; i += 2) {
|
||||||
|
if (i > 0) rows.add(Divider(height: 1, thickness: 1, color: s.divider));
|
||||||
|
rows.add(IntrinsicHeight(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Expanded(child: tiles[i]),
|
||||||
|
VerticalDivider(width: 1, thickness: 1, color: s.divider),
|
||||||
|
Expanded(child: i + 1 < tiles.length ? tiles[i + 1] : const SizedBox()),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
child: ColoredBox(color: s.card, child: Column(children: rows)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../services/app_settings.dart';
|
||||||
|
|
||||||
|
/// Dark dialog with one text field. Returns the trimmed text, or null if cancelled.
|
||||||
|
/// [onReset] adds a secondary button ([resetLabel], default "Reset to Default") that closes the dialog.
|
||||||
|
Future<String?> showTextPrompt(
|
||||||
|
BuildContext context, {
|
||||||
|
required String title,
|
||||||
|
String? message,
|
||||||
|
String initial = '',
|
||||||
|
String? hint,
|
||||||
|
TextInputType keyboardType = TextInputType.text,
|
||||||
|
String? confirmLabel,
|
||||||
|
String? resetLabel,
|
||||||
|
VoidCallback? onReset,
|
||||||
|
}) {
|
||||||
|
final s = AppSettings.instance;
|
||||||
|
final controller = TextEditingController(text: initial);
|
||||||
|
|
||||||
|
return showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder: (dialog) => AlertDialog(
|
||||||
|
title: Text(title),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (message != null) ...[
|
||||||
|
Text(message),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
|
TextField(
|
||||||
|
controller: controller,
|
||||||
|
autofocus: true,
|
||||||
|
keyboardType: keyboardType,
|
||||||
|
autocorrect: false,
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
cursorColor: s.bulletColor,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: hint,
|
||||||
|
hintStyle: const TextStyle(color: Colors.white38),
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.white10,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide(color: s.bulletColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (v) => Navigator.pop(dialog, v.trim()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
if (onReset != null)
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
onReset();
|
||||||
|
Navigator.pop(dialog);
|
||||||
|
},
|
||||||
|
child: Text(resetLabel ?? s.t('Reset to Default'), style: const TextStyle(color: Colors.white54)),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(dialog),
|
||||||
|
child: Text(s.t('Cancel'), style: const TextStyle(color: Colors.white70)),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
style: FilledButton.styleFrom(backgroundColor: s.bulletColor),
|
||||||
|
onPressed: () => Navigator.pop(dialog, controller.text.trim()),
|
||||||
|
child: Text(confirmLabel ?? s.t('Save')),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,13 +6,9 @@
|
|||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_linux/file_selector_plugin.h>
|
|
||||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
|
||||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
|
||||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_linux
|
|
||||||
url_launcher_linux
|
url_launcher_linux
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
_discoveryapis_commons:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: _discoveryapis_commons
|
|
||||||
sha256: "113c4100b90a5b70a983541782431b82168b3cae166ab130649c36eb3559d498"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.7"
|
|
||||||
archive:
|
archive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -114,7 +106,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.2"
|
version: "1.1.2"
|
||||||
collection:
|
collection:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
|
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
|
||||||
@@ -137,14 +129,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.6"
|
version: "3.0.6"
|
||||||
cupertino_icons:
|
cryptography:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: cryptography
|
||||||
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
|
sha256: "3eda3029d34ec9095a27a198ac9785630fe525c0eb6a49f3d575272f8e792ef0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "2.9.0"
|
||||||
dbus:
|
dbus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -177,51 +169,11 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.1"
|
version: "7.0.1"
|
||||||
file_selector_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_linux
|
|
||||||
sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.9.3+2"
|
|
||||||
file_selector_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_macos
|
|
||||||
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.9.4+2"
|
|
||||||
file_selector_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_platform_interface
|
|
||||||
sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.6.2"
|
|
||||||
file_selector_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: file_selector_windows
|
|
||||||
sha256: "320fcfb6f33caa90f0b58380489fc5ac05d99ee94b61aa96ec2bff0ba81d3c2b"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.9.3+4"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
flutter_exif_rotation:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_exif_rotation
|
|
||||||
sha256: f581601523bbb7fbec3a0498fe930bf6c48f627d4548d859b2772230edfbe658
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.5.2"
|
|
||||||
flutter_hooks:
|
flutter_hooks:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -231,7 +183,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.21.2"
|
version: "0.21.2"
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: flutter_launcher_icons
|
name: flutter_launcher_icons
|
||||||
sha256: bfa04787c85d80ecb3f8777bde5fc10c3de809240c48fa061a2c2bf15ea5211c
|
sha256: bfa04787c85d80ecb3f8777bde5fc10c3de809240c48fa061a2c2bf15ea5211c
|
||||||
@@ -286,14 +238,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.27"
|
version: "2.0.27"
|
||||||
flutter_svg:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_svg
|
|
||||||
sha256: c200fd79c918a40c5cd50ea0877fa13f81bdaf6f0a5d3dbcc2a13e3285d6aa1b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.17"
|
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -312,72 +256,8 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
google_identity_services_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: google_identity_services_web
|
|
||||||
sha256: "55580f436822d64c8ff9a77e37d61f5fb1e6c7ec9d632a43ee324e2a05c3c6c9"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.3"
|
|
||||||
google_sign_in:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: google_sign_in
|
|
||||||
sha256: d0a2c3bcb06e607bb11e4daca48bd4b6120f0bbc4015ccebbe757d24ea60ed2a
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "6.3.0"
|
|
||||||
google_sign_in_android:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: google_sign_in_android
|
|
||||||
sha256: "4e52c64366bdb3fe758f683b088ee514cc7a95e69c52b5ee9fc5919e1683d21b"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "6.2.0"
|
|
||||||
google_sign_in_ios:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: google_sign_in_ios
|
|
||||||
sha256: "29cd125f58f50ceb40e8253d3c0209e321eee3e5df16cd6d262495f7cad6a2bd"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "5.8.1"
|
|
||||||
google_sign_in_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: google_sign_in_platform_interface
|
|
||||||
sha256: "5f6f79cf139c197261adb6ac024577518ae48fdff8e53205c5373b5f6430a8aa"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.5.0"
|
|
||||||
google_sign_in_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: google_sign_in_web
|
|
||||||
sha256: "460547beb4962b7623ac0fb8122d6b8268c951cf0b646dd150d60498430e4ded"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.12.4+4"
|
|
||||||
googleapis:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: googleapis
|
|
||||||
sha256: "864f222aed3f2ff00b816c675edf00a39e2aaf373d728d8abec30b37bee1a81c"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "13.2.0"
|
|
||||||
googleapis_auth:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: googleapis_auth
|
|
||||||
sha256: befd71383a955535060acde8792e7efc11d2fccd03dd1d3ec434e85b68775938
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.6.0"
|
|
||||||
http:
|
http:
|
||||||
dependency: "direct overridden"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
|
sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2"
|
||||||
@@ -400,70 +280,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.5.4"
|
version: "4.5.4"
|
||||||
image_picker:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: image_picker
|
|
||||||
sha256: "021834d9c0c3de46bf0fe40341fa07168407f694d9b2bb18d532dc1261867f7a"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.2"
|
|
||||||
image_picker_android:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_android
|
|
||||||
sha256: "8bd392ba8b0c8957a157ae0dc9fcf48c58e6c20908d5880aea1d79734df090e9"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.12+22"
|
|
||||||
image_picker_for_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_for_web
|
|
||||||
sha256: "717eb042ab08c40767684327be06a5d8dbb341fe791d514e4b92c7bbe1b7bb83"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.6"
|
|
||||||
image_picker_ios:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_ios
|
|
||||||
sha256: "05da758e67bc7839e886b3959848aa6b44ff123ab4b28f67891008afe8ef9100"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.12+2"
|
|
||||||
image_picker_linux:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_linux
|
|
||||||
sha256: "34a65f6740df08bbbeb0a1abd8e6d32107941fd4868f67a507b25601651022c9"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1+2"
|
|
||||||
image_picker_macos:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_macos
|
|
||||||
sha256: "1b90ebbd9dcf98fb6c1d01427e49a55bd96b5d67b8c67cf955d60a5de74207c1"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1+2"
|
|
||||||
image_picker_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_platform_interface
|
|
||||||
sha256: "886d57f0be73c4b140004e78b9f28a8914a09e50c2d816bdd0520051a71236a0"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.10.1"
|
|
||||||
image_picker_windows:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_windows
|
|
||||||
sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1+1"
|
|
||||||
intl:
|
intl:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -516,10 +332,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.19"
|
version: "0.12.20"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -532,20 +348,12 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.17.0"
|
version: "1.19.0"
|
||||||
mime:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: mime
|
|
||||||
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0"
|
|
||||||
package_info_plus:
|
package_info_plus:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: package_info_plus
|
name: package_info_plus
|
||||||
sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191"
|
sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191"
|
||||||
@@ -568,14 +376,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.1"
|
version: "1.9.1"
|
||||||
path_parsing:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path_parsing
|
|
||||||
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.0"
|
|
||||||
path_provider:
|
path_provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -632,14 +432,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.1.0"
|
version: "6.1.0"
|
||||||
photo_view:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: photo_view
|
|
||||||
sha256: "1fc3d970a91295fbd1364296575f854c9863f225505c28c46e0a03e48960c75e"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.15.0"
|
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -672,14 +464,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.2.2"
|
version: "3.2.2"
|
||||||
screenshot:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: screenshot
|
|
||||||
sha256: "63817697a7835e6ce82add4228e15d233b74d42975c143ad8cfe07009fab866b"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.0"
|
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -736,14 +520,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
version: "2.4.1"
|
||||||
simple_gesture_detector:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: simple_gesture_detector
|
|
||||||
sha256: ba2cd5af24ff20a0b8d609cec3f40e5b0744d2a71804a2616ae086b9c19d19a3
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.1"
|
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -789,14 +565,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.1"
|
version: "1.4.1"
|
||||||
table_calendar:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: table_calendar
|
|
||||||
sha256: "0c0c6219878b363a2d5f40c7afb159d845f253d061dc3c822aa0d5fe0f721982"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.2.0"
|
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -809,10 +577,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
|
sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.10"
|
version: "0.7.12"
|
||||||
tflite_flutter:
|
tflite_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -901,38 +669,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.4"
|
version: "3.1.4"
|
||||||
vector_graphics:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vector_graphics
|
|
||||||
sha256: "44cc7104ff32563122a929e4620cf3efd584194eec6d1d913eb5ba593dbcf6de"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.18"
|
|
||||||
vector_graphics_codec:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vector_graphics_codec
|
|
||||||
sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.13"
|
|
||||||
vector_graphics_compiler:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vector_graphics_compiler
|
|
||||||
sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.16"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
sha256: fa49e1674cb84acb900141714e6c6e1f9ae099827c24d141430ff6819db4e1bc
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.4.4"
|
||||||
visibility_detector:
|
visibility_detector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -973,38 +717,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
webview_flutter:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: webview_flutter
|
|
||||||
sha256: "889a0a678e7c793c308c68739996227c9661590605e70b1f6cf6b9a6634f7aec"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.10.0"
|
|
||||||
webview_flutter_android:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: webview_flutter_android
|
|
||||||
sha256: e09150b28a07933839adef0e4a088bb43e8c8d9e6b93025b01882d4067a58ab0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.3.4"
|
|
||||||
webview_flutter_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: webview_flutter_platform_interface
|
|
||||||
sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.10.0"
|
|
||||||
webview_flutter_wkwebview:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: webview_flutter_wkwebview
|
|
||||||
sha256: c49a98510080378b1525132f407a92c3dcd3b7145bef04fb8137724aadcf1cf0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "3.18.4"
|
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1038,5 +750,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.9.0-0 <4.0.0"
|
dart: ">=3.11.0-0 <4.0.0"
|
||||||
flutter: ">=3.29.0"
|
flutter: ">=3.29.0"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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.1.0+4
|
version: 1.3.0+6
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.3.0 <4.0.0'
|
sdk: '>=3.3.0 <4.0.0'
|
||||||
@@ -10,43 +10,28 @@ environment:
|
|||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
cupertino_icons: ^1.0.8
|
|
||||||
google_sign_in: ^6.1.5
|
|
||||||
googleapis: ^13.2.0
|
|
||||||
googleapis_auth: ^1.6.0
|
|
||||||
shared_preferences: ^2.2.2
|
shared_preferences: ^2.2.2
|
||||||
photo_view: ^0.15.0
|
|
||||||
screenshot: ^3.0.0
|
|
||||||
flutter_mjpeg: ^2.0.0
|
flutter_mjpeg: ^2.0.0
|
||||||
webview_flutter: ^4.4.1
|
|
||||||
webview_flutter_android: ^4.3.3
|
|
||||||
webview_flutter_wkwebview: ^3.7.4
|
|
||||||
intl: any
|
intl: any
|
||||||
flutter_exif_rotation: any
|
|
||||||
flutter_launcher_icons: ^0.14.3
|
|
||||||
flutter_svg: ^2.0.9
|
|
||||||
collection: ^1.17.2
|
|
||||||
table_calendar: ^3.1.2
|
|
||||||
|
|
||||||
tflite_flutter: ^0.11.0
|
tflite_flutter: ^0.11.0
|
||||||
image: ^4.5.4
|
image: ^4.5.4
|
||||||
camera: ^0.10.0
|
camera: ^0.10.0
|
||||||
path_provider: ^2.0.15
|
path_provider: ^2.0.15
|
||||||
image_picker: ^1.0.4
|
|
||||||
wakelock_plus: ^1.2.11
|
wakelock_plus: ^1.2.11
|
||||||
url_launcher: ^6.1.0
|
url_launcher: ^6.1.0
|
||||||
flutter_local_notifications: ^18.0.1
|
flutter_local_notifications: ^18.0.1
|
||||||
timezone: ^0.9.4
|
timezone: ^0.9.4
|
||||||
flutter_timezone: ^3.0.0
|
flutter_timezone: ^3.0.0
|
||||||
|
package_info_plus: ^8.3.0
|
||||||
dependency_overrides:
|
cryptography: ^2.9.0
|
||||||
http: ^0.13.6
|
http: ^0.13.6
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^5.0.0
|
flutter_lints: ^5.0.0
|
||||||
|
flutter_launcher_icons: ^0.14.3
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: true
|
android: true
|
||||||
@@ -57,10 +42,7 @@ flutter_icons:
|
|||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
assets:
|
assets:
|
||||||
- assets/logo.png
|
- assets/club.enc
|
||||||
- assets/logo.svg
|
|
||||||
- assets/target.png
|
- assets/target.png
|
||||||
- assets/target.svg
|
|
||||||
- assets/google_logo.png
|
|
||||||
- assets/best_float32_nms.tflite
|
- assets/best_float32_nms.tflite
|
||||||
- assets/targets/
|
- assets/targets/
|
||||||
|
|||||||
@@ -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()
|
||||||
|
After Width: | Height: | Size: 384 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 418 KiB |
|
After Width: | Height: | Size: 586 KiB |
|
After Width: | Height: | Size: 758 KiB |
|
After Width: | Height: | Size: 808 KiB |
|
After Width: | Height: | Size: 802 KiB |
|
After Width: | Height: | Size: 788 KiB |
|
After Width: | Height: | Size: 411 KiB |
|
After Width: | Height: | Size: 405 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 167 KiB |
|
After Width: | Height: | Size: 168 KiB |
|
After Width: | Height: | Size: 688 KiB |
|
After Width: | Height: | Size: 170 KiB |
|
After Width: | Height: | Size: 172 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 954 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
@@ -1,30 +0,0 @@
|
|||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility in the flutter_test package. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:test1/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
|
||||||
// Build our app and trigger a frame.
|
|
||||||
await tester.pumpWidget(const MyApp());
|
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
|
||||||
expect(find.text('0'), findsOneWidget);
|
|
||||||
expect(find.text('1'), findsNothing);
|
|
||||||
|
|
||||||
// Tap the '+' icon and trigger a frame.
|
|
||||||
await tester.tap(find.byIcon(Icons.add));
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
// Verify that our counter has incremented.
|
|
||||||
expect(find.text('0'), findsNothing);
|
|
||||||
expect(find.text('1'), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
// Encrypts tool/club_data.json into assets/club.enc using the club code.
|
||||||
|
//
|
||||||
|
// dart run tool/encrypt_club_data.dart
|
||||||
|
//
|
||||||
|
// The code is asked interactively (not echoed, not saved in shell history).
|
||||||
|
// tool/club_data.json holds the plain contacts and is gitignored — keep it private.
|
||||||
|
// Re-run after editing contacts or to change the club code, then rebuild the app.
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:sdk_kovinar/services/club_crypto.dart';
|
||||||
|
|
||||||
|
const _input = 'tool/club_data.json';
|
||||||
|
const _output = 'assets/club.enc';
|
||||||
|
|
||||||
|
Future<void> main() async {
|
||||||
|
final source = File(_input);
|
||||||
|
if (!source.existsSync()) {
|
||||||
|
stderr.writeln('Missing $_input');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
final plaintext = source.readAsStringSync();
|
||||||
|
final contacts = (jsonDecode(plaintext) as Map<String, dynamic>)['contacts'] as List;
|
||||||
|
|
||||||
|
final code = _ask('Club code: ');
|
||||||
|
if (ClubCrypto.normalize(code).length < 8) {
|
||||||
|
stderr.writeln('Use at least 8 characters — short codes can be guessed by brute force.');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (_ask('Repeat club code: ') != code) {
|
||||||
|
stderr.writeln('Codes do not match.');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
final encrypted = await ClubCrypto.encrypt(plaintext, code);
|
||||||
|
if (await ClubCrypto.decrypt(encrypted, code) != plaintext) {
|
||||||
|
stderr.writeln('Self-check failed, nothing written.');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
File(_output).writeAsStringSync(encrypted);
|
||||||
|
stdout.writeln('Wrote $_output with ${contacts.length} contacts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
String _ask(String prompt) {
|
||||||
|
stdout.write(prompt);
|
||||||
|
final terminal = stdin.hasTerminal;
|
||||||
|
if (terminal) stdin.echoMode = false;
|
||||||
|
final value = stdin.readLineSync() ?? '';
|
||||||
|
if (terminal) stdin.echoMode = true;
|
||||||
|
stdout.writeln();
|
||||||
|
return value;
|
||||||
|
}
|
||||||