90 lines
2.7 KiB
Dart
90 lines
2.7 KiB
Dart
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<MainNavigationHolder> createState() => _MainNavigationHolderState();
|
|
}
|
|
|
|
class _MainNavigationHolderState extends State<MainNavigationHolder> {
|
|
int _selectedIndex = 0;
|
|
|
|
// Incrémentés à chaque ouverture de l'onglet correspondant pour forcer le
|
|
// rechargement (les écrans sont gardés vivants par l'IndexedStack et ne se
|
|
// rafraîchissent pas seuls).
|
|
int _statsTick = 0;
|
|
int _historyTick = 0;
|
|
|
|
void _onItemTapped(int index) {
|
|
setState(() {
|
|
_selectedIndex = index;
|
|
if (index == 1) _historyTick++;
|
|
if (index == 2) _statsTick++;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final screens = [
|
|
const HomeScreen(),
|
|
HistoryScreen(refreshTick: _historyTick),
|
|
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',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|