- Add 'Previous' and 'Submit' buttons to mobile recap screens (Parent & AM) - Fix imports for navigation buttons and widgets - Adjust ChildCardWidget width to fill available space on mobile editing Co-authored-by: Cursor <cursoragent@cursor.com>
242 lines
9.2 KiB
Dart
242 lines
9.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'dart:math' as math;
|
|
|
|
import '../../models/am_registration_data.dart';
|
|
import '../../models/card_assets.dart';
|
|
import '../../config/display_config.dart';
|
|
import '../../widgets/hover_relief_widget.dart';
|
|
import '../../widgets/image_button.dart';
|
|
import '../../widgets/custom_navigation_button.dart';
|
|
import '../../widgets/personal_info_form_screen.dart';
|
|
import '../../widgets/professional_info_form_screen.dart';
|
|
import '../../widgets/presentation_form_screen.dart';
|
|
|
|
class AmRegisterStep4Screen extends StatefulWidget {
|
|
const AmRegisterStep4Screen({super.key});
|
|
|
|
@override
|
|
_AmRegisterStep4ScreenState createState() => _AmRegisterStep4ScreenState();
|
|
}
|
|
|
|
class _AmRegisterStep4ScreenState extends State<AmRegisterStep4Screen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final registrationData = Provider.of<AmRegistrationData>(context);
|
|
final screenSize = MediaQuery.of(context).size;
|
|
final config = DisplayConfig.fromContext(context, mode: DisplayMode.readonly);
|
|
|
|
return Scaffold(
|
|
body: Stack(
|
|
children: [
|
|
Positioned.fill(
|
|
child: Image.asset('assets/images/paper2.png', fit: BoxFit.cover, repeat: ImageRepeat.repeatY),
|
|
),
|
|
Center(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.symmetric(vertical: 40.0),
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: config.isMobile ? 0 : screenSize.width / 4.0
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text('Étape 4/4', style: GoogleFonts.merienda(fontSize: 16, color: Colors.black54)),
|
|
const SizedBox(height: 20),
|
|
Text('Récapitulatif de votre demande', style: GoogleFonts.merienda(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black87), textAlign: TextAlign.center),
|
|
const SizedBox(height: 30),
|
|
|
|
// Carte 1: Informations personnelles
|
|
_buildPersonalInfo(context, registrationData),
|
|
const SizedBox(height: 30),
|
|
|
|
// Carte 2: Informations professionnelles
|
|
_buildProfessionalInfo(context, registrationData),
|
|
const SizedBox(height: 30),
|
|
|
|
// Carte 3: Présentation
|
|
_buildPresentation(context, registrationData),
|
|
const SizedBox(height: 40),
|
|
|
|
// Boutons Mobile (Retour + Soumettre) ou Bouton Soumettre Desktop
|
|
if (config.isMobile)
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: screenSize.width * 0.05),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: HoverReliefWidget(
|
|
child: CustomNavigationButton(
|
|
text: 'Précédent',
|
|
style: NavigationButtonStyle.purple,
|
|
onPressed: () {
|
|
if (context.canPop()) {
|
|
context.pop();
|
|
} else {
|
|
context.go('/am-register-step3');
|
|
}
|
|
},
|
|
width: double.infinity,
|
|
height: 50,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: HoverReliefWidget(
|
|
child: CustomNavigationButton(
|
|
text: 'Soumettre',
|
|
style: NavigationButtonStyle.green,
|
|
onPressed: () {
|
|
print("Données AM finales: ${registrationData.firstName} ${registrationData.lastName}");
|
|
_showConfirmationModal(context);
|
|
},
|
|
width: double.infinity,
|
|
height: 50,
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
else
|
|
ImageButton(
|
|
bg: 'assets/images/bg_green.png',
|
|
text: 'Soumettre ma demande',
|
|
textColor: const Color(0xFF2D6A4F),
|
|
width: 350,
|
|
height: 50,
|
|
fontSize: 18,
|
|
onPressed: () {
|
|
print("Données AM finales: ${registrationData.firstName} ${registrationData.lastName}");
|
|
_showConfirmationModal(context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// Chevrons desktop uniquement
|
|
if (!config.isMobile)
|
|
Positioned(
|
|
top: screenSize.height / 2 - 20,
|
|
left: 40,
|
|
child: IconButton(
|
|
icon: Transform(
|
|
alignment: Alignment.center,
|
|
transform: Matrix4.rotationY(math.pi),
|
|
child: Image.asset('assets/images/chevron_right.png', height: 40),
|
|
),
|
|
onPressed: () {
|
|
if (context.canPop()) {
|
|
context.pop();
|
|
} else {
|
|
context.go('/am-register-step3');
|
|
}
|
|
},
|
|
tooltip: 'Retour',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildPersonalInfo(BuildContext context, AmRegistrationData data) {
|
|
return PersonalInfoFormScreen(
|
|
mode: DisplayMode.readonly,
|
|
embedContentOnly: true,
|
|
stepText: '',
|
|
title: 'Informations personnelles',
|
|
cardColor: CardColorHorizontal.blue,
|
|
initialData: PersonalInfoData(
|
|
firstName: data.firstName,
|
|
lastName: data.lastName,
|
|
phone: data.phone,
|
|
email: data.email,
|
|
address: data.streetAddress,
|
|
postalCode: data.postalCode,
|
|
city: data.city,
|
|
),
|
|
onSubmit: (d, {hasSecondPerson, sameAddress}) {}, // No-op en readonly
|
|
previousRoute: '',
|
|
onEdit: () => context.go('/am-register-step1'),
|
|
);
|
|
}
|
|
|
|
Widget _buildProfessionalInfo(BuildContext context, AmRegistrationData data) {
|
|
return ProfessionalInfoFormScreen(
|
|
mode: DisplayMode.readonly,
|
|
embedContentOnly: true,
|
|
stepText: '',
|
|
title: 'Informations professionnelles',
|
|
cardColor: CardColorHorizontal.green,
|
|
initialData: ProfessionalInfoData(
|
|
// TODO: Gérer photoPath vs photoFile correctement
|
|
photoPath: null, // Pas d'accès facile au fichier ici, on verra
|
|
dateOfBirth: data.dateOfBirth,
|
|
birthCity: data.birthCity,
|
|
birthCountry: data.birthCountry,
|
|
nir: data.nir,
|
|
agrementNumber: data.agrementNumber,
|
|
capacity: data.capacity,
|
|
photoConsent: data.photoConsent,
|
|
),
|
|
onSubmit: (d) {},
|
|
previousRoute: '',
|
|
onEdit: () => context.go('/am-register-step2'),
|
|
);
|
|
}
|
|
|
|
Widget _buildPresentation(BuildContext context, AmRegistrationData data) {
|
|
return PresentationFormScreen(
|
|
mode: DisplayMode.readonly,
|
|
embedContentOnly: true,
|
|
stepText: '',
|
|
title: 'Présentation & CGU',
|
|
cardColor: CardColorHorizontal.peach,
|
|
textFieldHint: '',
|
|
initialText: data.presentationText,
|
|
initialCguAccepted: data.cguAccepted,
|
|
previousRoute: '',
|
|
onSubmit: (t, c) {},
|
|
onEdit: () => context.go('/am-register-step3'),
|
|
);
|
|
}
|
|
|
|
void _showConfirmationModal(BuildContext context) {
|
|
showDialog<void>(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext dialogContext) {
|
|
return AlertDialog(
|
|
title: Text(
|
|
'Demande enregistrée',
|
|
style: GoogleFonts.merienda(fontWeight: FontWeight.bold),
|
|
),
|
|
content: Text(
|
|
'Votre dossier a bien été pris en compte. Un gestionnaire le validera bientôt.',
|
|
style: GoogleFonts.merienda(fontSize: 14),
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text('OK', style: GoogleFonts.merienda(fontWeight: FontWeight.bold)),
|
|
onPressed: () {
|
|
Navigator.of(dialogContext).pop();
|
|
context.go('/login');
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|