171 lines
6.1 KiB
Dart
171 lines
6.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:afterwork/presentation/screens/event/event_screen.dart';
|
|
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 {
|
|
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();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateMixin {
|
|
late TabController _tabController;
|
|
|
|
@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) {
|
|
switch (option) {
|
|
case 'Publier':
|
|
debugPrint('Option "Publier" sélectionnée');
|
|
// Rediriger vers la page de publication.
|
|
break;
|
|
case '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;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: 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 votre logo.
|
|
height: 40,
|
|
),
|
|
),
|
|
actions: [
|
|
// Bouton pour ajouter du contenu (Publier, Story).
|
|
CircleAvatar(
|
|
backgroundColor: Colors.white,
|
|
radius: 18,
|
|
child: PopupMenuButton<String>(
|
|
onSelected: (value) {
|
|
_onMenuSelected(context, value);
|
|
debugPrint('Menu contextuel sélectionné: $value');
|
|
},
|
|
itemBuilder: (context) => [
|
|
const PopupMenuItem(
|
|
value: 'Publier',
|
|
child: Text('Publier'),
|
|
),
|
|
const PopupMenuItem(
|
|
value: 'Story',
|
|
child: Text('Story'),
|
|
),
|
|
],
|
|
icon: const Icon(Icons.add, color: Colors.blueAccent, size: 20),
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(width: 8), // Espacement entre les boutons.
|
|
|
|
// Bouton Recherche.
|
|
CircleAvatar(
|
|
backgroundColor: Colors.white,
|
|
radius: 18,
|
|
child: IconButton(
|
|
icon: const Icon(Icons.search, color: Colors.blueAccent, size: 20),
|
|
onPressed: () {
|
|
debugPrint('Bouton Recherche appuyé');
|
|
// Implémenter la logique de recherche ici.
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(width: 8), // Espacement entre les boutons.
|
|
|
|
// Bouton Messagerie.
|
|
CircleAvatar(
|
|
backgroundColor: Colors.white,
|
|
radius: 18,
|
|
child: IconButton(
|
|
icon: const Icon(Icons.message, color: Colors.blueAccent, size: 20),
|
|
onPressed: () {
|
|
debugPrint('Bouton Messagerie appuyé');
|
|
// Implémenter la logique de messagerie ici.
|
|
},
|
|
),
|
|
),
|
|
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'),
|
|
Tab(icon: Icon(Icons.location_city), text: 'Établissements'),
|
|
Tab(icon: Icon(Icons.people), text: 'Social'),
|
|
Tab(icon: Icon(Icons.person), text: 'Profil'),
|
|
],
|
|
),
|
|
),
|
|
body: TabBarView(
|
|
controller: _tabController,
|
|
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.
|
|
);
|
|
}
|
|
}
|