fix: reset espacement calibration + refresh auto historique
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
/// Les anneaux sont répartis proportionnellement.
|
/// Les anneaux sont répartis proportionnellement.
|
||||||
library;
|
library;
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../../core/theme/app_theme.dart';
|
import '../../../core/theme/app_theme.dart';
|
||||||
import '../../../data/models/target_type.dart';
|
import '../../../data/models/target_type.dart';
|
||||||
@@ -130,7 +131,14 @@ class TargetCalibrationState extends State<TargetCalibration> {
|
|||||||
_currentEspacementRatio = (_radius > 0) ? (_innerRadius / _radius).clamp(0.01, 0.70) : 0.1;
|
_currentEspacementRatio = (_radius > 0) ? (_innerRadius / _radius).clamp(0.01, 0.70) : 0.1;
|
||||||
shouldReinit = true;
|
shouldReinit = true;
|
||||||
}
|
}
|
||||||
if (widget.initialRingRadii != oldWidget.initialRingRadii && widget.initialRingRadii != null) {
|
// On ne rafraîchit le profil d'usine que si les rayons entrants proviennent
|
||||||
|
// réellement d'une nouvelle détection (ils diffèrent de notre état courant).
|
||||||
|
// Sinon il s'agit de l'écho de notre propre _notifyChange (aller-retour via
|
||||||
|
// le provider) : le clobber effacerait le profil d'origine et casserait le
|
||||||
|
// bouton de réinitialisation de l'espacement.
|
||||||
|
if (widget.initialRingRadii != oldWidget.initialRingRadii &&
|
||||||
|
widget.initialRingRadii != null &&
|
||||||
|
!listEquals(widget.initialRingRadii, _ringRadii)) {
|
||||||
_originalRingRadii = List.from(widget.initialRingRadii!);
|
_originalRingRadii = List.from(widget.initialRingRadii!);
|
||||||
shouldReinit = true;
|
shouldReinit = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,13 @@ import 'widgets/session_list_item.dart';
|
|||||||
import 'widgets/history_chart.dart';
|
import 'widgets/history_chart.dart';
|
||||||
|
|
||||||
class HistoryScreen extends StatefulWidget {
|
class HistoryScreen extends StatefulWidget {
|
||||||
const HistoryScreen({super.key});
|
/// Incrémenté par la navigation à chaque ouverture de l'onglet Historique,
|
||||||
|
/// pour forcer un rechargement des sessions (l'écran est gardé vivant par un
|
||||||
|
/// IndexedStack, sinon une session tout juste clôturée n'apparaîtrait pas
|
||||||
|
/// tant qu'on ne tire pas manuellement pour rafraîchir).
|
||||||
|
final int refreshTick;
|
||||||
|
|
||||||
|
const HistoryScreen({super.key, this.refreshTick = 0});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<HistoryScreen> createState() => _HistoryScreenState();
|
State<HistoryScreen> createState() => _HistoryScreenState();
|
||||||
@@ -31,6 +37,16 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
|||||||
_loadSessions();
|
_loadSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(HistoryScreen oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
// L'onglet vient d'être ré-ouvert : on recharge pour afficher les sessions
|
||||||
|
// récemment clôturées sans avoir à tirer manuellement pour rafraîchir.
|
||||||
|
if (oldWidget.refreshTick != widget.refreshTick) {
|
||||||
|
_loadSessions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _loadSessions() async {
|
Future<void> _loadSessions() async {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() => _isLoading = true);
|
setState(() => _isLoading = true);
|
||||||
|
|||||||
@@ -15,13 +15,16 @@ class MainNavigationHolder extends StatefulWidget {
|
|||||||
class _MainNavigationHolderState extends State<MainNavigationHolder> {
|
class _MainNavigationHolderState extends State<MainNavigationHolder> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
// Incrémenté à chaque ouverture de l'onglet Stats pour forcer le rechargement
|
// Incrémentés à chaque ouverture de l'onglet correspondant pour forcer le
|
||||||
// (l'écran est gardé vivant par l'IndexedStack et ne se rafraîchit pas seul).
|
// rechargement (les écrans sont gardés vivants par l'IndexedStack et ne se
|
||||||
|
// rafraîchissent pas seuls).
|
||||||
int _statsTick = 0;
|
int _statsTick = 0;
|
||||||
|
int _historyTick = 0;
|
||||||
|
|
||||||
void _onItemTapped(int index) {
|
void _onItemTapped(int index) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedIndex = index;
|
_selectedIndex = index;
|
||||||
|
if (index == 1) _historyTick++;
|
||||||
if (index == 2) _statsTick++;
|
if (index == 2) _statsTick++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -30,7 +33,7 @@ class _MainNavigationHolderState extends State<MainNavigationHolder> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screens = [
|
final screens = [
|
||||||
const HomeScreen(),
|
const HomeScreen(),
|
||||||
const HistoryScreen(),
|
HistoryScreen(refreshTick: _historyTick),
|
||||||
StatisticsScreen(refreshTick: _statsTick),
|
StatisticsScreen(refreshTick: _statsTick),
|
||||||
const WeaponListScreen(),
|
const WeaponListScreen(),
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user