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,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:p_tits_pas/controllers/parent_dashboard_controller.dart';
|
||||
import 'package:p_tits_pas/models/user.dart';
|
||||
import 'package:p_tits_pas/services/auth_service.dart';
|
||||
import 'package:p_tits_pas/services/dashboardService.dart';
|
||||
import 'package:p_tits_pas/widgets/app_footer.dart';
|
||||
import 'package:p_tits_pas/widgets/dashbord_parent/app_layout.dart';
|
||||
import 'package:p_tits_pas/widgets/dashbord_parent/children_sidebar.dart';
|
||||
import 'package:p_tits_pas/widgets/dashbord_parent/dashboard_app_bar.dart';
|
||||
import 'package:p_tits_pas/widgets/dashbord_parent/wid_dashbord.dart';
|
||||
import 'package:p_tits_pas/widgets/dashboard/dashboard_bandeau.dart';
|
||||
import 'package:p_tits_pas/widgets/main_content_area.dart';
|
||||
import 'package:p_tits_pas/widgets/messaging_sidebar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -19,6 +20,7 @@ class ParentDashboardScreen extends StatefulWidget {
|
||||
|
||||
class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
|
||||
int selectedIndex = 0;
|
||||
AppUser? _user;
|
||||
|
||||
void onTabChange(int index) {
|
||||
setState(() {
|
||||
@@ -29,12 +31,18 @@ class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUser();
|
||||
// Initialiser les données du dashboard
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<ParentDashboardController>().initDashboard();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadUser() async {
|
||||
final user = await AuthService.getCurrentUser();
|
||||
if (mounted) setState(() => _user = user);
|
||||
}
|
||||
|
||||
Widget _getBody() {
|
||||
switch (selectedIndex) {
|
||||
case 0:
|
||||
@@ -53,29 +61,43 @@ class _ParentDashboardScreenState extends State<ParentDashboardScreen> {
|
||||
return ChangeNotifierProvider(
|
||||
create: (context) => ParentDashboardController(DashboardService())..initDashboard(),
|
||||
child: Scaffold(
|
||||
appBar: PreferredSize(preferredSize: const Size.fromHeight(60.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.shade300),
|
||||
),
|
||||
),
|
||||
child: DashboardAppBar(
|
||||
selectedIndex: selectedIndex,
|
||||
onTabChange: onTabChange,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(60.0),
|
||||
child: DashboardBandeau(
|
||||
tabItems: const [
|
||||
DashboardTabItem(label: 'Mon tableau de bord'),
|
||||
DashboardTabItem(label: 'Trouver une nounou'),
|
||||
DashboardTabItem(label: 'Paramètres'),
|
||||
],
|
||||
selectedTabIndex: selectedIndex,
|
||||
onTabSelected: onTabChange,
|
||||
userDisplayName: _user?.fullName.isNotEmpty == true
|
||||
? _user!.fullName
|
||||
: 'Parent',
|
||||
userEmail: _user?.email,
|
||||
userRole: _user?.role,
|
||||
onProfileTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Modification du profil – à venir')),
|
||||
);
|
||||
},
|
||||
onSettingsTap: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Paramètres – à venir')),
|
||||
);
|
||||
},
|
||||
onLogout: () {},
|
||||
showLogoutConfirmation: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded (child: _getBody(),
|
||||
),
|
||||
Expanded(child: _getBody()),
|
||||
const AppFooter(),
|
||||
],
|
||||
),
|
||||
)
|
||||
// body: _buildResponsiveBody(context, controller),
|
||||
// footer: const AppFooter(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user