feat: Version 3.3.4 - Nouvelle architecture pages, optimisations widgets Flutter et API

- Mise à jour VERSION vers 3.3.4
- Optimisations et révisions architecture API (deploy-api.sh, scripts de migration)
- Ajout documentation Stripe Tap to Pay complète
- Migration vers polices Inter Variable pour Flutter
- Optimisations build Android et nettoyage fichiers temporaires
- Amélioration système de déploiement avec gestion backups
- Ajout scripts CRON et migrations base de données

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
pierre
2025-10-05 20:11:15 +02:00
parent 2786252307
commit 570a1fa1f0
212 changed files with 24275 additions and 11321 deletions

View File

@@ -52,106 +52,38 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
// Utiliser la vue split responsive pour toutes les plateformes
return _buildResponsiveSplitView(context);
}
Widget _buildMobileView(BuildContext context) {
final helpText = ChatConfigLoader.instance.getHelpText(_service.currentUserRole);
return ValueListenableBuilder<Box<Room>>(
valueListenable: _service.roomsBox.listenable(),
builder: (context, box, _) {
final rooms = box.values.toList()
..sort((a, b) => (b.lastMessageAt ?? b.createdAt)
.compareTo(a.lastMessageAt ?? a.createdAt));
if (rooms.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.chat_bubble_outline,
size: 64,
color: Colors.grey[400],
),
const SizedBox(height: 16),
Text(
'Aucune conversation',
style: TextStyle(
fontSize: 16,
color: Colors.grey[600],
),
),
const SizedBox(height: 8),
TextButton(
onPressed: widget.onAddPressed ?? createNewConversation,
child: const Text('Démarrer une conversation'),
),
if (helpText.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 8),
child: Text(
helpText,
style: TextStyle(
fontSize: 13,
color: Colors.grey[500],
),
textAlign: TextAlign.center,
),
),
],
),
);
}
return RefreshIndicator(
onRefresh: () async {
// Pull to refresh = sync complète forcée par l'utilisateur
setState(() => _isLoading = true);
await _service.getRooms(forceFullSync: true);
setState(() => _isLoading = false);
},
child: ListView.builder(
itemCount: rooms.length,
itemBuilder: (context, index) {
final room = rooms[index];
return _RoomTile(
room: room,
currentUserId: _service.currentUserId,
onDelete: () => _handleDeleteRoom(room),
);
},
),
);
},
);
// Méthode publique pour rafraîchir
void refresh() {
_loadRooms();
}
Future<void> createNewConversation() async {
final currentRole = _service.currentUserRole;
final config = ChatConfigLoader.instance.getPossibleRecipientsConfig(currentRole);
// Déterminer si on permet la sélection multiple
// Pour role 1 (membre), permettre la sélection multiple pour contacter plusieurs membres/admins
// Pour role 2 (admin amicale), permettre la sélection multiple pour GEOSECTOR ou Amicale
// Pour role 9 (super admin), permettre la sélection multiple selon config
final allowMultiple = (currentRole == 1) || (currentRole == 2) ||
final allowMultiple = (currentRole == 1) || (currentRole == 2) ||
(currentRole == 9 && config.any((c) => c['allow_selection'] == true));
// Ouvrir le dialog de sélection
final result = await RecipientSelectorDialog.show(
context,
allowMultiple: allowMultiple,
);
if (result != null) {
final recipients = result['recipients'] as List<Map<String, dynamic>>?;
final initialMessage = result['initial_message'] as String?;
final isBroadcast = result['is_broadcast'] as bool? ?? false;
if (recipients != null && recipients.isNotEmpty) {
try {
Room? newRoom;
if (recipients.length == 1) {
// Conversation privée
final recipient = recipients.first;
@@ -159,7 +91,7 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
final firstName = recipient['first_name'] ?? '';
final lastName = recipient['name'] ?? '';
final fullName = '$firstName $lastName'.trim();
newRoom = await _service.createPrivateRoom(
recipientId: recipient['id'],
recipientName: fullName.isNotEmpty ? fullName : 'Sans nom',
@@ -168,16 +100,16 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
initialMessage: initialMessage,
);
} else {
// Conversation de groupe
// Conversation de groupe
final participantIds = recipients.map((r) => r['id'] as int).toList();
// Déterminer le titre en fonction du type de groupe
String title;
if (currentRole == 1) {
// Pour un membre
final hasAdmins = recipients.any((r) => r['role'] == 2);
final hasMembers = recipients.any((r) => r['role'] == 1);
if (hasAdmins && !hasMembers) {
title = 'Administrateurs Amicale';
} else if (recipients.length > 3) {
@@ -197,7 +129,7 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
// Pour un admin d'amicale
final hasSuperAdmins = recipients.any((r) => r['role'] == 9);
final hasMembers = recipients.any((r) => r['role'] == 1);
if (hasSuperAdmins && !hasMembers) {
title = 'Support GEOSECTOR';
} else if (!hasSuperAdmins && hasMembers && recipients.length > 5) {
@@ -231,7 +163,7 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
}).join(', ');
}
}
// Créer la room avec le bon type (broadcast si coché, sinon group)
newRoom = await _service.createRoom(
title: title,
@@ -240,7 +172,7 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
initialMessage: initialMessage,
);
}
if (newRoom != null && mounted) {
// Sur le web, sélectionner la room, sur mobile naviguer
if (kIsWeb) {
@@ -275,11 +207,6 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
}
}
// Méthode publique pour rafraîchir
void refresh() {
_loadRooms();
}
/// Méthode pour créer la vue split responsive
Widget _buildResponsiveSplitView(BuildContext context) {
return ValueListenableBuilder<Box<Room>>(
@@ -621,7 +548,7 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
});
},
onDelete: () {
print('🗑️ Clic suppression: room.createdBy=${room.createdBy}, currentUserId=${_service.currentUserId}');
debugPrint('🗑️ Clic suppression: room.createdBy=${room.createdBy}, currentUserId=${_service.currentUserId}');
_handleDeleteRoom(room);
},
),
@@ -830,7 +757,7 @@ class RoomsPageEmbeddedState extends State<RoomsPageEmbedded> {
/// Supprimer une room
Future<void> _handleDeleteRoom(Room room) async {
print('🚀 _handleDeleteRoom appelée: room.createdBy=${room.createdBy}, currentUserId=${_service.currentUserId}');
debugPrint('🚀 _handleDeleteRoom appelée: room.createdBy=${room.createdBy}, currentUserId=${_service.currentUserId}');
// Vérifier que l'utilisateur est bien le créateur
if (room.createdBy != _service.currentUserId) {
@@ -1328,194 +1255,6 @@ class _QuickBroadcastDialogState extends State<_QuickBroadcastDialog> {
}
}
/// Widget simple pour une tuile de room
class _RoomTile extends StatelessWidget {
final Room room;
final int currentUserId;
final VoidCallback onDelete;
const _RoomTile({
required this.room,
required this.currentUserId,
required this.onDelete,
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(color: Colors.grey[200]!),
),
),
child: ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
leading: CircleAvatar(
backgroundColor: room.type == 'broadcast'
? Colors.amber.shade600
: const Color(0xFF2563EB),
child: room.type == 'broadcast'
? const Icon(Icons.campaign, color: Colors.white, size: 20)
: Text(
_getInitials(room.title),
style: const TextStyle(color: Colors.white, fontSize: 14),
),
),
title: Row(
children: [
Expanded(
child: Text(
room.title,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
),
overflow: TextOverflow.ellipsis,
),
),
if (room.type == 'broadcast')
Container(
margin: const EdgeInsets.only(left: 8),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: Colors.amber.shade100,
borderRadius: BorderRadius.circular(8),
),
child: Text(
'ANNONCE',
style: TextStyle(
fontSize: 9,
fontWeight: FontWeight.bold,
color: Colors.amber.shade800,
),
),
),
],
),
subtitle: room.lastMessage != null
? Text(
room.lastMessage!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.grey[600]),
)
: null,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (room.lastMessageAt != null)
Text(
_formatTime(room.lastMessageAt!),
style: TextStyle(
fontSize: 12,
color: Colors.grey[500],
),
),
if (room.unreadCount > 0)
Container(
margin: const EdgeInsets.only(top: 4),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFF2563EB),
borderRadius: BorderRadius.circular(10),
),
child: Text(
room.unreadCount.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 11,
fontWeight: FontWeight.bold,
),
),
),
],
),
// Bouton de suppression si l'utilisateur est le créateur
if (room.createdBy == currentUserId) ...[
const SizedBox(width: 8),
IconButton(
icon: Icon(
Icons.delete_outline,
size: 20,
color: Colors.red[400],
),
onPressed: onDelete,
tooltip: 'Supprimer la conversation',
padding: EdgeInsets.zero,
constraints: const BoxConstraints(
minWidth: 36,
minHeight: 36,
),
),
],
],
),
onTap: () {
// Navigation normale car on est dans la vue mobile
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ChatPage(
roomId: room.id,
roomTitle: room.title,
roomType: room.type,
roomCreatorId: room.createdBy,
),
),
);
},
),
);
}
String _formatTime(DateTime date) {
final now = DateTime.now();
final diff = now.difference(date);
if (diff.inDays > 0) {
return '${diff.inDays}j';
} else if (diff.inHours > 0) {
return '${diff.inHours}h';
} else if (diff.inMinutes > 0) {
return '${diff.inMinutes}m';
} else {
return 'Maintenant';
}
}
String _getInitials(String title) {
// Pour les titres spéciaux, retourner des initiales appropriées
if (title == 'Support GEOSECTOR') return 'SG';
if (title == 'Toute l\'Amicale') return 'TA';
if (title == 'Administrateurs Amicale') return 'AA';
// Pour les noms de personnes, extraire les initiales
final words = title.split(' ').where((w) => w.isNotEmpty).toList();
if (words.isEmpty) return '?';
// Si c'est un seul mot, prendre les 2 premières lettres
if (words.length == 1) {
final word = words[0];
return word.length >= 2
? '${word[0]}${word[1]}'.toUpperCase()
: word[0].toUpperCase();
}
// Si c'est prénom + nom, prendre la première lettre de chaque
if (words.length == 2) {
return '${words[0][0]}${words[1][0]}'.toUpperCase();
}
// Pour les groupes avec plusieurs noms, prendre les 2 premières initiales
return '${words[0][0]}${words[1][0]}'.toUpperCase();
}
}
/// Widget spécifique pour les tuiles de room sur le web
class _WebRoomTile extends StatelessWidget {
final Room room;
@@ -1534,7 +1273,7 @@ class _WebRoomTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
print('🔍 _WebRoomTile pour ${room.title}: createdBy=${room.createdBy}, currentUserId=$currentUserId, showDelete=${room.createdBy == currentUserId}');
debugPrint('🔍 _WebRoomTile pour ${room.title}: createdBy=${room.createdBy}, currentUserId=$currentUserId, showDelete=${room.createdBy == currentUserId}');
return ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),