feat(frontend): add back button in top bar (in-app navigation)
This commit is contained in:
@@ -41,10 +41,11 @@ class HomeScreen extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const EnsupTopBar(
|
EnsupTopBar(
|
||||||
campusTag: "Paris · Ensitech",
|
campusTag: "Paris · Ensitech",
|
||||||
userName: "Lucas Martin",
|
userName: "Lucas Martin",
|
||||||
userInitials: "LM",
|
userInitials: "LM",
|
||||||
|
onBack: () => Navigator.of(context).pop(),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import "package:flutter/material.dart";
|
|||||||
import "package:google_fonts/google_fonts.dart";
|
import "package:google_fonts/google_fonts.dart";
|
||||||
import "../theme/ensup_colors.dart";
|
import "../theme/ensup_colors.dart";
|
||||||
|
|
||||||
/// Barre supérieure ENSUP. L'utilisateur est optionnel (absent sur l'écran
|
/// Barre supérieure ENSUP. L'utilisateur et le bouton retour sont optionnels
|
||||||
/// d'identification, présent une fois l'étudiant connecté).
|
/// (absents sur l'écran d'identification).
|
||||||
class EnsupTopBar extends StatelessWidget {
|
class EnsupTopBar extends StatelessWidget {
|
||||||
const EnsupTopBar({
|
const EnsupTopBar({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -11,27 +11,34 @@ class EnsupTopBar extends StatelessWidget {
|
|||||||
required this.campusTag,
|
required this.campusTag,
|
||||||
this.userName,
|
this.userName,
|
||||||
this.userInitials,
|
this.userInitials,
|
||||||
|
this.onBack,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String brandText;
|
final String brandText;
|
||||||
final String campusTag;
|
final String campusTag;
|
||||||
final String? userName;
|
final String? userName;
|
||||||
final String? userInitials;
|
final String? userInitials;
|
||||||
|
final VoidCallback? onBack;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final name = userName;
|
final name = userName;
|
||||||
final initials = userInitials;
|
final initials = userInitials;
|
||||||
|
final onBack = this.onBack;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
height: 56,
|
height: 56,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
color: EnsupColors.blue3,
|
color: EnsupColors.blue3,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
if (onBack != null) ...[
|
||||||
|
_BackButton(onTap: onBack),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
const Icon(Icons.badge_outlined, color: Colors.white, size: 18),
|
const Icon(Icons.badge_outlined, color: Colors.white, size: 18),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text(
|
Text(
|
||||||
@@ -84,6 +91,38 @@ class EnsupTopBar extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _BackButton extends StatelessWidget {
|
||||||
|
const _BackButton({required this.onTap});
|
||||||
|
|
||||||
|
final VoidCallback onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.arrow_back, size: 16, color: Colors.white.withValues(alpha: 0.85)),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
"Retour",
|
||||||
|
style: GoogleFonts.titilliumWeb(
|
||||||
|
color: Colors.white.withValues(alpha: 0.85),
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _Avatar extends StatelessWidget {
|
class _Avatar extends StatelessWidget {
|
||||||
const _Avatar({required this.initials});
|
const _Avatar({required this.initials});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user