import 'package:flutter/material.dart'; import 'package:manager_app/Components/rounded_input_field.dart'; import 'package:manager_app/constants.dart'; /// Champ texte étiqueté : le libellé au-dessus, le champ dessous. /// /// Il était en `Row`, chaque écran ayant donc une colonne de libellés d'une largeur /// différente : plus rien ne s'alignait d'une ligne à l'autre. Le composant ne /// décide plus de sa largeur — le parent le place dans sa grille. class StringInputContainer extends StatelessWidget { final Color? color; final String label; final String? initialValue; final ValueChanged onChanged; final bool isUrl; final bool isSmall; final int maxLength; final double fontSize; final double fontSizeText; final String? hint; final bool isMandatory; const StringInputContainer({ Key? key, this.color = kSurface2, required this.label, this.initialValue = "", required this.onChanged, this.isUrl = false, this.isSmall = false, this.maxLength = 50, this.fontSize = 25, this.fontSizeText = 13, this.hint, this.isMandatory = false, }) : super(key: key); @override Widget build(BuildContext context) { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisSize: MainAxisSize.min, children: [ Flexible(child: Text(label, style: kLabelField)), if (isMandatory) const Padding( padding: EdgeInsets.only(left: kSpace1), child: Text("*", style: TextStyle(fontSize: 12.5, color: kError)), ), ], ), const SizedBox(height: kSpace2), RoundedInputField( color: color!, fontSize: fontSizeText, initialValue: initialValue, onChanged: onChanged, maxLength: maxLength, ), if (hint != null) Padding( padding: const EdgeInsets.only(top: kSpace1), child: Text(hint!, style: kTextHint), ), ], ); } }