feat: Bandeau générique, dashboards et doc (squash develop, Closes #100)
- Bandeau générique (DashboardBandeau) pour Parent, Admin, Gestionnaire, AM - ParentDashboardScreen, AdminDashboardScreen, GestionnaireDashboardScreen, AM dashboard - AppFooter responsive, scripts Gitea (create/list issues parent API) - Doc: ticket #101 Inscription Parent API, mise à jour 23_LISTE-TICKETS - User.fromJson robustesse (nullable id/email/role) - Suppression dashboard_app_bar.dart au profit de dashboard_bandeau.dart Refs: #100, #101 Made-with: Cursor
This commit is contained in:
parent
51d279e341
commit
e713c05da1
89
backend/scripts/create-gitea-issue-parent-api.js
Normal file
89
backend/scripts/create-gitea-issue-parent-api.js
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Crée l'issue Gitea "[Frontend] Inscription Parent – Branchement soumission formulaire à l'API"
|
||||
* Usage: node backend/scripts/create-gitea-issue-parent-api.js
|
||||
* Token : .gitea-token (racine du dépôt), sinon GITEA_TOKEN, sinon docs/BRIEFING-FRONTEND.md (voir PROCEDURE-API-GITEA.md)
|
||||
*/
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const repoRoot = path.join(__dirname, '../..');
|
||||
let token = process.env.GITEA_TOKEN;
|
||||
if (!token) {
|
||||
try {
|
||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
||||
if (fs.existsSync(tokenFile)) {
|
||||
token = fs.readFileSync(tokenFile, 'utf8').trim();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
if (!token) {
|
||||
try {
|
||||
const briefing = fs.readFileSync(path.join(repoRoot, 'docs/BRIEFING-FRONTEND.md'), 'utf8');
|
||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
||||
if (m) token = m[1].trim();
|
||||
} catch (_) {}
|
||||
}
|
||||
if (!token) {
|
||||
console.error('Token non trouvé : créer .gitea-token à la racine ou export GITEA_TOKEN (voir docs/PROCEDURE-API-GITEA.md)');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const body = `## Description
|
||||
|
||||
Branchement du formulaire d'inscription parent (étape 5, récapitulatif) à l'endpoint d'inscription. Aujourd'hui la soumission n'appelle pas l'API : elle affiche uniquement une modale puis redirige vers le login.
|
||||
|
||||
**Estimation** : 4h | **Labels** : frontend, p3, auth, cdc
|
||||
|
||||
## Tâches
|
||||
|
||||
- [ ] Créer un service ou méthode (ex. AuthService.registerParent) appelant POST /api/v1/auth/register/parent
|
||||
- [ ] Construire le body (DTO) à partir de UserRegistrationData (parent1, parent2, children, motivationText, CGU) en cohérence avec le backend (#18)
|
||||
- [ ] Dans ParentRegisterStep5Screen, au clic « Soumettre » : appel API puis modale + redirection ou message d'erreur
|
||||
- [ ] Gestion des photos enfants (base64 ou multipart selon API)
|
||||
|
||||
## Référence
|
||||
|
||||
20_WORKFLOW-CREATION-COMPTE.md § Étape 3 – Inscription d'un parent, backend #18`;
|
||||
|
||||
const payload = JSON.stringify({
|
||||
title: "[Frontend] Inscription Parent – Branchement soumission formulaire à l'API",
|
||||
body,
|
||||
});
|
||||
|
||||
const opts = {
|
||||
hostname: 'git.ptits-pas.fr',
|
||||
path: '/api/v1/repos/jmartin/petitspas/issues',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: 'token ' + token,
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(payload),
|
||||
},
|
||||
};
|
||||
|
||||
const req = https.request(opts, (res) => {
|
||||
let d = '';
|
||||
res.on('data', (c) => (d += c));
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const o = JSON.parse(d);
|
||||
if (o.number) {
|
||||
console.log('NUMBER:', o.number);
|
||||
console.log('URL:', o.html_url);
|
||||
} else {
|
||||
console.error('Erreur API:', o.message || d);
|
||||
process.exit(1);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Réponse:', d);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
req.on('error', (e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
req.write(payload);
|
||||
req.end();
|
||||
64
backend/scripts/list-gitea-issues.js
Normal file
64
backend/scripts/list-gitea-issues.js
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Liste toutes les issues Gitea (ouvertes + fermées) pour jmartin/petitspas.
|
||||
* Token : .gitea-token (racine), GITEA_TOKEN, ou docs/BRIEFING-FRONTEND.md
|
||||
*/
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const repoRoot = path.join(__dirname, '../..');
|
||||
let token = process.env.GITEA_TOKEN;
|
||||
if (!token) {
|
||||
try {
|
||||
const tokenFile = path.join(repoRoot, '.gitea-token');
|
||||
if (fs.existsSync(tokenFile)) token = fs.readFileSync(tokenFile, 'utf8').trim();
|
||||
} catch (_) {}
|
||||
}
|
||||
if (!token) {
|
||||
try {
|
||||
const briefing = fs.readFileSync(path.join(repoRoot, 'docs/BRIEFING-FRONTEND.md'), 'utf8');
|
||||
const m = briefing.match(/Token:\s*(giteabu_[a-f0-9]+)/);
|
||||
if (m) token = m[1].trim();
|
||||
} catch (_) {}
|
||||
}
|
||||
if (!token) {
|
||||
console.error('Token non trouvé');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function get(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const opts = { hostname: 'git.ptits-pas.fr', path, method: 'GET', headers: { Authorization: 'token ' + token } };
|
||||
const req = https.request(opts, (res) => {
|
||||
let d = '';
|
||||
res.on('data', (c) => (d += c));
|
||||
res.on('end', () => {
|
||||
try { resolve(JSON.parse(d)); } catch (e) { reject(e); }
|
||||
});
|
||||
});
|
||||
req.on('error', reject);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const seen = new Map();
|
||||
for (const state of ['open', 'closed']) {
|
||||
for (let page = 1; ; page++) {
|
||||
const raw = await get('/api/v1/repos/jmartin/petitspas/issues?state=' + state + '&limit=50&page=' + page + '&type=issues');
|
||||
if (raw && raw.message && !Array.isArray(raw)) {
|
||||
console.error('API:', raw.message);
|
||||
process.exit(1);
|
||||
}
|
||||
const list = Array.isArray(raw) ? raw : [];
|
||||
for (const i of list) {
|
||||
if (!i.pull_request) seen.set(i.number, { number: i.number, title: i.title, state: i.state });
|
||||
}
|
||||
if (list.length < 50) break;
|
||||
}
|
||||
}
|
||||
const all = [...seen.values()].sort((a, b) => a.number - b.number);
|
||||
console.log(JSON.stringify(all, null, 2));
|
||||
}
|
||||
|
||||
main().catch((e) => { console.error(e); process.exit(1); });
|
||||
@ -29,6 +29,7 @@
|
||||
| 16 | [Doc] Documentation configuration on-premise | Ouvert |
|
||||
| 17 | [Backend] API Création gestionnaire | ✅ Terminé |
|
||||
| 91 | [Frontend] Inscription AM – Branchement soumission formulaire à l'API | Ouvert |
|
||||
| 101 | [Frontend] Inscription Parent – Branchement soumission formulaire à l'API | Ouvert |
|
||||
| 92 | [Frontend] Dashboard Admin - Données réelles et branchement API | ✅ Terminé |
|
||||
| 93 | [Frontend] Panneau Admin - Homogeneiser la presentation des onglets | ✅ Fermé |
|
||||
| 94 | [Backend] Relais - modele, API CRUD et liaison gestionnaire | ✅ Terminé |
|
||||
@ -1076,6 +1077,26 @@ Branchement du formulaire d'inscription AM (étape 4) à l'endpoint d'inscriptio
|
||||
|
||||
---
|
||||
|
||||
### Ticket #101 : [Frontend] Inscription Parent – Branchement soumission formulaire à l'API
|
||||
**Estimation** : 4h
|
||||
**Labels** : `frontend`, `p3`, `auth`, `cdc`
|
||||
|
||||
**Description** :
|
||||
Branchement du formulaire d'inscription parent (étape 5, récapitulatif) à l'endpoint d'inscription. Aujourd'hui la soumission n'appelle pas l'API : elle affiche uniquement une modale de confirmation puis redirige vers le login. Ce ticket vise à envoyer les données collectées (Parent 1, Parent 2 optionnel, enfants, présentation, CGU) à l'API.
|
||||
|
||||
**Tâches** :
|
||||
- [ ] Créer un service ou méthode (ex. `AuthService.registerParent` ou `UserService`) appelant `POST /api/v1/auth/register/parent`
|
||||
- [ ] Construire le body (DTO) à partir de `UserRegistrationData` (parent1, parent2, children, motivationText, CGU acceptée, etc.) en cohérence avec le contrat backend (voir ticket #18 refonte)
|
||||
- [ ] Dans `ParentRegisterStep5Screen`, au clic « Soumettre » : appel API puis en cas de succès afficher la modale et redirection vers `/login` ; en cas d'erreur afficher le message (SnackBar/dialog)
|
||||
- [ ] Gestion des photos enfants (base64 ou multipart selon API)
|
||||
- [ ] Optionnel : réinitialiser ou conserver `UserRegistrationData` après succès (selon UX)
|
||||
|
||||
**Référence** : [20_WORKFLOW-CREATION-COMPTE.md](./20_WORKFLOW-CREATION-COMPTE.md#étape-3--inscription-dun-parent), backend #18 (refonte API inscription parent).
|
||||
|
||||
**Création** : issue Gitea #101 créée. Pour recréer ou script : `node backend/scripts/create-gitea-issue-parent-api.js` (token dans `.gitea-token` ou voir [PROCEDURE-API-GITEA.md](./PROCEDURE-API-GITEA.md)).
|
||||
|
||||
---
|
||||
|
||||
### Ticket #93 : [Frontend] Panneau Admin - Homogénéisation des onglets ✅
|
||||
**Estimation** : 4h
|
||||
**Labels** : `frontend`, `p3`, `admin`, `ux`
|
||||
|
||||
@ -22,6 +22,9 @@ import '../screens/home/home_screen.dart';
|
||||
import '../screens/administrateurs/admin_dashboardScreen.dart';
|
||||
import '../screens/gestionnaire/gestionnaire_dashboard_screen.dart';
|
||||
import '../screens/home/parent_screen/ParentDashboardScreen.dart';
|
||||
import '../screens/am/am_dashboard_screen.dart';
|
||||
import '../screens/legal/privacy_page.dart';
|
||||
import '../screens/legal/legal_page.dart';
|
||||
import '../screens/unknown_screen.dart';
|
||||
|
||||
// --- Provider Instances ---
|
||||
@ -64,7 +67,16 @@ class AppRouter {
|
||||
),
|
||||
GoRoute(
|
||||
path: '/am-dashboard',
|
||||
builder: (BuildContext context, GoRouterState state) => const HomeScreen(),
|
||||
builder: (BuildContext context, GoRouterState state) =>
|
||||
const AmDashboardScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/privacy',
|
||||
builder: (BuildContext context, GoRouterState state) => const PrivacyPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/legal',
|
||||
builder: (BuildContext context, GoRouterState state) => const LegalPage(),
|
||||
),
|
||||
|
||||
// --- Parent Registration Flow ---
|
||||
|
||||
@ -41,9 +41,9 @@ class AppUser {
|
||||
relaisJson is Map<String, dynamic> ? relaisJson : <String, dynamic>{};
|
||||
|
||||
return AppUser(
|
||||
id: json['id'] as String,
|
||||
email: json['email'] as String,
|
||||
role: json['role'] as String,
|
||||
id: (json['id'] as String?) ?? '',
|
||||
email: (json['email'] as String?) ?? '',
|
||||
role: (json['role'] as String?) ?? '',
|
||||
createdAt: json['cree_le'] != null
|
||||
? DateTime.parse(json['cree_le'] as String)
|
||||
: (json['createdAt'] != null
|
||||
|
||||
@ -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: DashboardAppBarAdmin(
|
||||
selectedIndex: mainTabIndex,
|
||||
onTabChange: onMainTabChange,
|
||||
setupCompleted: _setupCompleted!,
|
||||
child: DashboardBandeau(
|
||||
tabItems: [
|
||||
DashboardTabItem(
|
||||
label: 'Gestion des utilisateurs',
|
||||
enabled: _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(
|
||||
|
||||
78
frontend/lib/screens/am/am_dashboard_screen.dart
Normal file
78
frontend/lib/screens/am/am_dashboard_screen.dart
Normal file
@ -0,0 +1,78 @@
|
||||
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/widgets/app_footer.dart';
|
||||
import 'package:p_tits_pas/widgets/dashboard/dashboard_bandeau.dart';
|
||||
|
||||
/// Dashboard assistante maternelle – page blanche avec bandeau générique.
|
||||
/// Contenu détaillé à venir.
|
||||
class AmDashboardScreen extends StatefulWidget {
|
||||
const AmDashboardScreen({super.key});
|
||||
|
||||
@override
|
||||
State<AmDashboardScreen> createState() => _AmDashboardScreenState();
|
||||
}
|
||||
|
||||
class _AmDashboardScreenState extends State<AmDashboardScreen> {
|
||||
int selectedTabIndex = 0;
|
||||
AppUser? _user;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUser();
|
||||
}
|
||||
|
||||
Future<void> _loadUser() async {
|
||||
final user = await AuthService.getCurrentUser();
|
||||
if (mounted) setState(() => _user = user);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(60.0),
|
||||
child: DashboardBandeau(
|
||||
tabItems: const [
|
||||
DashboardTabItem(label: 'Mon tableau de bord'),
|
||||
DashboardTabItem(label: 'Paramètres'),
|
||||
],
|
||||
selectedTabIndex: selectedTabIndex,
|
||||
onTabSelected: (index) => setState(() => selectedTabIndex = index),
|
||||
userDisplayName: _user?.fullName.isNotEmpty == true
|
||||
? _user!.fullName
|
||||
: 'Assistante maternelle',
|
||||
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: Center(
|
||||
child: Text(
|
||||
'Dashboard AM – à venir',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
const AppFooter(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/dashboard_admin.dart';
|
||||
import 'package:p_tits_pas/models/user.dart';
|
||||
import 'package:p_tits_pas/services/auth_service.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/dashboard/dashboard_bandeau.dart';
|
||||
|
||||
/// Dashboard gestionnaire – même shell que l'admin, sans onglet Paramètres.
|
||||
/// Réutilise [UserManagementPanel].
|
||||
@ -14,24 +16,47 @@ class GestionnaireDashboardScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _GestionnaireDashboardScreenState extends State<GestionnaireDashboardScreen> {
|
||||
AppUser? _user;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUser();
|
||||
}
|
||||
|
||||
Future<void> _loadUser() async {
|
||||
final user = await AuthService.getCurrentUser();
|
||||
if (mounted) setState(() => _user = user);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(60.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.shade300),
|
||||
),
|
||||
),
|
||||
child: DashboardAppBarAdmin(
|
||||
selectedIndex: 0,
|
||||
onTabChange: (_) {},
|
||||
showSettingsTab: false,
|
||||
roleLabel: 'Gestionnaire',
|
||||
setupCompleted: true,
|
||||
),
|
||||
child: DashboardBandeau(
|
||||
tabItems: const [
|
||||
DashboardTabItem(label: 'Gestion des utilisateurs'),
|
||||
],
|
||||
selectedTabIndex: 0,
|
||||
onTabSelected: (_) {},
|
||||
userDisplayName: _user?.fullName.isNotEmpty == true
|
||||
? _user!.fullName
|
||||
: 'Gestionnaire',
|
||||
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(
|
||||
|
||||
@ -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(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,143 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:p_tits_pas/services/auth_service.dart';
|
||||
|
||||
/// Barre du dashboard admin : onglets Gestion des utilisateurs | Paramètres + déconnexion.
|
||||
/// Pour le dashboard gestionnaire : [showSettingsTab] = false, [roleLabel] = 'Gestionnaire'.
|
||||
class DashboardAppBarAdmin extends StatelessWidget
|
||||
implements PreferredSizeWidget {
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onTabChange;
|
||||
final bool setupCompleted;
|
||||
final bool showSettingsTab;
|
||||
final String roleLabel;
|
||||
|
||||
const DashboardAppBarAdmin({
|
||||
Key? key,
|
||||
required this.selectedIndex,
|
||||
required this.onTabChange,
|
||||
this.setupCompleted = true,
|
||||
this.showSettingsTab = true,
|
||||
this.roleLabel = 'Admin',
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight + 10);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Row(
|
||||
children: [
|
||||
const SizedBox(width: 24),
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
height: 40,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildNavItem(context, 'Gestion des utilisateurs', 0,
|
||||
enabled: setupCompleted),
|
||||
if (showSettingsTab) ...[
|
||||
const SizedBox(width: 24),
|
||||
_buildNavItem(context, 'Paramètres', 1, enabled: true),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
roleLabel,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: TextButton(
|
||||
onPressed: () => _handleLogout(context),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF9CC5C0),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),
|
||||
child: const Text('Se déconnecter'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavItem(BuildContext context, String title, int index,
|
||||
{bool enabled = true}) {
|
||||
final bool isActive = index == selectedIndex;
|
||||
return InkWell(
|
||||
onTap: enabled ? () => onTabChange(index) : null,
|
||||
child: Opacity(
|
||||
opacity: enabled ? 1.0 : 0.5,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? const Color(0xFF9CC5C0) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: isActive ? null : Border.all(color: Colors.black26),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.white : Colors.black,
|
||||
fontWeight: isActive ? FontWeight.w600 : FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleLogout(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Déconnexion'),
|
||||
content: const Text('Êtes-vous sûr de vouloir vous déconnecter ?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
await AuthService.logout();
|
||||
if (context.mounted) context.go('/login');
|
||||
},
|
||||
child: const Text('Déconnecter'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sous-barre : Gestionnaires | Parents | Assistantes maternelles | [Administrateurs].
|
||||
/// [subTabCount] = 3 pour masquer l'onglet Administrateurs (dashboard gestionnaire).
|
||||
@ -212,31 +73,6 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _pillField({required double width, required Widget child}) {
|
||||
return Container(
|
||||
width: width,
|
||||
height: 34,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
border: Border.all(color: Colors.black26),
|
||||
),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAddButton() {
|
||||
return ElevatedButton.icon(
|
||||
onPressed: onAddPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(addLabel),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSubNavItem(BuildContext context, String title, int index) {
|
||||
final bool isActive = index == selectedSubIndex;
|
||||
return InkWell(
|
||||
onTap: () => onSubTabChange(index),
|
||||
child: Container(
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:p_tits_pas/models/m_dashbord/child_model.dart';
|
||||
import 'package:p_tits_pas/services/bug_report_service.dart';
|
||||
@ -185,13 +186,11 @@ class AppFooter extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _handleLegalNotices(BuildContext context) {
|
||||
// Handle legal notices action
|
||||
Navigator.pushNamed(context, '/legal');
|
||||
context.push('/legal');
|
||||
}
|
||||
|
||||
void _handlePrivacyPolicy(BuildContext context) {
|
||||
// Handle privacy policy action
|
||||
Navigator.pushNamed(context, '/privacy');
|
||||
context.push('/privacy');
|
||||
}
|
||||
|
||||
void _handleContactSupport(BuildContext context) {
|
||||
|
||||
299
frontend/lib/widgets/dashboard/dashboard_bandeau.dart
Normal file
299
frontend/lib/widgets/dashboard/dashboard_bandeau.dart
Normal file
@ -0,0 +1,299 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:p_tits_pas/services/auth_service.dart';
|
||||
|
||||
/// Item d'onglet pour le bandeau (label + enabled).
|
||||
class DashboardTabItem {
|
||||
final String label;
|
||||
final bool enabled;
|
||||
|
||||
const DashboardTabItem({
|
||||
required this.label,
|
||||
this.enabled = true,
|
||||
});
|
||||
}
|
||||
|
||||
/// Icône associée au rôle utilisateur (alignée sur le panneau admin).
|
||||
IconData _iconForRole(String? role) {
|
||||
if (role == null || role.isEmpty) return Icons.person_outline;
|
||||
final r = role.toLowerCase();
|
||||
if (r == 'super_admin') return Icons.verified_user_outlined;
|
||||
if (r == 'admin' || r == 'administrateur') return Icons.manage_accounts_outlined;
|
||||
if (r == 'gestionnaire') return Icons.assignment_ind_outlined;
|
||||
if (r == 'parent') return Icons.supervisor_account_outlined;
|
||||
if (r == 'assistante_maternelle') return Icons.face;
|
||||
return Icons.person_outline;
|
||||
}
|
||||
|
||||
/// Bandeau générique type Gitea : icône | onglets | capsule (Prénom Nom ▼) → menu (email, Profil, Paramètres, Déconnexion).
|
||||
class DashboardBandeau extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Widget? leading;
|
||||
final List<DashboardTabItem> tabItems;
|
||||
final int selectedTabIndex;
|
||||
final ValueChanged<int> onTabSelected;
|
||||
final String userDisplayName;
|
||||
final String? userEmail;
|
||||
/// Rôle de l'utilisateur pour afficher l'icône correspondante (même que panneau admin).
|
||||
final String? userRole;
|
||||
final VoidCallback? onProfileTap;
|
||||
final VoidCallback? onSettingsTap;
|
||||
final VoidCallback? onLogout;
|
||||
final bool showLogoutConfirmation;
|
||||
final bool bottomBorder;
|
||||
final double? preferredHeight;
|
||||
|
||||
const DashboardBandeau({
|
||||
super.key,
|
||||
this.leading,
|
||||
required this.tabItems,
|
||||
required this.selectedTabIndex,
|
||||
required this.onTabSelected,
|
||||
required this.userDisplayName,
|
||||
this.userEmail,
|
||||
this.userRole,
|
||||
this.onProfileTap,
|
||||
this.onSettingsTap,
|
||||
this.onLogout,
|
||||
this.showLogoutConfirmation = true,
|
||||
this.bottomBorder = true,
|
||||
this.preferredHeight,
|
||||
});
|
||||
|
||||
@override
|
||||
Size get preferredSize =>
|
||||
Size.fromHeight(preferredHeight ?? (kToolbarHeight + 10));
|
||||
|
||||
Widget _defaultLeading() {
|
||||
return Image.asset(
|
||||
'assets/images/logo.png',
|
||||
height: 40,
|
||||
fit: BoxFit.contain,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).appBarTheme.backgroundColor ?? Colors.white,
|
||||
border: bottomBorder
|
||||
? Border(bottom: BorderSide(color: Colors.grey.shade300))
|
||||
: null,
|
||||
),
|
||||
child: AppBar(
|
||||
elevation: 0,
|
||||
automaticallyImplyLeading: false,
|
||||
title: Row(
|
||||
children: [
|
||||
const SizedBox(width: 24),
|
||||
leading ?? _defaultLeading(),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (int i = 0; i < tabItems.length; i++) ...[
|
||||
if (i > 0) const SizedBox(width: 24),
|
||||
_buildNavItem(
|
||||
context,
|
||||
title: tabItems[i].label,
|
||||
index: i,
|
||||
enabled: tabItems[i].enabled,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
_buildUserCapsule(context),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavItem(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required int index,
|
||||
bool enabled = true,
|
||||
}) {
|
||||
final isActive = index == selectedTabIndex;
|
||||
return InkWell(
|
||||
onTap: enabled ? () => onTabSelected(index) : null,
|
||||
child: Opacity(
|
||||
opacity: enabled ? 1.0 : 0.5,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? const Color(0xFF9CC5C0) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: isActive ? null : Border.all(color: Colors.black26),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.white : Colors.black,
|
||||
fontWeight: isActive ? FontWeight.w600 : FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildUserCapsule(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: PopupMenuButton<String?>(
|
||||
offset: const Offset(0, 45),
|
||||
position: PopupMenuPosition.under,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'profile':
|
||||
onProfileTap?.call();
|
||||
break;
|
||||
case 'settings':
|
||||
onSettingsTap?.call();
|
||||
break;
|
||||
case 'logout':
|
||||
_handleLogout(context);
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) {
|
||||
final entries = <PopupMenuEntry<String?>>[];
|
||||
if (userEmail != null && userEmail!.isNotEmpty) {
|
||||
entries.add(
|
||||
PopupMenuItem<String?>(
|
||||
enabled: false,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.email_outlined, size: 16, color: Colors.grey.shade700),
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
userEmail!,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade700,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
entries.add(const PopupMenuDivider());
|
||||
}
|
||||
if (onProfileTap != null) {
|
||||
entries.add(
|
||||
const PopupMenuItem<String?>(
|
||||
value: 'profile',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.person_outline, size: 20),
|
||||
title: Text('Modification du profil'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (onSettingsTap != null) {
|
||||
entries.add(
|
||||
const PopupMenuItem<String?>(
|
||||
value: 'settings',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.settings_outlined, size: 20),
|
||||
title: Text('Paramètres'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (onLogout != null) {
|
||||
if (entries.isNotEmpty) entries.add(const PopupMenuDivider());
|
||||
entries.add(
|
||||
const PopupMenuItem<String?>(
|
||||
value: 'logout',
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.logout, size: 20),
|
||||
title: Text('Déconnexion'),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return entries;
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(color: Colors.grey.shade300),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(_iconForRole(userRole), size: 18, color: Colors.grey.shade700),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
userDisplayName,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(Icons.keyboard_arrow_down, size: 20, color: Colors.grey.shade700),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleLogout(BuildContext context) {
|
||||
if (showLogoutConfirmation) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: const Text('Déconnexion'),
|
||||
content: const Text(
|
||||
'Êtes-vous sûr de vouloir vous déconnecter ?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(ctx),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(ctx);
|
||||
onLogout?.call();
|
||||
await AuthService.logout();
|
||||
if (context.mounted) context.go('/login');
|
||||
},
|
||||
child: const Text('Déconnecter'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
onLogout?.call();
|
||||
AuthService.logout().then((_) {
|
||||
if (context.mounted) context.go('/login');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,156 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DashboardAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onTabChange;
|
||||
|
||||
const DashboardAppBar({Key? key, required this.selectedIndex, required this.onTabChange}) : super(key: key);
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight + 10);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isMobile = MediaQuery.of(context).size.width < 768;
|
||||
return AppBar(
|
||||
// backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
title: Row(
|
||||
children: [
|
||||
// Logo de la ville
|
||||
// Container(
|
||||
// height: 32,
|
||||
// width: 32,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// ),
|
||||
// child: const Icon(
|
||||
// Icons.location_city,
|
||||
// color: Color(0xFF9CC5C0),
|
||||
// size: 20,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(width: MediaQuery.of(context).size.width * 0.19),
|
||||
const Text(
|
||||
"P'tit Pas",
|
||||
style: TextStyle(
|
||||
color: Color(0xFF9CC5C0),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
SizedBox(width: MediaQuery.of(context).size.width * 0.1),
|
||||
|
||||
// Navigation principale
|
||||
_buildNavItem(context, 'Mon tableau de bord', 0),
|
||||
const SizedBox(width: 24),
|
||||
_buildNavItem(context, 'Trouver une nounou', 1),
|
||||
const SizedBox(width: 24),
|
||||
_buildNavItem(context, 'Paramètres', 2),
|
||||
],
|
||||
),
|
||||
actions: isMobile
|
||||
? [_buildMobileMenu(context)]
|
||||
: [
|
||||
// Nom de l'utilisateur
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Jean Dupont',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Bouton déconnexion
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: TextButton(
|
||||
onPressed: () => _handleLogout(context),
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF9CC5C0),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
),
|
||||
child: const Text('Se déconnecter'),
|
||||
),
|
||||
),
|
||||
SizedBox(width: MediaQuery.of(context).size.width * 0.1),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildNavItem(BuildContext context, String title, int index) {
|
||||
final bool isActive = index == selectedIndex;
|
||||
return InkWell(
|
||||
onTap: () => onTabChange(index),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isActive ? const Color(0xFF9CC5C0) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: isActive ? null : Border.all(color: Colors.black26),
|
||||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? Colors.white : Colors.black,
|
||||
fontWeight: isActive ? FontWeight.w600 : FontWeight.normal,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildMobileMenu(BuildContext context) {
|
||||
return PopupMenuButton<int>(
|
||||
icon: const Icon(Icons.menu, color: Colors.white),
|
||||
onSelected: (value) {
|
||||
if (value == 3) {
|
||||
_handleLogout(context);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
const PopupMenuItem(value: 0, child: Text("Mon tableau de bord")),
|
||||
const PopupMenuItem(value: 1, child: Text("Trouver une nounou")),
|
||||
const PopupMenuItem(value: 2, child: Text("Paramètres")),
|
||||
const PopupMenuDivider(),
|
||||
const PopupMenuItem(value: 3, child: Text("Se déconnecter")),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _handleLogout(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Déconnexion'),
|
||||
content: const Text('Êtes-vous sûr de vouloir vous déconnecter ?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Annuler'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
// TODO: Implémenter la logique de déconnexion
|
||||
},
|
||||
child: const Text('Déconnecter'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user