fix: add form validador
This commit is contained in:
parent
f6bc7ecf6a
commit
8eeda2d54b
|
@ -52,8 +52,8 @@ Future<List<SelectedFile>?> selectMediaWithSourceBottomSheet({
|
|||
required bool allowPhoto,
|
||||
bool allowVideo = false,
|
||||
String pickerFontFamily = 'Roboto',
|
||||
Color textColor = const Color(0xFF111417),
|
||||
Color backgroundColor = const Color(0xFFF5F5F5),
|
||||
// Color textColor = const Color(0xFF111417),
|
||||
// Color backgroundColor = const Color(0xFFF5F5F5),
|
||||
bool includeDimensions = false,
|
||||
bool includeBlurHash = false,
|
||||
}) async {
|
||||
|
@ -63,12 +63,12 @@ Future<List<SelectedFile>?> selectMediaWithSourceBottomSheet({
|
|||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.getFont(
|
||||
pickerFontFamily,
|
||||
color: textColor,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
tileColor: backgroundColor,
|
||||
tileColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
dense: false,
|
||||
onTap: () => Navigator.pop(
|
||||
context,
|
||||
|
@ -77,7 +77,7 @@ Future<List<SelectedFile>?> selectMediaWithSourceBottomSheet({
|
|||
);
|
||||
final mediaSource = await showModalBottomSheet<MediaSource>(
|
||||
context: context,
|
||||
backgroundColor: backgroundColor,
|
||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
builder: (context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -91,13 +91,13 @@ Future<List<SelectedFile>?> selectMediaWithSourceBottomSheet({
|
|||
textAlign: TextAlign.center,
|
||||
style: GoogleFonts.getFont(
|
||||
pickerFontFamily,
|
||||
color: textColor.withOpacity(0.65),
|
||||
color: FlutterFlowTheme.of(context).primaryText.withOpacity(0.65),
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 20,
|
||||
),
|
||||
),
|
||||
tileColor: backgroundColor,
|
||||
dense: false,
|
||||
tileColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
dense: true,
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
|
|
|
@ -17,10 +17,28 @@ class RegisterVisitorPageModel
|
|||
FocusNode? textFieldFocusNode1;
|
||||
TextEditingController? textController1;
|
||||
String? Function(BuildContext, String?)? textController1Validator;
|
||||
String? _textController1Validator(BuildContext context, String? val) {
|
||||
if (val == null || val.isEmpty) {
|
||||
return FFLocalizations.of(context).getVariableText(
|
||||
enText: 'This field is required',
|
||||
ptText: 'Este campo é obrigatório',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// State field(s) for TextField widget.
|
||||
FocusNode? textFieldFocusNode2;
|
||||
TextEditingController? textController2;
|
||||
String? Function(BuildContext, String?)? textController2Validator;
|
||||
String? _textController2Validator(BuildContext context, String? val) {
|
||||
if (val == null || val.isEmpty) {
|
||||
return FFLocalizations.of(context).getVariableText(
|
||||
enText: 'This field is required',
|
||||
ptText: 'Este campo é obrigatório',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// State field(s) for DropDown widget.
|
||||
String? dropDownValue;
|
||||
FormFieldController<String>? dropDownValueController;
|
||||
|
@ -28,17 +46,56 @@ class RegisterVisitorPageModel
|
|||
FocusNode? textFieldFocusNode3;
|
||||
TextEditingController? textController3;
|
||||
String? Function(BuildContext, String?)? textController3Validator;
|
||||
String? _textController3Validator(BuildContext context, String? val) {
|
||||
if (val == null || val.isEmpty) {
|
||||
return FFLocalizations.of(context).getVariableText(
|
||||
enText: 'This field is required',
|
||||
ptText: 'Este campo é obrigatório',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// State field(s) for TextField widget.
|
||||
FocusNode? textFieldFocusNode4;
|
||||
TextEditingController? textController4;
|
||||
String? Function(BuildContext, String?)? textController4Validator;
|
||||
String? _textController4Validator(BuildContext context, String? val) {
|
||||
if (val == null || val.isEmpty) {
|
||||
return FFLocalizations.of(context).getVariableText(
|
||||
enText: 'This field is required',
|
||||
ptText: 'Este campo é obrigatório',
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Stores action output result for [Custom Action - convertImageFileToBase64] action in Button widget.
|
||||
String? imgBase64;
|
||||
// Stores action output result for [Backend Call - API (postScheduleVisitor)] action in Button widget.
|
||||
ApiCallResponse? scheduleVisitor;
|
||||
|
||||
@override
|
||||
void initState(BuildContext context) {}
|
||||
void initState(BuildContext context) {
|
||||
|
||||
textFieldFocusNode1 = FocusNode();
|
||||
textController1 = TextEditingController();
|
||||
textController1Validator = _textController1Validator;
|
||||
|
||||
textFieldFocusNode2 = FocusNode();
|
||||
textController2 = TextEditingController();
|
||||
textController2Validator = _textController2Validator;
|
||||
|
||||
|
||||
dropDownValue = '';
|
||||
// dropDownValueController = FormFieldController<String>(initialValue: dropDownValue);
|
||||
|
||||
textFieldFocusNode3 = FocusNode();
|
||||
textController3 = TextEditingController();
|
||||
textController3Validator = _textController3Validator;
|
||||
|
||||
textFieldFocusNode4 = FocusNode();
|
||||
textController4 = TextEditingController();
|
||||
textController4Validator = _textController4Validator;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
|
|
@ -116,6 +116,9 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Form(
|
||||
// key: UniqueKey(),
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
|
@ -474,7 +477,9 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.95,
|
||||
decoration: const BoxDecoration(),
|
||||
child: Row(
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -549,12 +554,32 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
isOverButton: true,
|
||||
isSearchable: false,
|
||||
isMultiSelect: false,
|
||||
|
||||
),
|
||||
),
|
||||
]
|
||||
.divide(const SizedBox(width: 19.0))
|
||||
.addToStart(const SizedBox(width: 30.0)),
|
||||
),
|
||||
if (_model.dropDownValue == null ||
|
||||
_model.dropDownValue == '')
|
||||
Align(
|
||||
alignment: const AlignmentDirectional(0.4, 0),
|
||||
child: Text(FFLocalizations.of(context).getVariableText(
|
||||
enText: 'This field is required',
|
||||
ptText: 'Este campo é obrigatório',
|
||||
),
|
||||
style: FlutterFlowTheme.of(context).bodySmall.override(
|
||||
fontFamily: FlutterFlowTheme.of(context)
|
||||
.bodySmallFamily,
|
||||
color: FlutterFlowTheme.of(context).error,
|
||||
letterSpacing: 0.0,
|
||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||
FlutterFlowTheme.of(context).bodySmallFamily),
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
|
@ -773,7 +798,27 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
nome: 'Test',
|
||||
tipo: 'V',
|
||||
foto: 'base64;jpeg,klajsalkjslkajslkajl',
|
||||
).onError((e, s) async {
|
||||
return await showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Padding(
|
||||
padding: MediaQuery.viewInsetsOf(context),
|
||||
child: Dialog(
|
||||
child: ThrowExceptionWidget(
|
||||
msg: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Você esqueceu de adicionar algum dado obrigatório. Verifique se a imagem, nome, tipo e documento foram preenchidos corretamente.',
|
||||
enText: 'You forgot to add some required data. Check if the image, name, type and document were filled in correctly.',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (PhpGroup.postScheduleVisitorCall.error(
|
||||
(_model.scheduleVisitor?.jsonBody ?? ''),
|
||||
|
@ -789,10 +834,7 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
_model.dropDownValueController?.reset();
|
||||
});
|
||||
} else {
|
||||
await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
enableDrag: false,
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return GestureDetector(
|
||||
|
@ -804,12 +846,13 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
child: Padding(
|
||||
padding:
|
||||
MediaQuery.viewInsetsOf(context),
|
||||
child: Dialog(
|
||||
child: ThrowExceptionWidget(
|
||||
msg:
|
||||
'\\devUUID=${FFAppState().devUUID}\\userUUID=${FFAppState().userUUID}\\cliID=${FFAppState().cliUUID}\\Documento=${_model.textController2.text}\\Nome=${_model.textController1.text}\\dropdown${_model.dropDownValue}\\${PhpGroup.postScheduleVisitorCall.errorMsg(
|
||||
(_model.scheduleVisitor?.jsonBody ??
|
||||
''),
|
||||
)}',
|
||||
msg:FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Erro ao cadastrar visitante. Tente novamente.',
|
||||
enText: 'Error registering visitor. Try again.',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -817,23 +860,20 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
).then((value) => safeSetState(() {}));
|
||||
}
|
||||
} else {
|
||||
await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
enableDrag: false,
|
||||
await showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return GestureDetector(
|
||||
onTap: () => _model
|
||||
.unfocusNode.canRequestFocus
|
||||
? FocusScope.of(context)
|
||||
.requestFocus(_model.unfocusNode)
|
||||
: FocusScope.of(context).unfocus(),
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Padding(
|
||||
padding: MediaQuery.viewInsetsOf(context),
|
||||
child: Dialog(
|
||||
child: ThrowExceptionWidget(
|
||||
msg:
|
||||
'Você esqueceu de adicionar algum dado obrigatório. Verifique se a imagem, nome, tipo e documento estão foram preenchidos corretamente.- devUUID=${FFAppState().devUUID}- userUUID=${FFAppState().userUUID}- cliID=${FFAppState().cliUUID}- Documento=${_model.textController2.text}- Nome=${_model.textController1.text}- Tipo=${_model.dropDownValue}',
|
||||
msg: FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Você esqueceu de adicionar algum dado obrigatório. Verifique se a imagem, nome, tipo e documento foram preenchidos corretamente.',
|
||||
enText: 'You forgot to add some required data. Check if the image, name, type and document were filled in correctly.',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -888,6 +928,7 @@ class _RegisterVisitorPageWidgetState extends State<RegisterVisitorPageWidget> {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue