feat(navigation): titre 'Mon/Mes Organisations' dynamique + fallback modules
Plus page (more_page.dart) : - Titre entrée Organisations dynamique selon rôle/nombre d'orgs : * SuperAdmin → 'Gestion des Organisations' * OrgAdmin 1 org → 'Mon Organisation' * OrgAdmin 2+ orgs → 'Mes Organisations' - Sous-titres adaptés - Helpers _orgTitle/_orgSubtitle utilisent OrgSwitcherBloc pour le count - 7 modules non encore implémentés (TONTINE, CREDIT, AGRICULTURE, COLLECTE_FONDS, PROJETS_ONG, CULTE_DONS, VOTES) : Navigator.pushNamed remplacé par _comingSoon() SnackBar 'Disponible prochainement' (les routes n'étaient enregistrées nulle part) - Entrée 'Comptes épargne' → 'Épargne & Crédit' (terme métier pour mutuelles) Organizations page : - AppBar title dynamique via _appBarTitle() (même logique que more_page) - SnackBars OrganizationCreated/Updated/Deleted : Color(0xFF16A34A) → AppColors.success
This commit is contained in:
@@ -8,10 +8,6 @@ import '../../shared/widgets/mini_avatar.dart';
|
||||
import '../di/injection_container.dart';
|
||||
import '../network/org_context_service.dart';
|
||||
|
||||
import '../../features/admin/presentation/pages/user_management_page.dart';
|
||||
import '../../features/settings/presentation/pages/system_settings_page.dart';
|
||||
import '../../features/backup/presentation/pages/backup_page.dart';
|
||||
import '../../features/logs/presentation/pages/logs_page.dart';
|
||||
import '../../features/reports/presentation/pages/reports_page_wrapper.dart';
|
||||
import '../../features/epargne/presentation/pages/epargne_page.dart';
|
||||
import '../../features/contributions/presentation/pages/contributions_page_wrapper.dart' show CotisationsPageWrapper;
|
||||
@@ -20,6 +16,7 @@ import '../../features/solidarity/presentation/pages/demandes_aide_page_wrapper.
|
||||
import '../../features/organizations/presentation/pages/organizations_page_wrapper.dart';
|
||||
import '../../features/organizations/presentation/pages/org_selector_page.dart';
|
||||
import '../../features/organizations/bloc/org_switcher_bloc.dart';
|
||||
import '../../shared/design_system/tokens/app_colors.dart';
|
||||
import '../../features/profile/presentation/pages/profile_page_wrapper.dart';
|
||||
|
||||
/// Page "Plus" avec les fonctions avancées selon le rôle et les modules actifs.
|
||||
@@ -39,10 +36,10 @@ class MorePage extends StatelessWidget {
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.lightBackground,
|
||||
appBar: const UFAppBar(
|
||||
title: 'PLUS',
|
||||
automaticallyImplyLeading: false,
|
||||
moduleGradient: ModuleColors.systemeGradient,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(12),
|
||||
@@ -65,9 +62,7 @@ class MorePage extends StatelessWidget {
|
||||
|
||||
Widget _buildUserProfile(
|
||||
BuildContext context, AuthAuthenticated state, OrgContextService orgCtx) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final textColor = isDark ? AppColors.textPrimaryDark : AppColors.textPrimaryLight;
|
||||
final roleColor = isDark ? AppColors.brandGreenLight : AppColors.primaryGreen;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
|
||||
return CoreCard(
|
||||
onTap: () => Navigator.of(context).push(
|
||||
@@ -89,12 +84,12 @@ class MorePage extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
'${state.user.firstName} ${state.user.lastName}',
|
||||
style: AppTypography.actionText.copyWith(color: textColor),
|
||||
style: AppTypography.actionText.copyWith(color: scheme.onSurface),
|
||||
),
|
||||
Text(
|
||||
state.effectiveRole.displayName.toUpperCase(),
|
||||
style: AppTypography.badgeText.copyWith(
|
||||
color: roleColor,
|
||||
color: ModuleColors.profil,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
@@ -105,20 +100,16 @@ class MorePage extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right,
|
||||
color: isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight,
|
||||
size: 16),
|
||||
Icon(Icons.chevron_right, color: scheme.onSurfaceVariant, size: 16),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openOrgSelector(BuildContext context) {
|
||||
// Vérifier que OrgSwitcherBloc est disponible (fourni par un ancêtre)
|
||||
try {
|
||||
showOrgSelector(context);
|
||||
} catch (_) {
|
||||
// OrgSwitcherBloc pas fourni dans ce contexte, navigation vers ProfilePage
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const ProfilePageWrapper()),
|
||||
);
|
||||
@@ -129,48 +120,24 @@ class MorePage extends StatelessWidget {
|
||||
BuildContext context, AuthAuthenticated state, OrgContextService orgCtx) {
|
||||
final options = <Widget>[];
|
||||
|
||||
if (state.effectiveRole == UserRole.superAdmin) {
|
||||
options.addAll([
|
||||
_buildSectionTitle(context, 'Administration Système'),
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.people,
|
||||
title: 'Gestion des utilisateurs',
|
||||
subtitle: 'Utilisateurs Keycloak et rôles',
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const UserManagementPage())),
|
||||
),
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.settings,
|
||||
title: 'Paramètres Système',
|
||||
subtitle: 'Configuration globale',
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const SystemSettingsPage())),
|
||||
),
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.backup,
|
||||
title: 'Sauvegarde & Restauration',
|
||||
subtitle: 'Gestion des sauvegardes',
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const BackupPage())),
|
||||
),
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.article,
|
||||
title: 'Logs & Monitoring',
|
||||
subtitle: 'Surveillance et journaux',
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const LogsPage())),
|
||||
),
|
||||
]);
|
||||
}
|
||||
// Note: les items SYSTÈME (Gestion utilisateurs, Paramètres Système,
|
||||
// Sauvegarde & Restauration, Logs & Monitoring) ont été déplacés dans
|
||||
// le burger drawer (section "Système" — super admin only) afin de
|
||||
// respecter la démarcation Métier (Plus) / Système (Drawer).
|
||||
|
||||
if (state.effectiveRole == UserRole.orgAdmin ||
|
||||
state.effectiveRole == UserRole.superAdmin) {
|
||||
final isSuperAdmin = state.effectiveRole == UserRole.superAdmin;
|
||||
final orgTitle = _orgTitle(context, isSuperAdmin);
|
||||
final orgSubtitle = _orgSubtitle(context, isSuperAdmin);
|
||||
|
||||
options.addAll([
|
||||
_buildSectionTitle(context, 'Administration'),
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.business,
|
||||
title: 'Gestion des Organisations',
|
||||
subtitle: 'Créer et gérer les organisations',
|
||||
title: orgTitle,
|
||||
subtitle: orgSubtitle,
|
||||
accentColor: ModuleColors.organisations,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const OrganizationsPageWrapper())),
|
||||
),
|
||||
@@ -179,12 +146,14 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.pending_actions,
|
||||
title: 'Approbations en attente',
|
||||
subtitle: 'Valider les transactions financières',
|
||||
accentColor: ModuleColors.financeWorkflow,
|
||||
onTap: () => Navigator.pushNamed(context, '/approvals'),
|
||||
),
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.account_balance_wallet,
|
||||
title: 'Gestion des Budgets',
|
||||
subtitle: 'Créer et suivre les budgets',
|
||||
accentColor: ModuleColors.financeWorkflow,
|
||||
onTap: () => Navigator.pushNamed(context, '/budgets'),
|
||||
),
|
||||
_buildSectionTitle(context, 'Communication'),
|
||||
@@ -192,6 +161,7 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.message,
|
||||
title: 'Messages & Broadcast',
|
||||
subtitle: 'Communiquer avec les membres',
|
||||
accentColor: ModuleColors.communication,
|
||||
onTap: () => Navigator.pushNamed(context, '/messages'),
|
||||
),
|
||||
_buildSectionTitle(context, 'Rapports & Analytics'),
|
||||
@@ -199,6 +169,7 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.assessment,
|
||||
title: 'Rapports & Analytics',
|
||||
subtitle: 'Statistiques détaillées',
|
||||
accentColor: ModuleColors.rapports,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const ReportsPageWrapper())),
|
||||
),
|
||||
@@ -212,6 +183,7 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.message,
|
||||
title: 'Messages aux membres',
|
||||
subtitle: 'Communiquer avec les membres',
|
||||
accentColor: ModuleColors.communication,
|
||||
onTap: () => Navigator.pushNamed(context, '/messages'),
|
||||
),
|
||||
]);
|
||||
@@ -227,101 +199,92 @@ class MorePage extends StatelessWidget {
|
||||
final isAdmin = state.effectiveRole == UserRole.orgAdmin ||
|
||||
state.effectiveRole == UserRole.superAdmin;
|
||||
|
||||
// Module TONTINE
|
||||
if (orgCtx.isModuleActif('TONTINE')) {
|
||||
options.add(_buildSectionTitle(context, 'Tontine'));
|
||||
if (isAdmin) {
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.autorenew,
|
||||
title: 'Gestion Tontine',
|
||||
subtitle: 'Cycles, cotisations et remises',
|
||||
onTap: () => Navigator.pushNamed(context, '/tontine'),
|
||||
));
|
||||
} else {
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.autorenew,
|
||||
title: 'Ma Tontine',
|
||||
subtitle: 'Mes cycles et cotisations',
|
||||
onTap: () => Navigator.pushNamed(context, '/tontine'),
|
||||
));
|
||||
}
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.autorenew,
|
||||
title: isAdmin ? 'Gestion Tontine' : 'Ma Tontine',
|
||||
subtitle: isAdmin ? 'Cycles, cotisations et remises' : 'Mes cycles et cotisations',
|
||||
accentColor: ModuleColors.cotisations,
|
||||
onTap: () => _comingSoon(context, 'Tontine'),
|
||||
));
|
||||
}
|
||||
|
||||
// Module EPARGNE
|
||||
if (orgCtx.isModuleActif('EPARGNE')) {
|
||||
options.add(_buildSectionTitle(context, 'Épargne'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.savings,
|
||||
title: isAdmin ? 'Gestion Épargne' : 'Mon Épargne',
|
||||
subtitle: isAdmin ? 'Comptes épargne et transactions' : 'Mon compte épargne',
|
||||
subtitle: isAdmin ? 'Épargne, dépôts, crédits et transactions' : 'Mon épargne et mes crédits',
|
||||
accentColor: ModuleColors.epargne,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const EpargnePage())),
|
||||
));
|
||||
}
|
||||
|
||||
// Module CREDIT
|
||||
if (orgCtx.isModuleActif('CREDIT')) {
|
||||
options.add(_buildSectionTitle(context, 'Crédit'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.account_balance,
|
||||
title: isAdmin ? 'Gestion Crédit' : 'Mon Crédit',
|
||||
subtitle: isAdmin ? 'Demandes et suivi des crédits' : 'Mes demandes de crédit',
|
||||
onTap: () => Navigator.pushNamed(context, '/credit'),
|
||||
accentColor: ModuleColors.financeWorkflow,
|
||||
onTap: () => _comingSoon(context, 'Crédit'),
|
||||
));
|
||||
}
|
||||
|
||||
// Module AGRICULTURE
|
||||
if (orgCtx.isModuleActif('AGRICULTURE')) {
|
||||
options.add(_buildSectionTitle(context, 'Agriculture'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.eco,
|
||||
title: 'Campagnes Agricoles',
|
||||
subtitle: 'Parcelles, récoltes et stocks',
|
||||
onTap: () => Navigator.pushNamed(context, '/agricole'),
|
||||
accentColor: ModuleColors.epargne,
|
||||
onTap: () => _comingSoon(context, 'Agriculture'),
|
||||
));
|
||||
}
|
||||
|
||||
// Module COLLECTE_FONDS
|
||||
if (orgCtx.isModuleActif('COLLECTE_FONDS')) {
|
||||
options.add(_buildSectionTitle(context, 'Collecte de Fonds'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.volunteer_activism,
|
||||
title: 'Campagnes de Collecte',
|
||||
subtitle: 'Dons et levées de fonds',
|
||||
onTap: () => Navigator.pushNamed(context, '/collecte'),
|
||||
accentColor: ModuleColors.solidarite,
|
||||
onTap: () => _comingSoon(context, 'Collecte de Fonds'),
|
||||
));
|
||||
}
|
||||
|
||||
// Module PROJETS_ONG
|
||||
if (orgCtx.isModuleActif('PROJETS_ONG')) {
|
||||
options.add(_buildSectionTitle(context, 'Projets ONG'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.public,
|
||||
title: 'Projets',
|
||||
subtitle: 'Gérer et suivre les projets',
|
||||
onTap: () => Navigator.pushNamed(context, '/projets-ong'),
|
||||
accentColor: ModuleColors.rapports,
|
||||
onTap: () => _comingSoon(context, 'Projets ONG'),
|
||||
));
|
||||
}
|
||||
|
||||
// Module CULTE_DONS
|
||||
if (orgCtx.isModuleActif('CULTE_DONS')) {
|
||||
options.add(_buildSectionTitle(context, 'Culte & Dons'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.church,
|
||||
title: 'Dons et Offrandes',
|
||||
subtitle: 'Gestion des dons religieux',
|
||||
onTap: () => Navigator.pushNamed(context, '/culte'),
|
||||
accentColor: ModuleColors.solidarite,
|
||||
onTap: () => _comingSoon(context, 'Culte & Dons'),
|
||||
));
|
||||
}
|
||||
|
||||
// Module VOTES
|
||||
if (orgCtx.isModuleActif('VOTES')) {
|
||||
options.add(_buildSectionTitle(context, 'Votes'));
|
||||
options.add(_buildOptionTile(context,
|
||||
icon: Icons.how_to_vote,
|
||||
title: 'Votes & Élections',
|
||||
subtitle: 'Campagnes et résultats',
|
||||
onTap: () => Navigator.pushNamed(context, '/votes'),
|
||||
accentColor: ModuleColors.financeWorkflow,
|
||||
onTap: () => _comingSoon(context, 'Votes & Élections'),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -335,6 +298,7 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.payment,
|
||||
title: 'Cotisations',
|
||||
subtitle: 'Gérer les cotisations',
|
||||
accentColor: ModuleColors.cotisations,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const CotisationsPageWrapper())),
|
||||
),
|
||||
@@ -342,6 +306,7 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.how_to_reg,
|
||||
title: 'Demandes d\'adhésion',
|
||||
subtitle: 'Demandes d\'adhésion à une organisation',
|
||||
accentColor: ModuleColors.adhesions,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const AdhesionsPageWrapper())),
|
||||
),
|
||||
@@ -349,24 +314,64 @@ class MorePage extends StatelessWidget {
|
||||
icon: Icons.volunteer_activism,
|
||||
title: 'Demandes d\'aide',
|
||||
subtitle: 'Solidarité – demandes d\'aide',
|
||||
accentColor: ModuleColors.solidarite,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const DemandesAidePageWrapper())),
|
||||
),
|
||||
// Épargne — affiché en commun uniquement si le module n'est PAS actif (évite doublon avec section module)
|
||||
if (!orgCtx.isModuleActif('EPARGNE'))
|
||||
_buildOptionTile(context,
|
||||
icon: Icons.savings_outlined,
|
||||
title: 'Comptes épargne',
|
||||
subtitle: 'Mutuelle épargne – dépôts (LCB-FT)',
|
||||
title: 'Épargne & Crédit',
|
||||
subtitle: 'Comptes épargne, dépôts et crédits (LCB-FT)',
|
||||
accentColor: ModuleColors.epargne,
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(builder: (_) => const EpargnePage())),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(BuildContext context, String title) {
|
||||
// ─── Helpers titre organisation ─────────────────────────────────────────
|
||||
|
||||
/// Titre de l'entrée "Organisation(s)" selon le rôle et le nombre d'orgs gérées.
|
||||
String _orgTitle(BuildContext context, bool isSuperAdmin) {
|
||||
if (isSuperAdmin) return 'Gestion des Organisations';
|
||||
final switcherState = context.read<OrgSwitcherBloc>().state;
|
||||
final count = switcherState is OrgSwitcherLoaded
|
||||
? switcherState.organisations.length
|
||||
: 1;
|
||||
return count > 1 ? 'Mes Organisations' : 'Mon Organisation';
|
||||
}
|
||||
|
||||
String _orgSubtitle(BuildContext context, bool isSuperAdmin) {
|
||||
if (isSuperAdmin) return 'Créer et gérer les organisations';
|
||||
final switcherState = context.read<OrgSwitcherBloc>().state;
|
||||
final count = switcherState is OrgSwitcherLoaded
|
||||
? switcherState.organisations.length
|
||||
: 1;
|
||||
return count > 1 ? 'Gérer mes organisations' : 'Gérer mon organisation';
|
||||
}
|
||||
|
||||
// ─── Modules non encore implémentés ─────────────────────────────────────
|
||||
|
||||
void _comingSoon(BuildContext context, String feature) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Row(children: [
|
||||
const Icon(Icons.construction_outlined, color: Colors.white, size: 16),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text('$feature — Disponible prochainement')),
|
||||
]),
|
||||
backgroundColor: isDark ? AppColors.surfaceVariantDark : AppColors.textSecondary,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 3),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionTitle(BuildContext context, String title) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 16, bottom: 6, left: 4),
|
||||
child: Text(
|
||||
@@ -374,7 +379,7 @@ class MorePage extends StatelessWidget {
|
||||
style: AppTypography.subtitleSmall.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 1.1,
|
||||
color: isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -388,16 +393,8 @@ class MorePage extends StatelessWidget {
|
||||
required VoidCallback onTap,
|
||||
Color? accentColor,
|
||||
}) {
|
||||
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final accent = accentColor ?? AppColors.primaryGreen;
|
||||
final titleColor = accentColor != null
|
||||
? accentColor
|
||||
: (isDark ? AppColors.textPrimaryDark : AppColors.textPrimaryLight);
|
||||
final subtitleColor =
|
||||
isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight;
|
||||
final chevronColor =
|
||||
isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final accent = accentColor ?? scheme.primary;
|
||||
|
||||
return CoreCard(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
@@ -407,7 +404,7 @@ class MorePage extends StatelessWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(7),
|
||||
decoration: BoxDecoration(
|
||||
color: accent.withOpacity(isDark ? 0.2 : 0.1),
|
||||
color: accent.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, color: accent, size: 18),
|
||||
@@ -419,16 +416,18 @@ class MorePage extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: AppTypography.actionText.copyWith(color: titleColor),
|
||||
style: AppTypography.actionText.copyWith(
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: AppTypography.subtitleSmall.copyWith(color: subtitleColor),
|
||||
style: AppTypography.subtitleSmall.copyWith(color: scheme.onSurfaceVariant),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Icon(Icons.chevron_right, color: chevronColor, size: 16),
|
||||
Icon(Icons.chevron_right, color: scheme.onSurfaceVariant, size: 16),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user