- Framework: Flutter web - Pages: Login, inscription, dashboards - Services: API client, authentification, gestion d'état - Intégration avec backend NestJS - Dockerfile pour déploiement web
145 lines
4.5 KiB
Dart
145 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class DashboardAppBarAdmin extends StatelessWidget implements PreferredSizeWidget {
|
|
final int selectedIndex;
|
|
final ValueChanged<int> onTabChange;
|
|
|
|
const DashboardAppBarAdmin({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(
|
|
elevation: 0,
|
|
automaticallyImplyLeading: false,
|
|
title: Row(
|
|
children: [
|
|
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, 'Gestionnaires', 0),
|
|
const SizedBox(width: 24),
|
|
_buildNavItem(context, 'Parents', 1),
|
|
const SizedBox(width: 24),
|
|
_buildNavItem(context, 'Assistantes maternelles', 2),
|
|
const SizedBox(width: 24),
|
|
_buildNavItem(context, 'Administrateurs', 3),
|
|
],
|
|
),
|
|
actions: isMobile
|
|
? [_buildMobileMenu(context)]
|
|
: [
|
|
// Nom de l'utilisateur
|
|
const Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16),
|
|
child: Center(
|
|
child: Text(
|
|
'Admin',
|
|
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 == 4) {
|
|
_handleLogout(context);
|
|
}
|
|
},
|
|
itemBuilder: (context) => [
|
|
const PopupMenuItem(value: 0, child: Text("Gestionnaires")),
|
|
const PopupMenuItem(value: 1, child: Text("Parents")),
|
|
const PopupMenuItem(value: 2, child: Text("Assistantes maternelles")),
|
|
const PopupMenuItem(value: 3, child: Text("Administrateurs")),
|
|
const PopupMenuDivider(),
|
|
const PopupMenuItem(value: 4, 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'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |