WIP
This commit is contained in:
parent
262b8dd63b
commit
2a5acf1016
|
@ -344,7 +344,6 @@ Future<bool> visitRequestComponentAction(
|
||||||
|
|
||||||
if (respondeSolicitacaoCall.statusCode == 200) {
|
if (respondeSolicitacaoCall.statusCode == 200) {
|
||||||
log('jsonBody: ${respondeSolicitacaoCall.jsonBody}; actionValue: $actionValue; refUUID: $refUUID; responseValue: $responseValue; vteUUID: $vteUUID; status: ${respondeSolicitacaoCall.jsonBody['error']}');
|
log('jsonBody: ${respondeSolicitacaoCall.jsonBody}; actionValue: $actionValue; refUUID: $refUUID; responseValue: $responseValue; vteUUID: $vteUUID; status: ${respondeSolicitacaoCall.jsonBody['error']}');
|
||||||
|
|
||||||
return !respondeSolicitacaoCall.jsonBody['error'];
|
return !respondeSolicitacaoCall.jsonBody['error'];
|
||||||
} else {
|
} else {
|
||||||
log('headers: ${respondeSolicitacaoCall.headers}');
|
log('headers: ${respondeSolicitacaoCall.headers}');
|
||||||
|
@ -485,8 +484,10 @@ Future changeStatusAction(
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
if (blockVisitRequest == true) {
|
if (blockVisitRequest == true) {
|
||||||
log('Bloqueado');
|
log('Bloqueado');
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
log('Erro ao bloquear');
|
log('Erro ao bloquear');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1370,39 +1370,53 @@ class PostProvVisitSchedulingCall {
|
||||||
}
|
}
|
||||||
|
|
||||||
class GetVisitsCall {
|
class GetVisitsCall {
|
||||||
Future<ApiCallResponse> call({
|
Stream<ApiCallResponse> call({
|
||||||
String? devUUID = '',
|
String? devUUID = '',
|
||||||
String? userUUID = '',
|
String? userUUID = '',
|
||||||
String? cliID = '',
|
String? cliID = '',
|
||||||
String? atividade = '',
|
String? atividade = '',
|
||||||
int? pageSize,
|
int? pageSize,
|
||||||
int? pageNumber,
|
int? pageNumber,
|
||||||
}) async {
|
}) {
|
||||||
final baseUrl = PhpGroup.getBaseUrl();
|
final baseUrl = PhpGroup.getBaseUrl();
|
||||||
|
final StreamController<ApiCallResponse> controller = StreamController();
|
||||||
|
|
||||||
return ApiManager.instance.makeApiCall(
|
Future.microtask(
|
||||||
callName: 'getVisits',
|
() async {
|
||||||
apiUrl: '$baseUrl/processRequest.php',
|
try {
|
||||||
callType: ApiCallType.POST,
|
final response = await ApiManager.instance.makeApiCall(
|
||||||
headers: {
|
callName: 'getVisits',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
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(
|
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/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_icon_button.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_theme.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/flutter_flow_widgets.dart';
|
||||||
import 'package:hub/flutter_flow/internationalization.dart';
|
import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||||
|
@ -105,13 +106,47 @@ Widget buildDetails(
|
||||||
ptText: 'Sim',
|
ptText: 'Sim',
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await changeStatusAction?.call(
|
await changeStatusAction
|
||||||
|
?.call(
|
||||||
context,
|
context,
|
||||||
'B',
|
'B',
|
||||||
visitaWrapItem['VAW_REF'] ?? '',
|
visitaWrapItem['VAW_REF'] ?? '',
|
||||||
'Mensagem',
|
'Mensagem',
|
||||||
visitaWrapItem['VTE_ID'] ?? '',
|
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(
|
options: FFButtonOptions(
|
||||||
width: 100,
|
width: 100,
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:from_css_color/from_css_color.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 'dart:math' show pow, pi, sin;
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:json_path/json_path.dart';
|
import 'package:json_path/json_path.dart';
|
||||||
|
@ -505,7 +506,8 @@ void setDarkModeSetting(BuildContext context, ThemeMode themeMode) =>
|
||||||
|
|
||||||
void showSnackbar(
|
void showSnackbar(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
String message, {
|
String message,
|
||||||
|
bool error, {
|
||||||
bool loading = false,
|
bool loading = false,
|
||||||
int duration = 4,
|
int duration = 4,
|
||||||
}) {
|
}) {
|
||||||
|
@ -515,20 +517,32 @@ void showSnackbar(
|
||||||
content: Row(
|
content: Row(
|
||||||
children: [
|
children: [
|
||||||
if (loading)
|
if (loading)
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsetsDirectional.only(end: 10.0),
|
padding: const EdgeInsetsDirectional.only(end: 10.0),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
width: 20,
|
width: 20,
|
||||||
child: CircularProgressIndicator(
|
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),
|
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',
|
tarefa: 'I',
|
||||||
)
|
)
|
||||||
.then((value) {
|
.then((value) {
|
||||||
FFAppState().deleteCliUUID();
|
log(value.jsonBody['error'].toString());
|
||||||
FFAppState().deleteLocal();
|
if (value.jsonBody['error'] == false) {
|
||||||
FFAppState().deleteOwnerUUID();
|
FFAppState().deleteCliUUID();
|
||||||
Navigator.pop(context);
|
FFAppState().deleteLocal();
|
||||||
Navigator.pop(context);
|
FFAppState().deleteOwnerUUID();
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Device unlinked successfully',
|
enText: 'Device unlinked successfully',
|
||||||
ptText:
|
ptText:
|
||||||
'Dispositivo desvinculado com sucesso',
|
'Dispositivo desvinculado com sucesso',
|
||||||
),
|
),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: FlutterFlowTheme.of(context).info,
|
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,
|
// ignore: body_might_complete_normally_catch_error
|
||||||
shape: RoundedRectangleBorder(
|
.catchError((err, stack) {
|
||||||
borderRadius: BorderRadius.circular(30),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).catchError((err, stack) {
|
|
||||||
log(err.toString());
|
log(err.toString());
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Error unlinking device',
|
enText: 'Error unlinking device',
|
||||||
ptText: 'Erro ao desvincular dispositivo',
|
ptText: 'Erro ao desvincular dispositivo',
|
||||||
),
|
),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: FlutterFlowTheme.of(context).info,
|
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
FlutterFlowTheme.of(context).error,
|
FlutterFlowTheme.of(context).error,
|
||||||
duration: const Duration(seconds: 3),
|
duration: const Duration(seconds: 3),
|
||||||
|
@ -454,18 +435,20 @@ class PreferencesPageModel with ChangeNotifier {
|
||||||
userUUID: FFAppState().userUUID,
|
userUUID: FFAppState().userUUID,
|
||||||
)
|
)
|
||||||
.then((value) {
|
.then((value) {
|
||||||
FFAppState().deleteAll();
|
if (value.jsonBody['error'] == false) {
|
||||||
FFAppState().isLogged = false;
|
FFAppState().deleteAll();
|
||||||
context.goNamed(
|
FFAppState().isLogged = false;
|
||||||
'welcomePage',
|
context.goNamed(
|
||||||
extra: <String, dynamic>{
|
'welcomePage',
|
||||||
kTransitionInfoKey: const TransitionInfo(
|
extra: <String, dynamic>{
|
||||||
hasTransition: true,
|
kTransitionInfoKey: const TransitionInfo(
|
||||||
transitionType: PageTransitionType.scale,
|
hasTransition: true,
|
||||||
alignment: Alignment.bottomCenter,
|
transitionType: PageTransitionType.scale,
|
||||||
),
|
alignment: Alignment.bottomCenter,
|
||||||
},
|
),
|
||||||
);
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}).catchError((err) {
|
}).catchError((err) {
|
||||||
log(err.toString());
|
log(err.toString());
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
|
|
@ -12,11 +12,11 @@ import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class ScheduleCompleteVisitPageModel
|
class ScheduleCompleteVisitPageModel
|
||||||
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
|
extends FlutterFlowModel<ScheduleCompleteVisitPageWidget> {
|
||||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||||
Future<ApiCallResponse> visitHistory({
|
Stream<ApiCallResponse> visitHistory({
|
||||||
String? uniqueQueryKey,
|
String? uniqueQueryKey,
|
||||||
bool? overrideCache,
|
bool? overrideCache,
|
||||||
required Future<ApiCallResponse> Function() requestFn,
|
required Stream<ApiCallResponse> Function() requestFn,
|
||||||
}) =>
|
}) =>
|
||||||
_visitHistoryManager.performRequest(
|
_visitHistoryManager.performRequest(
|
||||||
uniqueQueryKey: uniqueQueryKey,
|
uniqueQueryKey: uniqueQueryKey,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -1694,204 +1696,201 @@ Widget visitHistory(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(
|
child: StreamBuilder<ApiCallResponse>(
|
||||||
child: FutureBuilder<ApiCallResponse>(
|
stream: _model.visitHistory(
|
||||||
future: _model.visitHistory(
|
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
devUUID: FFAppState().devUUID,
|
||||||
devUUID: FFAppState().devUUID,
|
userUUID: FFAppState().userUUID,
|
||||||
userUUID: FFAppState().userUUID,
|
cliID: FFAppState().cliUUID,
|
||||||
cliID: FFAppState().cliUUID,
|
atividade: 'getVisitas',
|
||||||
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:flutter/material.dart';
|
||||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_model.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';
|
import 'package:hub/pages/visit_history_page/visit_history_page_widget.dart';
|
||||||
|
|
||||||
class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
|
class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
|
||||||
final _visitHistoryManager = FutureRequestManager<ApiCallResponse>();
|
final _visitHistoryManager = StreamRequestManager<ApiCallResponse>();
|
||||||
Future<ApiCallResponse> visitHistory({
|
Stream<ApiCallResponse> visitHistory({
|
||||||
String? uniqueQueryKey,
|
String? uniqueQueryKey,
|
||||||
bool? overrideCache,
|
bool? overrideCache,
|
||||||
required Future<ApiCallResponse> Function() requestFn,
|
required Stream<ApiCallResponse> Function() requestFn,
|
||||||
}) =>
|
}) =>
|
||||||
_visitHistoryManager.performRequest(
|
_visitHistoryManager.performRequest(
|
||||||
uniqueQueryKey: uniqueQueryKey,
|
uniqueQueryKey: uniqueQueryKey,
|
||||||
|
@ -105,4 +103,4 @@ class VisitHistoryPageModel extends FlutterFlowModel<VisitHistoryPageWidget> {
|
||||||
|
|
||||||
return false;
|
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:hub/pages/visit_history_page/visit_history_page_model.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
|
||||||
class VisitHistoryPageWidget extends StatefulWidget {
|
class VisitHistoryPageWidget extends StatefulWidget {
|
||||||
const VisitHistoryPageWidget({
|
const VisitHistoryPageWidget({
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -233,8 +232,8 @@ Widget visitHistory(
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
FutureBuilder<ApiCallResponse>(
|
StreamBuilder<ApiCallResponse>(
|
||||||
future: _model.visitHistory(
|
stream: _model.visitHistory(
|
||||||
requestFn: () => PhpGroup.getVisitsCall.call(
|
requestFn: () => PhpGroup.getVisitsCall.call(
|
||||||
devUUID: FFAppState().devUUID,
|
devUUID: FFAppState().devUUID,
|
||||||
userUUID: FFAppState().userUUID,
|
userUUID: FFAppState().userUUID,
|
||||||
|
@ -586,9 +585,8 @@ Widget visitHistory(
|
||||||
return FlutterFlowTheme
|
return FlutterFlowTheme
|
||||||
.of(context)
|
.of(context)
|
||||||
.success;
|
.success;
|
||||||
} else if ((
|
} else if ((jsonToStr(
|
||||||
jsonToStr(
|
getJsonField(
|
||||||
getJsonField(
|
|
||||||
visitaWrapItem,
|
visitaWrapItem,
|
||||||
r'''$.VAW_STATUS''',
|
r'''$.VAW_STATUS''',
|
||||||
)) ==
|
)) ==
|
||||||
|
@ -614,9 +612,8 @@ Widget visitHistory(
|
||||||
return FlutterFlowTheme
|
return FlutterFlowTheme
|
||||||
.of(context)
|
.of(context)
|
||||||
.error;
|
.error;
|
||||||
} else if (
|
} else if (jsonToStr(
|
||||||
jsonToStr(
|
getJsonField(
|
||||||
getJsonField(
|
|
||||||
visitaWrapItem,
|
visitaWrapItem,
|
||||||
r'''$.VAW_STATUS''',
|
r'''$.VAW_STATUS''',
|
||||||
)) ==
|
)) ==
|
||||||
|
@ -655,9 +652,8 @@ Widget visitHistory(
|
||||||
ptText: 'Ativo',
|
ptText: 'Ativo',
|
||||||
enText: 'Active',
|
enText: 'Active',
|
||||||
);
|
);
|
||||||
} else if ((
|
} else if ((jsonToStr(
|
||||||
jsonToStr(
|
getJsonField(
|
||||||
getJsonField(
|
|
||||||
visitaWrapItem,
|
visitaWrapItem,
|
||||||
r'''$.VAW_STATUS''',
|
r'''$.VAW_STATUS''',
|
||||||
)) ==
|
)) ==
|
||||||
|
@ -754,4 +750,4 @@ Widget visitHistory(
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue