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:
128
lib/presentation/widgets/friend_suggestion_card.dart
Normal file
128
lib/presentation/widgets/friend_suggestion_card.dart
Normal file
@@ -0,0 +1,128 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/models/friend_suggestion_model.dart';
|
||||
|
||||
/// Widget réutilisable pour afficher une suggestion d'ami.
|
||||
///
|
||||
/// Ce widget affiche les informations d'un utilisateur suggéré avec
|
||||
/// un bouton pour envoyer une demande d'ami.
|
||||
///
|
||||
/// **Principe DRY :** Ce widget est réutilisable dans n'importe quelle
|
||||
/// partie de l'application nécessitant d'afficher des suggestions.
|
||||
class FriendSuggestionCard extends StatelessWidget {
|
||||
const FriendSuggestionCard({
|
||||
required this.suggestion,
|
||||
required this.onAddFriend,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// La suggestion d'ami à afficher
|
||||
final Map<String, dynamic> suggestion;
|
||||
|
||||
/// Callback appelé quand l'utilisateur veut ajouter cet ami
|
||||
final VoidCallback onAddFriend;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
// Parse la suggestion depuis le JSON
|
||||
final suggestionModel = FriendSuggestionModel.fromJson(suggestion);
|
||||
|
||||
// Obtenir l'initiale pour l'avatar
|
||||
final initial = suggestionModel.fullName.isNotEmpty
|
||||
? suggestionModel.fullName[0].toUpperCase()
|
||||
: '?';
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Row(
|
||||
children: [
|
||||
// Avatar avec image de profil ou initiale
|
||||
CircleAvatar(
|
||||
radius: 24,
|
||||
backgroundColor: theme.colorScheme.primaryContainer,
|
||||
backgroundImage: suggestionModel.profileImageUrl.isNotEmpty &&
|
||||
suggestionModel.profileImageUrl.startsWith('http')
|
||||
? NetworkImage(suggestionModel.profileImageUrl)
|
||||
: null,
|
||||
child: suggestionModel.profileImageUrl.isEmpty ||
|
||||
!suggestionModel.profileImageUrl.startsWith('http')
|
||||
? Text(
|
||||
initial,
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onPrimaryContainer,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
||||
// Informations de la suggestion
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Nom complet
|
||||
Text(
|
||||
suggestionModel.fullName,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
|
||||
// Raison de la suggestion
|
||||
Text(
|
||||
suggestionModel.suggestionReason,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Bouton d'ajout
|
||||
_buildAddButton(theme),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit le bouton pour ajouter l'ami suggéré
|
||||
Widget _buildAddButton(ThemeData theme) {
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: onAddFriend,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.person_add_rounded,
|
||||
color: theme.colorScheme.primary,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user