180 lines
6.5 KiB
Dart
180 lines
6.5 KiB
Dart
import 'package:flutter/material.dart';
|
||
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';
|
||
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),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
// Carte de bienvenue avec couleurs dynamiques
|
||
_buildWelcomeCard(themeProvider),
|
||
const SizedBox(height: 15), // Espacement entre les sections
|
||
|
||
// 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),
|
||
),
|
||
const SizedBox(height: 10),
|
||
StorySection(size: size),
|
||
],
|
||
),
|
||
),
|
||
const SizedBox(height: 15),
|
||
|
||
// Section des "Événements recommandés"
|
||
_buildCard(
|
||
context: context,
|
||
themeProvider: themeProvider,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const SectionHeader(
|
||
title: 'Événements recommandés',
|
||
icon: Icons.star,
|
||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||
),
|
||
const SizedBox(height: 10),
|
||
RecommendedEventList(size: size),
|
||
],
|
||
),
|
||
),
|
||
const SizedBox(height: 15),
|
||
|
||
// Section des "Activités populaires"
|
||
_buildCard(
|
||
context: context,
|
||
themeProvider: themeProvider,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const SectionHeader(
|
||
title: 'Activités populaires',
|
||
icon: Icons.local_activity,
|
||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||
),
|
||
const SizedBox(height: 10),
|
||
PopularActivityList(size: size),
|
||
],
|
||
),
|
||
),
|
||
const SizedBox(height: 15),
|
||
|
||
// Section "Groupes à rejoindre"
|
||
_buildCard(
|
||
context: context,
|
||
themeProvider: themeProvider,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const SectionHeader(
|
||
title: 'Groupes à rejoindre',
|
||
icon: Icons.group_add,
|
||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||
),
|
||
const SizedBox(height: 10),
|
||
GroupList(size: size),
|
||
],
|
||
),
|
||
),
|
||
const SizedBox(height: 15),
|
||
|
||
// Section des "Suggestions d'amis"
|
||
_buildCard(
|
||
context: context,
|
||
themeProvider: themeProvider,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const SectionHeader(
|
||
title: 'Suggestions d’amis',
|
||
icon: Icons.person_add,
|
||
textStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
||
),
|
||
const SizedBox(height: 10),
|
||
FriendSuggestions(size: size),
|
||
],
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
/// 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: themeProvider.isDarkMode ? AppColors.darkSurface : AppColors.lightSurface,
|
||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(16.0),
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Text(
|
||
'Bienvenue, Dahoud!',
|
||
style: TextStyle(
|
||
color: themeProvider.isDarkMode ? AppColors.darkOnPrimary : AppColors.lightPrimary,
|
||
fontSize: 22,
|
||
fontWeight: FontWeight.w600,
|
||
),
|
||
),
|
||
Icon(Icons.waving_hand, color: Colors.orange.shade300, size: 24),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
/// 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,
|
||
color: themeProvider.isDarkMode ? AppColors.darkSurface : AppColors.lightSurface,
|
||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(12.0),
|
||
child: child,
|
||
),
|
||
);
|
||
}
|
||
}
|