Files
afterwork/lib/presentation/widgets/search_friends.dart
dahoud 92612abbd7 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
2026-01-10 10:43:17 +00:00

107 lines
2.9 KiB
Dart

import 'package:flutter/material.dart';
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(
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('');
}
}