feat(session): add armory shortcut and 50-shot preset

This commit is contained in:
qlionbleusam
2026-08-29 08:48:41 +02:00
parent 8dc6542603
commit 96cc487b55
+46 -8
View File
@@ -28,7 +28,7 @@ class _SessionSetupScreenState extends State<SessionSetupScreen> {
DateTime _selectedDate = DateTime.now(); DateTime _selectedDate = DateTime.now();
static const List<int> _presetDistances = [10, 15, 25, 50, 100, 200]; static const List<int> _presetDistances = [10, 15, 25, 50, 100, 200];
static const List<int> _presetShots = [3, 5, 10, 15, 20, 30]; static const List<int> _presetShots = [3, 5, 10, 15, 20, 30, 50];
@override @override
void initState() { void initState() {
@@ -53,6 +53,35 @@ class _SessionSetupScreenState extends State<SessionSetupScreen> {
} }
} }
Future<void> _openArmory() async {
final knownIds = _availableWeapons.map((w) => w.id).toSet();
await Navigator.push(
context,
MaterialPageRoute(builder: (_) => const WeaponListScreen()),
);
if (!mounted) return;
await _loadWeapons();
if (!mounted) return;
// Selectionne automatiquement l'arme qui vient d'etre ajoutee.
Weapon? added;
for (final weapon in _availableWeapons) {
if (!knownIds.contains(weapon.id)) {
added = weapon;
break;
}
}
if (added != null) {
final newWeapon = added;
setState(() {
_selectedWeapon = newWeapon;
_updateSettingsForWeapon(newWeapon);
});
}
}
void _updateSettingsForWeapon(Weapon weapon) { void _updateSettingsForWeapon(Weapon weapon) {
_shotsPerTarget = weapon.magazineCapacity > 0 ? weapon.magazineCapacity : 5; _shotsPerTarget = weapon.magazineCapacity > 0 ? weapon.magazineCapacity : 5;
_distance = (weapon.type == WeaponType.handgun) ? 25 : 50; _distance = (weapon.type == WeaponType.handgun) ? 25 : 50;
@@ -177,12 +206,7 @@ class _SessionSetupScreenState extends State<SessionSetupScreen> {
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
ElevatedButton.icon( ElevatedButton.icon(
onPressed: () { onPressed: _openArmory,
Navigator.push(
context,
MaterialPageRoute(builder: (_) => const WeaponListScreen()),
).then((_) => _loadWeapons());
},
icon: const Icon(Icons.shield), icon: const Icon(Icons.shield),
label: const Text('Aller à l\'armurerie'), label: const Text('Aller à l\'armurerie'),
), ),
@@ -236,7 +260,21 @@ class _SessionSetupScreenState extends State<SessionSetupScreen> {
} }
}, },
), ),
const SizedBox(height: 12), const SizedBox(height: 4),
Align(
alignment: Alignment.centerLeft,
child: TextButton.icon(
onPressed: _openArmory,
icon: const Icon(Icons.add_circle_outline, size: 18),
label: const Text('Ajouter une nouvelle arme'),
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
visualDensity: VisualDensity.compact,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
),
const SizedBox(height: 8),
InkWell( InkWell(
onTap: _pickDate, onTap: _pickDate,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),