Merge pull request #20 from FRE-Informatica/fix/fd-605
FIX: Tela de Histórico de Liberação
This commit is contained in:
commit
54218a19d9
|
@ -422,25 +422,33 @@ Future<bool> checkLocals({
|
|||
}
|
||||
}
|
||||
|
||||
Future answersRequest(BuildContext context, String? ref, String? task,
|
||||
String? response, String? id) async {
|
||||
ApiCallResponse? respondeSolicitacaoCall;
|
||||
Future<String> answersRequest(BuildContext context, String? ref, String? task, String? response, String? id) async {
|
||||
try {
|
||||
ApiCallResponse? respondeSolicitacaoCall;
|
||||
|
||||
respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call(
|
||||
userUUID: FFAppState().userUUID,
|
||||
devUUID: FFAppState().devUUID,
|
||||
cliUUID: FFAppState().cliUUID,
|
||||
atividade: 'respondeSolicitacao',
|
||||
referencia: ref,
|
||||
tarefa: task,
|
||||
resposta: response,
|
||||
idVisitante: id,
|
||||
);
|
||||
respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call(
|
||||
userUUID: FFAppState().userUUID,
|
||||
devUUID: FFAppState().devUUID,
|
||||
cliUUID: FFAppState().cliUUID,
|
||||
atividade: 'respondeSolicitacao',
|
||||
referencia: ref,
|
||||
tarefa: task,
|
||||
resposta: response,
|
||||
idVisitante: id,
|
||||
);
|
||||
|
||||
if (respondeSolicitacaoCall.statusCode == 200) {
|
||||
return !respondeSolicitacaoCall.jsonBody['error'];
|
||||
} else {
|
||||
return false;
|
||||
|
||||
if (respondeSolicitacaoCall.statusCode == 200) {
|
||||
if (!respondeSolicitacaoCall.jsonBody['error']) {
|
||||
return '';
|
||||
} else {
|
||||
return respondeSolicitacaoCall.jsonBody['error_msg'].toString();
|
||||
}
|
||||
} else {
|
||||
return FFLocalizations.of(context).getVariableText(ptText: 'Falha ao Responder Solicitação', enText: 'Failed to Response Request');
|
||||
}
|
||||
} catch (e, s) {
|
||||
return FFLocalizations.of(context).getVariableText(ptText: 'Falha ao Responder Solicitação', enText: 'Failed to Response Request');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -267,8 +267,11 @@ class _DetailsComponentWidgetState
|
|||
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
||||
if (widget.buttons
|
||||
.isNotEmpty) // Adicione este SizedBox com a altura desejada
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
OverflowBar(
|
||||
overflowAlignment: OverflowBarAlignment.center,
|
||||
overflowSpacing: 2,
|
||||
spacing: 2,
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: widget.buttons,
|
||||
),
|
||||
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
||||
|
|
|
@ -59,6 +59,26 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
void _showErrorSnackbar(BuildContext context) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: "Visitante já adicionado.",
|
||||
enText: "Visitor already added."),
|
||||
),
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: FlutterFlowTheme.of(context).error,
|
||||
dismissDirection: DismissDirection.up,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
margin: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).size.height - 150,
|
||||
left: 10,
|
||||
right: 10),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<FFAppState>();
|
||||
|
@ -68,7 +88,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||
color: Colors.transparent,
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(0.0),
|
||||
bottomRight: Radius.circular(0.0),
|
||||
|
@ -90,7 +110,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsetsDirectional.fromSTEB(16.0, 10.0, 16.0, 0.0),
|
||||
const EdgeInsetsDirectional.fromSTEB(16.0, 15.0, 16.0, 0.0),
|
||||
child: TextFormField(
|
||||
controller: _model.textController,
|
||||
focusNode: _model.textFieldFocusNode,
|
||||
|
@ -231,12 +251,14 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
builder: (context) {
|
||||
final visitor =
|
||||
_model.visitors.map((e) => e).toList();
|
||||
final doc = _model.docs.map((e) => e).toList();
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.zero,
|
||||
scrollDirection: Axis.vertical,
|
||||
itemCount: visitor.length,
|
||||
itemBuilder: (context, visitorIndex) {
|
||||
final visitorItem = visitor[visitorIndex];
|
||||
final docItem = doc[visitorIndex];
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
0.0, 0.0, 0.0, 1.0),
|
||||
|
@ -245,38 +267,6 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
focusColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
onTap: () async {
|
||||
// await showModalBottomSheet(
|
||||
// isScrollControlled: true,
|
||||
// enableDrag: true,
|
||||
// isDismissible: true,
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return Padding(
|
||||
// padding:
|
||||
// MediaQuery.viewInsetsOf(context),
|
||||
// child: SizedBox(
|
||||
// height: 610.0,
|
||||
// child:
|
||||
// VisitorDetailsModalTemplateComponentWidget(
|
||||
// visitorImageURL:
|
||||
// "https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(
|
||||
// visitorItem,
|
||||
// r'''$.VTE_DOCUMENTO''',
|
||||
// ).toString()}&tipo=E",
|
||||
// visitorEmail: '',
|
||||
// visitorName: getJsonField(
|
||||
// visitorItem,
|
||||
// r'''$.VTE_NOME''',
|
||||
// )?.toString(),
|
||||
// visitorPhone: '',
|
||||
// visitorType: '',
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// ).then((value) => safeSetState(() {}));
|
||||
},
|
||||
child: Container(
|
||||
width: 100.0,
|
||||
decoration: BoxDecoration(
|
||||
|
@ -364,6 +354,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
onPressed: () async {
|
||||
_model.removeFromVisitors(
|
||||
visitorItem);
|
||||
_model.removeFromDocs(docItem);
|
||||
safeSetState(() {});
|
||||
},
|
||||
),
|
||||
|
@ -487,12 +478,18 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
|||
PhpGroup.getVisitorByDocCall
|
||||
.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) !=
|
||||
null) {
|
||||
_model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante(
|
||||
(_model.getVisitorByDoc?.jsonBody ?? ''),
|
||||
));
|
||||
safeSetState(() {});
|
||||
_model.addToDocs(_model.textController.text);
|
||||
safeSetState(() {});
|
||||
String newDoc = _model.textController.text;
|
||||
bool existDoc = _model.docs.contains(newDoc);
|
||||
if (existDoc == false) {
|
||||
_model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante(
|
||||
(_model.getVisitorByDoc?.jsonBody ?? ''),
|
||||
));
|
||||
safeSetState(() {});
|
||||
_model.addToDocs(_model.textController.text);
|
||||
safeSetState(() {});
|
||||
} else if (existDoc == true) {
|
||||
_showErrorSnackbar(context);
|
||||
}
|
||||
} else {
|
||||
await showAdaptiveDialog(
|
||||
useSafeArea: true,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
// import 'dart:js_interop';
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:hub/actions/actions.dart';
|
||||
|
@ -8,444 +6,384 @@ import 'package:hub/backend/push_notification/pushNotificationService.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_widget.dart';
|
||||
import 'package:hub/flutter_flow/custom_functions.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/nav/nav.dart';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/pages/liberation_history/liberation_history_model.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class LiberationHistoryWidget extends StatefulWidget {
|
||||
const LiberationHistoryWidget({super.key});
|
||||
|
||||
@override
|
||||
State<LiberationHistoryWidget> createState() =>
|
||||
_LiberationHistoryWidgetState();
|
||||
State<LiberationHistoryWidget> createState() => _LiberationHistoryWidgetState();
|
||||
}
|
||||
|
||||
class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
|
||||
late LiberationHistoryModel _model;
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
bool _hasData = false;
|
||||
bool _loading = false;
|
||||
|
||||
late Future<void> _requestFuture;
|
||||
List<dynamic> _requestWrap = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_model = createModel(context, () => LiberationHistoryModel());
|
||||
_requestFuture = _fetchRequests();
|
||||
|
||||
_model.textController ??= TextEditingController();
|
||||
_model.textFieldFocusNode ??= FocusNode();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_model.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onUpdate(BuildContext context) {
|
||||
_model.clearGetLiberationsCache();
|
||||
safeSetState(() {});
|
||||
}
|
||||
|
||||
String _imagePath(dynamic request) {
|
||||
return 'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${request['VTE_ID'] ?? ''}&tipo=E';
|
||||
}
|
||||
|
||||
Map<String, String> _labelsHashMap(dynamic request, bool details) {
|
||||
return Map<String, String>.from({
|
||||
'${FFLocalizations.of(context).getVariableText(ptText: 'Nome', enText: 'Name')}:': request['VTE_NOME'],
|
||||
'${FFLocalizations.of(context).getVariableText(ptText: 'Dt. Envio', enText: 'Date Send')}:': request['NOT_DTENVIO'] != null ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', request['NOT_DTENVIO']) : '',
|
||||
'${FFLocalizations.of(context).getVariableText(ptText: 'Motivo', enText: 'Reason')}:': request['NOT_MOTIVO'],
|
||||
if (details == true)
|
||||
'${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': request['NOT_MSGENVIO'],
|
||||
});
|
||||
}
|
||||
|
||||
Map<String, Color> _statusHashMap(dynamic request) {
|
||||
return Map<String, Color>.from({
|
||||
if (request['NOT_STATUS'] == 'L')
|
||||
FFLocalizations.of(context).getVariableText(ptText: 'Finalizado', enText: 'Finished'): FlutterFlowTheme.of(context).success
|
||||
else if (request['NOT_STATUS'] == 'B')
|
||||
FFLocalizations.of(context).getVariableText(ptText: 'Bloqueado', enText: 'Blocked'): FlutterFlowTheme.of(context).error
|
||||
else
|
||||
FFLocalizations.of(context).getVariableText(ptText: 'Ativo', enText: 'Active'): FlutterFlowTheme.of(context).warning
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
context.watch<FFAppState>();
|
||||
return GestureDetector(
|
||||
onTap: () => _model.unfocusNode.canRequestFocus
|
||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
||||
: FocusScope.of(context).unfocus(),
|
||||
child: Scaffold(
|
||||
key: scaffoldKey,
|
||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
appBar: appBarLiberationHistoryPage(context),
|
||||
body: bodyLiberationHistoryPage(context, _model),
|
||||
return Scaffold(
|
||||
key: scaffoldKey,
|
||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
appBar: _appBar(context),
|
||||
body: _body(context),
|
||||
);
|
||||
}
|
||||
|
||||
PreferredSizeWidget _appBar(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
automaticallyImplyLeading: false,
|
||||
forceMaterialTransparency: true,
|
||||
leading: FlutterFlowIconButton(
|
||||
borderColor: Colors.transparent,
|
||||
borderRadius: 30.0,
|
||||
borderWidth: 1.0,
|
||||
buttonSize: 60.0,
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
size: 30.0,
|
||||
),
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
FFLocalizations.of(context).getText(
|
||||
'784f83pc' /* Histórico de Liberação */,
|
||||
),
|
||||
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
||||
fontFamily: 'Nunito',
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
fontSize: 17.0,
|
||||
letterSpacing: 0.0,
|
||||
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
|
||||
),
|
||||
),
|
||||
actions: const [],
|
||||
centerTitle: true,
|
||||
elevation: 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return SafeArea(
|
||||
top: true,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
if (_hasData == false && _loading == false && _requestWrap.isEmpty)
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(FFLocalizations.of(context).getVariableText(
|
||||
ptText: "Nenhuma solicitação encontrada!",
|
||||
enText: "No visit found")),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (_hasData == true && _loading == false && _requestWrap.isNotEmpty)
|
||||
Expanded(child: _listItems(context)),
|
||||
if ( _loading == true)
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
FlutterFlowTheme.of(context).primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _listItems(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(),
|
||||
child: FutureBuilder<void>(
|
||||
future: _requestFuture,
|
||||
builder: (context, snapshot) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: _requestWrap.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final item = _requestWrap[index];
|
||||
return _item(context, item);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _item(BuildContext context, dynamic liberationHistoryItem) {
|
||||
return CardItemTemplateComponentWidget(
|
||||
imagePath: _imagePath(liberationHistoryItem),
|
||||
labelsHashMap: _labelsHashMap(liberationHistoryItem, false),
|
||||
statusHashMap: [_statusHashMap(liberationHistoryItem)],
|
||||
onTapCardItemAction: () async {
|
||||
showDialog(
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
alignment: Alignment.center,
|
||||
child: DetailsComponentWidget(
|
||||
labelsHashMap: _labelsHashMap(liberationHistoryItem, true),
|
||||
buttons: [
|
||||
if (liberationHistoryItem['NOT_STATUS'] == 'S')
|
||||
FFButtonWidget(
|
||||
text: FFLocalizations.of(context).getVariableText(ptText: "Aceitar", enText: "Accept"),
|
||||
options: FFButtonOptions(
|
||||
width: 130,
|
||||
height: 40,
|
||||
color: FlutterFlowTheme.of(context).primary,
|
||||
elevation: 0,
|
||||
textStyle: const TextStyle(color: Colors.white),
|
||||
borderSide: BorderSide(
|
||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||
width: 1,
|
||||
),
|
||||
// borderRadius: 12,
|
||||
),
|
||||
icon: const Icon(Icons.done),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
|
||||
safeSetState(() {
|
||||
_requestWrap = [];
|
||||
_requestFuture = _fetchRequests();
|
||||
});
|
||||
|
||||
var message = await answersRequest.call(
|
||||
context,
|
||||
liberationHistoryItem['NOT_ID'].toString(),
|
||||
'L',
|
||||
'',
|
||||
liberationHistoryItem['VTE_ID'].toString(),
|
||||
);
|
||||
|
||||
if (message.isEmpty) {
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false);
|
||||
} else {
|
||||
showSnackbar(context, message, true);
|
||||
}
|
||||
|
||||
},
|
||||
),
|
||||
if (liberationHistoryItem['NOT_STATUS'] == 'S')
|
||||
FFButtonWidget(
|
||||
text: FFLocalizations.of(context).getVariableText(ptText: "Bloquear", enText: "Block"),
|
||||
options: FFButtonOptions(
|
||||
width: 130,
|
||||
height: 40,
|
||||
color: FlutterFlowTheme.of(context).error,
|
||||
elevation: 0,
|
||||
textStyle: const TextStyle(color: Colors.white),
|
||||
borderSide: BorderSide(
|
||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||
width: 1,
|
||||
),
|
||||
// borderRadius: 12,
|
||||
),
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
|
||||
safeSetState(() {
|
||||
_requestWrap = [];
|
||||
_requestFuture = _fetchRequests();
|
||||
});
|
||||
|
||||
var message = await answersRequest.call(
|
||||
context,
|
||||
liberationHistoryItem['NOT_ID'].toString(),
|
||||
'B',
|
||||
'',
|
||||
liberationHistoryItem['VTE_ID'].toString(),
|
||||
);
|
||||
|
||||
if (message.isEmpty) {
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false);
|
||||
} else {
|
||||
showSnackbar(context, message, true);
|
||||
}
|
||||
|
||||
},
|
||||
)
|
||||
],
|
||||
statusHashMap: [_statusHashMap(liberationHistoryItem)],
|
||||
imagePath: _imagePath(liberationHistoryItem),
|
||||
),
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
|
||||
PushNotificationManager _pushNotificationService = PushNotificationManager();
|
||||
|
||||
_pushNotificationService.onMessageReceived.listen((received) {
|
||||
if (received.data['click_action'] == 'cancel_request') {
|
||||
_pushNotificationService.dispose();
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Successfully resolved visit',
|
||||
ptText: 'Visita resolvida com sucesso'),
|
||||
false);
|
||||
context.pushReplacementNamed(
|
||||
'liberationHistory',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
}).whenComplete(() {
|
||||
safeSetState(() {
|
||||
_requestWrap = [];
|
||||
_requestFuture = _fetchRequests();
|
||||
});
|
||||
}).catchError((e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Solitiações", e, s);
|
||||
safeSetState(() {
|
||||
_hasData = false;
|
||||
_loading = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<ApiCallResponse?> _fetchRequests() async {
|
||||
try {
|
||||
setState(() => _loading = true);
|
||||
var response = await PhpGroup.getLiberationsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getSolicitacoes',
|
||||
).first;
|
||||
|
||||
final List<dynamic> requests = response.jsonBody['solicitacoes'] ?? [];
|
||||
|
||||
if (requests != null && requests.isNotEmpty) {
|
||||
setState(() {
|
||||
_requestWrap.addAll(requests);
|
||||
_hasData = true;
|
||||
_loading = false;
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
_showNoMoreDataSnackBar(context);
|
||||
|
||||
setState(() {
|
||||
_hasData = false;
|
||||
_loading = false;
|
||||
});
|
||||
|
||||
return null;
|
||||
} catch (e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Solicitações", e, s);
|
||||
setState(() {
|
||||
_hasData = false;
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _showNoMoreDataSnackBar(BuildContext context) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: "Não há mais dados.", enText: "No more data."),
|
||||
),
|
||||
duration: const Duration(seconds: 3),
|
||||
backgroundColor: FlutterFlowTheme.of(context).primary,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
PreferredSizeWidget appBarLiberationHistoryPage(BuildContext context) {
|
||||
return AppBar(
|
||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||
automaticallyImplyLeading: false,
|
||||
forceMaterialTransparency: true,
|
||||
leading: FlutterFlowIconButton(
|
||||
borderColor: Colors.transparent,
|
||||
borderRadius: 30.0,
|
||||
borderWidth: 1.0,
|
||||
buttonSize: 60.0,
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
size: 30.0,
|
||||
),
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
FFLocalizations.of(context).getText(
|
||||
'784f83pc' /* Histórico de Liberação */,
|
||||
),
|
||||
style: FlutterFlowTheme.of(context).headlineMedium.override(
|
||||
fontFamily: 'Nunito',
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
fontSize: 17.0,
|
||||
letterSpacing: 0.0,
|
||||
useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'),
|
||||
),
|
||||
),
|
||||
actions: const [],
|
||||
centerTitle: true,
|
||||
elevation: 0.0,
|
||||
);
|
||||
}
|
||||
|
||||
Widget bodyLiberationHistoryPage(
|
||||
BuildContext context, LiberationHistoryModel _model) {
|
||||
return SafeArea(
|
||||
top: true,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
searchBarContainer(context, _model),
|
||||
Expanded(child: liberationDynamicListView(context, _model)),
|
||||
].addToStart(const SizedBox(height: 0)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget searchBarContainer(BuildContext context, LiberationHistoryModel _model) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(8.0, 8.0, 8.0, 8.0),
|
||||
child: SizedBox(
|
||||
width: 300.0,
|
||||
height: 40.0,
|
||||
child: TextFormField(
|
||||
controller: _model.textController,
|
||||
focusNode: _model.textFieldFocusNode,
|
||||
autofocus: false,
|
||||
obscureText: false,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
labelText: FFLocalizations.of(context).getText(
|
||||
'dy0mx15f' /* Pesquise aqui */,
|
||||
),
|
||||
labelStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
||||
fontFamily:
|
||||
FlutterFlowTheme.of(context).labelMediumFamily,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
letterSpacing: 0.0,
|
||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||
FlutterFlowTheme.of(context).labelMediumFamily),
|
||||
),
|
||||
hintStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
||||
fontFamily:
|
||||
FlutterFlowTheme.of(context).labelMediumFamily,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
letterSpacing: 0.0,
|
||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||
FlutterFlowTheme.of(context).labelMediumFamily),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: FlutterFlowTheme.of(context).alternate,
|
||||
width: 2.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: FlutterFlowTheme.of(context).primary,
|
||||
width: 2.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: FlutterFlowTheme.of(context).error,
|
||||
width: 2.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: FlutterFlowTheme.of(context).error,
|
||||
width: 2.0,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: FlutterFlowTheme.of(context).alternate,
|
||||
prefixIcon: Icon(
|
||||
Icons.search_sharp,
|
||||
color: FlutterFlowTheme.of(context).primaryText,
|
||||
),
|
||||
),
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily,
|
||||
letterSpacing: 0.0,
|
||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||
FlutterFlowTheme.of(context).bodyMediumFamily),
|
||||
),
|
||||
validator: _model.textControllerValidator.asValidator(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
].addToStart(const SizedBox(height: 0)),
|
||||
);
|
||||
}
|
||||
|
||||
Widget liberationDynamicListView(
|
||||
BuildContext context,
|
||||
LiberationHistoryModel _model,
|
||||
) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
decoration: const BoxDecoration(),
|
||||
child: StreamBuilder<ApiCallResponse>(
|
||||
stream: _model.getLiberations(
|
||||
requestFn: () => PhpGroup.getLiberationsCall.call(
|
||||
devUUID: FFAppState().devUUID,
|
||||
userUUID: FFAppState().userUUID,
|
||||
cliID: FFAppState().cliUUID,
|
||||
atividade: 'getSolicitacoes',
|
||||
),
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Center(
|
||||
child: SizedBox(
|
||||
width: 50.0,
|
||||
height: 50.0,
|
||||
child: SpinKitCircle(
|
||||
color: FlutterFlowTheme.of(context).primary,
|
||||
size: 50.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
final columnGetLiberationsResponse = snapshot.data!;
|
||||
final liberationHistory = PhpGroup.getLiberationsCall
|
||||
.rqList(
|
||||
columnGetLiberationsResponse.jsonBody,
|
||||
)
|
||||
?.toList() ??
|
||||
[];
|
||||
final filteredLiberationHistory = _model.textController.text.isNotEmpty
|
||||
? liberationHistory
|
||||
.where((item) => jsonToStr(getJsonField(
|
||||
item,
|
||||
r'''$.VTE_NOME''',
|
||||
)).toLowerCase().contains(
|
||||
_model.textController.text.toLowerCase(),
|
||||
))
|
||||
.toList()
|
||||
: liberationHistory;
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: filteredLiberationHistory.length,
|
||||
addAutomaticKeepAlives: false,
|
||||
addRepaintBoundaries: true,
|
||||
cacheExtent: 1000.0,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final liberationHistoryItem = filteredLiberationHistory[index];
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: index == 0
|
||||
? MediaQuery.of(context).size.height * 0.075
|
||||
: 8.0,
|
||||
left: 8.0,
|
||||
right: 8.0,
|
||||
bottom: 8.0,
|
||||
),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional(0.0, 0.0),
|
||||
child: liberationHistoryItemCard(
|
||||
context,
|
||||
liberationHistoryItem,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget liberationHistoryItemCard(
|
||||
BuildContext context, dynamic liberationHistoryItem) {
|
||||
return CardItemTemplateComponentWidget(
|
||||
imagePath:
|
||||
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E',
|
||||
labelsHashMap: Map<String, String>.from({
|
||||
'Nome:': liberationHistoryItem['VTE_NOME'],
|
||||
'Data:': liberationHistoryItem['NOT_DTENVIO'],
|
||||
'Motivo:': liberationHistoryItem['NOT_MOTIVO'],
|
||||
}),
|
||||
statusHashMap: [
|
||||
liberationHistoryItem['NOT_STATUS'] == 'L'
|
||||
? Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Finalizado',
|
||||
enText: 'Finished',
|
||||
): FlutterFlowTheme.of(context).success,
|
||||
})
|
||||
: liberationHistoryItem['NOT_STATUS'] == 'B'
|
||||
? Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Bloqueado',
|
||||
enText: 'Blocked',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
})
|
||||
: Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
): FlutterFlowTheme.of(context).warning,
|
||||
})
|
||||
],
|
||||
onTapCardItemAction: () async {
|
||||
showDialog(
|
||||
// isScrollControlled: true,
|
||||
// isDismissible: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Dialog(
|
||||
alignment: Alignment.center,
|
||||
child: DetailsComponentWidget(
|
||||
// vteName: liberationHistoryItem['VTE_NOME'],
|
||||
// vteReason: liberationHistoryItem['NOT_MOTIVO'],
|
||||
// vawDate: liberationHistoryItem['NOT_STATUS'] == 'S'
|
||||
// ? liberationHistoryItem['NOT_DTENVIO']
|
||||
// : liberationHistoryItem['NOT_DTRESPOSTA'],
|
||||
// vawStatus: liberationHistoryItem['NOT_STATUS'],
|
||||
// vteMsg: liberationHistoryItem['NOT_MSGENVIO'],
|
||||
// vteUUID: liberationHistoryItem['VTE_ID'],
|
||||
// cliUUID: FFAppState().cliUUID,
|
||||
// msgUUID: liberationHistoryItem['NOT_ID'],
|
||||
// vawDestino: liberationHistoryItem['NOT_DESTINO'],
|
||||
// vawUUID: liberationHistoryItem['NOT_ID'],
|
||||
// vawName: liberationHistoryItem['NOT_NOME'],
|
||||
// vawRef: liberationHistoryItem['NOT_ID'],
|
||||
labelsHashMap: Map<String, String>.from({
|
||||
'Nome:': liberationHistoryItem['VTE_NOME'],
|
||||
'Data:': liberationHistoryItem['NOT_DTENVIO'],
|
||||
'Motivo:': liberationHistoryItem['NOT_MOTIVO'],
|
||||
'Mensagem:': liberationHistoryItem['NOT_MSGENVIO'],
|
||||
// 'Resposta:': liberationHistoryItem['NOT_MSGRESPOSTA'],
|
||||
}),
|
||||
buttons: [
|
||||
if (liberationHistoryItem['NOT_STATUS'] == 'S')
|
||||
FlutterFlowIconButton(
|
||||
icon: const Icon(Icons.done),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
await answersRequest
|
||||
.call(
|
||||
context,
|
||||
liberationHistoryItem['NOT_ID'].toString(),
|
||||
'L',
|
||||
'Mensagem',
|
||||
liberationHistoryItem['VTE_ID'].toString(),
|
||||
)
|
||||
.then((value) {
|
||||
if (value) {
|
||||
return showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Successfully resolved visit',
|
||||
ptText: 'Visita resolvida com sucesso'),
|
||||
false);
|
||||
} else {
|
||||
return showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Error resolving visit',
|
||||
ptText: 'Erro ao resolver visita'),
|
||||
true);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
statusHashMap: [
|
||||
liberationHistoryItem['NOT_STATUS'] == 'L'
|
||||
? Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Finalizado',
|
||||
enText: 'Finished',
|
||||
): FlutterFlowTheme.of(context).success,
|
||||
})
|
||||
: liberationHistoryItem['NOT_STATUS'] == 'B'
|
||||
? Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Bloqueado',
|
||||
enText: 'Blocked',
|
||||
): FlutterFlowTheme.of(context).error,
|
||||
})
|
||||
: Map<String, Color>.from({
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Ativo',
|
||||
enText: 'Active',
|
||||
): FlutterFlowTheme.of(context).warning,
|
||||
})
|
||||
],
|
||||
imagePath:
|
||||
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E',
|
||||
),
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
PushNotificationManager _pushNotificationService =
|
||||
PushNotificationManager();
|
||||
|
||||
_pushNotificationService.onMessageReceived.listen((received) {
|
||||
if (received.data['click_action'] == 'cancel_request') {
|
||||
_pushNotificationService.dispose();
|
||||
showSnackbar(
|
||||
context,
|
||||
FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Successfully resolved visit',
|
||||
ptText: 'Visita resolvida com sucesso'),
|
||||
false);
|
||||
context.pushReplacementNamed(
|
||||
'liberationHistory',
|
||||
extra: <String, dynamic>{
|
||||
kTransitionInfoKey: const TransitionInfo(
|
||||
hasTransition: true,
|
||||
transitionType: PageTransitionType.scale,
|
||||
alignment: Alignment.bottomCenter,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue