Add profile in parameters, initialized page map, group, count.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../components/home/home_content.dart';
|
||||
import '../components/settings/settings_content.dart';
|
||||
import '../components/profile/profile_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});
|
||||
@@ -13,21 +15,28 @@ class HomePage extends StatefulWidget {
|
||||
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) {
|
||||
// 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]),
|
||||
title: Text(titles[_currentIndex]), // Debug
|
||||
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
@@ -49,6 +58,7 @@ class _HomePageState extends State<HomePage> {
|
||||
title: Text("Accueil"),
|
||||
selected: _currentIndex == 0,
|
||||
onTap: () {
|
||||
print('Clicked Accueil - Setting index to 0'); // Debug
|
||||
setState(() {
|
||||
_currentIndex = 0;
|
||||
});
|
||||
@@ -60,6 +70,7 @@ class _HomePageState extends State<HomePage> {
|
||||
title: Text("Paramètres"),
|
||||
selected: _currentIndex == 1,
|
||||
onTap: () {
|
||||
print('Clicked Paramètres - Setting index to 1'); // Debug
|
||||
setState(() {
|
||||
_currentIndex = 1;
|
||||
});
|
||||
@@ -67,16 +78,41 @@ class _HomePageState extends State<HomePage> {
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.person),
|
||||
title: Text("Profil"),
|
||||
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),
|
||||
@@ -93,7 +129,7 @@ class _HomePageState extends State<HomePage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
body: _pages[_currentIndex],
|
||||
body: pages[_currentIndex],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/user.dart';
|
||||
import '../services/user_service.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/user_provider.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
@@ -63,6 +65,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||
|
||||
if (user != null) {
|
||||
// Naviguer vers la page d'accueil
|
||||
Provider.of<UserProvider>(context, listen: false).setCurrentUser(user);
|
||||
Navigator.pushReplacementNamed(context, '/home');
|
||||
} else {
|
||||
// Échec de la connexion
|
||||
|
||||
Reference in New Issue
Block a user