556 lines
22 KiB
Dart
556 lines
22 KiB
Dart
import 'package:f_r_e_hub/components/templates_components/visit_request_template_component/visit_request_template_component_widget.dart';
|
|
|
|
import '/backend/api_requests/api_calls.dart';
|
|
import '/flutter_flow/flutter_flow_icon_button.dart';
|
|
import '/flutter_flow/flutter_flow_theme.dart';
|
|
import '/flutter_flow/flutter_flow_util.dart';
|
|
import '/flutter_flow/custom_functions.dart' as functions;
|
|
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:provider/provider.dart';
|
|
import 'liberation_history_model.dart';
|
|
export 'liberation_history_model.dart';
|
|
|
|
class LiberationHistoryWidget extends StatefulWidget {
|
|
const LiberationHistoryWidget({super.key});
|
|
|
|
@override
|
|
State<LiberationHistoryWidget> createState() =>
|
|
_LiberationHistoryWidgetState();
|
|
}
|
|
|
|
class _LiberationHistoryWidgetState extends State<LiberationHistoryWidget> {
|
|
late LiberationHistoryModel _model;
|
|
|
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model = createModel(context, () => LiberationHistoryModel());
|
|
|
|
_model.textController ??= TextEditingController();
|
|
_model.textFieldFocusNode ??= FocusNode();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.dispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
@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),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
PreferredSizeWidget appBarLiberationHistoryPage(BuildContext context) {
|
|
return AppBar(
|
|
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
automaticallyImplyLeading: false,
|
|
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,
|
|
);
|
|
}
|
|
|
|
Widget bodyLiberationHistoryPage(
|
|
BuildContext context, LiberationHistoryModel _model) {
|
|
return SafeArea(
|
|
top: true,
|
|
child: Stack(
|
|
children: [
|
|
liberationDynamicListViw(context, _model),
|
|
searchBarContainer(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 liberationDynamicListViw(
|
|
BuildContext context, LiberationHistoryModel _model) {
|
|
return Expanded(
|
|
child: 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) => functions
|
|
.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 ? 60.0 : 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 InkWell(
|
|
onTap: () {
|
|
showModalBottomSheet(
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
useSafeArea: true,
|
|
context: context,
|
|
builder: (context) {
|
|
return const VisitRequestTemplateComponentWidget();
|
|
},
|
|
);
|
|
},
|
|
child: Card(
|
|
clipBehavior: Clip.antiAliasWithSaveLayer,
|
|
color: FlutterFlowTheme.of(context).secondaryBackground,
|
|
elevation: 5.0,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
),
|
|
child: Container(
|
|
width: 350.0,
|
|
height: 115.0,
|
|
decoration: BoxDecoration(
|
|
color: FlutterFlowTheme.of(context).secondaryBackground,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 10.0, 0.0),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(100.0),
|
|
child: CachedNetworkImage(
|
|
fadeInDuration: const Duration(milliseconds: 500),
|
|
fadeOutDuration: const Duration(milliseconds: 500),
|
|
imageUrl: valueOrDefault<String>(
|
|
"https://freaccess.com.br/freaccess/getImage.php?&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=${getJsonField(
|
|
liberationHistoryItem,
|
|
r'''$.VTE_ID''',
|
|
).toString()}&tipo=E",
|
|
"https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg",
|
|
),
|
|
width: 80.0,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
decoration: const BoxDecoration(),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Align(
|
|
alignment: const AlignmentDirectional(-1.0, -1.0),
|
|
child: Text(
|
|
getJsonField(
|
|
liberationHistoryItem,
|
|
r'''$.VTE_NOME''',
|
|
).toString(),
|
|
style: FlutterFlowTheme.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
fontSize: 12.5,
|
|
letterSpacing: 0.0,
|
|
fontWeight: FontWeight.bold,
|
|
useGoogleFonts: GoogleFonts.asMap()
|
|
.containsKey(FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
]
|
|
.addToStart(const SizedBox(width: 10.0))
|
|
.addToEnd(const SizedBox(width: 10.0)),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
FFLocalizations.of(context).getText(
|
|
'dkzewokx' /* Date: */,
|
|
),
|
|
style: FlutterFlowTheme.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
fontSize: 12.5,
|
|
letterSpacing: 0.0,
|
|
fontWeight: FontWeight.bold,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
Text(
|
|
(functions.jsonToStr(getJsonField(
|
|
liberationHistoryItem,
|
|
r'''$.NOT_STATUS''',
|
|
)) ==
|
|
'"L"'
|
|
? getJsonField(
|
|
liberationHistoryItem,
|
|
r'''$.NOT_DTRESPOSTA''',
|
|
)
|
|
: getJsonField(
|
|
liberationHistoryItem,
|
|
r'''$.NOT_DTENVIO''',
|
|
))
|
|
.toString(),
|
|
style: FlutterFlowTheme.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
fontSize: 12.5,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
]
|
|
.divide(const SizedBox(width: 10.0))
|
|
.addToStart(const SizedBox(width: 10.0)),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
FFLocalizations.of(context).getText(
|
|
'2s9avwbq' /* Motivo: */,
|
|
),
|
|
style: FlutterFlowTheme.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
fontSize: 12.5,
|
|
letterSpacing: 0.0,
|
|
fontWeight: FontWeight.bold,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
Text(
|
|
getJsonField(
|
|
liberationHistoryItem,
|
|
r'''$.NOT_MOTIVO''',
|
|
).toString(),
|
|
style: FlutterFlowTheme.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
fontSize: 12.5,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
]
|
|
.divide(const SizedBox(width: 10.0))
|
|
.addToStart(const SizedBox(width: 10.0)),
|
|
),
|
|
Align(
|
|
alignment: const AlignmentDirectional(-1.0, 0.0),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
10.0, 0.0, 0.0, 0.0),
|
|
child: Container(
|
|
width: 200.0,
|
|
height: 27.0,
|
|
decoration: BoxDecoration(
|
|
color: valueOrDefault<Color>(
|
|
() {
|
|
if (liberationHistoryItem["NOT_STATUS"] ==
|
|
'L') {
|
|
return FlutterFlowTheme.of(context).success;
|
|
} else if (liberationHistoryItem[
|
|
"NOT_STATUS"] ==
|
|
'B') {
|
|
return FlutterFlowTheme.of(context).error;
|
|
} else if (liberationHistoryItem[
|
|
"NOT_STATUS"] ==
|
|
'S') {
|
|
return FlutterFlowTheme.of(context).warning;
|
|
} else {
|
|
return FlutterFlowTheme.of(context).primary;
|
|
}
|
|
}(),
|
|
FlutterFlowTheme.of(context).primary,
|
|
),
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
),
|
|
child: Align(
|
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
|
child: Text(
|
|
"${() {
|
|
if (liberationHistoryItem["NOT_STATUS"] ==
|
|
'L') {
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(
|
|
ptText: 'Ativa',
|
|
enText: 'Active',
|
|
);
|
|
} else if (liberationHistoryItem[
|
|
"NOT_STATUS"] ==
|
|
'B') {
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(
|
|
ptText: 'Bloqueada',
|
|
enText: 'Blocked',
|
|
);
|
|
} else if (liberationHistoryItem[
|
|
"NOT_STATUS"] ==
|
|
'S') {
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(
|
|
ptText: 'Pendente',
|
|
enText: 'Pending',
|
|
);
|
|
} else {
|
|
return FFLocalizations.of(context)
|
|
.getVariableText(
|
|
ptText: 'Desconhecida',
|
|
enText: 'Unknow',
|
|
);
|
|
}
|
|
}()}",
|
|
style: FlutterFlowTheme.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
color: FlutterFlowTheme.of(context).info,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap()
|
|
.containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
].divide(const SizedBox(height: 3.0)),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|