diff --git a/lib/components/atomic_components/shared_components_atoms/custom_input.dart b/lib/components/atomic_components/shared_components_atoms/custom_input.dart index cac159f4..cb02aba7 100644 --- a/lib/components/atomic_components/shared_components_atoms/custom_input.dart +++ b/lib/components/atomic_components/shared_components_atoms/custom_input.dart @@ -5,6 +5,15 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; +class UpperCaseTextFormatter extends TextInputFormatter { + @override + TextEditingValue formatEditUpdate( + TextEditingValue oldValue, TextEditingValue newValue) { + return TextEditingValue( + text: newValue.text.toUpperCase(), selection: newValue.selection); + } +} + // ignore: must_be_immutable class CustomInputUtil extends StatefulWidget { final TextEditingController? controller; @@ -20,22 +29,25 @@ class CustomInputUtil extends StatefulWidget { final String? Function(String?)? validator; final bool haveMaxLength; final void Function(String)? onChanged; + final List? inputFormatters; - CustomInputUtil( - {super.key, - this.controller, - required this.labelText, - required this.hintText, - required this.suffixIcon, - this.autoFocus = false, - required this.focusNode, - this.onChanged, - this.textInputAction = TextInputAction.next, - this.keyboardType = TextInputType.text, - this.maxLength = 80, - this.validator, - this.obscureText, - required this.haveMaxLength}); + CustomInputUtil({ + super.key, + this.controller, + required this.labelText, + required this.hintText, + required this.suffixIcon, + this.autoFocus = false, + required this.focusNode, + this.onChanged, + this.textInputAction = TextInputAction.next, + this.keyboardType = TextInputType.text, + this.maxLength = 80, + this.validator, + this.obscureText, + this.inputFormatters, + required this.haveMaxLength, + }); @override State createState() => _CustomInputUtilState(); @@ -152,6 +164,7 @@ class _CustomInputUtilState extends State { keyboardType: widget.keyboardType, inputFormatters: [ LengthLimitingTextInputFormatter(widget.maxLength), + if (widget.inputFormatters != null) ...widget.inputFormatters! ], ), ], diff --git a/lib/pages/vehicles_on_the_property/vehicle_register_screen.dart b/lib/pages/vehicles_on_the_property/vehicle_register_screen.dart index b11e0db7..ff32d4ab 100644 --- a/lib/pages/vehicles_on_the_property/vehicle_register_screen.dart +++ b/lib/pages/vehicles_on_the_property/vehicle_register_screen.dart @@ -43,6 +43,8 @@ class _VehicleRegisterScreenState extends State { hintText: FFLocalizations.of(context) .getVariableText(ptText: 'Placa', enText: 'License Plate'), suffixIcon: Symbols.format_color_text, + inputFormatters: [UpperCaseTextFormatter()], + maxLength: 7, ), _buildCustomInput( context: context, @@ -54,6 +56,7 @@ class _VehicleRegisterScreenState extends State { hintText: FFLocalizations.of(context).getVariableText( ptText: 'Ex: Voyage, Ford', enText: 'e.g. Voyage, Ford'), suffixIcon: Symbols.car_repair, + inputFormatters: [], ), _buildCustomInput( context: context, @@ -66,6 +69,7 @@ class _VehicleRegisterScreenState extends State { ptText: 'Ex: Preto, Amarelo, Branco', enText: 'e.g. Black, Yellow, White'), suffixIcon: Symbols.palette, + inputFormatters: [], ), Padding( padding: const EdgeInsets.fromLTRB(70, 20, 70, 30), @@ -91,6 +95,8 @@ class _VehicleRegisterScreenState extends State { required String labelText, required String hintText, required IconData suffixIcon, + required final List? inputFormatters, + int maxLength = 80, }) { return CustomInputUtil( controller: controller, @@ -101,7 +107,8 @@ class _VehicleRegisterScreenState extends State { suffixIcon: suffixIcon, haveMaxLength: true, onChanged: (value) => setState(() {}), - maxLength: 80, + inputFormatters: inputFormatters, + maxLength: maxLength, ); } diff --git a/lib/pages/vehicles_on_the_property/vehicle_update_screen.dart b/lib/pages/vehicles_on_the_property/vehicle_update_screen.dart index f780c103..1f746b50 100644 --- a/lib/pages/vehicles_on_the_property/vehicle_update_screen.dart +++ b/lib/pages/vehicles_on_the_property/vehicle_update_screen.dart @@ -43,6 +43,8 @@ class _VehicleUpdateScreenState extends State { hintText: FFLocalizations.of(context) .getVariableText(ptText: 'Placa', enText: 'License Plate'), suffixIcon: Symbols.format_color_text, + inputFormatters: [UpperCaseTextFormatter()], + maxLength: 7, ), _buildCustomInput( context: context, @@ -54,6 +56,7 @@ class _VehicleUpdateScreenState extends State { hintText: FFLocalizations.of(context).getVariableText( ptText: 'Ex: Voyage, Ford', enText: 'e.g. Voyage, Ford'), suffixIcon: Symbols.car_repair, + inputFormatters: [], ), _buildCustomInput( context: context, @@ -66,6 +69,7 @@ class _VehicleUpdateScreenState extends State { ptText: 'Ex: Preto, Amarelo, Branco', enText: 'e.g. Black, Yellow, White'), suffixIcon: Symbols.palette, + inputFormatters: [], ), _buildSubmitButton(context), ], @@ -104,6 +108,8 @@ class _VehicleUpdateScreenState extends State { required String labelText, required String hintText, required IconData suffixIcon, + required List? inputFormatters, + int maxLength = 80, }) { return CustomInputUtil( controller: controller, @@ -114,6 +120,8 @@ class _VehicleUpdateScreenState extends State { suffixIcon: suffixIcon, haveMaxLength: true, onChanged: (value) => setState(() {}), + inputFormatters: inputFormatters, + maxLength: maxLength, ); } diff --git a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart index eafe8305..7d5571d1 100644 --- a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart +++ b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/custom_input.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/submit_button.dart';