fixed controller and coloring
This commit is contained in:
@@ -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),
|
||||
onPressed: () => setState(() => _selectedBulletIndexInEdit = null),
|
||||
splashRadius: 20,
|
||||
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: 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,10 +1022,12 @@ Widget build(BuildContext context) {
|
||||
// Score buttons
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Row(
|
||||
children: List.generate(
|
||||
_mappedBullets.length,
|
||||
(index) {
|
||||
child: AbsorbPointer(
|
||||
absorbing: _isEditMode && _selectedBulletIndexInEdit != null,
|
||||
child: Row(
|
||||
children: List.generate(
|
||||
_mappedBullets.length,
|
||||
(index) {
|
||||
final bullet = _mappedBullets[index];
|
||||
final isManual = index >= (_mappedBullets.length - _manualBulletScores.length);
|
||||
final score = isManual
|
||||
@@ -1110,9 +1125,9 @@ Widget build(BuildContext context) {
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
),
|
||||
|
||||
+105
-88
@@ -43,7 +43,7 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadBulletColor(); // 👈 this will load bullet color
|
||||
_loadBulletColor();
|
||||
_loadJsonAndImage();
|
||||
}
|
||||
|
||||
@@ -285,32 +285,33 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
child: Image.memory(_targetImageBytes!, fit: BoxFit.fill),
|
||||
),
|
||||
..._bullets.asMap().entries.map((entry) {
|
||||
final i = entry.key;
|
||||
final bullet = entry.value;
|
||||
final dx = bullet.dx * scaleX + offsetX;
|
||||
final dy = bullet.dy * scaleY + offsetY;
|
||||
final score = _scoreForBullet(bullet, _targetCenter!);
|
||||
final isHighlighted = widget.isCombinedView
|
||||
? (_pressedScoreGroup == score)
|
||||
: (i == _highlightedBulletIndex);
|
||||
final i = entry.key;
|
||||
final bullet = entry.value;
|
||||
final dx = bullet.dx * scaleX + offsetX;
|
||||
final dy = bullet.dy * scaleY + offsetY;
|
||||
final score = _scoreForBullet(bullet, _targetCenter ?? Offset.zero);
|
||||
final isHighlighted = widget.isCombinedView
|
||||
? (_pressedScoreGroup == score)
|
||||
: (i == _highlightedBulletIndex);
|
||||
|
||||
return Positioned(
|
||||
left: dx - bulletSize / 2,
|
||||
top: dy - bulletSize / 2,
|
||||
child: Container(
|
||||
width: bulletSize,
|
||||
height: bulletSize,
|
||||
decoration: BoxDecoration(
|
||||
color: _bulletColor.withOpacity(0.8),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: isHighlighted ? Colors.red : Colors.black,
|
||||
width: isHighlighted ? 3 : 1,
|
||||
),
|
||||
return Positioned(
|
||||
left: dx - bulletSize / 2,
|
||||
top: dy - bulletSize / 2,
|
||||
child: Container(
|
||||
width: bulletSize,
|
||||
height: bulletSize,
|
||||
decoration: BoxDecoration(
|
||||
color: _bulletColor.withOpacity(0.8),
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: isHighlighted ? Colors.red : Colors.black,
|
||||
width: isHighlighted ? 3 : 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).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,
|
||||
),
|
||||
],
|
||||
@@ -406,8 +411,8 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: _pressedScoreGroup == score
|
||||
? Colors.red[400]
|
||||
: _bulletColor.withOpacity(0.85),
|
||||
? Colors.red[400]
|
||||
: _bulletColor.withOpacity(0.85),
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(16),
|
||||
bottomRight: Radius.circular(16),
|
||||
@@ -437,79 +442,91 @@ class _TargetViewScreenState extends State<TargetViewScreen> {
|
||||
}
|
||||
|
||||
|
||||
List<Widget> _buildIndividualScoreButtons() {
|
||||
return List.generate(_bullets.length, (index) {
|
||||
final bullet = _bullets[index];
|
||||
final score = _scoreForBullet(bullet, _targetCenter!);
|
||||
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: GestureDetector(
|
||||
onTapDown: (_) => setState(() => _highlightedBulletIndex = index),
|
||||
onTapUp: (_) => setState(() => _highlightedBulletIndex = null),
|
||||
onTapCancel: () => setState(() => _highlightedBulletIndex = null),
|
||||
child: Container(
|
||||
height: 100,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: const Offset(0, 2),
|
||||
blurRadius: 6,
|
||||
List<Widget> _buildIndividualScoreButtons() {
|
||||
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(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: GestureDetector(
|
||||
onTapDown: (_) => setState(() => _highlightedBulletIndex = index),
|
||||
onTapUp: (_) => setState(() => _highlightedBulletIndex = null),
|
||||
onTapCancel: () => setState(() => _highlightedBulletIndex = null),
|
||||
child: Container(
|
||||
height: 100,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset(0, 2),
|
||||
blurRadius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 30,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 30,
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
color: _highlightedBulletIndex == index
|
||||
? Colors.red[400]
|
||||
: _bulletColor.withOpacity(0.85),
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
bottomLeft: Radius.circular(16),
|
||||
bottomRight: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
'$score',
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
color: Colors.black87,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: _highlightedBulletIndex == index
|
||||
? Colors.red[400]
|
||||
: _bulletColor.withOpacity(0.85),
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(16),
|
||||
bottomRight: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'$score',
|
||||
style: const TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user