From d4bc01f202777ed7b6b2b589a7076668b29c9070 Mon Sep 17 00:00:00 2001 From: Jan Pleterski Date: Fri, 13 Nov 2026 09:15:17 +0100 Subject: [PATCH] stage2 --- analysis_options.yaml | 7 + android/app/src/main/AndroidManifest.xml | 7 +- android/build.gradle.kts | 26 ++ android/gradle.properties | 4 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- android/settings.gradle.kts | 4 +- lib/screens/book_screen.dart | 143 +++++-- lib/screens/calendar_screen.dart | 3 +- lib/screens/camera_screen.dart | 2 +- lib/screens/preview_screen.dart | 249 +----------- lib/screens/spectator_screen.dart | 2 +- lib/screens/stream_screen.dart | 246 +++--------- lib/screens/target_view.dart | 77 ++-- lib/screens/yolo_detector.dart | 7 - lib/services/target_repository.dart | 4 +- lib/utils/translations.dart | 380 +----------------- lib/widgets/camera_sheet.dart | 4 +- linux/flutter/generated_plugin_registrant.cc | 4 - linux/flutter/generated_plugins.cmake | 1 - pubspec.lock | 248 +----------- pubspec.yaml | 22 +- 21 files changed, 294 insertions(+), 1148 deletions(-) create mode 100644 analysis_options.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..0bd80c1 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,7 @@ +analyzer: + exclude: + - build/** + - android/** + - ios/** + - linux/** +include: package:flutter_lints/flutter.yaml diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ea50365..f7fb9db 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ - + @@ -8,6 +9,8 @@ + + ().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()?.let { android -> + if ((android.compileSdk ?: 0) < 36) android.compileSdk = 36 + } + } +} subprojects { project.evaluationDependsOn(":app") } diff --git a/android/gradle.properties b/android/gradle.properties index f018a61..475a628 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,7 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=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 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index afa1e8e..2d428bf 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME 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 diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 11662c3..19a97ee 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -18,8 +18,8 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.7.0" apply false - id("org.jetbrains.kotlin.android") version "2.1.0" apply false + id("com.android.application") version "8.13.0" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false } include(":app") diff --git a/lib/screens/book_screen.dart b/lib/screens/book_screen.dart index 7390ea0..4c4429a 100644 --- a/lib/screens/book_screen.dart +++ b/lib/screens/book_screen.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../services/app_settings.dart'; import '../services/target_repository.dart'; import '../theme/app_theme.dart'; @@ -44,7 +45,60 @@ class _BookScreenState extends State with WidgetsBindingObserver { void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); - _load(); + _restoreSettings().then((_) => _load()); + } + + // The view settings survive leaving the screen and restarting the app. + // Which month the graph is scrolled to is not a setting: it opens on the latest. + static const _prefix = 'book.'; + + Future _restoreSettings() async { + final p = await SharedPreferences.getInstance(); + T pick(List values, String key, T fallback) { + final i = p.getInt(_prefix + key); + return i != null && i >= 0 && i < values.length ? values[i] : fallback; + } + + final start = p.getInt('${_prefix}customStart'); + final end = p.getInt('${_prefix}customEnd'); + if (!mounted) return; + setState(() { + _filter = pick(_Filter.values, 'filter', _filter); + _period = pick(_Period.values, 'period', _period); + _shots = p.getInt('${_prefix}shots'); + _sortByScore = p.getBool('${_prefix}sortByScore') ?? _sortByScore; + _chartByYear = p.getBool('${_prefix}chartByYear') ?? _chartByYear; + if (start != null && end != null) { + _custom = DateTimeRange( + start: DateTime.fromMillisecondsSinceEpoch(start), + end: DateTime.fromMillisecondsSinceEpoch(end)); + } + // A custom period without its range can't be shown + if (_period == _Period.custom && _custom == null) _period = _Period.year; + }); + } + + Future _saveSettings() async { + final p = await SharedPreferences.getInstance(); + await p.setInt('${_prefix}filter', _filter.index); + await p.setInt('${_prefix}period', _period.index); + if (_shots == null) { + await p.remove('${_prefix}shots'); + } else { + await p.setInt('${_prefix}shots', _shots!); + } + await p.setBool('${_prefix}sortByScore', _sortByScore); + await p.setBool('${_prefix}chartByYear', _chartByYear); + if (_custom != null) { + await p.setInt('${_prefix}customStart', _custom!.start.millisecondsSinceEpoch); + await p.setInt('${_prefix}customEnd', _custom!.end.millisecondsSinceEpoch); + } + } + + // setState for a view setting, then remember it + void _change(VoidCallback update) { + setState(update); + _saveSettings(); } @override @@ -124,7 +178,7 @@ class _BookScreenState extends State with WidgetsBindingObserver { if (picked == null) return; _custom = picked; } - setState(() { + _change(() { _period = p; _shots = null; }); @@ -260,7 +314,7 @@ class _BookScreenState extends State with WidgetsBindingObserver { BarTab(s.t('Tournaments'), Icons.emoji_events_rounded), ], selected: _filter.index, - onSelect: (i) => setState(() { + onSelect: (i) => _change(() { _filter = _Filter.values[i]; _shots = null; _chartAt = null; @@ -293,7 +347,7 @@ class _BookScreenState extends State with WidgetsBindingObserver { selected: n == selected, empty: !formats.contains(n), onTap: formats.contains(n) - ? () => setState(() => _shots = n) + ? () => _change(() => _shots = n) : null), ), ], @@ -533,7 +587,7 @@ class _BookScreenState extends State with WidgetsBindingObserver { labels: [s.t('Month'), s.t('Year')], selected: _chartByYear ? 1 : 0, color: s.bulletColor, - onSelect: (i) => setState(() { + onSelect: (i) => _change(() { _chartByYear = i == 1; _chartAt = at; }), @@ -624,14 +678,15 @@ class _BookScreenState extends State with WidgetsBindingObserver { icon: Icon( _sortByScore ? Icons.leaderboard_rounded : Icons.event_rounded, color: surf.textSecondary), - onPressed: () => setState(() => _sortByScore = !_sortByScore), + onPressed: () => _change(() => _sortByScore = !_sortByScore), ), ], ), ); } - // Date block left; average per shot right, with how far it is from [average]. + // Date block left; points (Skupek) and average per shot right, the average + // with how far it is from [average]. // Tap shows this session's targets on one target; long press opens details. Widget _sessionCard(Session session, double? average) { final s = AppSettings.instance; @@ -683,7 +738,7 @@ class _BookScreenState extends State with WidgetsBindingObserver { ), const SizedBox(height: 3), Text( - '${targetCount(session.targets.length)} · ${s.t('Total').toLowerCase()} ${session.totalScore}', + targetCount(session.targets.length), style: TextStyle( fontSize: 12, color: surf.textSecondary), ), @@ -691,27 +746,14 @@ class _BookScreenState extends State with WidgetsBindingObserver { ), ), ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 10), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( - avg?.toStringAsFixed(2) ?? '–', - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.w800, - color: surf.textPrimary), - ), - if (delta != null) - Text(_signed(delta), - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w700, - color: _deltaColor(delta))), - ], - ), + _CardFigure( + label: s.t('Sum'), value: '${session.totalScore}'), + const SizedBox(width: 14), + _CardFigure( + label: s.t('Average'), + value: avg?.toStringAsFixed(2) ?? '–', + note: delta == null ? null : _signed(delta), + noteColor: delta == null ? null : _deltaColor(delta), ), IconButton( tooltip: s.t('Details'), @@ -1015,6 +1057,49 @@ class _Toggle extends StatelessWidget { } } +/// One figure on a history card: small uppercase label over a bold number, +/// with an optional coloured note underneath. +class _CardFigure extends StatelessWidget { + final String label; + final String value; + final String? note; + final Color? noteColor; + + const _CardFigure( + {required this.label, required this.value, this.note, this.noteColor}); + + @override + Widget build(BuildContext context) { + final surf = Surfaces.current; + return Padding( + padding: const EdgeInsets.symmetric(vertical: 10), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text(label.toUpperCase(), + style: TextStyle( + fontSize: 9, + fontWeight: FontWeight.bold, + letterSpacing: 1, + color: surf.textSecondary)), + Text(value, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w800, + color: surf.textPrimary)), + if (note != null) + Text(note!, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w700, + color: noteColor)), + ], + ), + ); + } +} + /// Small pill on the dark bar: white when selected, outlined otherwise. class _BarPill extends StatelessWidget { final String label; diff --git a/lib/screens/calendar_screen.dart b/lib/screens/calendar_screen.dart index 2fcac65..0cda949 100644 --- a/lib/screens/calendar_screen.dart +++ b/lib/screens/calendar_screen.dart @@ -490,8 +490,9 @@ class _CalendarScreenState extends State { String _timeText(CalendarEvent event) { final startTime = event.startTime; - if (event.isAllDay || startTime == null || event.endTime == null) + if (event.isAllDay || startTime == null || event.endTime == null) { return _t('All day'); + } return '${DateFormat('HH:mm').format(startTime.toLocal())} – ${DateFormat('HH:mm').format(event.endTime!.toLocal())}'; } diff --git a/lib/screens/camera_screen.dart b/lib/screens/camera_screen.dart index 85a27ed..fc093ea 100644 --- a/lib/screens/camera_screen.dart +++ b/lib/screens/camera_screen.dart @@ -194,7 +194,7 @@ class _CameraScreenState extends State { ), ); } catch (e) { - print('Error taking picture: $e'); + debugPrint('Error taking picture: $e'); } } diff --git a/lib/screens/preview_screen.dart b/lib/screens/preview_screen.dart index d60dea1..d0ca3dd 100644 --- a/lib/screens/preview_screen.dart +++ b/lib/screens/preview_screen.dart @@ -12,89 +12,6 @@ import 'dart:math'; import 'package:shared_preferences/shared_preferences.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 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 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 { final String imagePath; final List detections; @@ -122,7 +39,6 @@ class _PreviewScreenState extends State { img.Image? _realImageDecoded; img.Image? _targetImageDecoded; Future? _targetImageFuture; - Offset? _targetImageCenterForScoring; Uint8List? _cachedTargetImage; Uint8List? _cachedRealImage; @@ -136,8 +52,6 @@ class _PreviewScreenState extends State { double _scaleFactorX = 1.0; double _scaleFactorY = 1.0; img.Image? _defaultTargetDecoded; // Default target for reference dimensions - Offset? - _scaledTargetCenterForScoring; // Scaled center for scoring with display target int? _highlightedBulletIndex; @@ -193,7 +107,7 @@ class _PreviewScreenState extends State { } } } catch (e) { - print("Error loading current folder info: $e"); + debugPrint("Error loading current folder info: $e"); } } @@ -258,19 +172,11 @@ class _PreviewScreenState extends State { if (_defaultTargetDecoded == null || _targetImageDecoded == null) { _scaleFactorX = 1.0; _scaleFactorY = 1.0; - _scaledTargetCenterForScoring = null; return; } _scaleFactorX = _targetImageDecoded!.width / _defaultTargetDecoded!.width; _scaleFactorY = _targetImageDecoded!.height / _defaultTargetDecoded!.height; - // Scale the center point for scoring - if (_targetImageCenterForScoring != null) { - _scaledTargetCenterForScoring = Offset( - _targetImageCenterForScoring!.dx * _scaleFactorX, - _targetImageCenterForScoring!.dy * _scaleFactorY, - ); - } debugPrint( "📏 Scale factors calculated: X=$_scaleFactorX, Y=$_scaleFactorY"); } @@ -366,15 +272,7 @@ class _PreviewScreenState extends State { Future _loadAndDecodeTargetImage() async { final byteData = await rootBundle.load(targetAssetPath); final bytes = byteData.buffer.asUint8List(); - final tempDir = await getTemporaryDirectory(); - 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; + return img.decodeImage(bytes); } Future _runDetectionAndMapping() async { @@ -468,109 +366,6 @@ class _PreviewScreenState extends State { } } - 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) { showDialog( context: context, @@ -761,7 +556,7 @@ class _PreviewScreenState extends State { await _performSave(lastFolder, false); } catch (e) { - print("Error saving to last folder: $e"); + debugPrint("Error saving to last folder: $e"); } } @@ -788,7 +583,7 @@ class _PreviewScreenState extends State { await _performSave(selectedFolder, isTournament); } catch (e) { - print("Error saving target data: $e"); + debugPrint("Error saving target data: $e"); } } @@ -839,15 +634,17 @@ class _PreviewScreenState extends State { await jsonFile.writeAsString(jsonEncode(targetData)); // Close preview and signal refresh + if (!mounted) return; Navigator.pop(context, true); } catch (e) { - print("Error performing save: $e"); + debugPrint("Error performing save: $e"); } } Widget _buildEditController() { - if (!_isEditMode || _selectedBulletIndexInEdit == null) + if (!_isEditMode || _selectedBulletIndexInEdit == null) { return const SizedBox.shrink(); + } return Positioned( bottom: 20, @@ -986,6 +783,7 @@ class _PreviewScreenState extends State { final String nextTraining = '$trainingWord $trainingCount'; final String nextTournament = '$tournamentWord $tournamentCount'; + if (!mounted) return null; return showDialog( context: context, builder: (context) { @@ -1164,8 +962,11 @@ class _PreviewScreenState extends State { int get _totalScore { // Score is based on the default target coordinate system (1200x1200) // 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 - .take(widget.bulletCount - _manualBulletScores.length) + .take(min(detected, widget.bulletCount - _manualBulletScores.length)) .map((b) { // Scale bullet back to default coordinate system for scoring final defaultTargetBullet = Offset( @@ -1358,24 +1159,7 @@ class _PreviewScreenState extends State { ), ), ); - }).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) ..._mappedBullets .asMap() @@ -1434,14 +1218,15 @@ class _PreviewScreenState extends State { ), ), ); - }).toList(), + }), ], ); }, ), ), 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( children: [ // Score buttons for detected and missing bullets diff --git a/lib/screens/spectator_screen.dart b/lib/screens/spectator_screen.dart index 8000bc5..66c7a25 100644 --- a/lib/screens/spectator_screen.dart +++ b/lib/screens/spectator_screen.dart @@ -17,7 +17,7 @@ class SpectatorScreen extends StatefulWidget { } class _SpectatorScreenState extends State { - List _selectedCameras = List.generate(6, (_) => true); // All selected by default + final List _selectedCameras = List.generate(6, (_) => true); // All selected by default List _enabledCameras = List.generate(6, (_) => false); // Which cameras have IPs configured List> _cameras = []; Color _bulletColor = Colors.blue; // default/fallback bullet color diff --git a/lib/screens/stream_screen.dart b/lib/screens/stream_screen.dart index 6e59409..c184802 100644 --- a/lib/screens/stream_screen.dart +++ b/lib/screens/stream_screen.dart @@ -1,15 +1,8 @@ import 'dart:async'; -import 'package:flutter/foundation.dart' show compute, Uint8List; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:screenshot/screenshot.dart'; -import 'dart:io'; import 'package:flutter/services.dart'; import 'package:flutter_mjpeg/flutter_mjpeg.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:image/image.dart' as img; -import 'yolo_detector.dart'; -import 'preview_screen.dart'; import 'package:wakelock_plus/wakelock_plus.dart'; import '../utils/translations.dart'; import '../services/app_settings.dart'; @@ -18,17 +11,6 @@ import '../widgets/help_sheet.dart'; import '../widgets/image_settings.dart'; import '../services/wifi_binding.dart'; -// Top-level: runs in background isolate via compute(). -// Crops the capture to a square; filters are already baked into the screenshot. -Uint8List _processStreamImage(Uint8List bytes) { - final decoded = img.decodeImage(bytes)!; - final w = decoded.width, h = decoded.height; - final size = w < h ? w : h; - final cropped = img.copyCrop(decoded, - x: (w - size) ~/ 2, y: (h - size) ~/ 2, width: size, height: size); - return Uint8List.fromList(img.encodeJpg(cropped)); -} - class CameraStreamScreen extends StatefulWidget { final int cameraIndex; // shooting position 1–6 final String? ip; // chosen camera; falls back to the saved IP of the position @@ -51,19 +33,12 @@ class _CameraStreamScreenState extends State with TickerProviderStateMixin { String? _streamUrl; bool _isError = false; - bool _isCapturing = false; - final ScreenshotController _screenshotController = ScreenshotController(); final TransformationController _transformationController = TransformationController(); ImageAdjustments _image = const ImageAdjustments(); - late YOLODetector _yoloDetector; int _numberOfBullets = 5; - late AnimationController _zoomAnimController; - Animation? _zoomAnimation; - Matrix4? _originalMatrix; - Color _bulletColor = Colors.blue; String _selectedLanguage = 'English'; @@ -177,18 +152,11 @@ class _CameraStreamScreenState extends State _wifiReady = WifiBinding.acquire(); _loadAllPrefs(); - YOLODetector.create().then((detector) => _yoloDetector = detector); - _setSystemBarStyle(); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); _keepScreenAwake(); - _zoomAnimController = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 200), - ); - _shootProgressController = AnimationController(vsync: this); _reloadProgressController = AnimationController(vsync: this); _waitProgressController = AnimationController(vsync: this); @@ -280,108 +248,6 @@ class _CameraStreamScreenState extends State }); } - Future _captureAndPreviewImage() async { - if (_streamUrl == null || _isCapturing) return; - - setState(() => _isCapturing = true); - _originalMatrix = _transformationController.value; - - try { - final targetMatrix = Matrix4.identity()..scale(1.0); - final isZoomedIn = !_matrixEquals(_originalMatrix!, targetMatrix); - - if (isZoomedIn) { - _zoomAnimController.reset(); - _zoomAnimation = Matrix4Tween( - begin: _originalMatrix, - end: targetMatrix, - ).animate(CurvedAnimation( - parent: _zoomAnimController, - curve: Curves.easeOut, - )); - - void updateZoom() { - _transformationController.value = _zoomAnimation!.value; - } - - _zoomAnimController.addListener(updateZoom); - await _zoomAnimController.forward(); - _zoomAnimController.removeListener(updateZoom); - } - - await Future.delayed(const Duration(milliseconds: 100)); - final imageBytes = await _screenshotController.capture(); - if (imageBytes == null || imageBytes.isEmpty) return; - - final dir = await getApplicationDocumentsDirectory(); - final path = '${dir.path}/ip_capture_temp.jpg'; - - final processedBytes = await compute(_processStreamImage, imageBytes); - final file = File(path)..writeAsBytesSync(processedBytes); - - // Detect objects in the image using YOLO - final detections = await _yoloDetector.detect(file); - - if (!mounted) return; - - // Navigate to the preview screen - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => PreviewScreen( - imagePath: file.path, - detections: detections, - bulletCount: _numberOfBullets, - ), - ), - ); - } catch (e) { - debugPrint("❌ Capture error: $e"); - if (mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text("Capture failed: $e")), - ); - } - } finally { - _zoomAnimController.reset(); - _zoomAnimation = Matrix4Tween( - begin: _transformationController.value, - end: _originalMatrix!, - ).animate(CurvedAnimation( - parent: _zoomAnimController, - curve: Curves.easeIn, - )); - - void restoreZoom() { - _transformationController.value = _zoomAnimation!.value; - } - - _zoomAnimController.addListener(restoreZoom); - await _zoomAnimController.forward(); - _zoomAnimController.removeListener(restoreZoom); - - setState(() => _isCapturing = false); - } - } - - img.Image invertImage(img.Image source) { - final result = img.Image.from(source); - for (int y = 0; y < result.height; y++) { - for (int x = 0; x < result.width; x++) { - final pixel = result.getPixel(x, y); - result.setPixelRgb(x, y, 255 - pixel.r, 255 - pixel.g, 255 - pixel.b); - } - } - return result; - } - - bool _matrixEquals(Matrix4 a, Matrix4 b) { - for (int i = 0; i < 16; i++) { - if ((a.storage[i] - b.storage[i]).abs() > 0.001) return false; - } - return true; - } - void _showImageSettingsDialog() { showImageSettingsSheet( context, @@ -462,8 +328,6 @@ class _CameraStreamScreenState extends State _reloadProgressController.dispose(); _waitProgressController.dispose(); _flashController.dispose(); - _zoomAnimController.dispose(); - _yoloDetector.close(); WifiBinding.release(); _restoreScreenSettings(); _setSystemBarStyle(); @@ -873,8 +737,9 @@ class _CameraStreamScreenState extends State // Manual counter dots — shown at top when timer not running Widget _buildManualDotsOverlay() { - if (!_showManualCounter || _numberOfBullets <= 1) + if (!_showManualCounter || _numberOfBullets <= 1) { return const SizedBox.shrink(); + } return Positioned( top: 8, left: 0, @@ -1291,75 +1156,55 @@ class _CameraStreamScreenState extends State backgroundColor: Colors.black, body: Stack( children: [ - Screenshot( - controller: _screenshotController, - child: LayoutBuilder( - builder: (context, constraints) { - return Center( - child: (_isError || _streamUrl == null) - ? _buildErrorContent() - : InteractiveViewer( - clipBehavior: Clip.hardEdge, - constrained: false, - boundaryMargin: EdgeInsets.zero, - minScale: 1.0, - maxScale: 5.0, - transformationController: _transformationController, - child: SizedBox( - width: constraints.maxWidth, - height: constraints.maxHeight, - child: RepaintBoundary( - child: ColorFiltered( - colorFilter: _image.colorFilter, - child: RotatedBox( - quarterTurns: _image.quarterTurns, - child: Mjpeg( - key: ValueKey(_streamUrl), - stream: _streamUrl!, - isLive: true, - fit: BoxFit.contain, - error: (context, error, stackTrace) { - // Mark as error so we can display error placeholder outside filters - WidgetsBinding.instance - .addPostFrameCallback((_) { - if (mounted) { - setState(() { - _isError = true; - }); - } - }); - return SizedBox.expand( - child: Container(color: Colors.black), - ); - }, - ), + LayoutBuilder( + builder: (context, constraints) { + return Center( + child: (_isError || _streamUrl == null) + ? _buildErrorContent() + : InteractiveViewer( + clipBehavior: Clip.hardEdge, + constrained: false, + boundaryMargin: EdgeInsets.zero, + minScale: 1.0, + maxScale: 5.0, + transformationController: _transformationController, + child: SizedBox( + width: constraints.maxWidth, + height: constraints.maxHeight, + child: RepaintBoundary( + child: ColorFiltered( + colorFilter: _image.colorFilter, + child: RotatedBox( + quarterTurns: _image.quarterTurns, + child: Mjpeg( + key: ValueKey(_streamUrl), + stream: _streamUrl!, + isLive: true, + fit: BoxFit.contain, + error: (context, error, stackTrace) { + // Mark as error so we can display error placeholder outside filters + WidgetsBinding.instance + .addPostFrameCallback((_) { + if (mounted) { + setState(() { + _isError = true; + }); + } + }); + return SizedBox.expand( + child: Container(color: Colors.black), + ); + }, ), ), ), ), ), - ); - }, - ), + ), + ); + }, ), - if (_isCapturing) - Positioned.fill( - child: Container( - color: Colors.black.withValues(alpha: 0.4), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const CircularProgressIndicator(color: Colors.white), - const SizedBox(height: 16), - Text( - _t("Processing image..."), - style: const TextStyle(color: Colors.white, fontSize: 16), - ), - ], - ), - ), - ), _buildManualDotsOverlay(), _buildCountdownOverlay(), // Phase-change flash overlay @@ -1476,8 +1321,9 @@ class _CameraStreamScreenState extends State onTap: () async { setState(() { _manualCounterEnabled = !_manualCounterEnabled; - if (_manualCounterEnabled) + if (_manualCounterEnabled) { _manualShotsLeft = _numberOfBullets; + } }); final prefs = await SharedPreferences.getInstance(); await prefs.setBool( diff --git a/lib/screens/target_view.dart b/lib/screens/target_view.dart index 83f20b3..dbc0d53 100644 --- a/lib/screens/target_view.dart +++ b/lib/screens/target_view.dart @@ -26,7 +26,7 @@ class TargetViewScreen extends StatefulWidget { } class _TargetViewScreenState extends State { - int _currentIndex = 0; + final int _currentIndex = 0; List _bullets = []; List _scaledBullets = []; // Bullets scaled to display target size int _totalScore = 0; @@ -144,7 +144,7 @@ class _TargetViewScreenState extends State { img.Image? defaultTargetDecoded = img.decodeImage(defaultBytes); if (defaultTargetDecoded == null) { - print("Failed to decode default target image."); + debugPrint("Failed to decode default target image."); return; } @@ -160,7 +160,7 @@ class _TargetViewScreenState extends State { _targetImageDecoded = img.decodeImage(displayBytes); if (_targetImageDecoded == null) { - print("Failed to decode display target image."); + debugPrint("Failed to decode display target image."); return; } @@ -275,7 +275,7 @@ class _TargetViewScreenState extends State { setState(() {}); } catch (e) { - print("Error loading JSON or image: $e"); + debugPrint("Error loading JSON or image: $e"); } } @@ -293,13 +293,15 @@ class _TargetViewScreenState extends State { try { final file = File(_targetFilePath); await file.delete(); + widget.refreshFolders(); + if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Target deleted')), ); - widget.refreshFolders(); Navigator.pop(context); } catch (e) { - print("Error deleting target: $e"); + debugPrint("Error deleting target: $e"); + if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Failed to delete target')), ); @@ -311,18 +313,38 @@ class _TargetViewScreenState extends State { return Scaffold( backgroundColor: _backgroundColor, 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, children: [ - const Icon(Icons.calendar_today, size: 20, color: Colors.white), - const SizedBox(width: 8), - Text(_date, style: const TextStyle(color: Colors.white)), + Text( + _t('Total score').replaceAll(':', '').toUpperCase(), + 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], centerTitle: true, iconTheme: const IconThemeData(color: Colors.white), 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( icon: const Icon(Icons.delete), color: Colors.red, @@ -487,7 +509,7 @@ class _TargetViewScreenState extends State { ), ), ); - }).toList(), + }), ], ); }, @@ -517,33 +539,20 @@ class _TargetViewScreenState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - // Total score + // Date Row( children: [ - const Icon(Icons.track_changes, + const Icon(Icons.calendar_today, size: 20, color: Colors.white), const SizedBox(width: 12), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - _t('Total score'), - style: const TextStyle( - fontSize: 11, - color: Colors.white54, - fontWeight: FontWeight.w500, - ), - ), - Text( - "$_totalScore", - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - ), - ], + Text( + // Saved targets store dd/MM/yyyy; show it the Slovenian way + _date.replaceAll('/', '.'), + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Colors.white, + ), ), ], ), diff --git a/lib/screens/yolo_detector.dart b/lib/screens/yolo_detector.dart index 2427ace..955b050 100644 --- a/lib/screens/yolo_detector.dart +++ b/lib/screens/yolo_detector.dart @@ -43,9 +43,6 @@ class YOLODetector { final inputShape = inputTensor.shape; inputHeight = inputShape[1]; inputWidth = inputShape[2]; - - print("📐 Model input shape: $inputShape"); - print("📦 Model input type: ${inputTensor.type}"); } Future> detect(File imageFile) async { @@ -66,8 +63,6 @@ class YOLODetector { final numDetections = outputShape[1]; final outputBuffer = List.generate(1, (_) => List.generate(numDetections, (_) => List.filled(6, 0.0))); - - print("🚀 Running inference..."); _interpreter.run(inputBuffer, outputBuffer); final rawDetections = outputBuffer[0]; @@ -102,8 +97,6 @@ class YOLODetector { classId, )); } - - print("🎯 Detections found: ${results.length}"); return results; } diff --git a/lib/services/target_repository.dart b/lib/services/target_repository.dart index 5c401fb..337746b 100644 --- a/lib/services/target_repository.dart +++ b/lib/services/target_repository.dart @@ -105,9 +105,9 @@ class ShooterStats { } } -/// Reads and edits the saved targets under /saved_images//. +/// Reads and edits the saved targets under `/saved_images//`. /// -/// Score and shots of every target are cached in /target_index.json, +/// Score and shots of every target are cached in `/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. diff --git a/lib/utils/translations.dart b/lib/utils/translations.dart index 6c6e60e..0c56d3c 100644 --- a/lib/utils/translations.dart +++ b/lib/utils/translations.dart @@ -23,26 +23,12 @@ class AppTranslations { 'English': 'Appearance', 'Slovenian': 'Videz', }, - 'Appearance Settings': { - 'English': 'Appearance Settings', - 'Slovenian': 'Nastavitve videza', - }, 'Bullet': { 'English': 'Bullet', 'Slovenian': 'Zadetek', }, - // Bullet color - 'Select Bullet Color': { - 'English': 'Select Bullet Color', - 'Slovenian': 'Izberi barvo zadetka', - }, - // Target selection - 'Select Target': { - 'English': 'Select Target', - 'Slovenian': 'Izberi tarčo', - }, 'Default Target': { 'English': 'Default Target', 'Slovenian': 'Privzeta tarča', @@ -193,10 +179,6 @@ class AppTranslations { 'English': 'Camera', 'Slovenian': 'Kamera', }, - 'Enter Camera IP': { - 'English': 'Enter Camera IP', - 'Slovenian': 'Vnesi IP kamere', - }, 'Save': { 'English': 'Save', 'Slovenian': 'Shrani', @@ -309,10 +291,6 @@ class AppTranslations { 'English': 'in {n} days', 'Slovenian': 'čez {n} dni', }, - 'NOW': { - 'English': 'NOW', - 'Slovenian': 'ZDAJ', - }, 'Untitled Event': { 'English': 'Untitled Event', 'Slovenian': 'Brez naslova', @@ -321,36 +299,16 @@ class AppTranslations { 'English': 'All day', 'Slovenian': 'Cel dan', }, - 'Event Card Styles Preview': { - 'English': 'Event Card Styles Preview', - 'Slovenian': 'Predogled stilov dogodkov', - }, - 'Example Event Preview': { - 'English': 'Example Event Preview', - 'Slovenian': 'Primer dogodka', - }, - 'DEŽURSTVO': { - 'English': 'DUTY', - 'Slovenian': 'DEŽURSTVO', - }, 'DUTY': { 'English': 'DUTY', 'Slovenian': 'DEŽURSTVO', }, // Preview Screen - 'Enter Missing Bullet Scores': { - 'English': 'Enter Missing Bullet Scores', - 'Slovenian': 'Vnesi manjkajoče ocene zadetkov', - }, 'Bullet Score': { 'English': 'Bullet Score', 'Slovenian': 'Ocena zadetka', }, - 'Add Bullets': { - 'English': 'Add Bullets', - 'Slovenian': 'Dodaj zadetke', - }, 'Save Target Data': { 'English': 'Save Target Data', 'Slovenian': 'Shrani podatke tarče', @@ -385,30 +343,6 @@ class AppTranslations { 'English': 'Folder Settings', 'Slovenian': 'Nastavitve mape', }, - 'Enter new folder name': { - 'English': 'Enter new folder name', - 'Slovenian': 'Vnesi novo ime mape', - }, - 'Tournament Mode 🏆': { - 'English': 'Tournament Mode 🏆', - 'Slovenian': 'Tekmovalni način 🏆', - }, - 'Tournament Mode': { - 'English': 'Tournament Mode', - 'Slovenian': 'Tekmovalni način', - }, - 'Mark as Tournament 🏆': { - 'English': 'Mark as Tournament 🏆', - 'Slovenian': 'Označi kot tekmovanje 🏆', - }, - 'Mark as Tournament': { - 'English': 'Mark as Tournament', - 'Slovenian': 'Označi kot tekmovanje', - }, - 'Apply': { - 'English': 'Apply', - 'Slovenian': 'Uporabi', - }, 'Confirm Deletion': { 'English': 'Confirm Deletion', 'Slovenian': 'Potrdi brisanje', @@ -429,30 +363,10 @@ class AppTranslations { 'English': 'Close', 'Slovenian': 'Zapri', }, - 'Showing: 📂 All folders': { - 'English': 'Showing: 📂 All folders', - 'Slovenian': 'Prikaz: 📂 Vse mape', - }, - 'Showing: 🏆 Tournament folders': { - 'English': 'Showing: 🏆 Tournament folders', - 'Slovenian': 'Prikaz: 🏆 Tekmovalne mape', - }, - 'Showing: 🎯 Training folders': { - 'English': 'Showing: 🎯 Training folders', - 'Slovenian': 'Prikaz: 🎯 Treningske mape', - }, 'No saved target data found': { 'English': 'No saved target data found', 'Slovenian': 'Ni shranjenih podatkov tarče', }, - 'Filter Folders': { - 'English': 'Filter Folders', - 'Slovenian': 'Filtriraj mape', - }, - '📂 All folders': { - 'English': '📂 All folders', - 'Slovenian': '📂 Vse mape', - }, '🏆 Tournament': { 'English': '🏆 Tournament', 'Slovenian': '🏆 Tekmovanje', @@ -461,18 +375,6 @@ class AppTranslations { 'English': '🎯 Training', 'Slovenian': '🎯 Trening', }, - 'Sort By': { - 'English': 'Sort By', - 'Slovenian': 'Razvrsti po', - }, - '📅 Sort by Date': { - 'English': '📅 Sort by Date', - 'Slovenian': '📅 Razvrsti po datumu', - }, - '🏆 Sort by Score': { - 'English': '🏆 Sort by Score', - 'Slovenian': '🏆 Razvrsti po oceni', - }, // Navigation Menu 'Book': { @@ -511,16 +413,8 @@ class AppTranslations { 'English': 'Total score', 'Slovenian': 'Rezultat:', }, - 'Total score:': { - 'English': 'Total score:', - 'Slovenian': 'Skupni seštevek:', - }, // Stream Screen (Camera View) - 'Choose a Filter': { - 'English': 'Choose a Filter', - 'Slovenian': 'Izberi filter', - }, 'None': { 'English': 'None', 'Slovenian': 'Brez', @@ -533,102 +427,16 @@ class AppTranslations { 'English': 'Invert', 'Slovenian': 'Inverz', }, - 'Processing image...': { - 'English': 'Processing image...', - 'Slovenian': 'Obdelava slike...', - }, 'Unable to load camera stream': { 'English': 'Unable to load camera stream', 'Slovenian': 'Ni mogoče naložiti kamere', }, - // Mode Selection - 'Select Detection Mode': { - 'English': 'Select Detection Mode', - 'Slovenian': 'Izberi način zaznavanja', - }, - 'Capture & Shoot': { - 'English': 'Capture & Shoot', - 'Slovenian': 'Zajemi in streljaj', - }, - 'Take single photo and detect bullets': { - 'English': 'Take single photo and detect bullets', - 'Slovenian': 'Zajemi fotografijo in zazna zadetke', - }, - 'Live Detection': { - 'English': 'Live Detection', - 'Slovenian': 'Živa zaznava', - }, - 'Continuous monitoring with real-time scoring': { - 'English': 'Continuous monitoring with real-time scoring', - 'Slovenian': 'Neprekinjeno spremljanje z ocenjevanjem v živo', - }, - // Live Detection Screen - 'Capture Baseline': { - 'English': 'Capture Baseline', - 'Slovenian': 'Zajemi osnovno sliko', - }, - 'Position target and capture empty baseline': { - 'English': 'Position target and capture empty baseline', - 'Slovenian': 'Postavi tarčo in zajemi prazno osnovno sliko', - }, - 'Start Detection': { - 'English': 'Start Detection', - 'Slovenian': 'Začni zaznavanje', - }, - 'Stop Detection': { - 'English': 'Stop Detection', - 'Slovenian': 'Ustavi zaznavanje', - }, - 'Bullets Detected': { - 'English': 'Bullets Detected', - 'Slovenian': 'Zaznani zadetki', - }, - 'Current Score': { - 'English': 'Current Score', - 'Slovenian': 'Trenutna ocena', - }, - 'Monitoring...': { - 'English': 'Monitoring...', - 'Slovenian': 'Spremljanje...', - }, - 'Save & Exit': { - 'English': 'Save & Exit', - 'Slovenian': 'Shrani in zapri', - }, - 'Capturing baseline...': { - 'English': 'Capturing baseline...', - 'Slovenian': 'Zajemanje osnove...', - }, - 'Baseline captured!': { - 'English': 'Baseline captured!', - 'Slovenian': 'Osnova zajeta!', - }, - 'Analyzing frame...': { - 'English': 'Analyzing frame...', - 'Slovenian': 'Analiza slike...', - }, - 'New bullet detected!': { - 'English': 'New bullet detected!', - 'Slovenian': 'Nov zadetek zaznan!', - }, - 'Calculate Score': { - 'English': 'Calculate Score', - 'Slovenian': 'Izračunaj rezultat', - }, - 'Target reached': { - 'English': 'Target reached', - 'Slovenian': 'Cilj dosežen', - }, 'bullets': { 'English': 'bullets', 'Slovenian': 'zadetkov', }, - 'Click Calculate Score to continue': { - 'English': 'Click Calculate Score to continue', - 'Slovenian': 'Kliknite Izračunaj rezultat za nadaljevanje', - }, // Delete confirmations 'Are you sure you want to delete this file?': { @@ -703,10 +511,6 @@ class AppTranslations { }, // Brightness & Contrast dialog translations - 'Brightness & Contrast': { - 'English': 'Brightness & Contrast', - 'Slovenian': 'Svetlost in kontrast', - }, 'Brightness': { 'English': 'Brightness', 'Slovenian': 'Svetlost', @@ -733,42 +537,14 @@ class AppTranslations { 'English': 'Could not launch phone call: ', 'Slovenian': 'Ne morem zagnati klica: ', }, - 'League / Competition': { - 'English': 'League / Competition', - 'Slovenian': 'Liga / Tekmovanje', - }, - 'Team Meeting': { - 'English': 'Team Meeting', - 'Slovenian': 'Sestanek ekipe', - }, - 'Duty Shift': { - 'English': 'Duty Shift', - 'Slovenian': 'Dežurstvo', - }, - 'TEKMOVANJE': { - 'English': 'COMPETITION', - 'Slovenian': 'TEKMOVANJE', - }, 'COMPETITION': { 'English': 'COMPETITION', 'Slovenian': 'TEKMOVANJE', }, - 'SESTANEK': { - 'English': 'MEETING', - 'Slovenian': 'SESTANEK', - }, 'MEETING': { 'English': 'MEETING', 'Slovenian': 'SESTANEK', }, - 'Strelišče Ljubljana': { - 'English': 'Shooting Range', - 'Slovenian': 'Strelišče Ljubljana', - }, - 'Shooting Range': { - 'English': 'Shooting Range', - 'Slovenian': 'Strelišče Ljubljana', - }, 'Phone': { 'English': 'Phone', 'Slovenian': 'Telefon', @@ -781,38 +557,6 @@ class AppTranslations { 'English': 'copied to clipboard', 'Slovenian': 'kopirano v odložišče', }, - 'Select Cameras to Spectate': { - 'English': 'Select Cameras to Spectate', - 'Slovenian': 'Izberi kamere za ogled', - }, - 'Choose 1-6 cameras': { - 'English': 'Choose 1-6 cameras', - 'Slovenian': 'Izberi 1-6 kamer', - }, - 'No cameras configured': { - 'English': 'No cameras configured', - 'Slovenian': 'Ni nastavljenih kamer', - }, - 'View Cameras': { - 'English': 'View Cameras', - 'Slovenian': 'Prikaži kamere', - }, - 'Multi-Camera View': { - 'English': 'Multi-Camera View', - 'Slovenian': 'Več-kamerski pogled', - }, - 'Tap to return to grid': { - 'English': 'Tap to return to grid', - 'Slovenian': 'Tapni za vrnitev na mrežo', - }, - 'Stream unavailable': { - 'English': 'Stream unavailable', - 'Slovenian': 'Pretok ni na voljo', - }, - 'Select at least one camera': { - 'English': 'Select at least one camera', - 'Slovenian': 'Izberi vsaj eno kamero', - }, 'Spectate': { 'English': 'Spectate', 'Slovenian': 'Opazuj', @@ -821,10 +565,6 @@ class AppTranslations { 'English': 'Select Cameras', 'Slovenian': 'Izberi kamere', }, - 'Spectator Mode': { - 'English': 'Spectator Mode', - 'Slovenian': 'Način opazovanja', - }, 'Please ensure:': { 'English': 'Please ensure:', 'Slovenian': 'Prepričaj se:', @@ -843,62 +583,10 @@ class AppTranslations { }, // Analytics - 'Analytics': { - 'English': 'Analytics', - 'Slovenian': 'Analitika', - }, - 'Compare Sessions': { - 'English': 'Compare Sessions', - 'Slovenian': 'Primerjaj treninge', - }, - 'Select 2-4 sessions': { - 'English': 'Select 2-4 sessions to compare', - 'Slovenian': 'Izberi 2-4 treninge za primerjavo', - }, - 'Select at least 2 sessions': { - 'English': 'Select at least 2 sessions', - 'Slovenian': 'Izberi vsaj 2 treninga', - }, - 'Max 4 sessions': { - 'English': 'Maximum 4 sessions can be compared', - 'Slovenian': 'Primerjati je mogoče največ 4 treninge', - }, - 'No sessions available': { - 'English': 'No sessions available', - 'Slovenian': 'Ni razpoložljivih treningov', - }, - 'No data for target': { - 'English': 'No data for this target', - 'Slovenian': 'Ni podatkov za to tarčo', - }, - 'Training View': { - 'English': 'Training View', - 'Slovenian': 'Pogled treninga', - }, - 'Training Comparison': { - 'English': 'Training Comparison', - 'Slovenian': 'Primerjava treningov', - }, - 'Tournament Comparison': { - 'English': 'Tournament Comparison', - 'Slovenian': 'Primerjava tekmovanj', - }, - 'Compare with': { - 'English': 'Compare with', - 'Slovenian': 'Primerjaj s', - }, - 'No folder selected': { - 'English': 'No folder selected', - 'Slovenian': 'Ni izbrane mape', - }, 'Select': { 'English': 'Select', 'Slovenian': 'Izberi', }, - 'Clear': { - 'English': 'Clear', - 'Slovenian': 'Počisti', - }, 'Score': { 'English': 'Score', 'Slovenian': 'Rezultat', @@ -921,22 +609,10 @@ class AppTranslations { 'English': 'Shooting Timer', 'Slovenian': 'Časovnik streljanja', }, - 'What do you want to time?': { - 'English': 'What do you want to time?', - 'Slovenian': 'Kaj želiš časovno meriti?', - }, 'Shoot only': { 'English': 'Shoot only', 'Slovenian': 'Samo strel', }, - 'Wait only': { - 'English': 'Wait only', - 'Slovenian': 'Samo čakanje', - }, - 'Both': { - 'English': 'Both', - 'Slovenian': 'Oboje', - }, 'Shoot time': { 'English': 'Shoot time', 'Slovenian': 'Čas strela', @@ -965,14 +641,6 @@ class AppTranslations { 'English': 'Change target sign', 'Slovenian': 'Znak zamenjave tarče', }, - 'Bullet counter': { - 'English': 'Bullet counter', - 'Slovenian': 'Števec strelov', - }, - 'Disable': { - 'English': 'Disable', - 'Slovenian': 'Onemogoči', - }, 'left': { 'English': 'left', 'Slovenian': 'ostalo', @@ -987,14 +655,6 @@ class AppTranslations { 'English': 'Event Reminders', 'Slovenian': 'Opomniki za dogodke', }, - 'Notify before event': { - 'English': 'Notify before event', - 'Slovenian': 'Obvesti pred dogodkom', - }, - 'Hours before': { - 'English': 'Hours before', - 'Slovenian': 'Ur pred dogodkom', - }, 'hour': { 'English': 'hour', 'Slovenian': 'ura', @@ -1003,18 +663,6 @@ class AppTranslations { 'English': 'hours', 'Slovenian': 'ur', }, - 'Notifications enabled': { - 'English': 'Notifications enabled', - 'Slovenian': 'Obvestila vključena', - }, - 'Notifications disabled': { - 'English': 'Notifications disabled', - 'Slovenian': 'Obvestila izključena', - }, - 'Event types': { - 'English': 'Event types', - 'Slovenian': 'Vrste dogodkov', - }, 'Dežuranje': { 'English': 'Duty shifts', 'Slovenian': 'Dežuranje', @@ -1048,10 +696,6 @@ class AppTranslations { 'English': '{n} cameras', 'Slovenian': '{n} kamer', }, - 'Quick setup': { - 'English': 'Quick setup', - 'Slovenian': 'Hitra nastavitev', - }, 'Set all cameras from one IP': { 'English': 'Set all cameras from one IP', 'Slovenian': 'Nastavi vse kamere z enim IP', @@ -1121,10 +765,6 @@ class AppTranslations { 'English': 'Statistics', 'Slovenian': 'Statistika', }, - 'Best target': { - 'English': 'Best target', - 'Slovenian': 'Najboljša tarča', - }, 'Average target': { 'English': 'Average target', 'Slovenian': 'Povprečna tarča', @@ -1169,14 +809,6 @@ class AppTranslations { 'English': 'History', 'Slovenian': 'Zgodovina', }, - 'Average per shot by session': { - 'English': 'Average per shot by session', - 'Slovenian': 'Povprečje na strel po treningih', - }, - 'Shoot at least two sessions to see your progress': { - 'English': 'Shoot at least two sessions to see your progress', - 'Slovenian': 'Za prikaz napredka potrebuješ vsaj dva treninga', - }, 'Edit': { 'English': 'Edit', 'Slovenian': 'Uredi', @@ -1189,10 +821,6 @@ class AppTranslations { 'English': 'A folder with this name already exists', 'Slovenian': 'Mapa s tem imenom že obstaja', }, - 'last training': { - 'English': 'vs. last training', - 'Slovenian': 'zadnji trening', - }, 'Details': { 'English': 'Details', 'Slovenian': 'Podrobnosti', @@ -1374,6 +1002,14 @@ class AppTranslations { 'English': 'Member access is currently available only for SDK Kovinar Muta. Support for other clubs may be added in the future.', 'Slovenian': 'Članski dostop je trenutno na voljo samo za SDK Kovinar Muta. V prihodnje bo morda podprt tudi za druge klube.', }, + 'Average': { + 'English': 'Average', + 'Slovenian': 'Povprečje', + }, + 'Sum': { + 'English': 'Sum', + 'Slovenian': 'Skupek', + }, }; static String translate(String key, String language) { diff --git a/lib/widgets/camera_sheet.dart b/lib/widgets/camera_sheet.dart index 34cf27c..2391e4f 100644 --- a/lib/widgets/camera_sheet.dart +++ b/lib/widgets/camera_sheet.dart @@ -84,7 +84,7 @@ class SheetSlider extends StatelessWidget { final Color accent; final ValueChanged onChanged; - const SheetSlider({ + const SheetSlider({super.key, required this.icon, required this.label, required this.valueText, @@ -140,7 +140,7 @@ class SheetToggle extends StatelessWidget { final Color accent; final VoidCallback onTap; - const SheetToggle({ + const SheetToggle({super.key, required this.icon, required this.label, required this.active, diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 7299b5c..f6f23bf 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,13 +6,9 @@ #include "generated_plugin_registrant.h" -#include #include 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 = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 9cde083..bec505f 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - file_selector_linux url_launcher_linux ) diff --git a/pubspec.lock b/pubspec.lock index 004e102..8368861 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -106,7 +106,7 @@ packages: source: hosted version: "1.1.2" collection: - dependency: "direct main" + dependency: transitive description: name: collection sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" @@ -137,14 +137,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.9.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 - url: "https://pub.dev" - source: hosted - version: "1.0.8" dbus: dependency: transitive description: @@ -177,51 +169,11 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct main" description: flutter source: sdk 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: dependency: transitive description: @@ -231,7 +183,7 @@ packages: source: hosted version: "0.21.2" flutter_launcher_icons: - dependency: "direct main" + dependency: "direct dev" description: name: flutter_launcher_icons sha256: bfa04787c85d80ecb3f8777bde5fc10c3de809240c48fa061a2c2bf15ea5211c @@ -286,14 +238,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct dev" description: flutter @@ -313,7 +257,7 @@ packages: source: sdk version: "0.0.0" http: - dependency: "direct overridden" + dependency: "direct main" description: name: http sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" @@ -336,70 +280,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct main" description: @@ -452,10 +332,10 @@ packages: dependency: transitive description: name: matcher - sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" url: "https://pub.dev" source: hosted - version: "0.12.19" + version: "0.12.20" material_color_utilities: dependency: transitive description: @@ -468,18 +348,10 @@ packages: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9" url: "https://pub.dev" source: hosted - version: "1.17.0" - mime: - dependency: transitive - description: - name: mime - sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" - url: "https://pub.dev" - source: hosted - version: "2.0.0" + version: "1.19.0" package_info_plus: dependency: "direct main" description: @@ -504,14 +376,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct main" description: @@ -568,14 +432,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: @@ -608,14 +464,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct main" description: @@ -672,14 +520,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: flutter @@ -725,14 +565,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: @@ -745,10 +577,10 @@ packages: dependency: transitive description: name: test_api - sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" + sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11" url: "https://pub.dev" source: hosted - version: "0.7.10" + version: "0.7.12" tflite_flutter: dependency: "direct main" description: @@ -837,38 +669,14 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: name: vector_math - sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + sha256: fa49e1674cb84acb900141714e6c6e1f9ae099827c24d141430ff6819db4e1bc url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.4.4" visibility_detector: dependency: transitive description: @@ -909,38 +717,6 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: @@ -974,5 +750,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.9.0-0 <4.0.0" + dart: ">=3.11.0-0 <4.0.0" flutter: ">=3.29.0" diff --git a/pubspec.yaml b/pubspec.yaml index d1832b7..ca6d7e3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: test1 description: A new Flutter project. publish_to: 'none' # This prevents publishing to pub.dev -version: 1.2.0+5 +version: 1.3.0+6 environment: sdk: '>=3.3.0 <4.0.0' @@ -10,26 +10,14 @@ environment: dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.8 shared_preferences: ^2.2.2 - photo_view: ^0.15.0 - screenshot: ^3.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 - 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 image: ^4.5.4 camera: ^0.10.0 path_provider: ^2.0.15 - image_picker: ^1.0.4 wakelock_plus: ^1.2.11 url_launcher: ^6.1.0 flutter_local_notifications: ^18.0.1 @@ -37,15 +25,13 @@ dependencies: flutter_timezone: ^3.0.0 package_info_plus: ^8.3.0 cryptography: ^2.9.0 - -dependency_overrides: http: ^0.13.6 - dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^5.0.0 + flutter_launcher_icons: ^0.14.3 flutter_icons: android: true @@ -57,10 +43,6 @@ flutter: uses-material-design: true assets: - assets/club.enc - - assets/logo.png - - assets/logo.svg - assets/target.png - - assets/target.svg - - assets/google_logo.png - assets/best_float32_nms.tflite - assets/targets/