136 lines
4.1 KiB
Dart
136 lines
4.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../components/home/home_content.dart';
|
|
import '../components/settings/settings_content.dart';
|
|
import '../components/map/map_content.dart';
|
|
import '../components/group/group_content.dart';
|
|
import '../components/count/count_content.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
int _currentIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Définir les pages directement dans le build pour éviter les erreurs
|
|
final List<Widget> pages = [
|
|
HomeContent(), // 0
|
|
SettingsContent(), // 1
|
|
MapContent(), // 2
|
|
GroupContent(), // 3
|
|
CountContent(), // 4
|
|
];
|
|
|
|
final List<String> titles = [
|
|
'Accueil', // 0
|
|
'Paramètres', // 1
|
|
'Carte', // 2
|
|
'Mes groupes', // 3
|
|
'Comptes', // 4
|
|
];
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(titles[_currentIndex]), // Debug
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
drawer: Drawer(
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: [
|
|
DrawerHeader(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.inversePrimary,
|
|
),
|
|
child: Text(
|
|
"Travel Mate",
|
|
style: TextStyle(color: Colors.white, fontSize: 24),
|
|
),
|
|
),
|
|
ListTile(
|
|
leading: Icon(Icons.home),
|
|
title: Text("Accueil"),
|
|
selected: _currentIndex == 0,
|
|
onTap: () {
|
|
print('Clicked Accueil - Setting index to 0'); // Debug
|
|
setState(() {
|
|
_currentIndex = 0;
|
|
});
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: Icon(Icons.settings),
|
|
title: Text("Paramètres"),
|
|
selected: _currentIndex == 1,
|
|
onTap: () {
|
|
print('Clicked Paramètres - Setting index to 1'); // Debug
|
|
setState(() {
|
|
_currentIndex = 1;
|
|
});
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: Icon(Icons.map),
|
|
title: Text("Carte"),
|
|
selected: _currentIndex == 2,
|
|
onTap: () {
|
|
print('Clicked Carte - Setting index to 2'); // Debug
|
|
setState(() {
|
|
_currentIndex = 2;
|
|
});
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: Icon(Icons.group),
|
|
title: Text("Mes groupes"),
|
|
selected: _currentIndex == 3,
|
|
onTap: () {
|
|
print('Clicked Groupes - Setting index to 3'); // Debug
|
|
setState(() {
|
|
_currentIndex = 3;
|
|
});
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
ListTile(
|
|
leading: Icon(Icons.account_balance_wallet),
|
|
title: Text("Comptes"),
|
|
selected: _currentIndex == 4,
|
|
onTap: () {
|
|
print('Clicked Comptes - Setting index to 4'); // Debug
|
|
setState(() {
|
|
_currentIndex = 4;
|
|
});
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
Divider(),
|
|
ListTile(
|
|
leading: Icon(Icons.logout, color: Colors.red),
|
|
title: Text("Déconnexion", style: TextStyle(color: Colors.red)),
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
Navigator.pushNamedAndRemoveUntil(
|
|
context,
|
|
'/login',
|
|
(route) => false,
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
body: pages[_currentIndex],
|
|
);
|
|
}
|
|
}
|