button update shape
This commit is contained in:
+40
-110
@@ -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() {
|
||||
final missingCount = widget.bulletCount - _mappedBullets.length;
|
||||
final controllers = List.generate(missingCount, (_) => TextEditingController());
|
||||
@@ -1059,58 +997,50 @@ Widget build(BuildContext context) {
|
||||
),
|
||||
_buildEditController(),
|
||||
if (_mappedBullets.isNotEmpty)
|
||||
Positioned(
|
||||
top: 16,
|
||||
right: 16,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
if (!_isEditMode && _mappedBullets.length < widget.bulletCount) {
|
||||
final result = await _showMismatchOptionsDialog(_mappedBullets.length);
|
||||
Positioned(
|
||||
top: 16,
|
||||
right: 16,
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
if (!_isEditMode && _mappedBullets.length < widget.bulletCount) {
|
||||
_manualScoreEntry();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == 'retry') {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
} else if (result == 'manual') {
|
||||
_manualScoreEntry();
|
||||
return;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_isEditMode = !_isEditMode;
|
||||
_selectedBulletIndexInEdit = null;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: _isEditMode
|
||||
? Colors.red
|
||||
: (_mappedBullets.length < widget.bulletCount ? Colors.redAccent : _bulletColor),
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset(0, 3),
|
||||
blurRadius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
_isEditMode
|
||||
? Icons.check
|
||||
: (_mappedBullets.length < widget.bulletCount
|
||||
? Icons.warning_amber_rounded
|
||||
: Icons.edit),
|
||||
color: Colors.white,
|
||||
size: 28,
|
||||
),
|
||||
setState(() {
|
||||
_isEditMode = !_isEditMode;
|
||||
_selectedBulletIndexInEdit = null;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
width: 56,
|
||||
height: 56,
|
||||
decoration: BoxDecoration(
|
||||
color: _isEditMode
|
||||
? Colors.red
|
||||
: (_mappedBullets.length < widget.bulletCount ? Colors.redAccent : _bulletColor),
|
||||
borderRadius: BorderRadius.circular(16), // 👈 Rounded square
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
offset: Offset(0, 3),
|
||||
blurRadius: 6,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
_isEditMode
|
||||
? Icons.check
|
||||
: (_mappedBullets.length < widget.bulletCount
|
||||
? Icons.warning_amber_rounded
|
||||
: Icons.edit),
|
||||
color: Colors.white,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
|
||||
Reference in New Issue
Block a user