Files
TravelMate/lib/pages/home.dart

131 lines
3.7 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 = [
'Mes voyages', // 0
'Paramètres', // 1
'Carte', // 2
'Mes chats', // 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("Mes voyages"),
selected: _currentIndex == 0,
onTap: () {
setState(() {
_currentIndex = 0;
});
Navigator.pop(context);
},
),
ListTile(
leading: Icon(Icons.settings),
title: Text("Paramètres"),
selected: _currentIndex == 1,
onTap: () {
setState(() {
_currentIndex = 1;
});
Navigator.pop(context);
},
),
ListTile(
leading: Icon(Icons.map),
title: Text("Carte"),
selected: _currentIndex == 2,
onTap: () {
setState(() {
_currentIndex = 2;
});
Navigator.pop(context);
},
),
ListTile(
leading: Icon(Icons.group),
title: Text("Mes groupes"),
selected: _currentIndex == 3,
onTap: () {
setState(() {
_currentIndex = 3;
});
Navigator.pop(context);
},
),
ListTile(
leading: Icon(Icons.account_balance_wallet),
title: Text("Comptes"),
selected: _currentIndex == 4,
onTap: () {
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],
);
}
}