WIP
This commit is contained in:
parent
518e4140c4
commit
08e072e183
|
@ -37,6 +37,7 @@ class RegisiterVistorTemplateComponentModel
|
|||
|
||||
Future<bool?> getVisitanteByDocument(
|
||||
String document, BuildContext context) async {
|
||||
|
||||
final response = await PhpGroup.getVisitorByDocCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
|
@ -44,6 +45,7 @@ class RegisiterVistorTemplateComponentModel
|
|||
atividade: 'getVisitante',
|
||||
documento: document,
|
||||
);
|
||||
|
||||
log('${response.jsonBody}');
|
||||
if (response.jsonBody['visitante']['VTE_ID'] != '0' &&
|
||||
response.jsonBody['error'] != 'false') {
|
||||
|
|
|
@ -38,6 +38,8 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
bool _isVisitorRegistered = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
@ -71,6 +73,32 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
setState(() {});
|
||||
}
|
||||
|
||||
bool _isFormValid(BuildContext context) {
|
||||
|
||||
if (_model.uploadedLocalFile.bytes?.isEmpty ?? true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_model.textController1.text.isEmpty || _model.textController1.text == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_model.dropDownValue == null || _model.dropDownValue!.isEmpty || _model.dropDownValue == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_model.textController2.text.isEmpty || _model.textController2.text == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
log("Visitante Já Cadastrado $_isVisitorRegistered");
|
||||
if (_isVisitorRegistered) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
BehaviorSubject<bool> visitorAlreadyRegistered = BehaviorSubject<bool>();
|
||||
|
@ -216,9 +244,11 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
} else if (snapshot.hasError ||
|
||||
snapshot.data == null ||
|
||||
snapshot.data == '') {
|
||||
_isVisitorRegistered = false;
|
||||
visitorAlreadyRegistered.add(true);
|
||||
return const SizedBox();
|
||||
} else {
|
||||
_isVisitorRegistered = true;
|
||||
visitorAlreadyRegistered.add(false);
|
||||
return _model.textController2.text.isEmpty
|
||||
? const SizedBox()
|
||||
|
@ -775,12 +805,7 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
padding:
|
||||
const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0),
|
||||
child: FFButtonWidget(
|
||||
onPressed: (((_model.uploadedLocalFile.bytes?.isNotEmpty ??
|
||||
false)) &&
|
||||
(_model.textController1.text != '') &&
|
||||
(_model.dropDownValue != null &&
|
||||
_model.dropDownValue != '') &&
|
||||
(_model.textController2.text != ''))
|
||||
onPressed: _isFormValid(context)
|
||||
? () async {
|
||||
log(visitorAlreadyRegistered.value.toString());
|
||||
if (visitorAlreadyRegistered.value == true) {
|
||||
|
|
Loading…
Reference in New Issue