160 lines
7.0 KiB
Dart
160 lines
7.0 KiB
Dart
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";
|
||
import "../widgets/action_card.dart";
|
||
import "../widgets/brand_corners.dart";
|
||
import "catalogue_screen.dart";
|
||
import "restitution_select_screen.dart";
|
||
|
||
/// Écran d'accueil étudiant : profil + choix Emprunter / Restituer.
|
||
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(
|
||
backgroundColor: EnsupColors.soft,
|
||
body: Stack(
|
||
children: [
|
||
Center(
|
||
child: ConstrainedBox(
|
||
constraints: const BoxConstraints(maxWidth: 1280, maxHeight: 820),
|
||
child: Container(
|
||
margin: const EdgeInsets.all(24),
|
||
decoration: BoxDecoration(
|
||
color: Colors.white,
|
||
borderRadius: BorderRadius.circular(16),
|
||
boxShadow: [
|
||
BoxShadow(
|
||
color: EnsupColors.text.withValues(alpha: 0.14),
|
||
blurRadius: 60,
|
||
offset: const Offset(0, 18),
|
||
),
|
||
],
|
||
),
|
||
clipBehavior: Clip.antiAlias,
|
||
child: Column(
|
||
children: [
|
||
EnsupTopBar(
|
||
campusTag: DemoIdentity.campusTag,
|
||
userName: DemoIdentity.userName,
|
||
userInitials: DemoIdentity.userInitials,
|
||
onBack: () => _quitter(context),
|
||
),
|
||
Expanded(
|
||
child: SingleChildScrollView(
|
||
padding: const EdgeInsets.symmetric(
|
||
horizontal: 28,
|
||
vertical: 26,
|
||
),
|
||
child: Center(
|
||
child: ConstrainedBox(
|
||
constraints: const BoxConstraints(maxWidth: 1040),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
const ProfileCard(
|
||
name: DemoIdentity.userName,
|
||
subtitle: DemoIdentity.userSubtitle,
|
||
initials: DemoIdentity.userInitials,
|
||
),
|
||
const SizedBox(height: 28),
|
||
Text(
|
||
"Que souhaitez-vous faire ?",
|
||
style: GoogleFonts.darkerGrotesque(
|
||
fontSize: 30,
|
||
height: 1,
|
||
fontWeight: FontWeight.w900,
|
||
color: EnsupColors.text,
|
||
),
|
||
),
|
||
const SizedBox(height: 6),
|
||
Text(
|
||
"Choisissez l’opération à réaliser sur ce poste.",
|
||
style: GoogleFonts.titilliumWeb(
|
||
fontSize: 14,
|
||
color: EnsupColors.muted,
|
||
),
|
||
),
|
||
const SizedBox(height: 20),
|
||
LayoutBuilder(
|
||
builder: (context, constraints) {
|
||
final emprunter = ActionCard(
|
||
icon: Icons.inventory_2_outlined,
|
||
title: "EMPRUNTER",
|
||
description:
|
||
"Consulter les équipements disponibles et démarrer un nouvel emprunt.",
|
||
color: EnsupColors.cyan,
|
||
onTap: () => Navigator.of(context).push(
|
||
MaterialPageRoute(
|
||
builder: (_) =>
|
||
const CatalogueScreen(),
|
||
),
|
||
),
|
||
);
|
||
final restituer = ActionCard(
|
||
icon: Icons.assignment_return_outlined,
|
||
title: "RESTITUER",
|
||
description:
|
||
"Sélectionner un emprunt en cours et contrôler le matériel rendu.",
|
||
color: EnsupColors.teal,
|
||
onTap: () => Navigator.of(context).push(
|
||
MaterialPageRoute(
|
||
builder: (_) =>
|
||
const RestitutionSelectScreen(),
|
||
),
|
||
),
|
||
);
|
||
|
||
if (constraints.maxWidth < 720) {
|
||
return Column(
|
||
crossAxisAlignment:
|
||
CrossAxisAlignment.stretch,
|
||
children: [
|
||
emprunter,
|
||
const SizedBox(height: 14),
|
||
restituer,
|
||
],
|
||
);
|
||
}
|
||
|
||
return IntrinsicHeight(
|
||
child: Row(
|
||
crossAxisAlignment:
|
||
CrossAxisAlignment.stretch,
|
||
children: [
|
||
Expanded(child: emprunter),
|
||
const SizedBox(width: 16),
|
||
Expanded(child: restituer),
|
||
],
|
||
),
|
||
);
|
||
},
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
const Positioned.fill(child: BrandCorners()),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|