keyboard uppercasse and max length for licensePlate

This commit is contained in:
jantunesmessias 2025-02-13 17:54:29 -03:00
parent 9edd350f13
commit 0b38538d2b
4 changed files with 45 additions and 16 deletions

View File

@ -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,9 +29,10 @@ class CustomInputUtil extends StatefulWidget {
final String? Function(String?)? validator;
final bool haveMaxLength;
final void Function(String)? onChanged;
final List<TextInputFormatter>? inputFormatters;
CustomInputUtil(
{super.key,
CustomInputUtil({
super.key,
this.controller,
required this.labelText,
required this.hintText,
@ -35,7 +45,9 @@ class CustomInputUtil extends StatefulWidget {
this.maxLength = 80,
this.validator,
this.obscureText,
required this.haveMaxLength});
this.inputFormatters,
required this.haveMaxLength,
});
@override
State<CustomInputUtil> createState() => _CustomInputUtilState();
@ -152,6 +164,7 @@ class _CustomInputUtilState extends State<CustomInputUtil> {
keyboardType: widget.keyboardType,
inputFormatters: [
LengthLimitingTextInputFormatter(widget.maxLength),
if (widget.inputFormatters != null) ...widget.inputFormatters!
],
),
],

View File

@ -43,6 +43,8 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
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<VehicleRegisterScreen> {
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<VehicleRegisterScreen> {
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<VehicleRegisterScreen> {
required String labelText,
required String hintText,
required IconData suffixIcon,
required final List<TextInputFormatter>? inputFormatters,
int maxLength = 80,
}) {
return CustomInputUtil(
controller: controller,
@ -101,7 +107,8 @@ class _VehicleRegisterScreenState extends State<VehicleRegisterScreen> {
suffixIcon: suffixIcon,
haveMaxLength: true,
onChanged: (value) => setState(() {}),
maxLength: 80,
inputFormatters: inputFormatters,
maxLength: maxLength,
);
}

View File

@ -43,6 +43,8 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
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<VehicleUpdateScreen> {
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<VehicleUpdateScreen> {
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<VehicleUpdateScreen> {
required String labelText,
required String hintText,
required IconData suffixIcon,
required List<TextInputFormatter>? inputFormatters,
int maxLength = 80,
}) {
return CustomInputUtil(
controller: controller,
@ -114,6 +120,8 @@ class _VehicleUpdateScreenState extends State<VehicleUpdateScreen> {
suffixIcon: suffixIcon,
haveMaxLength: true,
onChanged: (value) => setState(() {}),
inputFormatters: inputFormatters,
maxLength: maxLength,
);
}

View File

@ -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';