google preperation 1
This commit is contained in:
+96
-241
@@ -1,6 +1,8 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../utils/target_colors.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import 'package:flutter/services.dart' show rootBundle;
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
@@ -273,121 +275,9 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
"📏 Scale factors calculated: X=$_scaleFactorX, Y=$_scaleFactorY");
|
||||
}
|
||||
|
||||
Color _getBackgroundColorForTarget(String targetPath) {
|
||||
// Map each target to its background color (extracted from first pixel of each image)
|
||||
switch (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
|
||||
}
|
||||
}
|
||||
// One source of truth for target colors (utils/target_colors.dart)
|
||||
Color _getBackgroundColorForTarget(String targetPath) =>
|
||||
TargetColors.getBackgroundColor(targetPath);
|
||||
|
||||
Future<void> _loadBulletColor() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@@ -940,6 +830,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
final targetData = {
|
||||
'date': dateString,
|
||||
'totalScore': _totalScore,
|
||||
'bulletCount': widget.bulletCount, // shots fired; missed ones are absent from 'bullets'
|
||||
'bullets': bulletsInDefaultCoordinates,
|
||||
};
|
||||
|
||||
@@ -1349,7 +1240,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
children: [
|
||||
// Training/Tournament Banner
|
||||
Container(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
@@ -1359,9 +1250,9 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
child: Text(
|
||||
_currentFolderName.isNotEmpty
|
||||
? _currentFolderName
|
||||
: 'No training selected',
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
: _t('No training selected'),
|
||||
style: TextStyle(
|
||||
color: Surfaces.current.textPrimary,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
@@ -1371,8 +1262,8 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
if (_currentDate.isNotEmpty)
|
||||
Text(
|
||||
_currentDate,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
style: TextStyle(
|
||||
color: Surfaces.current.textPrimary,
|
||||
fontSize: 11,
|
||||
),
|
||||
),
|
||||
@@ -1636,7 +1527,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius:
|
||||
const BorderRadius
|
||||
.only(
|
||||
@@ -1649,11 +1540,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Surfaces.current.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1728,7 +1619,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: Surfaces.current.card,
|
||||
borderRadius:
|
||||
const BorderRadius
|
||||
.only(
|
||||
@@ -1741,11 +1632,11 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'$bulletNum',
|
||||
style: const TextStyle(
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Surfaces.current.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1791,129 +1682,93 @@ 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(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Top bar - Total Score
|
||||
Container(
|
||||
color: Colors.grey[300],
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
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,
|
||||
// Same layout as the camera screen: number on the left, round white
|
||||
// main action docked in the notch, secondary icons on the right.
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
backgroundColor: Colors.white,
|
||||
onPressed: _saveToLastFolder,
|
||||
tooltip: _t("Save"),
|
||||
child: const Icon(Icons.save, color: Colors.black),
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
color: Colors.grey[900],
|
||||
shape: const CircularNotchedRectangle(),
|
||||
notchMargin: 8.0,
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: Row(
|
||||
children: [
|
||||
// Left - total score
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
_t('Total').toUpperCase(),
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1.2,
|
||||
color: Colors.white54,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'$_totalScore',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
height: 1.1,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
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],
|
||||
padding: EdgeInsets.zero,
|
||||
child: SizedBox(
|
||||
height: 60,
|
||||
child: Row(
|
||||
children: [
|
||||
// Plus button (left, no background)
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
icon: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
const Icon(Icons.folder, color: Colors.white, size: 24),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: const Icon(Icons.add, color: Colors.grey, size: 10),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: _saveTargetDataWithDialog,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 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(
|
||||
_isEditMode ? Icons.check : Icons.edit,
|
||||
color: _isEditMode ? Colors.red : Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isEditMode = !_isEditMode;
|
||||
_selectedBulletIndexInEdit = null;
|
||||
});
|
||||
},
|
||||
tooltip: _isEditMode ? _t("Done Editing") : _t("Edit Mode"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// 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,
|
||||
tooltip: _t("Save to folder"),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_isEditMode ? Icons.check : Icons.edit,
|
||||
color: _isEditMode ? Colors.red : Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isEditMode = !_isEditMode;
|
||||
_selectedBulletIndexInEdit = null;
|
||||
});
|
||||
},
|
||||
tooltip: _isEditMode ? _t("Done Editing") : _t("Edit Mode"),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user