fixes for detection with new target styles
This commit is contained in:
@@ -34,20 +34,28 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
int? _highlightedBulletIndex;
|
||||
int? _pressedScoreGroup;
|
||||
late String _targetFilePath;
|
||||
|
||||
final String targetAssetPath = 'assets/target.png';
|
||||
late String targetAssetPath;
|
||||
final double bulletSize = 19;
|
||||
|
||||
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
||||
String _selectedLanguage = 'English';
|
||||
Color _backgroundColor = Colors.white;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadBulletColor();
|
||||
_loadLanguage();
|
||||
_loadJsonAndImage();
|
||||
targetAssetPath = 'assets/target.png'; // Default
|
||||
_initializeScreen();
|
||||
}
|
||||
|
||||
Future<void> _initializeScreen() async {
|
||||
await Future.wait([
|
||||
_loadBulletColor(),
|
||||
_loadLanguage(),
|
||||
_loadSelectedTarget(),
|
||||
]);
|
||||
await _loadJsonAndImage();
|
||||
}
|
||||
|
||||
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 {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final selectedColor = prefs.getString('bulletColor') ?? 'Blue';
|
||||
@@ -194,7 +250,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
backgroundColor: _backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -365,7 +421,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
color: _backgroundColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Row(
|
||||
children: widget.isCombinedView
|
||||
|
||||
Reference in New Issue
Block a user