fixed controller and coloring

This commit is contained in:
2025-04-07 20:35:07 +02:00
parent aeda7ddd2e
commit b822fe1ca3
2 changed files with 144 additions and 112 deletions
+32 -17
View File
@@ -442,45 +442,57 @@ void _manualScoreEntry() {
right: 0,
child: Center(
child: Container(
padding: const EdgeInsets.all(8),
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 20),
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.75),
borderRadius: BorderRadius.circular(12),
borderRadius: BorderRadius.circular(16),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Up
IconButton(
icon: const Icon(Icons.arrow_drop_up, size: 32, color: Colors.white),
icon: const Icon(Icons.keyboard_arrow_up, size: 36, color: Colors.white),
onPressed: () => _moveBullet(const Offset(0, -3)),
splashRadius: 20,
splashRadius: 24,
),
// Left - Check - Right
Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.arrow_left, size: 32, color: Colors.white),
icon: const Icon(Icons.keyboard_arrow_left, size: 36, color: Colors.white),
onPressed: () => _moveBullet(const Offset(-3, 0)),
splashRadius: 20,
splashRadius: 24,
),
const SizedBox(width: 4),
IconButton(
icon: const Icon(Icons.check, size: 28, color: Colors.greenAccent),
const SizedBox(width: 8),
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.greenAccent.withOpacity(0.2),
border: Border.all(color: Colors.greenAccent, width: 2),
),
child: IconButton(
icon: const Icon(Icons.check, color: Colors.greenAccent, size: 28),
onPressed: () => setState(() => _selectedBulletIndexInEdit = null),
splashRadius: 20,
splashRadius: 22,
),
const SizedBox(width: 4),
),
const SizedBox(width: 8),
IconButton(
icon: const Icon(Icons.arrow_right, size: 32, color: Colors.white),
icon: const Icon(Icons.keyboard_arrow_right, size: 36, color: Colors.white),
onPressed: () => _moveBullet(const Offset(3, 0)),
splashRadius: 20,
splashRadius: 24,
),
],
),
// Down
IconButton(
icon: const Icon(Icons.arrow_drop_down, size: 32, color: Colors.white),
icon: const Icon(Icons.keyboard_arrow_down, size: 36, color: Colors.white),
onPressed: () => _moveBullet(const Offset(0, 3)),
splashRadius: 20,
splashRadius: 24,
),
],
),
@@ -490,6 +502,7 @@ void _manualScoreEntry() {
}
void _moveBullet(Offset offsetDelta) {
setState(() {
final index = _selectedBulletIndexInEdit!;
@@ -864,7 +877,7 @@ Widget build(BuildContext context) {
style: const TextStyle(color: Colors.white, fontSize: 16),
),
style: ElevatedButton.styleFrom(
backgroundColor: _activeColor,
backgroundColor: Colors.red,
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
@@ -1009,6 +1022,8 @@ Widget build(BuildContext context) {
// Score buttons
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: AbsorbPointer(
absorbing: _isEditMode && _selectedBulletIndexInEdit != null,
child: Row(
children: List.generate(
_mappedBullets.length,
@@ -1110,9 +1125,9 @@ Widget build(BuildContext context) {
),
),
),
),
],
),
const SizedBox(height: 12),
],
),
+29 -12
View File
@@ -43,7 +43,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
@override
void initState() {
super.initState();
_loadBulletColor(); // 👈 this will load bullet color
_loadBulletColor();
_loadJsonAndImage();
}
@@ -289,7 +289,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
final bullet = entry.value;
final dx = bullet.dx * scaleX + offsetX;
final dy = bullet.dy * scaleY + offsetY;
final score = _scoreForBullet(bullet, _targetCenter!);
final score = _scoreForBullet(bullet, _targetCenter ?? Offset.zero);
final isHighlighted = widget.isCombinedView
? (_pressedScoreGroup == score)
: (i == _highlightedBulletIndex);
@@ -310,7 +310,8 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
),
),
);
}).toList(),
})
.toList(),
],
);
},
@@ -355,7 +356,11 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
scoreGroups[score] = (scoreGroups[score] ?? 0) + 1;
}
return scoreGroups.entries.map((entry) {
// Sort scores descending (10 → 0)
final sortedEntries = scoreGroups.entries.toList()
..sort((a, b) => b.key.compareTo(a.key));
return sortedEntries.map((entry) {
final score = entry.key;
final count = entry.value;
@@ -370,10 +375,10 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
height: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
boxShadow: [
boxShadow: const [
BoxShadow(
color: Colors.black26,
offset: const Offset(0, 2),
offset: Offset(0, 2),
blurRadius: 6,
),
],
@@ -437,10 +442,21 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
}
List<Widget> _buildIndividualScoreButtons() {
return List.generate(_bullets.length, (index) {
final bullet = _bullets[index];
final score = _scoreForBullet(bullet, _targetCenter!);
final scoredBullets = _bullets.asMap().entries.map((entry) {
final index = entry.key;
final bullet = entry.value;
final score = _scoreForBullet(bullet, _targetCenter ?? Offset.zero);
return {'index': index, 'score': score, 'bullet': bullet};
}).toList();
// Sort descending by score
scoredBullets.sort((a, b) => (b['score'] as int).compareTo(a['score'] as int));
return scoredBullets.map((entry) {
final int index = entry['index'] as int;
final int score = entry['score'] as int;
return Expanded(
child: Padding(
@@ -453,10 +469,10 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
height: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
boxShadow: [
boxShadow: const [
BoxShadow(
color: Colors.black26,
offset: const Offset(0, 2),
offset: Offset(0, 2),
blurRadius: 6,
),
],
@@ -510,6 +526,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
),
),
);
});
}).toList();
}
}