100 lines
2.8 KiB
Dart
100 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../components/home/home_content.dart';
|
|
import '../components/settings/settings_content.dart';
|
|
import '../components/profile/profile_content.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
int _currentIndex = 0;
|
|
|
|
// Liste des composants à afficher
|
|
final List<Widget> _pages = [
|
|
HomeContent(),
|
|
SettingsContent(),
|
|
ProfileContent(),
|
|
];
|
|
|
|
// Titres correspondants
|
|
final List<String> _titles = ['Accueil', 'Paramètres', 'Profil'];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(_titles[_currentIndex]),
|
|
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: () {
|
|
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.person),
|
|
title: Text("Profil"),
|
|
selected: _currentIndex == 2,
|
|
onTap: () {
|
|
setState(() {
|
|
_currentIndex = 2;
|
|
});
|
|
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],
|
|
);
|
|
}
|
|
}
|