Files
afterwork/lib/presentation/widgets/date_picker.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

155 lines
4.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../../core/utils/date_formatter.dart';
/// Champ de sélection de date avec design moderne et support du thème.
///
/// Ce widget fournit un champ de sélection de date cohérent avec le design system,
/// utilisant automatiquement les couleurs du thème actif.
///
/// **Usage:**
/// ```dart
/// DatePickerField(
/// label: 'Date de début',
/// selectedDate: selectedDate,
/// onDatePicked: (date) {
/// setState(() => selectedDate = date);
/// },
/// )
/// ```
class DatePickerField extends StatelessWidget {
/// Crée un nouveau [DatePickerField].
///
/// [onDatePicked] La fonction appelée lorsqu'une date est sélectionnée
/// [selectedDate] La date actuellement sélectionnée (optionnel)
/// [label] Le texte du label (par défaut: 'Sélectionnez une date')
/// [firstDate] La première date sélectionnable (par défaut: aujourd'hui)
/// [lastDate] La dernière date sélectionnable (par défaut: 2101)
/// [initialDate] La date initiale affichée (par défaut: aujourd'hui ou selectedDate)
/// [helpText] Texte d'aide affiché dans le picker (optionnel)
const DatePickerField({
required this.onDatePicked,
super.key,
this.selectedDate,
this.label = 'Sélectionnez une date',
this.firstDate,
this.lastDate,
this.initialDate,
this.helpText,
});
/// La date actuellement sélectionnée
final DateTime? selectedDate;
/// La fonction appelée lorsqu'une date est sélectionnée
final Function(DateTime) onDatePicked;
/// Le texte du label
final String label;
/// La première date sélectionnable
final DateTime? firstDate;
/// La dernière date sélectionnable
final DateTime? lastDate;
/// La date initiale affichée dans le picker
final DateTime? initialDate;
/// Texte d'aide affiché dans le picker
final String? helpText;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final hasDate = selectedDate != null;
return InkWell(
onTap: () => _showDatePicker(context),
borderRadius: BorderRadius.circular(16),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 20),
decoration: BoxDecoration(
color: theme.colorScheme.surface,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: hasDate
? theme.colorScheme.primary
: theme.colorScheme.outline.withOpacity(0.5),
width: hasDate ? 2 : 1,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (hasDate)
Text(
'Date sélectionnée',
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.6),
),
),
const SizedBox(height: 4),
Text(
hasDate
? DateFormatter.formatDateShort(selectedDate!)
: label,
style: theme.textTheme.bodyLarge?.copyWith(
color: hasDate
? theme.colorScheme.onSurface
: theme.colorScheme.onSurface.withOpacity(0.6),
fontWeight: hasDate ? FontWeight.w600 : FontWeight.normal,
),
),
],
),
),
const SizedBox(width: 12),
Icon(
Icons.calendar_today,
color: hasDate
? theme.colorScheme.primary
: theme.colorScheme.onSurface.withOpacity(0.6),
size: 24,
),
],
),
),
);
}
/// Affiche le sélecteur de date.
Future<void> _showDatePicker(BuildContext context) async {
final theme = Theme.of(context);
final now = DateTime.now();
final picked = await showDatePicker(
context: context,
initialDate: initialDate ?? selectedDate ?? now,
firstDate: firstDate ?? now,
lastDate: lastDate ?? DateTime(2101),
helpText: helpText,
builder: (context, child) {
return Theme(
data: theme.copyWith(
colorScheme: theme.colorScheme.copyWith(
primary: theme.colorScheme.primary,
),
),
child: child!,
);
},
);
if (picked != null) {
onDatePicked(picked);
}
}
}