fixes for detection with new target styles
|
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 221 KiB |
|
Before Width: | Height: | Size: 221 KiB |
|
After Width: | Height: | Size: 392 KiB |
|
After Width: | Height: | Size: 357 KiB |
|
After Width: | Height: | Size: 317 KiB |
|
After Width: | Height: | Size: 368 KiB |
|
After Width: | Height: | Size: 403 KiB |
|
After Width: | Height: | Size: 308 KiB |
|
After Width: | Height: | Size: 422 KiB |
|
After Width: | Height: | Size: 484 KiB |
|
After Width: | Height: | Size: 452 KiB |
|
After Width: | Height: | Size: 272 KiB |
|
Before Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 143 KiB |
|
Before Width: | Height: | Size: 132 KiB |
|
Before Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 142 KiB |
|
Before Width: | Height: | Size: 179 KiB |
|
Before Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 131 KiB |
|
Before Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 216 KiB |
|
Before Width: | Height: | Size: 168 KiB |
|
Before Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 194 KiB |
|
Before Width: | Height: | Size: 148 KiB |
|
Before Width: | Height: | Size: 174 KiB |
|
Before Width: | Height: | Size: 184 KiB |
@@ -38,7 +38,7 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
Uint8List? _cachedTargetImage;
|
Uint8List? _cachedTargetImage;
|
||||||
Uint8List? _cachedRealImage;
|
Uint8List? _cachedRealImage;
|
||||||
|
|
||||||
final String targetAssetPath = 'assets/target.png';
|
late String targetAssetPath;
|
||||||
|
|
||||||
final Offset fixedRingTargetCenter = const Offset(602.51, 600.43);
|
final Offset fixedRingTargetCenter = const Offset(602.51, 600.43);
|
||||||
final Size fixedRingTargetSize = const Size(355.94, 359.27);
|
final Size fixedRingTargetSize = const Size(355.94, 359.27);
|
||||||
@@ -58,15 +58,23 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
Color get _activeColorWithOpacity => _activeColor.withOpacity(_bulletOpacity);
|
Color get _activeColorWithOpacity => _activeColor.withOpacity(_bulletOpacity);
|
||||||
|
|
||||||
String _selectedLanguage = 'English';
|
String _selectedLanguage = 'English';
|
||||||
|
Color _backgroundColor = Colors.grey[900]!;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_realImageDetections = widget.detections;
|
_realImageDetections = widget.detections;
|
||||||
_targetImageFuture = _loadAndDecodeTargetImage();
|
targetAssetPath = 'assets/target.png'; // Default
|
||||||
_loadBulletColor(); // 👈 Add this
|
_initializeScreen();
|
||||||
_loadLanguage();
|
}
|
||||||
_runDetectionAndMapping();
|
|
||||||
|
Future<void> _initializeScreen() async {
|
||||||
|
await Future.wait([
|
||||||
|
_loadSelectedTarget(),
|
||||||
|
_loadBulletColor(),
|
||||||
|
_loadLanguage(),
|
||||||
|
]);
|
||||||
|
await _runDetectionAndMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _t(String key) {
|
String _t(String key) {
|
||||||
@@ -80,6 +88,71 @@ class _PreviewScreenState extends State<PreviewScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _loadSelectedTarget() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
// For detection mode (cameraWithDetections), always use default target
|
||||||
|
// For presentation mode (mappedTarget), use selected target
|
||||||
|
final selectedTarget = _mode == PreviewMode.mappedTarget
|
||||||
|
? (prefs.getString('selectedTarget') ?? 'assets/target.png')
|
||||||
|
: 'assets/target.png';
|
||||||
|
|
||||||
|
// Update the target path and trigger image load
|
||||||
|
targetAssetPath = selectedTarget;
|
||||||
|
_targetImageFuture = _loadAndDecodeTargetImage();
|
||||||
|
_backgroundColor = _getBackgroundColorForTarget(selectedTarget);
|
||||||
|
|
||||||
|
// Await the image decoding to ensure it's populated before rebuilding
|
||||||
|
_targetImageDecoded = await _targetImageFuture;
|
||||||
|
if (_targetImageDecoded != null) {
|
||||||
|
_cachedTargetImage = Uint8List.fromList(img.encodePng(_targetImageDecoded!));
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
// Trigger rebuild with the new target
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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(0xFF000000); // Black
|
||||||
|
|
||||||
|
case 'assets/targets/Target7.jpg':
|
||||||
|
return const Color(0xFFFFD454); // Bright yellow
|
||||||
|
|
||||||
|
case 'assets/targets/Target11.jpg':
|
||||||
|
return const Color(0xFF1E5E81); // Dark teal blue
|
||||||
|
|
||||||
|
case 'assets/targets/Target14.jpg':
|
||||||
|
return const Color(0xFFFEFEFC); // Off-white
|
||||||
|
|
||||||
|
case 'assets/targets/Target15.jpg':
|
||||||
|
return const Color(0xFF98926E); // Olive green
|
||||||
|
|
||||||
|
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();
|
||||||
final selectedColor = prefs.getString('bulletColor') ?? 'Blue';
|
final selectedColor = prefs.getString('bulletColor') ?? 'Blue';
|
||||||
@@ -783,7 +856,7 @@ Color _getBulletButtonColor(int index) {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: _backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.grey[900],
|
backgroundColor: Colors.grey[900],
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
@@ -799,12 +872,13 @@ Widget build(BuildContext context) {
|
|||||||
: Icons.center_focus_strong,
|
: Icons.center_focus_strong,
|
||||||
),
|
),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_mode = _mode == PreviewMode.mappedTarget
|
_mode = _mode == PreviewMode.mappedTarget
|
||||||
? PreviewMode.cameraWithDetections
|
? PreviewMode.cameraWithDetections
|
||||||
: PreviewMode.mappedTarget;
|
: PreviewMode.mappedTarget;
|
||||||
});
|
});
|
||||||
|
await _loadSelectedTarget(); // Reload target based on new mode
|
||||||
},
|
},
|
||||||
tooltip: _mode == PreviewMode.mappedTarget
|
tooltip: _mode == PreviewMode.mappedTarget
|
||||||
? _t("Show Camera Detections")
|
? _t("Show Camera Detections")
|
||||||
|
|||||||
@@ -47,6 +47,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
{'code': 'sl', 'name': 'Slovenian', 'flag': '🇸🇮'},
|
{'code': 'sl', 'name': 'Slovenian', 'flag': '🇸🇮'},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
String _selectedTarget = 'assets/target.png';
|
||||||
|
final List<String> _availableTargets = [
|
||||||
|
'assets/target.png',
|
||||||
|
'assets/targets/Target1.jpg',
|
||||||
|
'assets/targets/Target2.jpg',
|
||||||
|
'assets/targets/Target3.jpg',
|
||||||
|
'assets/targets/Target4.jpg',
|
||||||
|
'assets/targets/Target5.jpg',
|
||||||
|
'assets/targets/Target6.jpg',
|
||||||
|
'assets/targets/Target7.jpg',
|
||||||
|
'assets/targets/Target11.jpg',
|
||||||
|
'assets/targets/Target14.jpg',
|
||||||
|
'assets/targets/Target15.jpg',
|
||||||
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -54,6 +68,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
_loadCameraIPs();
|
_loadCameraIPs();
|
||||||
_loadBulletColor();
|
_loadBulletColor();
|
||||||
_loadLanguage();
|
_loadLanguage();
|
||||||
|
_loadSelectedTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -134,6 +149,29 @@ Future<void> _saveLanguage(String language) async {
|
|||||||
setState(() => _selectedLanguage = language);
|
setState(() => _selectedLanguage = language);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _loadSelectedTarget() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
String savedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_selectedTarget = savedTarget;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _saveSelectedTarget(String target) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setString('selectedTarget', target);
|
||||||
|
setState(() => _selectedTarget = target);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _getTargetDisplayName(String targetPath) {
|
||||||
|
if (targetPath == 'assets/target.png') {
|
||||||
|
return 'Default Target';
|
||||||
|
}
|
||||||
|
return targetPath
|
||||||
|
.replaceAll('assets/targets/', '')
|
||||||
|
.replaceAll('.jpg', '');
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _loadCameraIPs() async {
|
Future<void> _loadCameraIPs() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
@@ -317,6 +355,8 @@ Future<void> _saveLanguage(String language) async {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
_buildBulletColorSelector(),
|
_buildBulletColorSelector(),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
_buildTargetSelector(),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
_buildCameraList(),
|
_buildCameraList(),
|
||||||
],
|
],
|
||||||
@@ -507,6 +547,87 @@ Future<void> _saveLanguage(String language) async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildTargetSelector() {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.grey.withValues(alpha: 0.3),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Header
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[900],
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(12),
|
||||||
|
topRight: Radius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 4,
|
||||||
|
height: 16,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(
|
||||||
|
_t("Select Target"),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Content
|
||||||
|
GestureDetector(
|
||||||
|
onTap: _showTargetPopup,
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey[300],
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
|
bottomLeft: Radius.circular(12),
|
||||||
|
bottomRight: Radius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
_getTargetDisplayName(_selectedTarget),
|
||||||
|
style: const TextStyle(color: Colors.black87, fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(Icons.chevron_right, color: Colors.black54),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _showLanguagePopup() {
|
void _showLanguagePopup() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -646,6 +767,130 @@ void _showBulletColorPopup() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showTargetPopup() {
|
||||||
|
String previewTarget = _selectedTarget;
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (context, innerSetState) {
|
||||||
|
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: Colors.grey[900],
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
_t("Select Target"),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
// Image Preview
|
||||||
|
Container(
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: Colors.white24),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Image.asset(
|
||||||
|
previewTarget,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
errorBuilder: (context, error, stackTrace) {
|
||||||
|
return Container(
|
||||||
|
color: Colors.grey[800],
|
||||||
|
child: const Center(
|
||||||
|
child: Icon(Icons.image_not_supported, color: Colors.white54),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
// Target List
|
||||||
|
SizedBox(
|
||||||
|
width: double.maxFinite,
|
||||||
|
height: 300,
|
||||||
|
child: ListView(
|
||||||
|
children: _availableTargets.map((targetPath) {
|
||||||
|
final isSelected = targetPath == previewTarget;
|
||||||
|
final displayName = _getTargetDisplayName(targetPath);
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 12.0),
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
innerSetState(() => previewTarget = targetPath);
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: isSelected
|
||||||
|
? _getColorFromName(_selectedBulletColor)
|
||||||
|
: Colors.grey[800],
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(displayName),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
// Action Buttons
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await _saveSelectedTarget(previewTarget);
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: _getColorFromName(_selectedBulletColor),
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Text(_t("Apply")),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: Text(_t("Cancel"), style: const TextStyle(color: Colors.white70)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildCameraList() {
|
Widget _buildCameraList() {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 0),
|
margin: const EdgeInsets.symmetric(vertical: 6, horizontal: 0),
|
||||||
|
|||||||
@@ -34,20 +34,28 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
int? _highlightedBulletIndex;
|
int? _highlightedBulletIndex;
|
||||||
int? _pressedScoreGroup;
|
int? _pressedScoreGroup;
|
||||||
late String _targetFilePath;
|
late String _targetFilePath;
|
||||||
|
late String targetAssetPath;
|
||||||
final String targetAssetPath = 'assets/target.png';
|
|
||||||
final double bulletSize = 19;
|
final double bulletSize = 19;
|
||||||
|
|
||||||
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
||||||
String _selectedLanguage = 'English';
|
String _selectedLanguage = 'English';
|
||||||
|
Color _backgroundColor = Colors.white;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadBulletColor();
|
targetAssetPath = 'assets/target.png'; // Default
|
||||||
_loadLanguage();
|
_initializeScreen();
|
||||||
_loadJsonAndImage();
|
}
|
||||||
|
|
||||||
|
Future<void> _initializeScreen() async {
|
||||||
|
await Future.wait([
|
||||||
|
_loadBulletColor(),
|
||||||
|
_loadLanguage(),
|
||||||
|
_loadSelectedTarget(),
|
||||||
|
]);
|
||||||
|
await _loadJsonAndImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _t(String key) {
|
String _t(String key) {
|
||||||
@@ -61,6 +69,54 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _loadSelectedTarget() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
final selectedTarget = prefs.getString('selectedTarget') ?? 'assets/target.png';
|
||||||
|
targetAssetPath = selectedTarget;
|
||||||
|
_backgroundColor = _getBackgroundColorForTarget(selectedTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
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(0xFF000000); // Black
|
||||||
|
|
||||||
|
case 'assets/targets/Target7.jpg':
|
||||||
|
return const Color(0xFFFFD454); // Bright yellow
|
||||||
|
|
||||||
|
case 'assets/targets/Target11.jpg':
|
||||||
|
return const Color(0xFF1E5E81); // Dark teal blue
|
||||||
|
|
||||||
|
case 'assets/targets/Target14.jpg':
|
||||||
|
return const Color(0xFFFEFEFC); // Off-white
|
||||||
|
|
||||||
|
case 'assets/targets/Target15.jpg':
|
||||||
|
return const Color(0xFF98926E); // Olive green
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Colors.white; // Fallback to white
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _loadBulletColor() async {
|
Future<void> _loadBulletColor() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
final selectedColor = prefs.getString('bulletColor') ?? 'Blue';
|
final selectedColor = prefs.getString('bulletColor') ?? 'Blue';
|
||||||
@@ -194,7 +250,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: _backgroundColor,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Row(
|
title: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@@ -365,7 +421,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Container(
|
Container(
|
||||||
color: Colors.white,
|
color: _backgroundColor,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: widget.isCombinedView
|
children: widget.isCombinedView
|
||||||
|
|||||||
@@ -57,5 +57,7 @@ flutter:
|
|||||||
- assets/logo.png
|
- assets/logo.png
|
||||||
- assets/logo.svg
|
- assets/logo.svg
|
||||||
- assets/target.png
|
- assets/target.png
|
||||||
|
- assets/target.svg
|
||||||
- assets/google_logo.png
|
- assets/google_logo.png
|
||||||
- assets/best_float32_nms.tflite
|
- assets/best_float32_nms.tflite
|
||||||
|
- assets/targets/
|
||||||
|
|||||||