Files
afterwork/lib/presentation/widgets/event_header.dart
2024-09-25 21:28:04 +00:00

102 lines
3.0 KiB
Dart

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 {
final String userName;
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 GlobalKey menuKey;
final BuildContext menuContext;
const EventHeader({
Key? key,
required this.userName,
required this.userLastName,
this.eventDate,
this.imageUrl,
required this.location, // Initialisation de "location"
required this.menuKey,
required this.menuContext,
}) : super(key: key);
@override
Widget build(BuildContext context) {
DateTime? date;
try {
date = DateTime.parse(eventDate ?? '');
} catch (e) {
date = null;
}
String formattedDate = date != null ? DateFormatter.formatDate(date) : 'Date inconnue';
return 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: [
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(
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),
],
),
],
),
),
IconButton(
key: menuKey,
icon: const Icon(Icons.more_vert, color: Colors.white54, size: 20),
splashRadius: 20,
onPressed: () {
showEventOptions(menuContext, menuKey);
},
),
],
);
}
}