WIP
This commit is contained in:
parent
262b8dd63b
commit
2a5acf1016
|
@ -344,7 +344,6 @@ Future<bool> visitRequestComponentAction(
|
|||
|
||||
if (respondeSolicitacaoCall.statusCode == 200) {
|
||||
log('jsonBody: ${respondeSolicitacaoCall.jsonBody}; actionValue: $actionValue; refUUID: $refUUID; responseValue: $responseValue; vteUUID: $vteUUID; status: ${respondeSolicitacaoCall.jsonBody['error']}');
|
||||
|
||||
return !respondeSolicitacaoCall.jsonBody['error'];
|
||||
} else {
|
||||
log('headers: ${respondeSolicitacaoCall.headers}');
|
||||
|
@ -485,8 +484,10 @@ Future changeStatusAction(
|
|||
if (!context.mounted) return;
|
||||
if (blockVisitRequest == true) {
|
||||
log('Bloqueado');
|
||||
return true;
|
||||
} else {
|
||||
log('Erro ao bloquear');
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1370,39 +1370,53 @@ class PostProvVisitSchedulingCall {
|
|||
}
|
||||
|
||||
class GetVisitsCall {
|
||||
Future<ApiCallResponse> call({
|
||||
Stream<ApiCallResponse> call({
|
||||
String? devUUID = '',
|
||||
String? userUUID = '',
|
||||
String? cliID = '',
|
||||
String? atividade = '',
|
||||
int? pageSize,
|
||||
int? pageNumber,
|
||||
}) async {
|
||||
}) {
|
||||
final baseUrl = PhpGroup.getBaseUrl();
|
||||
final StreamController<ApiCallResponse> controller = StreamController();
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'getVisits',
|
||||
apiUrl: '$baseUrl/processRequest.php',
|
||||
callType: ApiCallType.POST,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
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();
|
||||
}
|
||||
},
|
||||
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(
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:hub/app_state.dart';
|
|||
import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_util.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
|
||||
import 'package:hub/flutter_flow/internationalization.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
|
@ -105,13 +106,47 @@ Widget buildDetails(
|
|||
ptText: 'Sim',
|
||||
),
|
||||
onPressed: () async {
|
||||
await changeStatusAction?.call(
|
||||
await changeStatusAction
|
||||
?.call(
|
||||
context,
|
||||
'B',
|
||||
visitaWrapItem['VAW_REF'] ?? '',
|
||||
'Mensagem',
|
||||
visitaWrapItem['VTE_ID'] ?? '',
|
||||
);
|
||||
)
|
||||
.then((value) {
|
||||
Navigator.pop(context);
|
||||
if (value == false) {
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error blocking visit',
|
||||
ptText: 'Erro ao bloquear visita',
|
||||
),
|
||||
true,
|
||||
);
|
||||
} else if (value == true) {
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Success canceling visit',
|
||||
ptText: 'Succeso ao cancelar visita',
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
}).catchError((err, stack) {
|
||||
debugPrint('Error: $err');
|
||||
debugPrint('Stack: $stack');
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error blocking visit',
|
||||
ptText: 'Erro ao bloquear visita',
|
||||
),
|
||||
true,
|
||||
);
|
||||
});
|
||||
},
|
||||
options: FFButtonOptions(
|
||||
width: 100,
|
||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:from_css_color/from_css_color.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
|
||||
import 'dart:math' show pow, pi, sin;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:json_path/json_path.dart';
|
||||
|
@ -505,7 +506,8 @@ void setDarkModeSetting(BuildContext context, ThemeMode themeMode) =>
|
|||
|
||||
void showSnackbar(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
String message,
|
||||
bool error, {
|
||||
bool loading = false,
|
||||
int duration = 4,
|
||||
}) {
|
||||
|
@ -515,20 +517,32 @@ void showSnackbar(
|
|||
content: Row(
|
||||
children: [
|
||||
if (loading)
|
||||
const Padding(
|
||||
padding: EdgeInsetsDirectional.only(end: 10.0),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 10.0),
|
||||
child: SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(message),
|
||||
Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
duration: Duration(seconds: duration),
|
||||
backgroundColor: error
|
||||
? FlutterFlowTheme.of(context).error
|
||||
: FlutterFlowTheme.of(context).success,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -282,68 +282,49 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
tarefa: 'I',
|
||||
)
|
||||
.then((value) {
|
||||
FFAppState().deleteCliUUID();
|
||||
FFAppState().deleteLocal();
|
||||
FFAppState().deleteOwnerUUID();
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
log(value.jsonBody['error'].toString());
|
||||
if (value.jsonBody['error'] == false) {
|
||||
FFAppState().deleteCliUUID();
|
||||
FFAppState().deleteLocal();
|
||||
FFAppState().deleteOwnerUUID();
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Device unlinked successfully',
|
||||
ptText:
|
||||
'Dispositivo desvinculado com sucesso',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Device unlinked successfully',
|
||||
ptText:
|
||||
'Dispositivo desvinculado com sucesso',
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
FlutterFlowTheme.of(context).info)),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).success,
|
||||
duration: const Duration(seconds: 3),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).success,
|
||||
duration: const Duration(seconds: 3),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).catchError((err, stack) {
|
||||
);
|
||||
}
|
||||
})
|
||||
// ignore: body_might_complete_normally_catch_error
|
||||
.catchError((err, stack) {
|
||||
log(err.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error unlinking device',
|
||||
ptText: 'Erro ao desvincular dispositivo',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).error,
|
||||
duration: const Duration(seconds: 3),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).catchError((err, stack) {
|
||||
log(err.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error unlinking device',
|
||||
ptText: 'Erro ao desvincular dispositivo',
|
||||
),
|
||||
style: TextStyle(
|
||||
color: FlutterFlowTheme.of(context).info,
|
||||
),
|
||||
),
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error unlinking device',
|
||||
ptText: 'Erro ao desvincular dispositivo',
|
||||
),
|
||||
style: TextStyle(
|
||||
color:
|
||||
FlutterFlowTheme.of(context).info)),
|
||||
backgroundColor:
|
||||
FlutterFlowTheme.of(context).error,
|
||||
duration: const Duration(seconds: 3),
|
||||
|
@ -454,18 +435,20 @@ class PreferencesPageModel with ChangeNotifier {
|
|||
userUUID: FFAppState().userUUID,
|
||||
)
|
||||
.then((value) {
|
||||
FFAppState().deleteAll();
|
||||
FFAppState().isLogged = false;
|
||||
context.goNamed(
|
||||
'welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
if (value.jsonBody['error'] == false) {
|
||||
FFAppState().deleteAll();
|
||||
FFAppState().isLogged = false;
|
||||
context.goNamed(
|
||||
'welcomePage',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
}).catchError((err) {
|
||||
log(err.toString());
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
|
|
@ -12,11 +12,11 @@ import 'package:intl/intl.dart';
|
|||
|
||||
class ScheduleCompleteVisitPageModel
|
||||
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
|
||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||
Future<ApiCallResponse> visitHistory({
|
||||
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||
Stream<ApiCallResponse> visitHistory({
|
||||
String? uniqueQueryKey,
|
||||
bool? overrideCache,
|
||||
required Future<ApiCallResponse> Function() requestFn,
|
||||
required Stream<ApiCallResponse> Function() requestFn,
|
||||
}) =>
|
||||
_visitHistoryManager.performRequest(
|
||||
uniqueQueryKey: uniqueQueryKey,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -1694,204 +1696,201 @@ Widget visitHistory(
|
|||
decoration: BoxDecoration(
|
||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: FutureBuilder<ApiCallResponse>(
|
||||
future: _model.visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getVisitas',
|
||||
),
|
||||
child: StreamBuilder<ApiCallResponse>(
|
||||
stream: _model.visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getVisitas',
|
||||
pageSize: 100,
|
||||
pageNumber: 1,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
// Customize what your widget looks like when it's loading.
|
||||
if (!snapshot.hasData) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: 50.0,
|
||||
height: 50.0,
|
||||
child: SpinKitCircle(
|
||||
color: FlutterFlowTheme.of(context).primary,
|
||||
size: 50.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final wrapGetVisitsResponse = snapshot.data!;
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
final visitaWrap = PhpGroup.getVisitsCall
|
||||
.visitasList(
|
||||
wrapGetVisitsResponse.jsonBody,
|
||||
)
|
||||
?.toList() ??
|
||||
[];
|
||||
return ListView.builder(
|
||||
itemCount: visitaWrap.length,
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
addAutomaticKeepAlives: true,
|
||||
cacheExtent: 1000.0,
|
||||
addRepaintBoundaries: true,
|
||||
addSemanticIndexes: true,
|
||||
itemBuilder: (context, index) {
|
||||
final visitaWrapItem = visitaWrap[index];
|
||||
// visitaWrap.length, (visitaWrapIndex) {
|
||||
|
||||
return CardItemTemplateComponentWidget(
|
||||
imageHashMap: Map<String, String>.from({
|
||||
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
||||
'value': 'E',
|
||||
}),
|
||||
labelsHashMap: Map<String, String>.from({
|
||||
'Nome:': visitaWrapItem['VTE_NOME'] ?? '',
|
||||
'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '',
|
||||
'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '',
|
||||
}),
|
||||
statusHashMap: [
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.active)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
): FlutterFlowTheme.of(context).warning,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.finished)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Finalizado',
|
||||
enText: 'Finished',
|
||||
): FlutterFlowTheme.of(context).success,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.unknown)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Desconhecido',
|
||||
enText: 'Unknown',
|
||||
): FlutterFlowTheme.of(context).alternate,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.canceled)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Cancelado',
|
||||
enText: 'Canceled',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.blocked)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Bloqueado',
|
||||
enText: 'Blocked',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.inactive)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Inactive',
|
||||
enText: 'Inactive',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
}),
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
isDismissible: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return buildDetails(
|
||||
visitaWrapItem,
|
||||
context,
|
||||
changeStatusAction,
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
// PushNotificationManager _pushNotificationService =
|
||||
// PushNotificationManager();
|
||||
// _pushNotificationService.onMessageReceived
|
||||
// .listen((received) {
|
||||
// if (received.data['click_action'] ==
|
||||
// 'cancel_request') {
|
||||
// log('Aprovado');
|
||||
// _pushNotificationService.dispose();
|
||||
// snackbar(context, opt: true);
|
||||
// context.pushReplacementNamed(
|
||||
// 'liberationHistory',
|
||||
// extra: <String, dynamic>{
|
||||
// kTransitionInfoKey: const TransitionInfo(
|
||||
// hasTransition: true,
|
||||
// transitionType: PageTransitionType.scale,
|
||||
// alignment: Alignment.bottomCenter,
|
||||
// ),
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
});
|
||||
// await showModalBottomSheet(
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
// enableDrag: true,
|
||||
// isDismissible: true,
|
||||
// useSafeArea: true,
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return GestureDetector(
|
||||
// onTap: () => _model.unfocusNode.canRequestFocus
|
||||
// ? FocusScope.of(context)
|
||||
// .requestFocus(_model.unfocusNode)
|
||||
// : FocusScope.of(context).unfocus(),
|
||||
// child: VisitDetailsModalTemplateComponentWidget(
|
||||
// visitStatusStr: visitaWrapItem['VAW_STATUS'],
|
||||
// visitStartDateStr:
|
||||
// visitaWrapItem['VAW_DTINICIO'],
|
||||
// visitEndDateStr: visitaWrapItem['VAW_DTFIM'],
|
||||
// visitReasonStr:
|
||||
// visitaWrapItem['MOT_DESCRICAO'],
|
||||
// visitLevelStr:
|
||||
// visitaWrapItem['NAC_DESCRICAO'],
|
||||
// visitTempStr:
|
||||
// visitaWrapItem['VTE_UNICA'].toString(),
|
||||
// visitObsStr: visitaWrapItem['VAW_OBS'],
|
||||
// visitorImgPath: valueOrDefault<String>(
|
||||
// "https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(
|
||||
// visitaWrapItem,
|
||||
// r'''$.VTE_DOCUMENTO''',
|
||||
// ).toString()}&tipo=E",
|
||||
// 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg',
|
||||
// ),
|
||||
// visitorStrList:
|
||||
// visitaWrapItem['VTE_DOCUMENTO'],
|
||||
// visitIdStr: visitaWrapItem['VAW_ID'],
|
||||
// visitStatusColor:
|
||||
// visitaWrapItem['VAW_STATUS'] == 'A'
|
||||
// ? FlutterFlowTheme.of(context).success
|
||||
// : FlutterFlowTheme.of(context).error,
|
||||
// visitorJsonList:
|
||||
// PhpGroup.getVisitsCall.visitasList(
|
||||
// wrapGetVisitsResponse.jsonBody,
|
||||
// ),
|
||||
// updateToggleIdx: () async {},
|
||||
// repeatVisitSchedule: () async {},
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ).then((value) => safeSetState(() {}));
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
),
|
||||
));
|
||||
} else if (snapshot.hasError) {
|
||||
log('Error: ${snapshot.error}');
|
||||
return Center(child: Text('Error: ${snapshot.error}'));
|
||||
} else if (!snapshot.hasData || snapshot.data!.jsonBody == null) {
|
||||
log('No data or jsonBody is null');
|
||||
return const Center(child: Text('No visits found'));
|
||||
}
|
||||
|
||||
final wrapGetVisitsResponse = snapshot.data!;
|
||||
log('Response: ${wrapGetVisitsResponse.jsonBody}');
|
||||
|
||||
final visitaWrap = PhpGroup.getVisitsCall
|
||||
.visitasList(wrapGetVisitsResponse.jsonBody)
|
||||
?.toList() ??
|
||||
[];
|
||||
log('visitaWrap: $visitaWrap');
|
||||
return ListView.builder(
|
||||
itemCount: visitaWrap.length,
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.vertical,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
addAutomaticKeepAlives: true,
|
||||
cacheExtent: 1000.0,
|
||||
addRepaintBoundaries: true,
|
||||
addSemanticIndexes: true,
|
||||
itemBuilder: (context, index) {
|
||||
final visitaWrapItem = visitaWrap[index];
|
||||
return CardItemTemplateComponentWidget(
|
||||
imageHashMap: Map<String, String>.from({
|
||||
'key': visitaWrapItem['VTE_DOCUMENTO'] ?? '',
|
||||
'value': 'E',
|
||||
}),
|
||||
labelsHashMap: Map<String, String>.from({
|
||||
'Nome:': visitaWrapItem['VTE_NOME'] ?? '',
|
||||
'Inicio:': visitaWrapItem['VAW_DTINICIO'] ?? '',
|
||||
'Fim:': visitaWrapItem['VAW_DTFIM'] ?? '',
|
||||
}),
|
||||
statusHashMap: [
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.active)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
): FlutterFlowTheme.of(context).warning,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.finished)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Finalizado',
|
||||
enText: 'Finished',
|
||||
): FlutterFlowTheme.of(context).success,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.unknown)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Desconhecido',
|
||||
enText: 'Unknown',
|
||||
): FlutterFlowTheme.of(context).alternate,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.canceled)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Cancelado',
|
||||
enText: 'Canceled',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.blocked)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Bloqueado',
|
||||
enText: 'Blocked',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
}),
|
||||
if (getStatus(visitaWrapItem['VAW_STATUS']) ==
|
||||
status.inactive)
|
||||
Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Inactive',
|
||||
enText: 'Inactive',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
}),
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
isDismissible: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return buildDetails(
|
||||
visitaWrapItem,
|
||||
context,
|
||||
changeStatusAction,
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
// PushNotificationManager _pushNotificationService =
|
||||
// PushNotificationManager();
|
||||
// _pushNotificationService.onMessageReceived
|
||||
// .listen((received) {
|
||||
// if (received.data['click_action'] ==
|
||||
// 'cancel_request') {
|
||||
// log('Aprovado');
|
||||
// _pushNotificationService.dispose();
|
||||
// snackbar(context, opt: true);
|
||||
// context.pushReplacementNamed(
|
||||
// 'liberationHistory',
|
||||
// extra: <String, dynamic>{
|
||||
// kTransitionInfoKey: const TransitionInfo(
|
||||
// hasTransition: true,
|
||||
// transitionType: PageTransitionType.scale,
|
||||
// alignment: Alignment.bottomCenter,
|
||||
// ),
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
});
|
||||
// await showModalBottomSheet(
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
// enableDrag: true,
|
||||
// isDismissible: true,
|
||||
// useSafeArea: true,
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return GestureDetector(
|
||||
// onTap: () => _model.unfocusNode.canRequestFocus
|
||||
// ? FocusScope.of(context)
|
||||
// .requestFocus(_model.unfocusNode)
|
||||
// : FocusScope.of(context).unfocus(),
|
||||
// child: VisitDetailsModalTemplateComponentWidget(
|
||||
// visitStatusStr: visitaWrapItem['VAW_STATUS'],
|
||||
// visitStartDateStr:
|
||||
// visitaWrapItem['VAW_DTINICIO'],
|
||||
// visitEndDateStr: visitaWrapItem['VAW_DTFIM'],
|
||||
// visitReasonStr:
|
||||
// visitaWrapItem['MOT_DESCRICAO'],
|
||||
// visitLevelStr:
|
||||
// visitaWrapItem['NAC_DESCRICAO'],
|
||||
// visitTempStr:
|
||||
// visitaWrapItem['VTE_UNICA'].toString(),
|
||||
// visitObsStr: visitaWrapItem['VAW_OBS'],
|
||||
// visitorImgPath: valueOrDefault<String>(
|
||||
// "https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(
|
||||
// visitaWrapItem,
|
||||
// r'''$.VTE_DOCUMENTO''',
|
||||
// ).toString()}&tipo=E",
|
||||
// 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg',
|
||||
// ),
|
||||
// visitorStrList:
|
||||
// visitaWrapItem['VTE_DOCUMENTO'],
|
||||
// visitIdStr: visitaWrapItem['VAW_ID'],
|
||||
// visitStatusColor:
|
||||
// visitaWrapItem['VAW_STATUS'] == 'A'
|
||||
// ? FlutterFlowTheme.of(context).success
|
||||
// : FlutterFlowTheme.of(context).error,
|
||||
// visitorJsonList:
|
||||
// PhpGroup.getVisitsCall.visitasList(
|
||||
// wrapGetVisitsResponse.jsonBody,
|
||||
// ),
|
||||
// updateToggleIdx: () async {},
|
||||
// repeatVisitSchedule: () async {},
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ).then((value) => safeSetState(() {}));
|
||||
});
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||
import 'package:hub/flutter_flow/flutter_flow_model.dart';
|
||||
|
@ -8,11 +6,11 @@ import 'package:hub/flutter_flow/request_manager.dart';
|
|||
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';
|
||||
|
||||
class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
|
||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
||||
Future<ApiCallResponse> visitHistory({
|
||||
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||
Stream<ApiCallResponse> visitHistory({
|
||||
String? uniqueQueryKey,
|
||||
bool? overrideCache,
|
||||
required Future<ApiCallResponse> Function() requestFn,
|
||||
required Stream<ApiCallResponse> Function() requestFn,
|
||||
}) =>
|
||||
_visitHistoryManager.performRequest(
|
||||
uniqueQueryKey: uniqueQueryKey,
|
||||
|
@ -105,4 +103,4 @@ class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
|
|||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:hub/flutter_flow/nav/nav.dart';
|
|||
import 'package:hub/pages/visit_history_page/visit_history_page_model.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
||||
class VisitHistoryPageWidget extends StatefulWidget {
|
||||
const VisitHistoryPageWidget({
|
||||
super.key,
|
||||
|
@ -233,8 +232,8 @@ Widget visitHistory(
|
|||
),
|
||||
],
|
||||
),
|
||||
FutureBuilder<ApiCallResponse>(
|
||||
future: _model.visitHistory(
|
||||
StreamBuilder<ApiCallResponse>(
|
||||
stream: _model.visitHistory(
|
||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
|
@ -586,9 +585,8 @@ Widget visitHistory(
|
|||
return FlutterFlowTheme
|
||||
.of(context)
|
||||
.success;
|
||||
} else if ((
|
||||
jsonToStr(
|
||||
getJsonField(
|
||||
} else if ((jsonToStr(
|
||||
getJsonField(
|
||||
visitaWrapItem,
|
||||
r'''$.VAW_STATUS''',
|
||||
)) ==
|
||||
|
@ -614,9 +612,8 @@ Widget visitHistory(
|
|||
return FlutterFlowTheme
|
||||
.of(context)
|
||||
.error;
|
||||
} else if (
|
||||
jsonToStr(
|
||||
getJsonField(
|
||||
} else if (jsonToStr(
|
||||
getJsonField(
|
||||
visitaWrapItem,
|
||||
r'''$.VAW_STATUS''',
|
||||
)) ==
|
||||
|
@ -655,9 +652,8 @@ Widget visitHistory(
|
|||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
);
|
||||
} else if ((
|
||||
jsonToStr(
|
||||
getJsonField(
|
||||
} else if ((jsonToStr(
|
||||
getJsonField(
|
||||
visitaWrapItem,
|
||||
r'''$.VAW_STATUS''',
|
||||
)) ==
|
||||
|
@ -754,4 +750,4 @@ Widget visitHistory(
|
|||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue