import 'package:flutter/material.dart'; import 'features/home/home_screen.dart'; import 'features/history/history_screen.dart'; import 'features/statistics/statistics_screen.dart'; import 'features/garage/weapon_list_screen.dart'; import 'core/theme/app_theme.dart'; class MainNavigationHolder extends StatefulWidget { const MainNavigationHolder({super.key}); @override State createState() => _MainNavigationHolderState(); } class _MainNavigationHolderState extends State { int _selectedIndex = 0; // Incrémenté à chaque ouverture de l'onglet Stats pour forcer le rechargement // (l'écran est gardé vivant par l'IndexedStack et ne se rafraîchit pas seul). int _statsTick = 0; void _onItemTapped(int index) { setState(() { _selectedIndex = index; if (index == 2) _statsTick++; }); } @override Widget build(BuildContext context) { final screens = [ const HomeScreen(), const HistoryScreen(), StatisticsScreen(refreshTick: _statsTick), const WeaponListScreen(), ]; return Scaffold( body: IndexedStack( index: _selectedIndex, children: screens, ), bottomNavigationBar: Container( decoration: BoxDecoration( boxShadow: [ BoxShadow( color: Colors.black.withValues(alpha: 0.1), blurRadius: 10, offset: const Offset(0, -2), ), ], ), child: BottomNavigationBar( currentIndex: _selectedIndex, onTap: _onItemTapped, type: BottomNavigationBarType.fixed, backgroundColor: Theme.of(context).cardColor, selectedItemColor: AppTheme.primaryColor, unselectedItemColor: Colors.grey, showUnselectedLabels: true, items: const [ BottomNavigationBarItem( icon: Icon(Icons.home_outlined), activeIcon: Icon(Icons.home), label: 'Accueil', ), BottomNavigationBarItem( icon: Icon(Icons.history_outlined), activeIcon: Icon(Icons.history), label: 'Historique', ), BottomNavigationBarItem( icon: Icon(Icons.analytics_outlined), activeIcon: Icon(Icons.analytics), label: 'Stats', ), BottomNavigationBarItem( icon: Icon(Icons.shield_outlined), activeIcon: Icon(Icons.shield), label: 'Armurerie', ), ], ), ), ); } }