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,8 +422,8 @@ Future<bool> checkLocals({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future answersRequest(BuildContext context, String? ref, String? task,
|
Future<String> answersRequest(BuildContext context, String? ref, String? task, String? response, String? id) async {
|
||||||
String? response, String? id) async {
|
try {
|
||||||
ApiCallResponse? respondeSolicitacaoCall;
|
ApiCallResponse? respondeSolicitacaoCall;
|
||||||
|
|
||||||
respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call(
|
respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call(
|
||||||
|
@ -437,10 +437,18 @@ Future answersRequest(BuildContext context, String? ref, String? task,
|
||||||
idVisitante: id,
|
idVisitante: id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (respondeSolicitacaoCall.statusCode == 200) {
|
if (respondeSolicitacaoCall.statusCode == 200) {
|
||||||
return !respondeSolicitacaoCall.jsonBody['error'];
|
if (!respondeSolicitacaoCall.jsonBody['error']) {
|
||||||
|
return '';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
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),
|
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
||||||
if (widget.buttons
|
if (widget.buttons
|
||||||
.isNotEmpty) // Adicione este SizedBox com a altura desejada
|
.isNotEmpty) // Adicione este SizedBox com a altura desejada
|
||||||
Row(
|
OverflowBar(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
overflowAlignment: OverflowBarAlignment.center,
|
||||||
|
overflowSpacing: 2,
|
||||||
|
spacing: 2,
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: widget.buttons,
|
children: widget.buttons,
|
||||||
),
|
),
|
||||||
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
SizedBox(height: MediaQuery.of(context).size.height * 0.02),
|
||||||
|
|
|
@ -59,6 +59,26 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
super.dispose();
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
context.watch<FFAppState>();
|
context.watch<FFAppState>();
|
||||||
|
@ -68,7 +88,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: Colors.transparent,
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
bottomLeft: Radius.circular(0.0),
|
bottomLeft: Radius.circular(0.0),
|
||||||
bottomRight: Radius.circular(0.0),
|
bottomRight: Radius.circular(0.0),
|
||||||
|
@ -90,7 +110,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
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(
|
child: TextFormField(
|
||||||
controller: _model.textController,
|
controller: _model.textController,
|
||||||
focusNode: _model.textFieldFocusNode,
|
focusNode: _model.textFieldFocusNode,
|
||||||
|
@ -231,12 +251,14 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final visitor =
|
final visitor =
|
||||||
_model.visitors.map((e) => e).toList();
|
_model.visitors.map((e) => e).toList();
|
||||||
|
final doc = _model.docs.map((e) => e).toList();
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
scrollDirection: Axis.vertical,
|
scrollDirection: Axis.vertical,
|
||||||
itemCount: visitor.length,
|
itemCount: visitor.length,
|
||||||
itemBuilder: (context, visitorIndex) {
|
itemBuilder: (context, visitorIndex) {
|
||||||
final visitorItem = visitor[visitorIndex];
|
final visitorItem = visitor[visitorIndex];
|
||||||
|
final docItem = doc[visitorIndex];
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
0.0, 0.0, 0.0, 1.0),
|
0.0, 0.0, 0.0, 1.0),
|
||||||
|
@ -245,38 +267,6 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
focusColor: Colors.transparent,
|
focusColor: Colors.transparent,
|
||||||
hoverColor: Colors.transparent,
|
hoverColor: Colors.transparent,
|
||||||
highlightColor: 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(
|
child: Container(
|
||||||
width: 100.0,
|
width: 100.0,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
@ -364,6 +354,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
_model.removeFromVisitors(
|
_model.removeFromVisitors(
|
||||||
visitorItem);
|
visitorItem);
|
||||||
|
_model.removeFromDocs(docItem);
|
||||||
safeSetState(() {});
|
safeSetState(() {});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -487,12 +478,18 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
PhpGroup.getVisitorByDocCall
|
PhpGroup.getVisitorByDocCall
|
||||||
.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) !=
|
.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) !=
|
||||||
null) {
|
null) {
|
||||||
|
String newDoc = _model.textController.text;
|
||||||
|
bool existDoc = _model.docs.contains(newDoc);
|
||||||
|
if (existDoc == false) {
|
||||||
_model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante(
|
_model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante(
|
||||||
(_model.getVisitorByDoc?.jsonBody ?? ''),
|
(_model.getVisitorByDoc?.jsonBody ?? ''),
|
||||||
));
|
));
|
||||||
safeSetState(() {});
|
safeSetState(() {});
|
||||||
_model.addToDocs(_model.textController.text);
|
_model.addToDocs(_model.textController.text);
|
||||||
safeSetState(() {});
|
safeSetState(() {});
|
||||||
|
} else if (existDoc == true) {
|
||||||
|
_showErrorSnackbar(context);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await showAdaptiveDialog(
|
await showAdaptiveDialog(
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// import 'dart:js_interop';
|
|
||||||
|
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:hub/actions/actions.dart';
|
import 'package:hub/actions/actions.dart';
|
||||||
|
@ -8,72 +6,89 @@ 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/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/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_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_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/nav/nav.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/material.dart';
|
||||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:hub/pages/liberation_history/liberation_history_model.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';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class LiberationHistoryWidget extends StatefulWidget {
|
class LiberationHistoryWidget extends StatefulWidget {
|
||||||
const LiberationHistoryWidget({super.key});
|
const LiberationHistoryWidget({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<LiberationHistoryWidget> createState() =>
|
State<LiberationHistoryWidget> createState() => _LiberationHistoryWidgetState();
|
||||||
_LiberationHistoryWidgetState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
|
class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
|
||||||
late LiberationHistoryModel _model;
|
|
||||||
|
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
bool _hasData = false;
|
||||||
|
bool _loading = false;
|
||||||
|
|
||||||
|
late Future<void> _requestFuture;
|
||||||
|
List<dynamic> _requestWrap = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
_requestFuture = _fetchRequests();
|
||||||
_model = createModel(context, () => LiberationHistoryModel());
|
|
||||||
|
|
||||||
_model.textController ??= TextEditingController();
|
super.initState();
|
||||||
_model.textFieldFocusNode ??= FocusNode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_model.dispose();
|
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUpdate(BuildContext context) {
|
void onUpdate(BuildContext context) {
|
||||||
_model.clearGetLiberationsCache();
|
|
||||||
safeSetState(() {});
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
context.watch<FFAppState>();
|
context.watch<FFAppState>();
|
||||||
return GestureDetector(
|
return Scaffold(
|
||||||
onTap: () => _model.unfocusNode.canRequestFocus
|
|
||||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
|
||||||
: FocusScope.of(context).unfocus(),
|
|
||||||
child: Scaffold(
|
|
||||||
key: scaffoldKey,
|
key: scaffoldKey,
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
appBar: appBarLiberationHistoryPage(context),
|
appBar: _appBar(context),
|
||||||
body: bodyLiberationHistoryPage(context, _model),
|
body: _body(context),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PreferredSizeWidget appBarLiberationHistoryPage(BuildContext context) {
|
PreferredSizeWidget _appBar(BuildContext context) {
|
||||||
return AppBar(
|
return AppBar(
|
||||||
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
|
@ -108,321 +123,177 @@ PreferredSizeWidget appBarLiberationHistoryPage(BuildContext context) {
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
elevation: 0.0,
|
elevation: 0.0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget bodyLiberationHistoryPage(
|
Widget _body(BuildContext context) {
|
||||||
BuildContext context, LiberationHistoryModel _model) {
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
top: true,
|
top: true,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
searchBarContainer(context, _model),
|
if (_hasData == false && _loading == false && _requestWrap.isEmpty)
|
||||||
Expanded(child: liberationDynamicListView(context, _model)),
|
Expanded(
|
||||||
].addToStart(const SizedBox(height: 0)),
|
child: Column(
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget searchBarContainer(BuildContext context, LiberationHistoryModel _model) {
|
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Center(
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(8.0, 8.0, 8.0, 8.0),
|
child: Text(FFLocalizations.of(context).getVariableText(
|
||||||
child: SizedBox(
|
ptText: "Nenhuma solicitação encontrada!",
|
||||||
width: 300.0,
|
enText: "No visit found")),
|
||||||
height: 40.0,
|
)
|
||||||
child: TextFormField(
|
],
|
||||||
controller: _model.textController,
|
),
|
||||||
focusNode: _model.textFieldFocusNode,
|
)
|
||||||
autofocus: false,
|
else if (_hasData == true && _loading == false && _requestWrap.isNotEmpty)
|
||||||
obscureText: false,
|
Expanded(child: _listItems(context)),
|
||||||
decoration: InputDecoration(
|
if ( _loading == true)
|
||||||
isDense: true,
|
Container(
|
||||||
labelText: FFLocalizations.of(context).getText(
|
padding: const EdgeInsets.only(top: 15, bottom: 15),
|
||||||
'dy0mx15f' /* Pesquise aqui */,
|
child: Center(
|
||||||
),
|
child: CircularProgressIndicator(
|
||||||
labelStyle: FlutterFlowTheme.of(context).labelMedium.override(
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
fontFamily:
|
FlutterFlowTheme.of(context).primary,
|
||||||
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(
|
Widget _listItems(BuildContext context) {
|
||||||
BuildContext context,
|
|
||||||
LiberationHistoryModel _model,
|
|
||||||
) {
|
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
decoration: const BoxDecoration(),
|
decoration: const BoxDecoration(),
|
||||||
child: StreamBuilder<ApiCallResponse>(
|
child: FutureBuilder<void>(
|
||||||
stream: _model.getLiberations(
|
future: _requestFuture,
|
||||||
requestFn: () => PhpGroup.getLiberationsCall.call(
|
|
||||||
devUUID: FFAppState().devUUID,
|
|
||||||
userUUID: FFAppState().userUUID,
|
|
||||||
cliID: FFAppState().cliUUID,
|
|
||||||
atividade: 'getSolicitacoes',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData) {
|
return ListView.builder(
|
||||||
return Center(
|
shrinkWrap: true,
|
||||||
child: SizedBox(
|
physics: const BouncingScrollPhysics(),
|
||||||
width: 50.0,
|
itemCount: _requestWrap.length,
|
||||||
height: 50.0,
|
itemBuilder: (BuildContext context, int index) {
|
||||||
child: SpinKitCircle(
|
final item = _requestWrap[index];
|
||||||
color: FlutterFlowTheme.of(context).primary,
|
return _item(context, item);
|
||||||
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(
|
Widget _item(BuildContext context, dynamic liberationHistoryItem) {
|
||||||
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(
|
return CardItemTemplateComponentWidget(
|
||||||
imagePath:
|
imagePath: _imagePath(liberationHistoryItem),
|
||||||
'https://freaccess.com.br/freaccess/getImage.php?cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${liberationHistoryItem['VTE_ID'] ?? ''}&tipo=E',
|
labelsHashMap: _labelsHashMap(liberationHistoryItem, false),
|
||||||
labelsHashMap: Map<String, String>.from({
|
statusHashMap: [_statusHashMap(liberationHistoryItem)],
|
||||||
'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 {
|
onTapCardItemAction: () async {
|
||||||
showDialog(
|
showDialog(
|
||||||
// isScrollControlled: true,
|
|
||||||
// isDismissible: true,
|
|
||||||
// backgroundColor: Colors.transparent,
|
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: DetailsComponentWidget(
|
child: DetailsComponentWidget(
|
||||||
// vteName: liberationHistoryItem['VTE_NOME'],
|
labelsHashMap: _labelsHashMap(liberationHistoryItem, true),
|
||||||
// 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: [
|
buttons: [
|
||||||
if (liberationHistoryItem['NOT_STATUS'] == 'S')
|
if (liberationHistoryItem['NOT_STATUS'] == 'S')
|
||||||
FlutterFlowIconButton(
|
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),
|
icon: const Icon(Icons.done),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
await answersRequest
|
|
||||||
.call(
|
safeSetState(() {
|
||||||
|
_requestWrap = [];
|
||||||
|
_requestFuture = _fetchRequests();
|
||||||
|
});
|
||||||
|
|
||||||
|
var message = await answersRequest.call(
|
||||||
context,
|
context,
|
||||||
liberationHistoryItem['NOT_ID'].toString(),
|
liberationHistoryItem['NOT_ID'].toString(),
|
||||||
'L',
|
'L',
|
||||||
'Mensagem',
|
'',
|
||||||
liberationHistoryItem['VTE_ID'].toString(),
|
liberationHistoryItem['VTE_ID'].toString(),
|
||||||
)
|
);
|
||||||
.then((value) {
|
|
||||||
if (value) {
|
if (message.isEmpty) {
|
||||||
return showSnackbar(
|
showSnackbar(
|
||||||
context,
|
context,
|
||||||
FFLocalizations.of(context).getVariableText(
|
FFLocalizations.of(context).getVariableText(enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false);
|
||||||
enText: 'Successfully resolved visit',
|
|
||||||
ptText: 'Visita resolvida com sucesso'),
|
|
||||||
false);
|
|
||||||
} else {
|
} else {
|
||||||
return showSnackbar(
|
showSnackbar(context, message, true);
|
||||||
context,
|
|
||||||
FFLocalizations.of(context).getVariableText(
|
|
||||||
enText: 'Error resolving visit',
|
|
||||||
ptText: 'Erro ao resolver visita'),
|
|
||||||
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: [_statusHashMap(liberationHistoryItem)],
|
||||||
liberationHistoryItem['NOT_STATUS'] == 'L'
|
imagePath: _imagePath(liberationHistoryItem),
|
||||||
? 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((_) {
|
).then((_) {
|
||||||
PushNotificationManager _pushNotificationService =
|
|
||||||
PushNotificationManager();
|
PushNotificationManager _pushNotificationService = PushNotificationManager();
|
||||||
|
|
||||||
_pushNotificationService.onMessageReceived.listen((received) {
|
_pushNotificationService.onMessageReceived.listen((received) {
|
||||||
if (received.data['click_action'] == 'cancel_request') {
|
if (received.data['click_action'] == 'cancel_request') {
|
||||||
|
@ -445,7 +316,74 @@ Widget liberationHistoryItemCard(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}).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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue