feat(frontend): simulate authenticated user sessions

This commit is contained in:
SaidSoighiri94
2026-07-23 12:39:12 +02:00
parent 313bb1c6ef
commit 530bd52cb5
6 changed files with 104 additions and 54 deletions
+7 -1
View File
@@ -1,6 +1,7 @@
import "package:flutter/material.dart";
import "package:google_fonts/google_fonts.dart";
import "../demo_identity.dart";
import "../services/auth_service.dart";
import "../theme/ensup_colors.dart";
import "../widgets/ensup_top_bar.dart";
import "../widgets/profile_card.dart";
@@ -13,6 +14,11 @@ import "restitution_select_screen.dart";
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
void _quitter(BuildContext context) {
AuthService.clearSession();
Navigator.of(context).pop();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -42,7 +48,7 @@ class HomeScreen extends StatelessWidget {
campusTag: DemoIdentity.campusTag,
userName: DemoIdentity.userName,
userInitials: DemoIdentity.userInitials,
onBack: () => Navigator.of(context).pop(),
onBack: () => _quitter(context),
),
Expanded(
child: SingleChildScrollView(
+13 -9
View File
@@ -1,6 +1,7 @@
import "package:flutter/material.dart";
import "package:google_fonts/google_fonts.dart";
import "../demo_identity.dart";
import "../services/auth_service.dart";
import "../theme/ensup_colors.dart";
import "../widgets/ensup_top_bar.dart";
import "../widgets/identification_option.dart";
@@ -13,6 +14,7 @@ class LoginScreen extends StatelessWidget {
const LoginScreen({super.key});
void _identifier(BuildContext context) {
AuthService.selectDemoStudent();
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const HomeScreen(),
@@ -21,6 +23,16 @@ class LoginScreen extends StatelessWidget {
);
}
void _identifierResponsable(BuildContext context) {
AuthService.selectDemoResponsable();
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const ResponsableScreen(),
settings: const RouteSettings(name: "responsable"),
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -162,15 +174,7 @@ class LoginScreen extends StatelessWidget {
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () =>
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) =>
const ResponsableScreen(),
settings: const RouteSettings(
name: "responsable",
),
),
),
_identifierResponsable(context),
icon: const Icon(
Icons.person_outline,
size: 16,
@@ -2,6 +2,7 @@ import "package:flutter/material.dart";
import "package:google_fonts/google_fonts.dart";
import "../demo_identity.dart";
import "../services/auth_service.dart";
import "../services/responsable_service.dart";
import "../theme/ensup_colors.dart";
import "../utils/file_download.dart";
@@ -44,6 +45,11 @@ class _ResponsableScreenState extends State<ResponsableScreen> {
setState(() => _future = _charger());
}
void _quitter() {
AuthService.clearSession();
Navigator.of(context).pop();
}
Future<void> _changerStatut(Map<String, dynamic> anomalie) async {
final prochain = _prochainStatut(anomalie["statut"] as String?);
if (prochain == null || _transitionEnCours) {
@@ -124,10 +130,7 @@ class _ResponsableScreenState extends State<ResponsableScreen> {
body: SafeArea(
child: Column(
children: [
_ResponsableTopBar(
onExit: () => Navigator.of(context).pop(),
onRefresh: _rafraichir,
),
_ResponsableTopBar(onExit: _quitter, onRefresh: _rafraichir),
Expanded(
child: FutureBuilder<_ResponsableData>(
future: _future,
@@ -249,7 +252,7 @@ class _ResponsableScreenState extends State<ResponsableScreen> {
anomaliesActives: anomaliesActives,
notificationsNonLues: notificationsNonLues,
onChanged: (index) => setState(() => _onglet = index),
onExit: () => Navigator.of(context).pop(),
onExit: _quitter,
),
Expanded(
child: Column(