Refactoring + Checkpoint
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/constants/colors.dart'; // Importez les couleurs dynamiques
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../core/constants/colors.dart';
|
||||
import '../../../core/theme/theme_provider.dart';
|
||||
import '../../widgets/friend_suggestions.dart';
|
||||
import '../../widgets/group_list.dart';
|
||||
import '../../widgets/popular_activity_list.dart';
|
||||
@@ -7,45 +9,52 @@ import '../../widgets/recommended_event_list.dart';
|
||||
import '../../widgets/section_header.dart';
|
||||
import '../../widgets/story_section.dart';
|
||||
|
||||
/// Écran principal du contenu d'accueil, affichant diverses sections telles que
|
||||
/// les suggestions d'amis, les activités populaires, les groupes, etc.
|
||||
/// Les couleurs s'adaptent dynamiquement au thème sélectionné (clair ou sombre).
|
||||
class HomeContentScreen extends StatelessWidget {
|
||||
const HomeContentScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Récupération du fournisseur de thème pour appliquer le mode jour/nuit
|
||||
final themeProvider = Provider.of<ThemeProvider>(context);
|
||||
// Obtention des dimensions de l'écran pour adapter la mise en page
|
||||
final size = MediaQuery.of(context).size;
|
||||
print("Chargement de HomeContentScreen avec le thème actuel");
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 15.0), // Marges réduites
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 15.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Section de bienvenue
|
||||
_buildWelcomeCard(),
|
||||
// Carte de bienvenue avec couleurs dynamiques
|
||||
_buildWelcomeCard(themeProvider),
|
||||
const SizedBox(height: 15), // Espacement entre les sections
|
||||
|
||||
const SizedBox(height: 15), // Espacement vertical réduit
|
||||
|
||||
// Section "Moments populaires"
|
||||
// Section des "Moments populaires"
|
||||
_buildCard(
|
||||
context: context,
|
||||
themeProvider: themeProvider, // Fournit le thème
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SectionHeader(
|
||||
title: 'Moments populaires',
|
||||
icon: Icons.camera_alt,
|
||||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500), // Taille ajustée
|
||||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 10), // Espace vertical réduit
|
||||
const SizedBox(height: 10),
|
||||
StorySection(size: size),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
const SizedBox(height: 15), // Espacement réduit
|
||||
|
||||
// Section des événements recommandés
|
||||
// Section des "Événements recommandés"
|
||||
_buildCard(
|
||||
context: context,
|
||||
themeProvider: themeProvider,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -54,17 +63,17 @@ class HomeContentScreen extends StatelessWidget {
|
||||
icon: Icons.star,
|
||||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 10), // Espacement réduit
|
||||
const SizedBox(height: 10),
|
||||
RecommendedEventList(size: size),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
const SizedBox(height: 15), // Espacement réduit
|
||||
|
||||
// Section des activités populaires
|
||||
// Section des "Activités populaires"
|
||||
_buildCard(
|
||||
context: context,
|
||||
themeProvider: themeProvider,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -73,17 +82,17 @@ class HomeContentScreen extends StatelessWidget {
|
||||
icon: Icons.local_activity,
|
||||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 10), // Espacement réduit
|
||||
const SizedBox(height: 10),
|
||||
PopularActivityList(size: size),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
const SizedBox(height: 15), // Espacement réduit
|
||||
|
||||
// Section des groupes sociaux
|
||||
// Section "Groupes à rejoindre"
|
||||
_buildCard(
|
||||
context: context,
|
||||
themeProvider: themeProvider,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -92,17 +101,17 @@ class HomeContentScreen extends StatelessWidget {
|
||||
icon: Icons.group_add,
|
||||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 10), // Espacement réduit
|
||||
const SizedBox(height: 10),
|
||||
GroupList(size: size),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
|
||||
const SizedBox(height: 15), // Espacement réduit
|
||||
|
||||
// Section des suggestions d'amis
|
||||
// Section des "Suggestions d'amis"
|
||||
_buildCard(
|
||||
context: context,
|
||||
themeProvider: themeProvider,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -111,7 +120,7 @@ class HomeContentScreen extends StatelessWidget {
|
||||
icon: Icons.person_add,
|
||||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||||
),
|
||||
const SizedBox(height: 10), // Espacement réduit
|
||||
const SizedBox(height: 10),
|
||||
FriendSuggestions(size: size),
|
||||
],
|
||||
),
|
||||
@@ -121,11 +130,13 @@ class HomeContentScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// Widget pour la carte de bienvenue
|
||||
Widget _buildWelcomeCard() {
|
||||
/// Crée la carte de bienvenue, en utilisant les couleurs dynamiques en fonction du thème sélectionné.
|
||||
/// [themeProvider] fournit l'état actuel du thème pour adapter les couleurs.
|
||||
Widget _buildWelcomeCard(ThemeProvider themeProvider) {
|
||||
print("Création de la carte de bienvenue avec le thème actuel");
|
||||
return Card(
|
||||
elevation: 5,
|
||||
color: AppColors.surface, // Utilisation de la couleur dynamique pour la surface
|
||||
color: themeProvider.isDarkMode ? AppColors.darkSurface : AppColors.lightSurface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -135,26 +146,32 @@ class HomeContentScreen extends StatelessWidget {
|
||||
Text(
|
||||
'Bienvenue, Dahoud!',
|
||||
style: TextStyle(
|
||||
color: AppColors.textPrimary, // Texte dynamique
|
||||
fontSize: 22, // Taille de police réduite
|
||||
fontWeight: FontWeight.w600, // Poids de police ajusté
|
||||
color: themeProvider.isDarkMode ? AppColors.darkOnPrimary : AppColors.lightPrimary,
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
Icon(Icons.waving_hand, color: Colors.orange.shade300, size: 24), // Taille de l'icône ajustée
|
||||
Icon(Icons.waving_hand, color: Colors.orange.shade300, size: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Widget générique pour créer une carte design avec des espaces optimisés
|
||||
Widget _buildCard({required BuildContext context, required Widget child}) {
|
||||
/// Crée une carte générique pour afficher des sections avec un style uniforme.
|
||||
/// [themeProvider] est utilisé pour ajuster les couleurs de la carte selon le mode jour/nuit.
|
||||
Widget _buildCard({
|
||||
required BuildContext context,
|
||||
required ThemeProvider themeProvider,
|
||||
required Widget child,
|
||||
}) {
|
||||
print("Création d'une carte de section avec le thème actuel");
|
||||
return Card(
|
||||
elevation: 3, // Réduction de l'élévation pour un look plus épuré
|
||||
color: AppColors.surface, // Utilisation de la couleur dynamique pour la surface
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), // Coins légèrement arrondis
|
||||
elevation: 3,
|
||||
color: themeProvider.isDarkMode ? AppColors.darkSurface : AppColors.lightSurface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0), // Padding interne réduit pour un contenu plus compact
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart'; // Pour ThemeProvider
|
||||
import 'package:provider/provider.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';
|
||||
import 'package:afterwork/presentation/screens/notifications/notifications_screen.dart'; // Écran de notifications
|
||||
import 'package:afterwork/presentation/screens/notifications/notifications_screen.dart';
|
||||
import '../../../core/constants/colors.dart';
|
||||
import '../../../core/theme/theme_provider.dart';
|
||||
import '../friends/friends_screen.dart'; // Écran des amis
|
||||
import '../friends/friends_screen.dart';
|
||||
|
||||
class HomeScreen extends StatefulWidget {
|
||||
final EventRemoteDataSource eventRemoteDataSource;
|
||||
final String userId;
|
||||
final String userFirstName;
|
||||
final String userLastName;
|
||||
final String userProfileImage; // Image de profil de l'utilisateur
|
||||
final String userProfileImage;
|
||||
|
||||
const HomeScreen({
|
||||
Key? key,
|
||||
@@ -24,7 +24,7 @@ class HomeScreen extends StatefulWidget {
|
||||
required this.userId,
|
||||
required this.userFirstName,
|
||||
required this.userLastName,
|
||||
required this.userProfileImage, // Passer l'image de profil ici
|
||||
required this.userProfileImage,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -37,7 +37,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 6, vsync: this); // Ajouter un onglet pour les notifications
|
||||
_tabController = TabController(length: 6, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -47,51 +47,40 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
}
|
||||
|
||||
void _onMenuSelected(BuildContext context, String option) {
|
||||
switch (option) {
|
||||
case 'Publier':
|
||||
print('Publier sélectionné');
|
||||
break;
|
||||
case 'Story':
|
||||
print('Story sélectionné');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
print('$option sélectionné'); // Log pour chaque option
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Accès au ThemeProvider
|
||||
final themeProvider = Provider.of<ThemeProvider>(context);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
body: NestedScrollView(
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
return <Widget>[
|
||||
SliverAppBar(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
floating: true,
|
||||
pinned: true,
|
||||
snap: true,
|
||||
elevation: 2,
|
||||
backgroundColor: themeProvider.currentTheme.primaryColor,
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.all(4.0), // Ajustement du padding
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Image.asset(
|
||||
'lib/assets/images/logo.png',
|
||||
height: 40, // Taille ajustée du logo
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
_buildActionIcon(Icons.add, 'Publier', context),
|
||||
_buildActionIcon(Icons.search, 'Rechercher', context),
|
||||
_buildActionIcon(Icons.message, 'Message', context),
|
||||
_buildNotificationsIcon(context, 5), // Gérer la logique des notifications ici
|
||||
|
||||
// Bouton pour basculer entre les thèmes
|
||||
_buildNotificationsIcon(context, 105),
|
||||
Switch(
|
||||
value: themeProvider.isDarkMode,
|
||||
onChanged: (value) {
|
||||
themeProvider.toggleTheme(); // Changer le thème
|
||||
themeProvider.toggleTheme();
|
||||
},
|
||||
activeColor: AppColors.accentColor,
|
||||
),
|
||||
@@ -99,23 +88,17 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
indicatorColor: AppColors.lightPrimary,
|
||||
labelStyle: const TextStyle(
|
||||
fontSize: 12, // Taille réduite du texte
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
unselectedLabelStyle: const TextStyle(
|
||||
fontSize: 11, // Taille ajustée pour les onglets non sélectionnés
|
||||
),
|
||||
labelColor: AppColors.lightPrimary,
|
||||
unselectedLabelColor: AppColors.iconSecondary,
|
||||
|
||||
labelStyle: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
|
||||
unselectedLabelStyle: const TextStyle(fontSize: 11),
|
||||
labelColor: themeProvider.isDarkMode ? AppColors.darkOnPrimary : AppColors.lightOnPrimary,
|
||||
unselectedLabelColor: themeProvider.isDarkMode ? AppColors.darkIconSecondary : AppColors.lightIconSecondary,
|
||||
tabs: [
|
||||
const Tab(icon: Icon(Icons.home, size: 24), text: 'Accueil'),
|
||||
const Tab(icon: Icon(Icons.event, size: 24), text: 'Événements'),
|
||||
const Tab(icon: Icon(Icons.location_city, size: 24), text: 'Établissements'),
|
||||
const Tab(icon: Icon(Icons.people, size: 24), text: 'Social'),
|
||||
const Tab(icon: Icon(Icons.people_alt_outlined, size: 24), text: 'Ami(e)s'),
|
||||
_buildProfileTab(), // Onglet profil
|
||||
_buildProfileTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -129,10 +112,11 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
userId: widget.userId,
|
||||
userFirstName: widget.userFirstName,
|
||||
userLastName: widget.userLastName,
|
||||
profileImageUrl: widget.userProfileImage,
|
||||
),
|
||||
const EstablishmentsScreen(),
|
||||
const SocialScreen(),
|
||||
FriendsScreen(userId: widget.userId), // Correction ici : passer l'userId
|
||||
FriendsScreen(userId: widget.userId),
|
||||
const ProfileScreen(),
|
||||
],
|
||||
),
|
||||
@@ -140,20 +124,19 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
);
|
||||
}
|
||||
|
||||
// Widget pour l'affichage de la photo de profil dans l'onglet
|
||||
Tab _buildProfileTab() {
|
||||
return Tab(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.blue,
|
||||
color: AppColors.secondary,
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
child: CircleAvatar(
|
||||
radius: 16,
|
||||
backgroundColor: Colors.grey[200], // Couleur de fond par défaut
|
||||
backgroundColor: AppColors.surface,
|
||||
child: ClipOval(
|
||||
child: FadeInImage.assetNetwork(
|
||||
placeholder: 'lib/assets/images/user_placeholder.png',
|
||||
@@ -169,18 +152,17 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
);
|
||||
}
|
||||
|
||||
// Icône pour les notifications avec un badge
|
||||
Widget _buildNotificationsIcon(BuildContext context, int notificationCount) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none, // Permet d'afficher le badge en dehors des limites
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: AppColors.surface,
|
||||
radius: 18,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.notifications, color: AppColors.darkOnPrimary, size: 20),
|
||||
icon: Icon(Icons.notifications, color: AppColors.iconPrimary, size: 20),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
@@ -197,21 +179,17 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
top: -6,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: const BoxDecoration(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 18,
|
||||
minHeight: 18,
|
||||
),
|
||||
child: Text(
|
||||
notificationCount > 99 ? '99+' : '$notificationCount',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
@@ -221,7 +199,6 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
);
|
||||
}
|
||||
|
||||
// Icône d'action générique
|
||||
Widget _buildActionIcon(IconData iconData, String label, BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0),
|
||||
@@ -229,7 +206,7 @@ class _HomeScreenState extends State<HomeScreen> with SingleTickerProviderStateM
|
||||
backgroundColor: AppColors.surface,
|
||||
radius: 18,
|
||||
child: IconButton(
|
||||
icon: Icon(iconData, color: AppColors.darkOnPrimary, size: 20),
|
||||
icon: Icon(iconData, color: AppColors.iconPrimary, size: 20),
|
||||
onPressed: () {
|
||||
_onMenuSelected(context, label);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user