Bon checkpoint + refactoring
This commit is contained in:
61
lib/presentation/widgets/account_deletion_card.dart
Normal file
61
lib/presentation/widgets/account_deletion_card.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
|
||||
class AccountDeletionCard extends StatelessWidget {
|
||||
final BuildContext context;
|
||||
|
||||
const AccountDeletionCard({Key? key, required this.context}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: AppColors.cardColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 2,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.delete, color: Colors.redAccent),
|
||||
title: const Text(
|
||||
'Supprimer le compte',
|
||||
style: TextStyle(color: Colors.redAccent, fontWeight: FontWeight.bold),
|
||||
),
|
||||
onTap: () => _showDeleteConfirmationDialog(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showDeleteConfirmationDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
title: const Text(
|
||||
'Confirmer la suppression',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
content: const Text(
|
||||
'Êtes-vous sûr de vouloir supprimer votre compte ? Cette action est irréversible.',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text('Annuler', style: TextStyle(color: AppColors.accentColor)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
print("[LOG] Suppression du compte confirmée.");
|
||||
Navigator.of(context).pop();
|
||||
// Logique de suppression du compte
|
||||
},
|
||||
child: const Text(
|
||||
'Supprimer',
|
||||
style: TextStyle(color: Colors.redAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
31
lib/presentation/widgets/custom_list_tile.dart
Normal file
31
lib/presentation/widgets/custom_list_tile.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
|
||||
class CustomListTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const CustomListTile({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.onTap,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
splashColor: Colors.blueAccent.withOpacity(0.2),
|
||||
child: ListTile(
|
||||
leading: Icon(icon, color: AppColors.accentColor),
|
||||
title: Text(
|
||||
label,
|
||||
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
35
lib/presentation/widgets/edit_options_card.dart
Normal file
35
lib/presentation/widgets/edit_options_card.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'custom_list_tile.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
|
||||
class EditOptionsCard extends StatelessWidget {
|
||||
const EditOptionsCard({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: AppColors.cardColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 2,
|
||||
child: Column(
|
||||
children: [
|
||||
CustomListTile(
|
||||
icon: Icons.edit,
|
||||
label: 'Éditer le profil',
|
||||
onTap: () => print("[LOG] Édition du profil."),
|
||||
),
|
||||
CustomListTile(
|
||||
icon: Icons.camera_alt,
|
||||
label: 'Changer la photo de profil',
|
||||
onTap: () => print("[LOG] Changement de la photo de profil."),
|
||||
),
|
||||
CustomListTile(
|
||||
icon: Icons.lock,
|
||||
label: 'Changer le mot de passe',
|
||||
onTap: () => print("[LOG] Changement du mot de passe."),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import 'package:afterwork/core/utils/date_formatter.dart';
|
||||
import 'event_menu.dart';
|
||||
|
||||
class EventHeader extends StatelessWidget {
|
||||
final String userName;
|
||||
final String userFirstName;
|
||||
final String userLastName;
|
||||
final String? eventDate;
|
||||
final String? imageUrl;
|
||||
@@ -14,7 +14,7 @@ class EventHeader extends StatelessWidget {
|
||||
|
||||
const EventHeader({
|
||||
Key? key,
|
||||
required this.userName,
|
||||
required this.userFirstName,
|
||||
required this.userLastName,
|
||||
this.eventDate,
|
||||
this.imageUrl,
|
||||
@@ -51,7 +51,7 @@ class EventHeader extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'$userName $userLastName',
|
||||
'$userFirstName $userLastName',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
|
||||
@@ -18,7 +18,7 @@ class EventList extends StatelessWidget {
|
||||
return EventCard(
|
||||
event: event,
|
||||
userId: 'user_id_here', // Vous pouvez passer l'ID réel de l'utilisateur connecté
|
||||
userName: 'John', // Vous pouvez passer le prénom réel de l'utilisateur
|
||||
userFirstName: 'John', // Vous pouvez passer le prénom réel de l'utilisateur
|
||||
userLastName: 'Doe', // Vous pouvez passer le nom réel de l'utilisateur
|
||||
onReact: () => _handleReact(event),
|
||||
onComment: () => _handleComment(event),
|
||||
|
||||
38
lib/presentation/widgets/expandable_section_card.dart
Normal file
38
lib/presentation/widgets/expandable_section_card.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
|
||||
class ExpandableSectionCard extends StatelessWidget {
|
||||
final String title;
|
||||
final IconData icon;
|
||||
final List<Widget> children;
|
||||
|
||||
const ExpandableSectionCard({
|
||||
Key? key,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
required this.children,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: AppColors.cardColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 2,
|
||||
child: ExpansionTile(
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
leading: Icon(icon, color: AppColors.accentColor),
|
||||
iconColor: AppColors.accentColor,
|
||||
collapsedIconColor: AppColors.accentColor,
|
||||
children: children,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class FriendsCircle extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
// Combine firstName et lastName ou utilise "Ami inconnu" par défaut.
|
||||
String displayName = [friend.firstName, friend.lastName]
|
||||
.where((namePart) => namePart != null && namePart.isNotEmpty)
|
||||
.where((namePart) => namePart.isNotEmpty)
|
||||
.join(" ")
|
||||
.trim();
|
||||
|
||||
|
||||
109
lib/presentation/widgets/profile_header.dart
Normal file
109
lib/presentation/widgets/profile_header.dart
Normal file
@@ -0,0 +1,109 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
import '../../../../data/providers/user_provider.dart';
|
||||
import '../../../../domain/entities/user.dart';
|
||||
|
||||
/// [ProfileHeader] est un widget qui affiche l'en-tête du profil utilisateur.
|
||||
/// Comprend le nom de l'utilisateur, une image de fond, et un bouton de déconnexion avec confirmation.
|
||||
class ProfileHeader extends StatelessWidget {
|
||||
final User user;
|
||||
|
||||
const ProfileHeader({Key? key, required this.user}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverAppBar(
|
||||
expandedHeight: 200.0,
|
||||
floating: false,
|
||||
pinned: true,
|
||||
backgroundColor: AppColors.darkPrimary,
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
title: Text(
|
||||
'Profil de ${user.userFirstName}',
|
||||
style: TextStyle(
|
||||
color: AppColors.accentColor,
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
background: Image.network(
|
||||
user.profileImageUrl,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
// Log en cas d'erreur de chargement de l'image
|
||||
print("[ERROR] Erreur lors du chargement de l'image de profil : $error");
|
||||
return Image.asset('lib/assets/images/default_avatar.png', fit: BoxFit.cover);
|
||||
},
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.logout, color: Colors.white),
|
||||
onPressed: () {
|
||||
print("[LOG] Bouton de déconnexion cliqué."); // Log du clic du bouton de déconnexion
|
||||
_showLogoutConfirmationDialog(context); // Affiche le dialogue de confirmation
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Affiche une boîte de dialogue de confirmation pour la déconnexion.
|
||||
/// Log chaque action et résultat dans le terminal.
|
||||
void _showLogoutConfirmationDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
// Log affichage du dialogue
|
||||
print("[LOG] Affichage de la boîte de dialogue de confirmation de déconnexion.");
|
||||
|
||||
return AlertDialog(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
title: const Text(
|
||||
'Confirmer la déconnexion',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
content: const Text(
|
||||
'Voulez-vous vraiment vous déconnecter ?',
|
||||
style: TextStyle(color: Colors.white70),
|
||||
),
|
||||
actions: [
|
||||
// Bouton d'annulation de la déconnexion
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
print("[LOG] Déconnexion annulée par l'utilisateur.");
|
||||
Navigator.of(context).pop(); // Ferme le dialogue sans déconnecter
|
||||
},
|
||||
child: Text(
|
||||
'Annuler',
|
||||
style: TextStyle(color: AppColors.accentColor),
|
||||
),
|
||||
),
|
||||
// Bouton de confirmation de la déconnexion
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
print("[LOG] Déconnexion confirmée."); // Log de la confirmation
|
||||
Provider.of<UserProvider>(context, listen: false).resetUser(); // Réinitialise les infos utilisateur
|
||||
print("[LOG] Informations utilisateur réinitialisées dans UserProvider.");
|
||||
|
||||
Navigator.of(context).pop(); // Ferme la boîte de dialogue
|
||||
print("[LOG] Boîte de dialogue de confirmation fermée.");
|
||||
|
||||
Navigator.of(context).pushReplacementNamed('/'); // Redirige vers l'écran de connexion
|
||||
print("[LOG] Redirection vers l'écran de connexion.");
|
||||
},
|
||||
child: const Text(
|
||||
'Déconnexion',
|
||||
style: TextStyle(color: Colors.redAccent),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
// Log lorsque le dialogue est fermé pour toute raison (confirmation ou annulation)
|
||||
print("[LOG] La boîte de dialogue de confirmation de déconnexion est fermée.");
|
||||
});
|
||||
}
|
||||
}
|
||||
31
lib/presentation/widgets/stat_tile.dart
Normal file
31
lib/presentation/widgets/stat_tile.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
|
||||
class StatTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final String value;
|
||||
|
||||
const StatTile({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.value,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: Icon(icon, color: AppColors.accentColor),
|
||||
title: Text(label, style: const TextStyle(color: Colors.white)),
|
||||
trailing: Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
40
lib/presentation/widgets/statistics_section_card.dart
Normal file
40
lib/presentation/widgets/statistics_section_card.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
import '../../../../domain/entities/user.dart';
|
||||
import 'stat_tile.dart';
|
||||
|
||||
class StatisticsSectionCard extends StatelessWidget {
|
||||
final User user;
|
||||
|
||||
const StatisticsSectionCard({Key? key, required this.user}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: AppColors.cardColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Statistiques Personnelles',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
StatTile(icon: Icons.event, label: 'Événements Participés', value: '${user.eventsCount}'),
|
||||
StatTile(icon: Icons.place, label: 'Établissements Visités', value: '${user.visitedPlacesCount}'),
|
||||
StatTile(icon: Icons.post_add, label: 'Publications', value: '${user.postsCount}'),
|
||||
StatTile(icon: Icons.group, label: 'Amis/Followers', value: '${user.friendsCount}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
46
lib/presentation/widgets/support_section_card.dart
Normal file
46
lib/presentation/widgets/support_section_card.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
import 'custom_list_tile.dart';
|
||||
|
||||
class SupportSectionCard extends StatelessWidget {
|
||||
const SupportSectionCard({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: AppColors.cardColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 2,
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Text(
|
||||
'Support et Assistance',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
CustomListTile(
|
||||
icon: Icons.help,
|
||||
label: 'Support et Assistance',
|
||||
onTap: () => print("[LOG] Accès au Support et Assistance."),
|
||||
),
|
||||
CustomListTile(
|
||||
icon: Icons.article,
|
||||
label: 'Conditions d\'utilisation',
|
||||
onTap: () => print("[LOG] Accès aux conditions d'utilisation."),
|
||||
),
|
||||
CustomListTile(
|
||||
icon: Icons.privacy_tip,
|
||||
label: 'Politique de confidentialité',
|
||||
onTap: () => print("[LOG] Accès à la politique de confidentialité."),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
49
lib/presentation/widgets/user_info_card.dart
Normal file
49
lib/presentation/widgets/user_info_card.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../core/constants/colors.dart';
|
||||
import '../../../../domain/entities/user.dart';
|
||||
|
||||
class UserInfoCard extends StatelessWidget {
|
||||
final User user;
|
||||
|
||||
const UserInfoCard({Key? key, required this.user}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: AppColors.cardColor,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 50,
|
||||
backgroundImage: NetworkImage(user.profileImageUrl),
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
'${user.userFirstName} ${user.userLastName}',
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
letterSpacing: 1.2,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
user.email,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[600],
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user