Merge branch 'main' into bugfix/fd-645
This commit is contained in:
commit
bb66e77beb
|
@ -4,6 +4,7 @@ import 'dart:developer';
|
||||||
import 'package:hub/components/molecular_components/throw_exception/throw_exception_widget.dart';
|
import 'package:hub/components/molecular_components/throw_exception/throw_exception_widget.dart';
|
||||||
import 'package:hub/custom_code/actions/convert_image_file_to_base64.dart';
|
import 'package:hub/custom_code/actions/convert_image_file_to_base64.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||||
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
|
|
||||||
import '/backend/api_requests/api_calls.dart';
|
import '/backend/api_requests/api_calls.dart';
|
||||||
import '/flutter_flow/flutter_flow_util.dart';
|
import '/flutter_flow/flutter_flow_util.dart';
|
||||||
|
@ -12,15 +13,13 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'regisiter_vistor_template_component_widget.dart';
|
import 'regisiter_vistor_template_component_widget.dart';
|
||||||
|
|
||||||
class RegisiterVistorTemplateComponentModel
|
class RegisiterVistorTemplateComponentModel extends FlutterFlowModel<RegisiterVistorTemplateComponentWidget> {
|
||||||
extends FlutterFlowModel<RegisiterVistorTemplateComponentWidget> {
|
|
||||||
/// State fields for stateful widgets in this page.
|
/// State fields for stateful widgets in this page.
|
||||||
Timer? _debounceTimer;
|
Timer? _debounceTimer;
|
||||||
|
|
||||||
final unfocusNode = FocusNode();
|
final unfocusNode = FocusNode();
|
||||||
bool isDataUploading = false;
|
bool isDataUploading = false;
|
||||||
FFUploadedFile uploadedLocalFile =
|
FFUploadedFile uploadedLocalFile = FFUploadedFile(bytes: Uint8List.fromList([]));
|
||||||
FFUploadedFile(bytes: Uint8List.fromList([]));
|
|
||||||
|
|
||||||
void debounce(Function() fn, Duration time) {
|
void debounce(Function() fn, Duration time) {
|
||||||
if (_debounceTimer != null) {
|
if (_debounceTimer != null) {
|
||||||
|
@ -98,13 +97,7 @@ class RegisiterVistorTemplateComponentModel
|
||||||
TextEditingController? textController4;
|
TextEditingController? textController4;
|
||||||
String? Function(BuildContext, String?)? textController4Validator;
|
String? Function(BuildContext, String?)? textController4Validator;
|
||||||
String? _textController4Validator(BuildContext context, String? val) {
|
String? _textController4Validator(BuildContext context, String? val) {
|
||||||
if (val == null || val.isEmpty) {
|
if (val != null && val.isNotEmpty && ValidatorUtil.isValidEmail(val) == false) {
|
||||||
return FFLocalizations.of(context).getVariableText(
|
|
||||||
enText: 'This field is required',
|
|
||||||
ptText: 'Este campo é obrigatório',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!val.contains('@') || !val.contains('.')) {
|
|
||||||
return FFLocalizations.of(context).getVariableText(
|
return FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Invalid email',
|
enText: 'Invalid email',
|
||||||
ptText: 'Email inválido',
|
ptText: 'Email inválido',
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:hub/shared/utils/dialog_util.dart';
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
|
import 'package:hub/shared/utils/validator_util.dart';
|
||||||
import 'package:json_path/fun_sdk.dart';
|
import 'package:json_path/fun_sdk.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
import 'package:rxdart/rxdart.dart';
|
||||||
|
|
||||||
|
@ -87,19 +88,15 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_model.textController1.text.isEmpty ||
|
if (_model.textController1.text.isEmpty || _model.textController1.text == '') {
|
||||||
_model.textController1.text == '') {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_model.dropDownValue == null ||
|
if (_model.dropDownValue == null || _model.dropDownValue!.isEmpty || _model.dropDownValue == '') {
|
||||||
_model.dropDownValue!.isEmpty ||
|
|
||||||
_model.dropDownValue == '') {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_model.textController2.text.isEmpty ||
|
if (_model.textController2.text.isEmpty || _model.textController2.text == '') {
|
||||||
_model.textController2.text == '') {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,6 +104,10 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_model.textController4.text.isNotEmpty && _model.textController4.text != '' && ValidatorUtil.isValidEmail(_model.textController4.text) == false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,6 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Form(
|
child: Form(
|
||||||
// key: UniqueKey(),
|
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
@ -138,8 +138,7 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
Align(
|
Align(
|
||||||
alignment: const AlignmentDirectional(-1.0, 0.0),
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
padding: const EdgeInsetsDirectional.fromSTEB(20.0, 0.0, 0.0, 15.0),
|
||||||
20.0, 30.0, 0.0, 15.0),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
FFLocalizations.of(context).getText(
|
FFLocalizations.of(context).getText(
|
||||||
'zazj5d8b' /* Preencha o formulário com os d... */,
|
'zazj5d8b' /* Preencha o formulário com os d... */,
|
||||||
|
@ -368,8 +367,7 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
),
|
),
|
||||||
maxLines: null,
|
maxLines: null,
|
||||||
keyboardType: TextInputType.name,
|
keyboardType: TextInputType.name,
|
||||||
validator:
|
validator: _model.textController1Validator.asValidator(context),
|
||||||
_model.textController1Validator.asValidator(context),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -455,160 +453,162 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Builder(
|
Padding(
|
||||||
builder: (context) {
|
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0),
|
||||||
if ((_model.uploadedLocalFile.bytes?.isNotEmpty ?? false)) {
|
child: Builder(
|
||||||
return InkWell(
|
builder: (context) {
|
||||||
splashColor: Colors.transparent,
|
if ((_model.uploadedLocalFile.bytes?.isNotEmpty ?? false)) {
|
||||||
focusColor: Colors.transparent,
|
return InkWell(
|
||||||
hoverColor: Colors.transparent,
|
splashColor: Colors.transparent,
|
||||||
highlightColor: Colors.transparent,
|
focusColor: Colors.transparent,
|
||||||
onTap: () async {
|
hoverColor: Colors.transparent,
|
||||||
setState(() {
|
highlightColor: Colors.transparent,
|
||||||
_model.isDataUploading = false;
|
onTap: () async {
|
||||||
_model.uploadedLocalFile =
|
setState(() {
|
||||||
FFUploadedFile(bytes: Uint8List.fromList([]));
|
_model.isDataUploading = false;
|
||||||
});
|
_model.uploadedLocalFile =
|
||||||
},
|
FFUploadedFile(bytes: Uint8List.fromList([]));
|
||||||
child: ClipRRect(
|
});
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
},
|
||||||
child: Image.memory(
|
child: ClipRRect(
|
||||||
_model.uploadedLocalFile.bytes ??
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
Uint8List.fromList([]),
|
child: Image.memory(
|
||||||
width: 300.0,
|
_model.uploadedLocalFile.bytes ??
|
||||||
height: 200.0,
|
Uint8List.fromList([]),
|
||||||
fit: BoxFit.cover,
|
width: 300.0,
|
||||||
|
height: 200.0,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
return Stack(
|
||||||
return Stack(
|
children: [
|
||||||
children: [
|
Align(
|
||||||
Align(
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
alignment: const AlignmentDirectional(0.01, 0.0),
|
child: FFButtonWidget(
|
||||||
child: FFButtonWidget(
|
onPressed: () async {
|
||||||
onPressed: () async {
|
final selectedMedia =
|
||||||
final selectedMedia =
|
await selectMediaWithSourceBottomSheet(
|
||||||
await selectMediaWithSourceBottomSheet(
|
context: context,
|
||||||
context: context,
|
// maxWidth: 300.00,
|
||||||
// maxWidth: 300.00,
|
// maxHeight: 300.00,
|
||||||
// maxHeight: 300.00,
|
imageQuality: 100,
|
||||||
imageQuality: 100,
|
allowPhoto: true,
|
||||||
allowPhoto: true,
|
includeDimensions: true,
|
||||||
includeDimensions: true,
|
);
|
||||||
);
|
if (selectedMedia != null) {
|
||||||
if (selectedMedia != null) {
|
// &&
|
||||||
// &&
|
// selectedMedia.every((m) =>
|
||||||
// selectedMedia.every((m) =>
|
// validateFileFormat(
|
||||||
// validateFileFormat(
|
// m.storagePath, context))) {
|
||||||
// m.storagePath, context))) {
|
setState(() => _model.isDataUploading = true);
|
||||||
setState(() => _model.isDataUploading = true);
|
var selectedUploadedFiles =
|
||||||
var selectedUploadedFiles =
|
<FFUploadedFile>[];
|
||||||
<FFUploadedFile>[];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
showUploadMessage(
|
showUploadMessage(
|
||||||
context,
|
context,
|
||||||
'Uploading file...',
|
'Uploading file...',
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
);
|
);
|
||||||
selectedUploadedFiles = selectedMedia
|
selectedUploadedFiles = selectedMedia
|
||||||
.map((m) => FFUploadedFile(
|
.map((m) => FFUploadedFile(
|
||||||
name:
|
name:
|
||||||
m.storagePath.split('/').last,
|
m.storagePath.split('/').last,
|
||||||
bytes: m.bytes,
|
bytes: m.bytes,
|
||||||
height: m.dimensions?.height,
|
height: m.dimensions?.height,
|
||||||
width: m.dimensions?.width,
|
width: m.dimensions?.width,
|
||||||
// blurHash: m.blurHash,
|
// blurHash: m.blurHash,
|
||||||
))
|
))
|
||||||
.toList();
|
.toList();
|
||||||
} finally {
|
} finally {
|
||||||
ScaffoldMessenger.of(context)
|
ScaffoldMessenger.of(context)
|
||||||
.hideCurrentSnackBar();
|
.hideCurrentSnackBar();
|
||||||
_model.isDataUploading = false;
|
_model.isDataUploading = false;
|
||||||
|
}
|
||||||
|
if (selectedUploadedFiles.length ==
|
||||||
|
selectedMedia.length) {
|
||||||
|
setState(() {
|
||||||
|
_model.uploadedLocalFile =
|
||||||
|
selectedUploadedFiles.first;
|
||||||
|
});
|
||||||
|
showUploadMessage(context, 'Success!');
|
||||||
|
} else {
|
||||||
|
setState(() {});
|
||||||
|
showUploadMessage(
|
||||||
|
context, 'Failed to upload data');
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (selectedUploadedFiles.length ==
|
},
|
||||||
selectedMedia.length) {
|
text: '',
|
||||||
setState(() {
|
icon: Icon(
|
||||||
_model.uploadedLocalFile =
|
Icons.photo_camera,
|
||||||
selectedUploadedFiles.first;
|
|
||||||
});
|
|
||||||
showUploadMessage(context, 'Success!');
|
|
||||||
} else {
|
|
||||||
setState(() {});
|
|
||||||
showUploadMessage(
|
|
||||||
context, 'Failed to upload data');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
text: '',
|
|
||||||
icon: Icon(
|
|
||||||
Icons.photo_camera,
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
|
||||||
size: 30.0,
|
|
||||||
),
|
|
||||||
options: FFButtonOptions(
|
|
||||||
width: 300.0,
|
|
||||||
height: 80.0,
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
0.0, 0.0, 0.0, 0.0),
|
|
||||||
iconPadding:
|
|
||||||
const EdgeInsetsDirectional.fromSTEB(
|
|
||||||
14.0, 0.0, 0.0, 20.0),
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryBackground,
|
|
||||||
textStyle: FlutterFlowTheme.of(context)
|
|
||||||
.titleSmall
|
|
||||||
.override(
|
|
||||||
fontFamily: FlutterFlowTheme.of(context)
|
|
||||||
.titleSmallFamily,
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryText,
|
|
||||||
fontSize: 16.0,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey(
|
|
||||||
FlutterFlowTheme.of(context)
|
|
||||||
.titleSmallFamily),
|
|
||||||
),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
width: 0.2,
|
size: 30.0,
|
||||||
|
),
|
||||||
|
options: FFButtonOptions(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 120.0,
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 20.0),
|
||||||
|
iconPadding:
|
||||||
|
const EdgeInsetsDirectional.fromSTEB(
|
||||||
|
14.0, 0.0, 0.0, 20.0),
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryBackground,
|
||||||
|
textStyle: FlutterFlowTheme.of(context)
|
||||||
|
.titleSmall
|
||||||
|
.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.titleSmallFamily,
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
fontSize: 16.0,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.titleSmallFamily),
|
||||||
|
),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
|
width: 0.2,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Align(
|
||||||
Align(
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
||||||
alignment: const AlignmentDirectional(0.0, 0.0),
|
child: Padding(
|
||||||
child: Padding(
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
10.0, 65.0, 10.0, 0.0),
|
||||||
0.0, 50.0, 0.0, 0.0),
|
child: Text(
|
||||||
child: Text(
|
FFLocalizations.of(context).getText(
|
||||||
FFLocalizations.of(context).getText(
|
'p4ftwxcy' /* Clique para adicionar a foto p... */,
|
||||||
'p4ftwxcy' /* Clique para adicionar a foto p... */,
|
),
|
||||||
|
style: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMedium
|
||||||
|
.override(
|
||||||
|
fontFamily: FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily,
|
||||||
|
color: FlutterFlowTheme.of(context)
|
||||||
|
.primaryText,
|
||||||
|
letterSpacing: 0.0,
|
||||||
|
useGoogleFonts: GoogleFonts.asMap()
|
||||||
|
.containsKey(
|
||||||
|
FlutterFlowTheme.of(context)
|
||||||
|
.bodyMediumFamily),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
style: FlutterFlowTheme.of(context)
|
|
||||||
.bodyMedium
|
|
||||||
.override(
|
|
||||||
fontFamily: FlutterFlowTheme.of(context)
|
|
||||||
.bodyMediumFamily,
|
|
||||||
color: FlutterFlowTheme.of(context)
|
|
||||||
.primaryText,
|
|
||||||
letterSpacing: 0.0,
|
|
||||||
useGoogleFonts: GoogleFonts.asMap()
|
|
||||||
.containsKey(
|
|
||||||
FlutterFlowTheme.of(context)
|
|
||||||
.bodyMediumFamily),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
}
|
||||||
}
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
Align(
|
Align(
|
||||||
alignment: const AlignmentDirectional(-1.0, 0.0),
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
||||||
|
@ -792,13 +792,11 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
FlutterFlowTheme.of(context).bodyMediumFamily),
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
// validator:
|
validator: _model.textController4Validator.asValidator(context),
|
||||||
// _model.textController4Validator.asValidator(context),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding:
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0),
|
||||||
const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0),
|
|
||||||
child: FFButtonWidget(
|
child: FFButtonWidget(
|
||||||
onPressed: _isFormValid(context)
|
onPressed: _isFormValid(context)
|
||||||
? () async {
|
? () async {
|
||||||
|
|
Loading…
Reference in New Issue