refactoring
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:afterwork/core/utils/date_formatter.dart';
|
||||
import 'event_status_badge.dart';
|
||||
import 'event_menu.dart';
|
||||
|
||||
class EventHeader extends StatelessWidget {
|
||||
@@ -8,9 +7,10 @@ class EventHeader extends StatelessWidget {
|
||||
final String userLastName;
|
||||
final String? eventDate;
|
||||
final String? imageUrl;
|
||||
final String location; // Ajout du paramètre "location" pour le lieu de l'événement
|
||||
final String location;
|
||||
final GlobalKey menuKey;
|
||||
final BuildContext menuContext;
|
||||
final VoidCallback onClose; // Ajout d'un callback pour l'action de fermeture
|
||||
|
||||
const EventHeader({
|
||||
Key? key,
|
||||
@@ -18,9 +18,10 @@ class EventHeader extends StatelessWidget {
|
||||
required this.userLastName,
|
||||
this.eventDate,
|
||||
this.imageUrl,
|
||||
required this.location, // Initialisation de "location"
|
||||
required this.location,
|
||||
required this.menuKey,
|
||||
required this.menuContext,
|
||||
required this.onClose, // Initialisation du callback de fermeture
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -33,68 +34,85 @@ class EventHeader extends StatelessWidget {
|
||||
}
|
||||
String formattedDate = date != null ? DateFormatter.formatDate(date) : 'Date inconnue';
|
||||
|
||||
return Row(
|
||||
return Stack(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.grey.shade800,
|
||||
backgroundImage: imageUrl != null && imageUrl!.isNotEmpty
|
||||
? NetworkImage(imageUrl!)
|
||||
: const AssetImage('lib/assets/images/placeholder.png') as ImageProvider,
|
||||
radius: 22,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'$userName $userLastName',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
formattedDate,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
// Utilisation de Row pour afficher le lieu sur la même ligne
|
||||
Row(
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.grey.shade800,
|
||||
backgroundImage: imageUrl != null && imageUrl!.isNotEmpty
|
||||
? NetworkImage(imageUrl!)
|
||||
: const AssetImage('lib/assets/images/placeholder.png') as ImageProvider,
|
||||
radius: 22,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
location.isNotEmpty ? location : 'Lieu non spécifié',
|
||||
style: const TextStyle(
|
||||
color: Colors.white60,
|
||||
fontSize: 12,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
Text(
|
||||
'$userName $userLastName',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
formattedDate,
|
||||
style: const TextStyle(
|
||||
color: Colors.white54,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
location.isNotEmpty ? location : 'Lieu non spécifié',
|
||||
style: const TextStyle(
|
||||
color: Colors.white60,
|
||||
fontSize: 12,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Ajout des boutons dans le coin supérieur droit
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
key: menuKey,
|
||||
icon: const Icon(Icons.more_vert, color: Colors.white54, size: 20),
|
||||
splashRadius: 20,
|
||||
onPressed: () {
|
||||
showEventOptions(menuContext, menuKey);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white54, size: 20),
|
||||
splashRadius: 20,
|
||||
onPressed: onClose, // Appel du callback de fermeture
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
key: menuKey,
|
||||
icon: const Icon(Icons.more_vert, color: Colors.white54, size: 20),
|
||||
splashRadius: 20,
|
||||
onPressed: () {
|
||||
showEventOptions(menuContext, menuKey);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user