refactoring
This commit is contained in:
@@ -4,9 +4,26 @@ import 'package:afterwork/presentation/screens/profile/profile_screen.dart';
|
||||
import 'package:afterwork/presentation/screens/social/social_screen.dart';
|
||||
import 'package:afterwork/presentation/screens/establishments/establishments_screen.dart';
|
||||
import 'package:afterwork/presentation/screens/home/home_content.dart';
|
||||
import 'package:afterwork/data/datasources/event_remote_data_source.dart';
|
||||
|
||||
/// Classe principale pour l'écran d'accueil de l'application.
|
||||
/// Cette classe gère la navigation entre les différentes sections de l'application
|
||||
/// en utilisant un [TabController] pour contrôler les différents onglets.
|
||||
/// Les actions de l'AppBar sont également personnalisées pour offrir des fonctionnalités
|
||||
/// spécifiques comme la recherche, la publication et la messagerie.
|
||||
class HomeScreen extends StatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
final EventRemoteDataSource eventRemoteDataSource;
|
||||
final String userId;
|
||||
final String userName;
|
||||
final String userLastName;
|
||||
|
||||
const HomeScreen({
|
||||
Key? key,
|
||||
required this.eventRemoteDataSource,
|
||||
required this.userId,
|
||||
required this.userName,
|
||||
required this.userLastName,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HomeScreenState createState() => _HomeScreenState();
|
||||
@@ -18,25 +35,32 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Initialisation du TabController avec 5 onglets.
|
||||
_tabController = TabController(length: 5, vsync: this);
|
||||
debugPrint('HomeScreen initialisé avec userId: ${widget.userId}, userName: ${widget.userName}, userLastName: ${widget.userLastName}');
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Nettoyage du TabController pour éviter les fuites de mémoire.
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
debugPrint('HomeScreen dispose appelé');
|
||||
}
|
||||
|
||||
/// Gestion des sélections dans le menu contextuel de l'AppBar.
|
||||
void _onMenuSelected(BuildContext context, String option) {
|
||||
// Implémente la logique pour chaque option ici
|
||||
switch (option) {
|
||||
case 'Publier':
|
||||
// Redirige vers la page de publication
|
||||
debugPrint('Option "Publier" sélectionnée');
|
||||
// Rediriger vers la page de publication.
|
||||
break;
|
||||
case 'Story':
|
||||
// Redirige vers la page de création de Story
|
||||
debugPrint('Option "Story" sélectionnée');
|
||||
// Rediriger vers la page de création de Story.
|
||||
break;
|
||||
default:
|
||||
debugPrint('Option inconnue sélectionnée: $option');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -45,22 +69,25 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.black, // Fond noir pour l'AppBar
|
||||
elevation: 0, // Enlève l'ombre sous l'AppBar
|
||||
backgroundColor: Colors.black,
|
||||
elevation: 0,
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Image.asset(
|
||||
'lib/assets/images/logo.png', // Chemin correct de ton logo
|
||||
'lib/assets/images/logo.png', // Chemin correct de votre logo.
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
// Bouton +
|
||||
// Bouton pour ajouter du contenu (Publier, Story).
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.white, // Cercle blanc
|
||||
radius: 18, // Réduit la taille du bouton
|
||||
backgroundColor: Colors.white,
|
||||
radius: 18,
|
||||
child: PopupMenuButton<String>(
|
||||
onSelected: (value) => _onMenuSelected(context, value),
|
||||
onSelected: (value) {
|
||||
_onMenuSelected(context, value);
|
||||
debugPrint('Menu contextuel sélectionné: $value');
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
const PopupMenuItem(
|
||||
value: 'Publier',
|
||||
@@ -71,39 +98,48 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
child: Text('Story'),
|
||||
),
|
||||
],
|
||||
icon: const Icon(Icons.add, color: Colors.blueAccent, size: 20), // Icône bleue légèrement plus petite
|
||||
color: Colors.white, // Menu contextuel en blanc
|
||||
icon: const Icon(Icons.add, color: Colors.blueAccent, size: 20),
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8), // Réduit l'espacement entre les boutons
|
||||
// Bouton Recherche
|
||||
const SizedBox(width: 8), // Espacement entre les boutons.
|
||||
|
||||
// Bouton Recherche.
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
radius: 18, // Réduit la taille du bouton
|
||||
radius: 18,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.search, color: Colors.blueAccent, size: 20), // Icône bleue légèrement plus petite
|
||||
icon: const Icon(Icons.search, color: Colors.blueAccent, size: 20),
|
||||
onPressed: () {
|
||||
// Implémente la logique de recherche ici
|
||||
debugPrint('Bouton Recherche appuyé');
|
||||
// Implémenter la logique de recherche ici.
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8), // Réduit l'espacement entre les boutons
|
||||
// Bouton Messagerie
|
||||
const SizedBox(width: 8), // Espacement entre les boutons.
|
||||
|
||||
// Bouton Messagerie.
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
radius: 18, // Réduit la taille du bouton
|
||||
radius: 18,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.message, color: Colors.blueAccent, size: 20), // Icône bleue légèrement plus petite
|
||||
icon: const Icon(Icons.message, color: Colors.blueAccent, size: 20),
|
||||
onPressed: () {
|
||||
// Implémente la logique de messagerie ici
|
||||
debugPrint('Bouton Messagerie appuyé');
|
||||
// Implémenter la logique de messagerie ici.
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8), // Réduit l'espacement entre les boutons
|
||||
const SizedBox(width: 8), // Espacement entre les boutons.
|
||||
],
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
indicatorColor: Colors.blueAccent,
|
||||
labelColor: Colors.white, // Couleur du texte sélectionné.
|
||||
unselectedLabelColor: Colors.grey[400], // Couleur du texte non sélectionné.
|
||||
onTap: (index) {
|
||||
debugPrint('Onglet sélectionné: $index');
|
||||
},
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.home), text: 'Accueil'),
|
||||
Tab(icon: Icon(Icons.event), text: 'Événements'),
|
||||
@@ -115,15 +151,20 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: const [
|
||||
HomeContentScreen(), // Contenu de l'accueil
|
||||
EventScreen(), // Écran des événements
|
||||
EstablishmentsScreen(), // Écran des établissements
|
||||
SocialScreen(), // Écran social
|
||||
ProfileScreen(), // Écran du profil
|
||||
children: [
|
||||
const HomeContentScreen(), // Contenu de l'accueil.
|
||||
EventScreen(
|
||||
eventRemoteDataSource: widget.eventRemoteDataSource,
|
||||
userId: widget.userId,
|
||||
userName: widget.userName,
|
||||
userLastName: widget.userLastName,
|
||||
), // Écran des événements.
|
||||
const EstablishmentsScreen(), // Écran des établissements.
|
||||
const SocialScreen(), // Écran social.
|
||||
const ProfileScreen(), // Écran du profil.
|
||||
],
|
||||
),
|
||||
backgroundColor: Colors.black, // Arrière-plan de l'écran en noir
|
||||
backgroundColor: Colors.black, // Arrière-plan de l'écran en noir.
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user