- Corrige l'erreur SQL 'Unknown column fk_operation in users' - L'opération active est récupérée depuis operations.chk_active = 1 - Jointure avec users pour filtrer par entité de l'admin créateur - Query: SELECT o.id FROM operations o INNER JOIN users u ON u.fk_entite = o.fk_entite WHERE u.id = ? AND o.chk_active = 1
118 lines
3.1 KiB
Dart
Executable File
118 lines
3.1 KiB
Dart
Executable File
/// Exemple d'utilisation du module chat
|
|
///
|
|
/// Ce fichier montre comment intégrer le module chat dans votre application
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'chat_module.dart';
|
|
|
|
class ExampleApp extends StatelessWidget {
|
|
const ExampleApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Chat Module Example',
|
|
home: const HomePage(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
bool _isInitialized = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_initChat();
|
|
}
|
|
|
|
Future<void> _initChat() async {
|
|
// Initialiser le module chat avec vos paramètres et rôle
|
|
await ChatModule.init(
|
|
apiUrl: 'https://api.votre-domaine.com',
|
|
userId: 123, // ID de l'utilisateur connecté
|
|
userName: 'Jean Dupont', // Nom de l'utilisateur
|
|
userRole: 2, // Rôle: 1=membre, 2=admin amicale, 9=superadmin
|
|
userEntite: 5, // ID de l'amicale/entité (optionnel)
|
|
authToken: 'votre-token-jwt', // Token d'authentification (optionnel)
|
|
);
|
|
|
|
setState(() => _isInitialized = true);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Application Example'),
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Text('Bienvenue dans votre application'),
|
|
const SizedBox(height: 20),
|
|
if (_isInitialized)
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
// Ouvrir le chat
|
|
ChatModule.openChat(context);
|
|
},
|
|
child: const Text('Ouvrir le Chat'),
|
|
)
|
|
else
|
|
const CircularProgressIndicator(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// Nettoyer les ressources du chat
|
|
ChatModule.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
/// Comment l'utiliser dans votre application :
|
|
///
|
|
/// 1. Copier le dossier lib/chat dans votre projet
|
|
///
|
|
/// 2. Ajouter les dépendances dans pubspec.yaml :
|
|
/// dependencies:
|
|
/// dio: ^5.4.0
|
|
/// hive: ^2.2.3
|
|
/// hive_flutter: ^1.1.0
|
|
/// dev_dependencies:
|
|
/// hive_generator: ^2.0.1
|
|
/// build_runner: ^2.4.8
|
|
///
|
|
/// 3. Initialiser le module au démarrage :
|
|
/// await ChatModule.init(
|
|
/// apiUrl: 'https://votre-api.com',
|
|
/// userId: currentUserId,
|
|
/// userName: currentUserName,
|
|
/// userRole: currentUserRole, // 1, 2 ou 9
|
|
/// userEntite: currentUserEntite, // ID amicale
|
|
/// authToken: authToken,
|
|
/// );
|
|
///
|
|
/// 4. Ouvrir le chat depuis n'importe où :
|
|
/// ChatModule.openChat(context);
|
|
///
|
|
/// 5. Ou naviguer directement vers une conversation :
|
|
/// Navigator.push(
|
|
/// context,
|
|
/// MaterialPageRoute(
|
|
/// builder: (_) => ChatModule.getChatPage(roomId, roomTitle),
|
|
/// ),
|
|
/// ); |