button update shape

This commit is contained in:
2025-04-14 18:07:37 +02:00
parent 42fb4709df
commit ff0d6b7796
+40 -110
View File
@@ -226,68 +226,6 @@ Color _getColorFromName(String colorName) {
} }
} }
Future<String?> _showMismatchOptionsDialog(int detectedCount) async {
return showDialog<String>(
context: context,
builder: (context) {
final missing = widget.bulletCount - detectedCount;
return AlertDialog(
backgroundColor: Colors.grey[900],
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: const Text(
'Bullet Count Mismatch',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
content: Text(
'Detected $detectedCount bullet(s), expected ${widget.bulletCount}.\n'
'You can retry detection or manually add the ${missing.abs()} missing shot(s).',
style: const TextStyle(color: Colors.white70),
),
contentPadding: const EdgeInsets.fromLTRB(24, 20, 24, 12),
actionsPadding: const EdgeInsets.only(bottom: 16, left: 16, right: 16),
actions: [
Row(
children: [
Expanded(
child: ElevatedButton(
onPressed: () => Navigator.pop(context, 'retry'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.redAccent,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Icon(Icons.restart_alt, color: Colors.white),
),
),
const SizedBox(width: 16),
Expanded(
child: ElevatedButton(
onPressed: () => Navigator.pop(context, 'manual'),
style: ElevatedButton.styleFrom(
backgroundColor: _activeColor,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Icon(Icons.edit, color: Colors.white),
),
),
],
),
],
);
},
);
}
void _manualScoreEntry() { void _manualScoreEntry() {
final missingCount = widget.bulletCount - _mappedBullets.length; final missingCount = widget.bulletCount - _mappedBullets.length;
final controllers = List.generate(missingCount, (_) => TextEditingController()); final controllers = List.generate(missingCount, (_) => TextEditingController());
@@ -1059,58 +997,50 @@ Widget build(BuildContext context) {
), ),
_buildEditController(), _buildEditController(),
if (_mappedBullets.isNotEmpty) if (_mappedBullets.isNotEmpty)
Positioned( Positioned(
top: 16, top: 16,
right: 16, right: 16,
child: GestureDetector( child: GestureDetector(
onTap: () async { onTap: () async {
if (!_isEditMode && _mappedBullets.length < widget.bulletCount) { if (!_isEditMode && _mappedBullets.length < widget.bulletCount) {
final result = await _showMismatchOptionsDialog(_mappedBullets.length); _manualScoreEntry();
return;
}
if (result == 'retry') { setState(() {
Navigator.pop(context); _isEditMode = !_isEditMode;
return; _selectedBulletIndexInEdit = null;
} else if (result == 'manual') { });
_manualScoreEntry(); },
return; child: Container(
} else { width: 56,
return; height: 56,
} decoration: BoxDecoration(
} color: _isEditMode
? Colors.red
setState(() { : (_mappedBullets.length < widget.bulletCount ? Colors.redAccent : _bulletColor),
_isEditMode = !_isEditMode; borderRadius: BorderRadius.circular(16), // 👈 Rounded square
_selectedBulletIndexInEdit = null; boxShadow: const [
}); BoxShadow(
}, color: Colors.black26,
child: Container( offset: Offset(0, 3),
width: 60, blurRadius: 6,
height: 60, ),
decoration: BoxDecoration( ],
color: _isEditMode ),
? Colors.red child: Icon(
: (_mappedBullets.length < widget.bulletCount ? Colors.redAccent : _bulletColor), _isEditMode
shape: BoxShape.circle, ? Icons.check
boxShadow: const [ : (_mappedBullets.length < widget.bulletCount
BoxShadow( ? Icons.warning_amber_rounded
color: Colors.black26, : Icons.edit),
offset: Offset(0, 3), color: Colors.white,
blurRadius: 6, size: 28,
),
],
),
child: Icon(
_isEditMode
? Icons.check
: (_mappedBullets.length < widget.bulletCount
? Icons.warning_amber_rounded
: Icons.edit),
color: Colors.white,
size: 28,
),
), ),
), ),
), ),
),
], ],
), ),
bottomNavigationBar: BottomAppBar( bottomNavigationBar: BottomAppBar(