fix visitorRegister and visitHIstory
This commit is contained in:
parent
016be1df54
commit
bc1c684d72
|
@ -1417,53 +1417,39 @@ class PostProvVisitSchedulingCall {
|
|||
}
|
||||
|
||||
class GetVisitsCall {
|
||||
Stream<ApiCallResponse> call({
|
||||
Future<ApiCallResponse> call({
|
||||
String? devUUID = '',
|
||||
String? userUUID = '',
|
||||
String? cliID = '',
|
||||
String? atividade = '',
|
||||
int? pageSize,
|
||||
int? pageNumber,
|
||||
}) {
|
||||
}) async {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final StreamController<ApiCallResponse> controller = StreamController();
|
||||
|
||||
Future.microtask(
|
||||
() async {
|
||||
try {
|
||||
final response = await ApiManager.instance.makeApiCall(
|
||||
callName: 'getVisits',
|
||||
apiUrl: '$baseUrl/processRequest.php',
|
||||
callType: ApiCallType.POST,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
params: {
|
||||
'devUUID': devUUID,
|
||||
'userUUID': userUUID,
|
||||
'cliID': cliID,
|
||||
'atividade': atividade,
|
||||
'pageSize': pageSize,
|
||||
'pageNumber': pageNumber,
|
||||
},
|
||||
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
||||
returnBody: true,
|
||||
encodeBodyUtf8: false,
|
||||
decodeUtf8: false,
|
||||
cache: false,
|
||||
isStreamingApi: false,
|
||||
alwaysAllowBody: false,
|
||||
);
|
||||
controller.add(response);
|
||||
controller.close();
|
||||
} catch (e) {
|
||||
controller.addError(e);
|
||||
controller.close();
|
||||
}
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'getVisits',
|
||||
apiUrl: '$baseUrl/processRequest.php',
|
||||
callType: ApiCallType.POST,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
params: {
|
||||
'devUUID': devUUID,
|
||||
'userUUID': userUUID,
|
||||
'cliID': cliID,
|
||||
'atividade': atividade,
|
||||
'pageSize': pageSize,
|
||||
'pageNumber': pageNumber,
|
||||
},
|
||||
bodyType: BodyType.X_WWW_FORM_URL_ENCODED,
|
||||
returnBody: true,
|
||||
encodeBodyUtf8: false,
|
||||
decodeUtf8: false,
|
||||
cache: false,
|
||||
isStreamingApi: false,
|
||||
alwaysAllowBody: false,
|
||||
);
|
||||
|
||||
return controller.stream;
|
||||
}
|
||||
|
||||
bool? error(dynamic response) => castToType<bool>(getJsonField(
|
||||
|
|
|
@ -44,7 +44,7 @@ Widget buildDetails(
|
|||
visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
||||
)
|
||||
.then((value) {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context, value);
|
||||
if (value == false) {
|
||||
showSnackbar(
|
||||
context,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/components/molecular_components/throw_exception/throw_exception_widget.dart';
|
||||
|
@ -14,12 +15,20 @@ import 'regisiter_vistor_template_component_widget.dart';
|
|||
class RegisiterVistorTemplateComponentModel
|
||||
extends FlutterFlowModel<RegisiterVistorTemplateComponentWidget> {
|
||||
/// State fields for stateful widgets in this page.
|
||||
Timer? _debounceTimer;
|
||||
|
||||
final unfocusNode = FocusNode();
|
||||
bool isDataUploading = false;
|
||||
FFUploadedFile uploadedLocalFile =
|
||||
FFUploadedFile(bytes: Uint8List.fromList([]));
|
||||
|
||||
void debounce(Function() fn, Duration time) {
|
||||
if (_debounceTimer != null) {
|
||||
_debounceTimer!.cancel();
|
||||
}
|
||||
_debounceTimer = Timer(time, fn);
|
||||
}
|
||||
|
||||
// State field(s) for TextField widget.
|
||||
FocusNode? textFieldFocusNode1;
|
||||
TextEditingController? textController1;
|
||||
|
@ -35,7 +44,7 @@ class RegisiterVistorTemplateComponentModel
|
|||
return null;
|
||||
}
|
||||
|
||||
Future<bool?> getVisitanteByDocument(
|
||||
Future<bool> getVisitanteByDocument(
|
||||
String document, BuildContext context) async {
|
||||
final response = await PhpGroup.getVisitorByDocCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
|
@ -49,7 +58,7 @@ class RegisiterVistorTemplateComponentModel
|
|||
response.jsonBody['error'] != 'false') {
|
||||
return true;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// State field(s) for TextField widget.
|
||||
|
|
|
@ -39,10 +39,14 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
bool _isVisitorRegistered = false;
|
||||
BehaviorSubject<bool> visitorAlreadyRegistered = BehaviorSubject<bool>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
visitorAlreadyRegistered = BehaviorSubject<bool>.seeded(false);
|
||||
|
||||
_model =
|
||||
createModel(context, () => RegisiterVistorTemplateComponentModel());
|
||||
|
||||
|
@ -93,16 +97,15 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
return false;
|
||||
}
|
||||
|
||||
// if (_isVisitorRegistered) {
|
||||
// return false;
|
||||
// }
|
||||
if (_isVisitorRegistered) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
BehaviorSubject<bool> visitorAlreadyRegistered = BehaviorSubject<bool>();
|
||||
context.watch<FFAppState>();
|
||||
return Align(
|
||||
alignment: const AlignmentDirectional(0.0, 1.0),
|
||||
|
@ -226,71 +229,61 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||
),
|
||||
onChanged: (value) {
|
||||
_model.debounce(() async {
|
||||
log('data');
|
||||
var data = await _model.getVisitanteByDocument(
|
||||
value, context);
|
||||
log('data: $data');
|
||||
setState(() {
|
||||
_isVisitorRegistered = data;
|
||||
});
|
||||
}, const Duration(milliseconds: 500));
|
||||
},
|
||||
validator:
|
||||
_model.textController2Validator.asValidator(context),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||||
],
|
||||
),
|
||||
FutureBuilder(
|
||||
future: _model.textController2.text.isNotEmpty
|
||||
? _model.getVisitanteByDocument(
|
||||
_model.textController2.text, context)
|
||||
: null,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.waiting) {
|
||||
return const SizedBox();
|
||||
} else if (snapshot.hasError ||
|
||||
snapshot.data == null ||
|
||||
snapshot.data == '') {
|
||||
// safeSetState(() => _isVisitorRegistered = false);
|
||||
_isVisitorRegistered = false;
|
||||
visitorAlreadyRegistered.add(true);
|
||||
return const SizedBox();
|
||||
} else {
|
||||
_isVisitorRegistered = true;
|
||||
visitorAlreadyRegistered.add(false);
|
||||
return _model.textController2.text.isEmpty
|
||||
? const SizedBox()
|
||||
: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
top: 5, start: 12),
|
||||
child: Text(
|
||||
FFLocalizations.of(context)
|
||||
.getVariableText(
|
||||
enText:
|
||||
'Visitor already registered',
|
||||
ptText: 'Visitante já cadastrado',
|
||||
),
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.labelSmall
|
||||
.override(
|
||||
fontFamily: 'Nunito',
|
||||
color: Theme.of(context)
|
||||
.brightness ==
|
||||
Brightness.dark
|
||||
? Color.alphaBlend(
|
||||
Colors.white
|
||||
.withOpacity(0.7),
|
||||
Colors.red)
|
||||
: Color.alphaBlend(
|
||||
Colors.black
|
||||
.withOpacity(0.25),
|
||||
Colors.red),
|
||||
fontSize: 13.0,
|
||||
letterSpacing: 0.0,
|
||||
)),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
_model.textController2.text.isEmpty
|
||||
? const SizedBox()
|
||||
: _isVisitorRegistered == true
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(
|
||||
top: 5, start: 12),
|
||||
child: Text(
|
||||
FFLocalizations.of(context)
|
||||
.getVariableText(
|
||||
enText: 'Visitor already registered',
|
||||
ptText: 'Visitante já cadastrado',
|
||||
),
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.labelSmall
|
||||
.override(
|
||||
fontFamily: 'Nunito',
|
||||
color: Theme.of(context)
|
||||
.brightness ==
|
||||
Brightness.dark
|
||||
? Color.alphaBlend(
|
||||
Colors.white
|
||||
.withOpacity(0.7),
|
||||
Colors.red)
|
||||
: Color.alphaBlend(
|
||||
Colors.black
|
||||
.withOpacity(0.25),
|
||||
Colors.red),
|
||||
fontSize: 13.0,
|
||||
letterSpacing: 0.0,
|
||||
)),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox()
|
||||
]),
|
||||
),
|
||||
Padding(
|
||||
|
@ -805,111 +798,110 @@ class _RegisiterVistorTemplateComponentWidgetState
|
|||
child: FFButtonWidget(
|
||||
onPressed: _isFormValid(context)
|
||||
? () async {
|
||||
if (visitorAlreadyRegistered.value == true) {
|
||||
_model.imgBase64 =
|
||||
await actions.convertImageFileToBase64(
|
||||
_model.uploadedLocalFile,
|
||||
);
|
||||
_model.scheduleVisitor =
|
||||
await PhpGroup.postScheduleVisitorCall
|
||||
.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'putVisitante',
|
||||
documento: _model.textController2.text,
|
||||
nome: _model.textController1.text,
|
||||
tipo: _model.dropDownValue ==
|
||||
FFLocalizations.of(context).getText(
|
||||
'n8vddmcq' /* Visitante */,
|
||||
)
|
||||
? 'V'
|
||||
: 'P',
|
||||
foto: 'base64;jpeg,${_model.imgBase64}',
|
||||
)
|
||||
.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(
|
||||
backgroundColor: Colors.transparent,
|
||||
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.',
|
||||
),
|
||||
_model.imgBase64 =
|
||||
await actions.convertImageFileToBase64(
|
||||
_model.uploadedLocalFile,
|
||||
);
|
||||
_model.scheduleVisitor =
|
||||
await PhpGroup.postScheduleVisitorCall
|
||||
.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'putVisitante',
|
||||
documento: _model.textController2.text,
|
||||
nome: _model.textController1.text,
|
||||
tipo: _model.dropDownValue ==
|
||||
FFLocalizations.of(context).getText(
|
||||
'n8vddmcq' /* Visitante */,
|
||||
)
|
||||
? 'V'
|
||||
: 'P',
|
||||
foto: 'base64;jpeg,${_model.imgBase64}',
|
||||
)
|
||||
.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(
|
||||
backgroundColor: Colors.transparent,
|
||||
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 ?? ''),
|
||||
) ==
|
||||
false) {
|
||||
setState(() {
|
||||
_model.textController1?.clear();
|
||||
_model.textController2?.clear();
|
||||
_model.textController3?.clear();
|
||||
_model.textController4?.clear();
|
||||
_model.dropDownValueController?.reset();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText:
|
||||
'Visitante cadastrado com sucesso.',
|
||||
enText:
|
||||
'Visitor successfully registered.'),
|
||||
style: TextStyle(
|
||||
color:
|
||||
FlutterFlowTheme.of(context)
|
||||
.info)),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
duration: const Duration(seconds: 3),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(15),
|
||||
topRight: Radius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (widget.source ==
|
||||
'VisitorNotFoundComponent') {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return DialogUtil.error(
|
||||
context,
|
||||
PhpGroup.postScheduleVisitorCall
|
||||
.errorMsg(
|
||||
_model.scheduleVisitor?.jsonBody)
|
||||
.toString());
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
if (PhpGroup.postScheduleVisitorCall.error(
|
||||
(_model.scheduleVisitor?.jsonBody ?? ''),
|
||||
) ==
|
||||
false) {
|
||||
setState(() {
|
||||
_model.textController1?.clear();
|
||||
_model.textController2?.clear();
|
||||
_model.textController3?.clear();
|
||||
_model.textController4?.clear();
|
||||
_model.dropDownValueController?.reset();
|
||||
_model.uploadedLocalFile = FFUploadedFile(
|
||||
bytes: Uint8List.fromList([]));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText:
|
||||
'Visitante cadastrado com sucesso.',
|
||||
enText:
|
||||
'Visitor successfully registered.'),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context)
|
||||
.info)),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
duration: const Duration(seconds: 3),
|
||||
width: MediaQuery.of(context).size.width,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(15),
|
||||
topRight: Radius.circular(15),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (widget.source ==
|
||||
'VisitorNotFoundComponent') {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
DialogUtil.error(
|
||||
return DialogUtil.error(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText:
|
||||
'Visitante já cadastrado. Verifique se o documento foi preenchido corretamente.',
|
||||
enText:
|
||||
'Visitor already registered. Check if the document was filled in correctly.',
|
||||
));
|
||||
PhpGroup.postScheduleVisitorCall.errorMsg(
|
||||
_model
|
||||
.scheduleVisitor?.jsonBody) ==
|
||||
null
|
||||
? FFLocalizations.of(context)
|
||||
.getVariableText(
|
||||
ptText:
|
||||
'Erro ao se conectar com o servidor',
|
||||
enText: 'Error connecting to server',
|
||||
)
|
||||
: PhpGroup.postScheduleVisitorCall
|
||||
.errorMsg(
|
||||
_model.scheduleVisitor?.jsonBody)
|
||||
.toString());
|
||||
}
|
||||
}
|
||||
: null,
|
||||
|
|
|
@ -13,11 +13,11 @@ import 'package:intl/intl.dart';
|
|||
|
||||
class ScheduleCompleteVisitPageModel
|
||||
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
|
||||
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||
Stream<ApiCallResponse> visitHistory({
|
||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||
Future<ApiCallResponse> visitHistory({
|
||||
String? uniqueQueryKey,
|
||||
bool? overrideCache,
|
||||
required Stream<ApiCallResponse> Function() requestFn,
|
||||
required Future<ApiCallResponse> Function() requestFn,
|
||||
}) =>
|
||||
_visitHistoryManager.performRequest(
|
||||
uniqueQueryKey: uniqueQueryKey,
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'package:hub/actions/actions.dart';
|
|||
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||
import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart';
|
||||
import 'package:hub/components/templates_components/details_component/details_component_action.dart';
|
||||
import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
|
||||
import 'package:hub/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart';
|
||||
import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart';
|
||||
import 'package:hub/flutter_flow/custom_functions.dart';
|
||||
|
@ -1580,18 +1581,25 @@ Widget scheduleVisit(
|
|||
child: SizedBox(
|
||||
// width: MediaQuery.of(context).size.width,
|
||||
// height: MediaQuery.of(context).size.height * 0.7,
|
||||
child: VisitDetailsModalTemplateComponentWidget(
|
||||
visitStartDateStr: _model.textController1.text,
|
||||
visitEndDateStr: _model.textController2.text,
|
||||
visitReasonStr: _model.dropDownValue1,
|
||||
visitLevelStr: _model.dropDownValue2,
|
||||
visitTempStr:
|
||||
_model.switchValue == true ? 'Sim' : 'Não',
|
||||
visitObsStr: _model.textController3.text,
|
||||
visitorStrList: _model.visitorStrList,
|
||||
visitorJsonList: _model.visitorJsonList,
|
||||
updateToggleIdx: () async {},
|
||||
repeatVisitSchedule: () async {},
|
||||
// child: VisitDetailsModalTemplateComponentWidget(
|
||||
// visitStartDateStr: _model.textController1.text,
|
||||
// visitEndDateStr: _model.textController2.text,
|
||||
// visitReasonStr: _model.dropDownValue1,
|
||||
// visitLevelStr: _model.dropDownValue2,
|
||||
// visitTempStr:
|
||||
// _model.switchValue == true ? 'Sim' : 'Não',
|
||||
// visitObsStr: _model.textController3.text,
|
||||
// visitorStrList: _model.visitorStrList,
|
||||
// visitorJsonList: _model.visitorJsonList,
|
||||
// updateToggleIdx: () async {},
|
||||
// repeatVisitSchedule: () async {},
|
||||
// ),
|
||||
child: VisitRequestTemplateComponentWidget(
|
||||
buttons: [],
|
||||
imageHashMap: {},
|
||||
labelsHashMap: {},
|
||||
statusHashMap: [],
|
||||
onTapCardItemAction: () async {},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -11,7 +11,6 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
|||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class VisitHistoryWidget extends StatefulWidget {
|
||||
VisitHistoryWidget({
|
||||
|
@ -23,153 +22,153 @@ class VisitHistoryWidget extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _VisitHistoryWidgetState extends State<VisitHistoryWidget> {
|
||||
late Future<ApiCallResponse> visitFuture;
|
||||
var pageNumber = 1;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var response = ScheduleCompleteVisitPageModel().visitHistory(
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Inicialização inicial
|
||||
visitFuture = ScheduleCompleteVisitPageModel().visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getVisitas',
|
||||
pageSize: 100,
|
||||
pageNumber: 1,
|
||||
),
|
||||
);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 900.0,
|
||||
decoration: BoxDecoration(
|
||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||
),
|
||||
// child: Consumer<ScheduleCompleteVisitPageModel>(
|
||||
child: StreamBuilder<dynamic>(
|
||||
stream: response,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (!snapshot.hasData || snapshot.data!.jsonBody == null) {
|
||||
return const Center(child: Text('No visits found'));
|
||||
}
|
||||
var wrapGetVisitsResponse = snapshot.data!;
|
||||
var visitaWrap = PhpGroup.getVisitsCall
|
||||
.visitasList(wrapGetVisitsResponse.jsonBody)
|
||||
?.toList() ??
|
||||
[];
|
||||
return ListView.builder(
|
||||
itemCount: visitaWrap.length,
|
||||
shrinkWrap: true,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
final visitaWrapItem = visitaWrap[index];
|
||||
return CardItemTemplateComponentWidget(
|
||||
imageHashMap: {
|
||||
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
||||
'value': 'E',
|
||||
},
|
||||
labelsHashMap: {
|
||||
'Nome:': visitaWrapItem['VTE_NOME'] ?? '',
|
||||
'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '',
|
||||
'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '',
|
||||
},
|
||||
statusHashMap: [
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
): FlutterFlowTheme.of(context).warning,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.finished)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Finalizado',
|
||||
enText: 'Finished',
|
||||
): FlutterFlowTheme.of(context).success,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.unknown)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Desconhecido',
|
||||
enText: 'Unknown',
|
||||
): FlutterFlowTheme.of(context).alternate,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.canceled)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Cancelado',
|
||||
enText: 'Canceled',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.blocked)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Bloqueado',
|
||||
enText: 'Blocked',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.inactive)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Inactive',
|
||||
enText: 'Inactive',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
},
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
await showDialog(
|
||||
// isScrollControlled: true,
|
||||
// isDismissible: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
alignment: Alignment.center,
|
||||
child: buildDetails(
|
||||
visitaWrapItem,
|
||||
context,
|
||||
changeStatusAction,
|
||||
),
|
||||
);
|
||||
},
|
||||
).whenComplete(() async {
|
||||
final newResponseStream =
|
||||
ScheduleCompleteVisitPageModel().visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getVisitas',
|
||||
pageSize: 100,
|
||||
pageNumber: 1,
|
||||
),
|
||||
);
|
||||
newResponseStream.listen((newResponse) {
|
||||
if (mounted) {
|
||||
safeSetState(() {
|
||||
response = newResponse.jsonBody;
|
||||
});
|
||||
} else {}
|
||||
}).onError((err) {});
|
||||
}).catchError((err, stack) {});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
pageNumber: pageNumber,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void updateVisitFuture() {
|
||||
// Atualização do valor da variável late
|
||||
setState(() {
|
||||
visitFuture = ScheduleCompleteVisitPageModel().visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getVisitas',
|
||||
pageSize: 100,
|
||||
pageNumber: pageNumber,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder<dynamic>(
|
||||
future: visitFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (!snapshot.hasData || snapshot.data!.jsonBody == null) {
|
||||
return Center(
|
||||
child: Text(FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Nenhum visitante foi encontrado',
|
||||
enText: 'No visitors found',
|
||||
)));
|
||||
}
|
||||
|
||||
var wrapGetVisitsResponse = snapshot.data!;
|
||||
var visitaWrap = PhpGroup.getVisitsCall
|
||||
.visitasList(wrapGetVisitsResponse.jsonBody)
|
||||
?.toList() ??
|
||||
[];
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: visitaWrap.length,
|
||||
shrinkWrap: true,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemBuilder: (context, index) {
|
||||
final visitaWrapItem = visitaWrap[index];
|
||||
return CardItemTemplateComponentWidget(
|
||||
imageHashMap: {
|
||||
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
||||
'value': 'E',
|
||||
},
|
||||
labelsHashMap: {
|
||||
'Nome:': visitaWrapItem['VTE_NOME'] ?? '',
|
||||
'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '',
|
||||
'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '',
|
||||
},
|
||||
statusHashMap: [
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.active)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
): FlutterFlowTheme.of(context).warning,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.finished)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Finalizado',
|
||||
enText: 'Finished',
|
||||
): FlutterFlowTheme.of(context).success,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.unknown)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Desconhecido',
|
||||
enText: 'Unknown',
|
||||
): FlutterFlowTheme.of(context).alternate,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.canceled)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Cancelado',
|
||||
enText: 'Canceled',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.blocked)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Bloqueado',
|
||||
enText: 'Blocked',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
},
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) == status.inactive)
|
||||
{
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Inativo',
|
||||
enText: 'Inactive',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
},
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
await showDialog(
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
alignment: Alignment.center,
|
||||
child: buildDetails(
|
||||
visitaWrapItem,
|
||||
context,
|
||||
changeStatusAction,
|
||||
),
|
||||
);
|
||||
},
|
||||
).whenComplete(() {
|
||||
log('Dialog closed');
|
||||
updateVisitFuture();
|
||||
}).catchError((err, stack) {});
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue