feat(session): ajout du sélecteur de date et persistance dans l'historique de tir
This commit is contained in:
@@ -4,6 +4,8 @@ import '../../data/models/target_analysis.dart';
|
||||
import '../../data/models/weapon.dart';
|
||||
|
||||
class SessionProvider extends ChangeNotifier {
|
||||
DateTime? _sessionDate;
|
||||
DateTime? get sessionDate => _sessionDate;
|
||||
String? _currentWeaponName;
|
||||
String? _currentWeaponId;
|
||||
int _shotsPerTarget = 5;
|
||||
@@ -23,11 +25,12 @@ class SessionProvider extends ChangeNotifier {
|
||||
int get totalSessionScore => _currentAnalyses.fold(0, (sum, a) => sum + a.totalScore);
|
||||
int get targetCount => _currentAnalyses.length;
|
||||
|
||||
void startSession(String weaponName, int shots, String sessionId, {String? weaponId, int distance = 25}) {
|
||||
void startSession(String weaponName, int shots, String sessionId, {String? weaponId, int distance = 25, DateTime? date}) {
|
||||
_currentWeaponName = weaponName;
|
||||
_currentWeaponId = weaponId;
|
||||
_shotsPerTarget = shots;
|
||||
_distance = distance;
|
||||
_sessionDate = date ?? DateTime.now();
|
||||
_activeSessionId = sessionId;
|
||||
_currentAnalyses.clear();
|
||||
_isSessionActive = true;
|
||||
|
||||
Reference in New Issue
Block a user