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,38 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// [SearchFriends] est un widget permettant à l'utilisateur de rechercher des amis.
|
||||
/// Il inclut un champ de texte stylisé pour saisir la requête de recherche.
|
||||
/// Chaque modification du texte dans le champ génère un log dans le terminal pour suivre en temps réel l'activité.
|
||||
class SearchFriends extends StatelessWidget {
|
||||
const SearchFriends({Key? key}) : super(key: key);
|
||||
import '../../core/constants/env_config.dart';
|
||||
|
||||
/// Widget de recherche d'amis avec design moderne et compact.
|
||||
///
|
||||
/// Ce widget permet à l'utilisateur de rechercher des amis avec un champ
|
||||
/// de texte stylisé et une icône de nettoyage.
|
||||
///
|
||||
/// **Usage:**
|
||||
/// ```dart
|
||||
/// SearchFriends(
|
||||
/// onSearchChanged: (query) => filterFriends(query),
|
||||
/// )
|
||||
/// ```
|
||||
class SearchFriends extends StatefulWidget {
|
||||
const SearchFriends({
|
||||
super.key,
|
||||
this.onSearchChanged,
|
||||
this.hintText = 'Rechercher un ami...',
|
||||
});
|
||||
|
||||
/// Callback appelé lorsque la recherche change
|
||||
final ValueChanged<String>? onSearchChanged;
|
||||
|
||||
/// Texte d'indication
|
||||
final String hintText;
|
||||
|
||||
@override
|
||||
State<SearchFriends> createState() => _SearchFriendsState();
|
||||
}
|
||||
|
||||
class _SearchFriendsState extends State<SearchFriends> {
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return TextField(
|
||||
style: const TextStyle(
|
||||
color: Colors.white, // Le texte saisi est de couleur blanche.
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Rechercher un ami...', // Indication textuelle pour aider l'utilisateur.
|
||||
hintStyle: const TextStyle(
|
||||
color: Colors.white54, // Style de l'indicateur avec une couleur plus claire.
|
||||
),
|
||||
filled: true,
|
||||
fillColor: Colors.grey.shade800, // Couleur de fond du champ de recherche.
|
||||
prefixIcon: const Icon(
|
||||
Icons.search, // Icône de loupe pour indiquer la recherche.
|
||||
color: Colors.white54, // Couleur de l'icône de recherche.
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(30.0), // Bordure arrondie pour un style moderne.
|
||||
borderSide: BorderSide.none, // Aucune bordure visible pour un look propre.
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
// Fonction appelée chaque fois que l'utilisateur modifie le texte dans le champ de recherche.
|
||||
debugPrint('[LOG] Recherche d\'amis : $value'); // Log de chaque saisie.
|
||||
// Vous pouvez ajouter ici la logique de filtrage de la liste des amis en fonction de la recherche.
|
||||
},
|
||||
controller: _controller,
|
||||
decoration: _buildDecoration(theme),
|
||||
style: theme.textTheme.bodyMedium,
|
||||
onChanged: _handleSearchChanged,
|
||||
textInputAction: TextInputAction.search,
|
||||
);
|
||||
}
|
||||
|
||||
/// Construit la décoration du champ de recherche.
|
||||
InputDecoration _buildDecoration(ThemeData theme) {
|
||||
return InputDecoration(
|
||||
hintText: widget.hintText,
|
||||
hintStyle: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.5),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: theme.colorScheme.surfaceVariant.withOpacity(0.5),
|
||||
prefixIcon: Icon(
|
||||
Icons.search,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 20,
|
||||
),
|
||||
suffixIcon: _controller.text.isNotEmpty
|
||||
? IconButton(
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: theme.colorScheme.onSurface.withOpacity(0.6),
|
||||
size: 20,
|
||||
),
|
||||
onPressed: _clearSearch,
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: const BoxConstraints(),
|
||||
)
|
||||
: null,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
);
|
||||
}
|
||||
|
||||
/// Gère le changement de recherche.
|
||||
void _handleSearchChanged(String value) {
|
||||
setState(() {}); // Met à jour l'UI pour afficher/masquer l'icône clear
|
||||
|
||||
if (EnvConfig.enableDetailedLogs) {
|
||||
debugPrint('[SearchFriends] Recherche: $value');
|
||||
}
|
||||
|
||||
widget.onSearchChanged?.call(value);
|
||||
}
|
||||
|
||||
/// Nettoie le champ de recherche.
|
||||
void _clearSearch() {
|
||||
_controller.clear();
|
||||
setState(() {});
|
||||
widget.onSearchChanged?.call('');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user