[#101] [Frontend] Inscription parent — API, soumission et validation
Squash merge de develop vers master. Livrables principaux (ticket #101 et mise au point associée) : - Branchement du formulaire d'inscription parent sur POST /api/v1/auth/register/parent - Payload DTO (parents, enfants, photos base64, CGU) et services Auth - Parcours gestionnaire : cartes dossiers, wizard validation famille, images authentifiées - Scripts d'inscription test (Martin, Durand/Rousseau, Lecomte) ; .gitignore .cursor/ Inclut également les ajustements develop fusionnés dans ce lot (inscription AM, champs relais, etc.). Closes #101 Made-with: Cursor
This commit is contained in:
@@ -1,14 +1,41 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'dart:io' show File;
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import '../models/user_registration_data.dart';
|
||||
import '../models/card_assets.dart';
|
||||
import 'custom_app_text_field.dart';
|
||||
import 'form_field_wrapper.dart';
|
||||
import 'app_custom_checkbox.dart';
|
||||
import 'hover_relief_widget.dart';
|
||||
import '../config/display_config.dart';
|
||||
import 'package:p_tits_pas/utils/name_format_utils.dart';
|
||||
|
||||
const String _photoConsentTooltip =
|
||||
'Obligatoire : cochez cette case pour autoriser l’utilisation de la photo de l’enfant.\n'
|
||||
'Suivi du dossier et organisation de l’accueil (affichage interne, outils pédagogiques).\n'
|
||||
'Dans le respect de la politique de confidentialité.';
|
||||
|
||||
/// Cadre photo (centre transparent), même dossier que `photo.png`.
|
||||
const String _photoSketchFrameAsset = 'assets/images/photo_frame.png';
|
||||
|
||||
bool _hasChildPhoto(ChildData c) {
|
||||
final b = c.imageBytes;
|
||||
if (b != null && b.isNotEmpty) return true;
|
||||
return c.imageFile != null;
|
||||
}
|
||||
|
||||
Widget _buildChildPhotoImage(ChildData c, {required BoxFit fit}) {
|
||||
final bytes = c.imageBytes;
|
||||
if (bytes != null && bytes.isNotEmpty) {
|
||||
return Image.memory(bytes, fit: fit);
|
||||
}
|
||||
final f = c.imageFile;
|
||||
if (f != null) {
|
||||
return kIsWeb ? Image.network(f.path, fit: fit) : Image.file(f, fit: fit);
|
||||
}
|
||||
return Image.asset('assets/images/photo.png', fit: BoxFit.contain);
|
||||
}
|
||||
|
||||
/// Widget pour afficher et éditer une carte enfant
|
||||
/// Utilisé dans le workflow d'inscription des parents
|
||||
@@ -16,11 +43,14 @@ class ChildCardWidget extends StatefulWidget {
|
||||
final ChildData childData;
|
||||
final int childIndex;
|
||||
final VoidCallback onPickImage;
|
||||
/// Retire la photo sélectionnée (placeholder à la place).
|
||||
final VoidCallback onClearImage;
|
||||
final VoidCallback onDateSelect;
|
||||
final ValueChanged<String> onFirstNameChanged;
|
||||
final ValueChanged<String> onLastNameChanged;
|
||||
/// `H`, `F` ou `Autre` (API). « Inconnu » à l’UI = `Autre`.
|
||||
final ValueChanged<String> onGenreChanged;
|
||||
final ValueChanged<bool> onTogglePhotoConsent;
|
||||
final ValueChanged<bool> onToggleMultipleBirth;
|
||||
final ValueChanged<bool> onToggleIsUnborn;
|
||||
final VoidCallback onRemove;
|
||||
final bool canBeRemoved;
|
||||
@@ -32,11 +62,12 @@ class ChildCardWidget extends StatefulWidget {
|
||||
required this.childData,
|
||||
required this.childIndex,
|
||||
required this.onPickImage,
|
||||
required this.onClearImage,
|
||||
required this.onDateSelect,
|
||||
required this.onFirstNameChanged,
|
||||
required this.onLastNameChanged,
|
||||
required this.onGenreChanged,
|
||||
required this.onTogglePhotoConsent,
|
||||
required this.onToggleMultipleBirth,
|
||||
required this.onToggleIsUnborn,
|
||||
required this.onRemove,
|
||||
required this.canBeRemoved,
|
||||
@@ -49,10 +80,24 @@ class ChildCardWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
/// Largeur desktop : proportionnelle au côté du carré photo (512×1024 sur les PNG → portrait ~1:2 ; même idée qu’avant #78 : 345×1,1 pour 200 px de côté).
|
||||
static double _desktopEditableCardWidth({
|
||||
required double photoSide,
|
||||
required double maxWidth,
|
||||
required double scaleFactor,
|
||||
}) {
|
||||
final fromPhoto = photoSide * (345.0 * 1.1 / 200.0);
|
||||
final minForFields = 300.0 + 44.0 * scaleFactor;
|
||||
return math.min(maxWidth, math.max(minForFields, fromPhoto));
|
||||
}
|
||||
|
||||
late TextEditingController _firstNameController;
|
||||
late TextEditingController _lastNameController;
|
||||
late TextEditingController _dobController;
|
||||
|
||||
FocusNode? _firstNameFocus;
|
||||
FocusNode? _lastNameFocus;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -65,6 +110,38 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
_firstNameController.addListener(() => widget.onFirstNameChanged(_firstNameController.text));
|
||||
_lastNameController.addListener(() => widget.onLastNameChanged(_lastNameController.text));
|
||||
// Pour dob, la mise à jour se fait via _selectDate, pas besoin de listener ici
|
||||
|
||||
if (widget.mode == DisplayMode.editable) {
|
||||
_firstNameFocus = FocusNode();
|
||||
_lastNameFocus = FocusNode();
|
||||
_firstNameFocus!.addListener(_onFirstNameFocusChange);
|
||||
_lastNameFocus!.addListener(_onLastNameFocusChange);
|
||||
}
|
||||
}
|
||||
|
||||
void _onFirstNameFocusChange() {
|
||||
if (_firstNameFocus == null || _firstNameFocus!.hasFocus) {
|
||||
return;
|
||||
}
|
||||
_applyPersonNameFormat(_firstNameController);
|
||||
}
|
||||
|
||||
void _onLastNameFocusChange() {
|
||||
if (_lastNameFocus == null || _lastNameFocus!.hasFocus) {
|
||||
return;
|
||||
}
|
||||
_applyPersonNameFormat(_lastNameController);
|
||||
}
|
||||
|
||||
void _applyPersonNameFormat(TextEditingController controller) {
|
||||
final formatted = formatPersonNameCase(controller.text);
|
||||
if (formatted == controller.text) {
|
||||
return;
|
||||
}
|
||||
controller.value = TextEditingValue(
|
||||
text: formatted,
|
||||
selection: TextSelection.collapsed(offset: formatted.length),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -85,6 +162,10 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_firstNameFocus?.removeListener(_onFirstNameFocusChange);
|
||||
_lastNameFocus?.removeListener(_onLastNameFocusChange);
|
||||
_firstNameFocus?.dispose();
|
||||
_lastNameFocus?.dispose();
|
||||
_firstNameController.dispose();
|
||||
_lastNameController.dispose();
|
||||
_dobController.dispose();
|
||||
@@ -110,16 +191,25 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
final File? currentChildImage = widget.childData.imageFile;
|
||||
// ... (reste du code existant pour mobile/editable)
|
||||
final Color baseCardColorForShadow = widget.childData.cardColor == CardColorVertical.lavender
|
||||
? Colors.purple.shade200
|
||||
: (widget.childData.cardColor == CardColorVertical.pink ? Colors.pink.shade200 : Colors.grey.shade200);
|
||||
final Color initialPhotoShadow = baseCardColorForShadow.withAlpha(90);
|
||||
final Color hoverPhotoShadow = baseCardColorForShadow.withAlpha(130);
|
||||
final Color initialPhotoShadow =
|
||||
Color.alphaBlend(Colors.black.withValues(alpha: 0.22), baseCardColorForShadow);
|
||||
final Color hoverPhotoShadow =
|
||||
Color.alphaBlend(Colors.black.withValues(alpha: 0.32), baseCardColorForShadow);
|
||||
|
||||
final double photoSide = 200.0 * (config.isMobile ? 0.8 : 1.0);
|
||||
final double editableCardWidth = config.isMobile
|
||||
? double.infinity
|
||||
: _desktopEditableCardWidth(
|
||||
photoSide: photoSide,
|
||||
maxWidth: screenSize.width * 0.92,
|
||||
scaleFactor: scaleFactor,
|
||||
);
|
||||
|
||||
return Container(
|
||||
width: config.isMobile ? double.infinity : screenSize.width * 0.6,
|
||||
width: editableCardWidth,
|
||||
// On retire la hauteur fixe pour laisser le contenu définir la taille, comme les autres cartes
|
||||
// height: config.isMobile ? null : 600.0 * scaleFactor,
|
||||
padding: EdgeInsets.all(22.0 * scaleFactor),
|
||||
@@ -132,24 +222,20 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// ... (contenu existant)
|
||||
HoverReliefWidget(
|
||||
onPressed: config.isReadonly ? null : widget.onPickImage,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
initialShadowColor: initialPhotoShadow,
|
||||
hoverShadowColor: hoverPhotoShadow,
|
||||
child: SizedBox(
|
||||
height: 200.0 * (config.isMobile ? 0.8 : 1.0),
|
||||
width: 200.0 * (config.isMobile ? 0.8 : 1.0),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5.0 * scaleFactor),
|
||||
child: currentChildImage != null
|
||||
? ClipRRect(borderRadius: BorderRadius.circular(10 * scaleFactor), child: kIsWeb ? Image.network(currentChildImage.path, fit: BoxFit.cover) : Image.file(currentChildImage, fit: BoxFit.cover))
|
||||
: Image.asset('assets/images/photo.png', fit: BoxFit.contain),
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildEditablePhotoArea(
|
||||
context: context,
|
||||
config: config,
|
||||
scaleFactor: scaleFactor,
|
||||
photoSide: photoSide,
|
||||
childData: widget.childData,
|
||||
initialPhotoShadow: initialPhotoShadow,
|
||||
hoverPhotoShadow: hoverPhotoShadow,
|
||||
),
|
||||
SizedBox(height: 8.0 * scaleFactor),
|
||||
_buildPhotoConsentRow(
|
||||
context: context,
|
||||
config: config,
|
||||
labelFontSize: config.isMobile ? 13.0 : 16.0,
|
||||
),
|
||||
SizedBox(height: 10.0 * scaleFactor),
|
||||
Row(
|
||||
@@ -173,13 +259,16 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0 * scaleFactor),
|
||||
_buildGenreSegment(context, config, scaleFactor),
|
||||
SizedBox(height: 8.0 * scaleFactor),
|
||||
_buildField(
|
||||
config: config,
|
||||
scaleFactor: scaleFactor,
|
||||
label: 'Prénom',
|
||||
controller: _firstNameController,
|
||||
hint: 'Facultatif si à naître',
|
||||
hint: widget.childData.isUnbornChild ? 'Facultatif' : 'Prénom',
|
||||
isRequired: !widget.childData.isUnbornChild,
|
||||
focusNode: _firstNameFocus,
|
||||
),
|
||||
SizedBox(height: 5.0 * scaleFactor),
|
||||
_buildField(
|
||||
@@ -188,6 +277,7 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
label: 'Nom',
|
||||
controller: _lastNameController,
|
||||
hint: 'Nom de l\'enfant',
|
||||
focusNode: _lastNameFocus,
|
||||
),
|
||||
SizedBox(height: 8.0 * scaleFactor),
|
||||
_buildField(
|
||||
@@ -200,27 +290,6 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
onTap: config.isReadonly ? null : widget.onDateSelect,
|
||||
suffixIcon: Icons.calendar_today,
|
||||
),
|
||||
SizedBox(height: 10.0 * scaleFactor),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AppCustomCheckbox(
|
||||
label: 'Consentement photo',
|
||||
value: widget.childData.photoConsent,
|
||||
onChanged: config.isReadonly ? (v) {} : widget.onTogglePhotoConsent,
|
||||
checkboxSize: config.isMobile ? 20.0 : 22.0 * scaleFactor,
|
||||
fontSize: config.isMobile ? 13.0 : 16.0,
|
||||
),
|
||||
SizedBox(height: 5.0 * scaleFactor),
|
||||
AppCustomCheckbox(
|
||||
label: 'Naissance multiple',
|
||||
value: widget.childData.multipleBirth,
|
||||
onChanged: config.isReadonly ? (v) {} : widget.onToggleMultipleBirth,
|
||||
checkboxSize: config.isMobile ? 20.0 : 22.0 * scaleFactor,
|
||||
fontSize: config.isMobile ? 13.0 : 16.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.canBeRemoved && !config.isReadonly)
|
||||
@@ -230,7 +299,7 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
onTap: widget.onRemove,
|
||||
customBorder: const CircleBorder(),
|
||||
child: Image.asset(
|
||||
'assets/images/red_cross2.png',
|
||||
'assets/images/cross.png',
|
||||
width: config.isMobile ? 30 : 36,
|
||||
height: config.isMobile ? 30 : 36,
|
||||
fit: BoxFit.contain,
|
||||
@@ -252,6 +321,96 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEditablePhotoArea({
|
||||
required BuildContext context,
|
||||
required DisplayConfig config,
|
||||
required double scaleFactor,
|
||||
required double photoSide,
|
||||
required ChildData childData,
|
||||
required Color initialPhotoShadow,
|
||||
required Color hoverPhotoShadow,
|
||||
}) {
|
||||
final canInteract = !config.isReadonly;
|
||||
final hasPhoto = _hasChildPhoto(childData);
|
||||
final outerRadius = BorderRadius.circular(10 * scaleFactor);
|
||||
// Arrondi photo (sous le cadre) : proportionnel au carré, plus fort qu’avant (~10×scaleFactor).
|
||||
final photoClipRadius = BorderRadius.circular(photoSide * 0.14);
|
||||
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
HoverReliefWidget(
|
||||
onPressed: canInteract ? widget.onPickImage : null,
|
||||
borderRadius: outerRadius,
|
||||
initialElevation: 10,
|
||||
hoverElevation: 16,
|
||||
initialShadowColor: initialPhotoShadow,
|
||||
hoverShadowColor: hoverPhotoShadow,
|
||||
// Pas de clip Material sur la pile : l’arrondi de la photo est géré par ClipRRect (plus marqué).
|
||||
clipBehavior: hasPhoto ? Clip.none : Clip.antiAlias,
|
||||
child: SizedBox(
|
||||
width: photoSide,
|
||||
height: photoSide,
|
||||
child: !hasPhoto
|
||||
? ClipRRect(
|
||||
borderRadius: outerRadius,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/photo.png',
|
||||
fit: BoxFit.contain,
|
||||
width: photoSide,
|
||||
height: photoSide,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// Pas de fond opaque : les coins hors ClipRRect laissent voir la carte (aquarelle).
|
||||
Positioned.fill(
|
||||
child: ClipRRect(
|
||||
borderRadius: photoClipRadius,
|
||||
child: _buildChildPhotoImage(childData, fit: BoxFit.cover),
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
_photoSketchFrameAsset,
|
||||
fit: BoxFit.fill,
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (hasPhoto && canInteract)
|
||||
Positioned(
|
||||
top: 8 * scaleFactor,
|
||||
right: 8 * scaleFactor,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: widget.onClearImage,
|
||||
customBorder: const CircleBorder(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Image.asset(
|
||||
'assets/images/cross.png',
|
||||
width: config.isMobile ? 26 : 30,
|
||||
height: config.isMobile ? 26 : 30,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Layout SPÉCIAL Readonly Desktop (Ancien Design Horizontal)
|
||||
Widget _buildReadonlyDesktopCard(BuildContext context, DisplayConfig config, Size screenSize) {
|
||||
// Convertir la couleur verticale (pour mobile) en couleur horizontale (pour desktop/récap)
|
||||
@@ -266,8 +425,7 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
else if (widget.childData.cardColor.path.contains('peach')) horizontalCardAsset = CardColorHorizontal.peach.path;
|
||||
else if (widget.childData.cardColor.path.contains('pink')) horizontalCardAsset = CardColorHorizontal.pink.path;
|
||||
else if (widget.childData.cardColor.path.contains('red')) horizontalCardAsset = CardColorHorizontal.red.path;
|
||||
|
||||
final File? currentChildImage = widget.childData.imageFile;
|
||||
|
||||
final cardWidth = screenSize.width / 2.0;
|
||||
|
||||
return SizedBox(
|
||||
@@ -310,32 +468,41 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// PHOTO (1/3)
|
||||
// PHOTO (1/3) + consentement sous la photo
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 5),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 5),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
child: _hasChildPhoto(widget.childData)
|
||||
? _buildChildPhotoImage(widget.childData, fit: BoxFit.cover)
|
||||
: Image.asset('assets/images/photo.png', fit: BoxFit.contain),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
child: currentChildImage != null
|
||||
? (kIsWeb
|
||||
? Image.network(currentChildImage.path, fit: BoxFit.cover)
|
||||
: Image.file(currentChildImage, fit: BoxFit.cover))
|
||||
: Image.asset('assets/images/photo.png', fit: BoxFit.contain),
|
||||
const SizedBox(height: 12),
|
||||
_buildPhotoConsentRow(
|
||||
context: context,
|
||||
config: config,
|
||||
labelFontSize: 16.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -356,35 +523,14 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
widget.childData.isUnbornChild ? 'Date prévisionnelle :' : 'Date de naissance :',
|
||||
_dobController.text
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
_buildReadonlyField('Genre :', _genreDisplayLabel(widget.childData.genre)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
|
||||
// Consentements
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AppCustomCheckbox(
|
||||
label: 'Consentement photo',
|
||||
value: widget.childData.photoConsent,
|
||||
onChanged: (v) {}, // Readonly
|
||||
checkboxSize: 22.0,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
const SizedBox(width: 32),
|
||||
AppCustomCheckbox(
|
||||
label: 'Naissance multiple',
|
||||
value: widget.childData.multipleBirth,
|
||||
onChanged: (v) {}, // Readonly
|
||||
checkboxSize: 22.0,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -396,8 +542,6 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
|
||||
/// Carte en mode readonly MOBILE avec hauteur adaptative
|
||||
Widget _buildReadonlyMobileCard(BuildContext context, DisplayConfig config) {
|
||||
final File? currentChildImage = widget.childData.imageFile;
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
// Pas de height fixe
|
||||
@@ -452,14 +596,18 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
child: currentChildImage != null
|
||||
? (kIsWeb
|
||||
? Image.network(currentChildImage.path, fit: BoxFit.cover)
|
||||
: Image.file(currentChildImage, fit: BoxFit.cover))
|
||||
child: _hasChildPhoto(widget.childData)
|
||||
? _buildChildPhotoImage(widget.childData, fit: BoxFit.cover)
|
||||
: Image.asset('assets/images/photo.png', fit: BoxFit.contain),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildPhotoConsentRow(
|
||||
context: context,
|
||||
config: config,
|
||||
labelFontSize: 14.0,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Champs
|
||||
@@ -471,37 +619,8 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
widget.childData.isUnbornChild ? 'Date prévisionnelle :' : 'Date de naissance :',
|
||||
_dobController.text
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Consentements
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
AppCustomCheckbox(
|
||||
label: 'Consentement photo',
|
||||
value: widget.childData.photoConsent,
|
||||
onChanged: (v) {},
|
||||
checkboxSize: 20.0,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
AppCustomCheckbox(
|
||||
label: 'Naissance multiple',
|
||||
value: widget.childData.multipleBirth,
|
||||
onChanged: (v) {},
|
||||
checkboxSize: 20.0,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildReadonlyField('Genre :', _genreDisplayLabel(widget.childData.genre)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -525,6 +644,111 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPhotoConsentRow({
|
||||
required BuildContext context,
|
||||
required DisplayConfig config,
|
||||
required double labelFontSize,
|
||||
}) {
|
||||
final readonly = config.isReadonly;
|
||||
final primary = Theme.of(context).colorScheme.primary;
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Checkbox(
|
||||
value: widget.childData.photoConsent,
|
||||
onChanged: readonly
|
||||
? null
|
||||
: (v) {
|
||||
if (v != null) widget.onTogglePhotoConsent(v);
|
||||
},
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
visualDensity: VisualDensity.compact,
|
||||
activeColor: primary,
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
'Consentement photo',
|
||||
style: GoogleFonts.merienda(fontSize: labelFontSize),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Tooltip(
|
||||
message: _photoConsentTooltip,
|
||||
waitDuration: const Duration(milliseconds: 300),
|
||||
triggerMode: TooltipTriggerMode.tap,
|
||||
showDuration: const Duration(seconds: 6),
|
||||
child: Icon(
|
||||
Icons.info_outline,
|
||||
size: labelFontSize * 1.2,
|
||||
color: Colors.black54,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
static String _genreDisplayLabel(String genre) {
|
||||
switch (genre) {
|
||||
case 'F':
|
||||
return 'Fille';
|
||||
case 'H':
|
||||
return 'Garçon';
|
||||
case 'Autre':
|
||||
return 'Inconnu';
|
||||
default:
|
||||
return '—';
|
||||
}
|
||||
}
|
||||
|
||||
/// Fille / Garçon ; « Inconnu » (`Autre`) uniquement si enfant à naître.
|
||||
Widget _buildGenreSegment(BuildContext context, DisplayConfig config, double scaleFactor) {
|
||||
if (config.isReadonly) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final selected = widget.childData.genre;
|
||||
final isUnborn = widget.childData.isUnbornChild;
|
||||
final fontSize = config.isMobile ? 13.0 : 14.0 * scaleFactor;
|
||||
final padV = config.isMobile ? 6.0 : 8.0 * scaleFactor;
|
||||
|
||||
Widget seg(String label, String api) {
|
||||
final on = selected == api;
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||
child: OutlinedButton(
|
||||
onPressed: () => widget.onGenreChanged(api),
|
||||
style: OutlinedButton.styleFrom(
|
||||
padding: EdgeInsets.symmetric(vertical: padV),
|
||||
visualDensity: VisualDensity.compact,
|
||||
backgroundColor: on ? Colors.black.withValues(alpha: 0.08) : Colors.transparent,
|
||||
foregroundColor: Colors.black87,
|
||||
side: BorderSide(
|
||||
width: on ? 2 : 1,
|
||||
color: on ? Theme.of(context).primaryColor : Colors.black38,
|
||||
),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: GoogleFonts.merienda(fontSize: fontSize, fontWeight: on ? FontWeight.w700 : FontWeight.w500),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
seg('Fille', 'F'),
|
||||
seg('Garçon', 'H'),
|
||||
if (isUnborn) seg('Inconnu', 'Autre'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Helper pour champ Readonly style "Beige"
|
||||
Widget _buildReadonlyField(String label, String value) {
|
||||
return Column(
|
||||
@@ -566,6 +790,7 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
bool readOnly = false,
|
||||
VoidCallback? onTap,
|
||||
IconData? suffixIcon,
|
||||
FocusNode? focusNode,
|
||||
}) {
|
||||
if (config.isReadonly) {
|
||||
return FormFieldWrapper(
|
||||
@@ -576,6 +801,7 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
|
||||
} else {
|
||||
return CustomAppTextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
labelText: label,
|
||||
hintText: hint ?? label,
|
||||
isRequired: isRequired,
|
||||
|
||||
Reference in New Issue
Block a user