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,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user