feat(100): bandeau dashboard générique, icônes rôle/email, footer go_router, user fromJson défensif
- Bandeau générique DashboardBandeau (logo | onglets | capsule utilisateur) - Capsule: icône rôle (admin/gestionnaire/parent/AM) + Prénom Nom + menu (email avec icône, Profil, Paramètres, Déconnexion) - Migration admin, gestionnaire, parent, AM vers DashboardBandeau - Écran AM (page blanche), route /am-dashboard - Routes /privacy et /legal, footer avec context.push - AppUser.fromJson: id/email/role null-safe - Suppression DashboardAppBarAdmin et dashboard_app_bar.dart Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:p_tits_pas/models/user.dart';
|
||||
import 'package:p_tits_pas/services/auth_service.dart';
|
||||
import 'package:p_tits_pas/services/configuration_service.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/dashboard_admin.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/parametres_panel.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/user_management_panel.dart';
|
||||
import 'package:p_tits_pas/widgets/app_footer.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/dashboard_admin.dart';
|
||||
import 'package:p_tits_pas/widgets/dashboard/dashboard_bandeau.dart';
|
||||
|
||||
class AdminDashboardScreen extends StatefulWidget {
|
||||
const AdminDashboardScreen({super.key});
|
||||
@@ -14,6 +17,7 @@ class AdminDashboardScreen extends StatefulWidget {
|
||||
|
||||
class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
bool? _setupCompleted;
|
||||
AppUser? _user;
|
||||
int mainTabIndex = 0;
|
||||
int settingsSubIndex = 0;
|
||||
|
||||
@@ -31,9 +35,11 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
Future<void> _loadSetupStatus() async {
|
||||
try {
|
||||
final completed = await ConfigurationService.getSetupStatus();
|
||||
final user = await AuthService.getCurrentUser();
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_setupCompleted = completed;
|
||||
_user = user;
|
||||
if (!completed) mainTabIndex = 1;
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -68,17 +74,29 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(60.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.shade300),
|
||||
child: DashboardBandeau(
|
||||
tabItems: [
|
||||
DashboardTabItem(
|
||||
label: 'Gestion des utilisateurs',
|
||||
enabled: _setupCompleted!,
|
||||
),
|
||||
),
|
||||
child: DashboardAppBarAdmin(
|
||||
selectedIndex: mainTabIndex,
|
||||
onTabChange: onMainTabChange,
|
||||
setupCompleted: _setupCompleted!,
|
||||
),
|
||||
const DashboardTabItem(label: 'Paramètres'),
|
||||
],
|
||||
selectedTabIndex: mainTabIndex,
|
||||
onTabSelected: onMainTabChange,
|
||||
userDisplayName: _user?.fullName.isNotEmpty == true
|
||||
? _user!.fullName
|
||||
: 'Admin',
|
||||
userEmail: _user?.email,
|
||||
userRole: _user?.role,
|
||||
onProfileTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Modification du profil – à venir')),
|
||||
);
|
||||
},
|
||||
onSettingsTap: () => onMainTabChange(1),
|
||||
onLogout: () {},
|
||||
showLogoutConfirmation: true,
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
|
||||
Reference in New Issue
Block a user