86 lines
2.4 KiB
Dart
86 lines
2.4 KiB
Dart
// lib/utils/role_navigator.dart
|
|
import 'package:flutter/material.dart';
|
|
import '../pages/main_navigation.dart';
|
|
import '../pages/admin_dashboard.dart';
|
|
import '../pages/rechargeur_dashboard.dart';
|
|
|
|
class RoleNavigator {
|
|
/// Naviguer vers la page appropriée selon le rôle
|
|
static void navigateByRole(BuildContext context, String role) {
|
|
Widget destination;
|
|
|
|
switch (role.toLowerCase()) {
|
|
case 'admin':
|
|
destination = AdminDashboard();
|
|
break;
|
|
case 'rechargeur':
|
|
destination = RechargeurDashboard();
|
|
break;
|
|
case 'agent':
|
|
default:
|
|
destination = MainNavigationPage(initialIndex: 0);
|
|
break;
|
|
}
|
|
|
|
Navigator.of(context).pushReplacement(
|
|
PageRouteBuilder(
|
|
pageBuilder: (context, animation, secondaryAnimation) => destination,
|
|
transitionsBuilder: (context, animation, secondaryAnimation, child) {
|
|
return FadeTransition(
|
|
opacity: animation,
|
|
child: SlideTransition(
|
|
position: Tween<Offset>(
|
|
begin: Offset(0.1, 0),
|
|
end: Offset.zero,
|
|
).animate(
|
|
CurvedAnimation(parent: animation, curve: Curves.easeOut),
|
|
),
|
|
child: child,
|
|
),
|
|
);
|
|
},
|
|
transitionDuration: Duration(milliseconds: 600),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Obtenir l'icône selon le rôle
|
|
static IconData getRoleIcon(String role) {
|
|
switch (role.toLowerCase()) {
|
|
case 'admin':
|
|
return Icons.admin_panel_settings;
|
|
case 'rechargeur':
|
|
return Icons.add_circle;
|
|
case 'agent':
|
|
default:
|
|
return Icons.person;
|
|
}
|
|
}
|
|
|
|
/// Obtenir la couleur selon le rôle
|
|
static Color getRoleColor(String role) {
|
|
switch (role.toLowerCase()) {
|
|
case 'admin':
|
|
return Color(0xFFE53E3E); // Rouge
|
|
case 'rechargeur':
|
|
return Color(0xFF38A169); // Vert
|
|
case 'agent':
|
|
default:
|
|
return Color(0xFF006699); // Bleu Wortis
|
|
}
|
|
}
|
|
|
|
/// Obtenir le nom d'affichage du rôle
|
|
static String getRoleDisplayName(String role) {
|
|
switch (role.toLowerCase()) {
|
|
case 'admin':
|
|
return 'Administrateur';
|
|
case 'rechargeur':
|
|
return 'Rechargeur';
|
|
case 'agent':
|
|
default:
|
|
return 'Agent';
|
|
}
|
|
}
|
|
}
|