124 lines
4.8 KiB
Dart
124 lines
4.8 KiB
Dart
part of 'vehicles_on_the_property.dart';
|
|
|
|
/// [VehicleRegisterScreen] is a StatefulWidget that displays a form to register a vehicle.
|
|
|
|
// ignore: must_be_immutable
|
|
class VehicleRegisterScreen extends StatefulWidget {
|
|
VehicleRegisterScreen(this.model, {super.key});
|
|
late VehicleModel model;
|
|
|
|
@override
|
|
State<VehicleRegisterScreen> createState() => _VehicleRegisterScreenState();
|
|
}
|
|
|
|
class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
_buildHeader(context),
|
|
_buildBody(context),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Form _buildBody(BuildContext context) {
|
|
return Form(
|
|
key: widget.model.registerFormKey,
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
CustomInputUtil(
|
|
controller: widget.model.textFieldControllerLicensePlate,
|
|
validator: widget.model.textControllerLicensePlateValidator
|
|
.asValidator(context),
|
|
focusNode: widget.model.textFieldFocusLicensePlate,
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Placa', enText: 'License Plate'),
|
|
hintText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Placa', enText: 'License Plate'),
|
|
suffixIcon: Symbols.format_color_text,
|
|
haveMaxLength: true,
|
|
onChanged: (value) => setState(() {}),
|
|
maxLength: 80,
|
|
),
|
|
CustomInputUtil(
|
|
controller: widget.model.textFieldControllerModel,
|
|
validator: widget.model.textControllerModelValidator
|
|
.asValidator(context),
|
|
focusNode: widget.model.textFieldFocusModel,
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Modelo', enText: 'Model'),
|
|
hintText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Ex: Voyage, Ford',
|
|
enText: 'e.g. Voyage, Ford',
|
|
),
|
|
suffixIcon: Symbols.car_repair,
|
|
haveMaxLength: true,
|
|
onChanged: (value) => setState(() {}),
|
|
maxLength: 80,
|
|
),
|
|
CustomInputUtil(
|
|
controller: widget.model.textFieldControllerColor,
|
|
validator: widget.model.textControllerColorValidator
|
|
.asValidator(context),
|
|
focusNode: widget.model.textFieldFocusColor,
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Cor', enText: 'Color'),
|
|
hintText: FFLocalizations.of(context).getVariableText(
|
|
ptText: 'Ex: Preto, Amarelo, Branco',
|
|
enText: 'e.g. Black, Yellow, White',
|
|
),
|
|
suffixIcon: Symbols.palette,
|
|
haveMaxLength: true,
|
|
onChanged: (value) => setState(() {}),
|
|
maxLength: 80,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(70, 20, 70, 30),
|
|
child: SubmitButtonUtil(
|
|
labelText: FFLocalizations.of(context)
|
|
.getVariableText(ptText: 'Cadastrar', enText: 'Register'),
|
|
onPressed: widget.model.isFormValid(context)
|
|
? widget.model.registerVehicle
|
|
: null),
|
|
),
|
|
],
|
|
));
|
|
}
|
|
|
|
Align _buildHeader(BuildContext context) {
|
|
// double limitedInputFontSize = LimitedFontSizeUtil.getInputFontSize(context);
|
|
double limitedHeaderFontSize =
|
|
LimitedFontSizeUtil.getHeaderFontSize(context);
|
|
// double limitedSubHeaderFontSize = LimitedFontSizeUtil.getSubHeaderFontSize(context);
|
|
|
|
return Align(
|
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 20, 0.0, 15),
|
|
child: Text(
|
|
FFLocalizations.of(context).getVariableText(
|
|
ptText:
|
|
'Preencha o formulário de cadastro com os dados do seu veículo',
|
|
enText: 'Fill out the registration form with your vehicle data',
|
|
),
|
|
textAlign: TextAlign.start,
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap()
|
|
.containsKey(FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
fontSize: limitedHeaderFontSize,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|