- Configuration complète Stripe pour les 3 environnements (DEV/REC/PROD) * DEV: Clés TEST Pierre (mode test) * REC: Clés TEST Client (mode test) * PROD: Clés LIVE Client (mode live) - Ajout de la gestion des bases de données immeubles/bâtiments * Configuration buildings_database pour DEV/REC/PROD * Service BuildingService pour enrichissement des adresses - Optimisations pages et améliorations ergonomie - Mises à jour des dépendances Composer - Nettoyage des fichiers obsolètes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
166 lines
5.3 KiB
Dart
166 lines
5.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:geosector_app/chat/pages/rooms_page_embedded.dart';
|
|
import 'package:geosector_app/core/services/chat_manager.dart';
|
|
import 'package:geosector_app/core/services/current_user_service.dart';
|
|
|
|
/// Page de communication adaptative qui s'ajuste selon le rôle de l'utilisateur
|
|
/// et la plateforme (Web vs Mobile)
|
|
class ChatCommunicationPage extends StatefulWidget {
|
|
const ChatCommunicationPage({super.key});
|
|
|
|
@override
|
|
State<ChatCommunicationPage> createState() => _ChatCommunicationPageState();
|
|
}
|
|
|
|
class _ChatCommunicationPageState extends State<ChatCommunicationPage> {
|
|
final GlobalKey<RoomsPageEmbeddedState> _roomsPageKey = GlobalKey<RoomsPageEmbeddedState>();
|
|
|
|
// Récupération du rôle de l'utilisateur
|
|
int get _userRole => CurrentUserService.instance.currentUser?.role ?? 1;
|
|
|
|
// Configuration selon le rôle
|
|
MaterialColor get _themeColor {
|
|
switch (_userRole) {
|
|
case 1: return Colors.green; // Membre
|
|
case 2: return Colors.red; // Admin Amicale
|
|
case 9: return Colors.blue; // Super Admin
|
|
default: return Colors.grey;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
// Détection de la plateforme
|
|
final isWeb = kIsWeb;
|
|
|
|
// Construction adaptative
|
|
if (isWeb) {
|
|
return _buildWebLayout(context);
|
|
} else {
|
|
return _buildMobileLayout(context);
|
|
}
|
|
}
|
|
|
|
/// Layout pour Web (Desktop)
|
|
Widget _buildWebLayout(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
return Scaffold(
|
|
backgroundColor: Colors.transparent,
|
|
body: _buildContent(theme, isWeb: true),
|
|
);
|
|
}
|
|
|
|
/// Layout pour Mobile (iOS/Android)
|
|
Widget _buildMobileLayout(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
|
|
return Scaffold(
|
|
body: _buildContent(theme, isWeb: false),
|
|
floatingActionButton: FloatingActionButton(
|
|
onPressed: _handleNewConversation,
|
|
backgroundColor: _themeColor,
|
|
foregroundColor: Colors.white,
|
|
child: const Icon(Icons.add),
|
|
tooltip: 'Nouvelle conversation',
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Contenu principal commun
|
|
Widget _buildContent(ThemeData theme, {required bool isWeb}) {
|
|
// Vérifier si le chat est initialisé
|
|
if (!ChatManager.instance.isReady) {
|
|
return Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.chat_bubble_outline,
|
|
size: 80,
|
|
color: _themeColor.withOpacity(0.3),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(
|
|
'Module de communication non disponible',
|
|
style: theme.textTheme.titleLarge?.copyWith(
|
|
color: theme.colorScheme.onSurface.withOpacity(0.5),
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
_getUnavailableMessage(),
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: theme.colorScheme.onSurface.withOpacity(0.4),
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
if (_userRole == 9) ...[
|
|
const SizedBox(height: 16),
|
|
ElevatedButton.icon(
|
|
onPressed: _handleRetryInit,
|
|
icon: const Icon(Icons.refresh),
|
|
label: const Text('Réessayer'),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: _themeColor,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
// Le chat est initialisé
|
|
if (isWeb) {
|
|
// Version Web sans en-tête
|
|
return RoomsPageEmbedded(
|
|
key: _roomsPageKey,
|
|
onRefreshPressed: () {
|
|
debugPrint('Conversations actualisées');
|
|
},
|
|
);
|
|
} else {
|
|
// Version Mobile, contenu direct
|
|
return RoomsPageEmbedded(
|
|
key: _roomsPageKey,
|
|
onRefreshPressed: () {
|
|
debugPrint('Conversations actualisées');
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Message personnalisé selon le rôle quand le chat n'est pas disponible
|
|
String _getUnavailableMessage() {
|
|
switch (_userRole) {
|
|
case 1:
|
|
return 'Le service de messagerie n\'est pas disponible actuellement.\nVous pourrez bientôt contacter les membres de votre amicale.';
|
|
case 2:
|
|
return 'Le service de messagerie administration n\'est pas disponible.\nVous pourrez bientôt gérer les communications de votre amicale.';
|
|
case 9:
|
|
return 'Le centre de communication GEOSECTOR est temporairement indisponible.\nVérifiez la connexion au serveur.';
|
|
default:
|
|
return 'Le service de messagerie n\'est pas disponible actuellement.';
|
|
}
|
|
}
|
|
|
|
/// Gestionnaires d'événements
|
|
void _handleNewConversation() {
|
|
_roomsPageKey.currentState?.createNewConversation();
|
|
}
|
|
|
|
void _handleRetryInit() async {
|
|
// Réessayer l'initialisation du chat (pour Super Admin)
|
|
await ChatManager.instance.reinitialize();
|
|
if (mounted) {
|
|
setState(() {});
|
|
}
|
|
}
|
|
} |