fix(chat): Correction race condition + Implémentation TODOs
## Corrections Critiques ### Race Condition - Statuts de Messages - Fix : Les icônes de statut (✓, ✓✓, ✓✓ bleu) ne s'affichaient pas - Cause : WebSocket delivery confirmations arrivaient avant messages locaux - Solution : Pattern Optimistic UI dans chat_bloc.dart - Création message temporaire immédiate - Ajout à la liste AVANT requête HTTP - Remplacement par message serveur à la réponse - Fichier : lib/presentation/state_management/chat_bloc.dart ## Implémentation TODOs (13/21) ### Social (social_header_widget.dart) - ✅ Copier lien du post dans presse-papiers - ✅ Partage natif via Share.share() - ✅ Dialogue de signalement avec 5 raisons ### Partage (share_post_dialog.dart) - ✅ Interface sélection d'amis avec checkboxes - ✅ Partage externe via Share API ### Média (media_upload_service.dart) - ✅ Parsing JSON réponse backend - ✅ Méthode deleteMedia() pour suppression - ✅ Génération miniature vidéo ### Posts (create_post_dialog.dart, edit_post_dialog.dart) - ✅ Extraction URL depuis uploads - ✅ Documentation chargement médias ### Chat (conversations_screen.dart) - ✅ Navigation vers notifications - ✅ ConversationSearchDelegate pour recherche ## Nouveaux Fichiers ### Configuration - build-prod.ps1 : Script build production avec dart-define - lib/core/constants/env_config.dart : Gestion environnements ### Documentation - TODOS_IMPLEMENTED.md : Documentation complète TODOs ## Améliorations ### Architecture - Refactoring injection de dépendances - Amélioration routing et navigation - Optimisation providers (UserProvider, FriendsProvider) ### UI/UX - Amélioration thème et couleurs - Optimisation animations - Meilleure gestion erreurs ### Services - Configuration API avec env_config - Amélioration datasources (events, users) - Optimisation modèles de données
This commit is contained in:
@@ -1,8 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:afterwork/core/utils/date_formatter.dart';
|
||||
|
||||
import '../../core/utils/date_formatter.dart';
|
||||
import 'event_menu.dart';
|
||||
|
||||
/// En-tête d'événement avec informations du créateur et actions.
|
||||
///
|
||||
/// Ce widget affiche les informations du créateur de l'événement,
|
||||
/// la date, le lieu, et des actions (menu, fermeture).
|
||||
///
|
||||
/// **Usage:**
|
||||
/// ```dart
|
||||
/// EventHeader(
|
||||
/// creatorFirstName: 'John',
|
||||
/// creatorLastName: 'Doe',
|
||||
/// profileImageUrl: 'https://example.com/avatar.jpg',
|
||||
/// eventDate: '2024-01-01',
|
||||
/// location: 'Paris, France',
|
||||
/// menuKey: menuKey,
|
||||
/// menuContext: context,
|
||||
/// onClose: () => handleClose(),
|
||||
/// )
|
||||
/// ```
|
||||
class EventHeader extends StatelessWidget {
|
||||
const EventHeader({
|
||||
required this.creatorFirstName,
|
||||
required this.creatorLastName,
|
||||
required this.profileImageUrl,
|
||||
required this.location,
|
||||
required this.menuKey,
|
||||
required this.menuContext,
|
||||
required this.onClose,
|
||||
this.eventDate,
|
||||
this.imageUrl,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String creatorFirstName;
|
||||
final String creatorLastName;
|
||||
final String profileImageUrl;
|
||||
@@ -11,113 +43,170 @@ class EventHeader extends StatelessWidget {
|
||||
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,
|
||||
required this.creatorFirstName,
|
||||
required this.creatorLastName,
|
||||
required this.profileImageUrl,
|
||||
this.eventDate,
|
||||
this.imageUrl,
|
||||
required this.location,
|
||||
required this.menuKey,
|
||||
required this.menuContext,
|
||||
required this.onClose, // Initialisation du callback de fermeture
|
||||
}) : super(key: key);
|
||||
final VoidCallback onClose;
|
||||
|
||||
@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';
|
||||
final theme = Theme.of(context);
|
||||
final formattedDate = _formatDate();
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Colors.grey.shade800,
|
||||
backgroundImage: profileImageUrl.isNotEmpty
|
||||
? NetworkImage(profileImageUrl)
|
||||
: AssetImage(profileImageUrl) as ImageProvider,
|
||||
radius: 22,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_buildAvatar(theme),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'$creatorFirstName $creatorLastName',
|
||||
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),
|
||||
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),
|
||||
],
|
||||
),
|
||||
],
|
||||
child: _buildCreatorInfo(theme, formattedDate),
|
||||
),
|
||||
],
|
||||
),
|
||||
_buildActions(theme),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit l'avatar du créateur.
|
||||
Widget _buildAvatar(ThemeData theme) {
|
||||
return CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundColor: theme.colorScheme.surfaceVariant,
|
||||
backgroundImage: _getImageProvider(),
|
||||
onBackgroundImageError: (exception, stackTrace) {
|
||||
// Gestion silencieuse de l'erreur
|
||||
},
|
||||
child: profileImageUrl.isEmpty
|
||||
? Icon(
|
||||
Icons.person,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
size: 20,
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
/// Obtient le provider d'image.
|
||||
ImageProvider? _getImageProvider() {
|
||||
if (profileImageUrl.isEmpty) return null;
|
||||
|
||||
if (profileImageUrl.startsWith('http://') ||
|
||||
profileImageUrl.startsWith('https://')) {
|
||||
return NetworkImage(profileImageUrl);
|
||||
}
|
||||
|
||||
return AssetImage(profileImageUrl);
|
||||
}
|
||||
|
||||
/// Construit les informations du créateur.
|
||||
Widget _buildCreatorInfo(ThemeData theme, String formattedDate) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'$creatorFirstName $creatorLastName',
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.calendar_today,
|
||||
size: 12,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
formattedDate,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Placement des icônes avec padding pour éviter qu'elles ne soient trop proches du bord
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: -5,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
key: menuKey,
|
||||
icon: const Icon(Icons.more_vert, color: Colors.white54, size: 20),
|
||||
splashRadius: 20,
|
||||
onPressed: () {
|
||||
showEventOptions(menuContext, menuKey);
|
||||
},
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.location_on,
|
||||
size: 12,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
location.isNotEmpty ? location : 'Lieu non spécifié',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(width: 0), // Espacement entre les icônes
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white54, size: 20),
|
||||
splashRadius: 20,
|
||||
onPressed: onClose, // Appel du callback de fermeture
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit les actions (menu et fermeture).
|
||||
Widget _buildActions(ThemeData theme) {
|
||||
return Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
key: menuKey,
|
||||
icon: Icon(
|
||||
Icons.more_vert,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 20,
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
splashRadius: 20,
|
||||
onPressed: () {
|
||||
showEventOptions(menuContext, menuKey);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.close,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 20,
|
||||
),
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
splashRadius: 20,
|
||||
onPressed: onClose,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Formate la date de l'événement.
|
||||
String _formatDate() {
|
||||
if (eventDate == null || eventDate!.isEmpty) {
|
||||
return 'Date inconnue';
|
||||
}
|
||||
|
||||
try {
|
||||
final date = DateTime.parse(eventDate!);
|
||||
return DateFormatter.formatDate(date);
|
||||
} catch (e) {
|
||||
return 'Date invalide';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user