537 lines
27 KiB
Dart
537 lines
27 KiB
Dart
|
|
import 'package:hub/commons/actions/api_calls.dart';
|
|
import 'package:hub/modals/details/visitor_details_modal/widget.dart';
|
|
import 'package:hub/modals/exceptions/not_found/widget.dart';
|
|
|
|
import '/commons/widgets/flutter_flow_icon_button.dart';
|
|
import '/commons/widgets/flutter_flow_theme.dart';
|
|
import '/commons/widgets/flutter_flow_util.dart';
|
|
import '/commons/widgets/flutter_flow_widgets.dart';
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'model.dart';
|
|
export 'model.dart';
|
|
|
|
class VisitorSearchModalTemplateComponentWidget extends StatefulWidget {
|
|
const VisitorSearchModalTemplateComponentWidget({
|
|
super.key,
|
|
this.getVisitors,
|
|
this.getDocs,
|
|
});
|
|
|
|
final Future Function(List<dynamic>? visitorsParam)? getVisitors;
|
|
final Future Function(List<String>? docsParam)? getDocs;
|
|
|
|
@override
|
|
State<VisitorSearchModalTemplateComponentWidget> createState() =>
|
|
_VisitorSearchModalTemplateComponentWidgetState();
|
|
}
|
|
|
|
class _VisitorSearchModalTemplateComponentWidgetState
|
|
extends State<VisitorSearchModalTemplateComponentWidget>
|
|
with TickerProviderStateMixin {
|
|
late VisitorSearchModalTemplateComponentModel _model;
|
|
|
|
@override
|
|
void setState(VoidCallback callback) {
|
|
super.setState(callback);
|
|
_model.onUpdate();
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_model =
|
|
createModel(context, () => VisitorSearchModalTemplateComponentModel());
|
|
|
|
_model.textController ??= TextEditingController();
|
|
_model.textFieldFocusNode ??= FocusNode();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) => setState(() {
|
|
_model.textController?.text = FFLocalizations.of(context).getText(
|
|
'oj12tamm' /* test */,
|
|
);
|
|
}));
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_model.maybeDispose();
|
|
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
context.watch<FFAppState>();
|
|
|
|
return Align(
|
|
alignment: const AlignmentDirectional(0.0, 0.0),
|
|
child: Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(0.0, 300.0, 0.0, 0.0),
|
|
child: Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(0.0),
|
|
bottomRight: Radius.circular(0.0),
|
|
topLeft: Radius.circular(15.0),
|
|
topRight: Radius.circular(15.0),
|
|
),
|
|
),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(16.0, 10.0, 16.0, 0.0),
|
|
child: TextFormField(
|
|
controller: _model.textController,
|
|
focusNode: _model.textFieldFocusNode,
|
|
onFieldSubmitted: (_) async {
|
|
setState(() {
|
|
_model.textController?.text = valueOrDefault<String>(
|
|
_model.textController.text,
|
|
'69696777',
|
|
);
|
|
_model.textController?.selection =
|
|
TextSelection.collapsed(
|
|
offset: _model.textController!.text.length);
|
|
});
|
|
_model.getVisitorByDoc =
|
|
await PhpGroup.getVisitorByDocCall.call(
|
|
devUUID: FFAppState().devUUID,
|
|
userUUID: FFAppState().userUUID,
|
|
cliID: FFAppState().cliUUID,
|
|
atividade: 'getVisitante',
|
|
documento: _model.textController.text,
|
|
);
|
|
|
|
if (PhpGroup.getVisitorByDocCall.vistanteId(
|
|
(_model.getVisitorByDoc?.jsonBody ?? ''),
|
|
) !=
|
|
'0') {
|
|
_model
|
|
.addToVisitors(PhpGroup.getVisitorByDocCall.visitante(
|
|
(_model.getVisitorByDoc?.jsonBody ?? ''),
|
|
));
|
|
setState(() {});
|
|
_model.addToDocs(_model.textController.text);
|
|
setState(() {});
|
|
} else {
|
|
await showModalBottomSheet(
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
context: context,
|
|
builder: (context) {
|
|
return Padding(
|
|
padding: MediaQuery.viewInsetsOf(context),
|
|
child: const VisitorNotFoundComponentWidget(),
|
|
);
|
|
},
|
|
).then((value) => safeSetState(() {}));
|
|
}
|
|
|
|
setState(() {});
|
|
},
|
|
autofocus: false,
|
|
textInputAction: TextInputAction.done,
|
|
obscureText: false,
|
|
decoration: InputDecoration(
|
|
isDense: false,
|
|
labelText: FFLocalizations.of(context).getText(
|
|
'cjlpru1m' /* Procure pelo documento do visi... */,
|
|
),
|
|
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),
|
|
),
|
|
hintText: FFLocalizations.of(context).getText(
|
|
'8i1qszba' /* test */,
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).accent1,
|
|
width: 0.5,
|
|
),
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(15.0),
|
|
bottomRight: Radius.circular(15.0),
|
|
topLeft: Radius.circular(15.0),
|
|
topRight: Radius.circular(15.0),
|
|
),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).primary,
|
|
width: 0.5,
|
|
),
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(15.0),
|
|
bottomRight: Radius.circular(15.0),
|
|
topLeft: Radius.circular(15.0),
|
|
topRight: Radius.circular(15.0),
|
|
),
|
|
),
|
|
errorBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).error,
|
|
width: 0.5,
|
|
),
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(15.0),
|
|
bottomRight: Radius.circular(15.0),
|
|
topLeft: Radius.circular(15.0),
|
|
topRight: Radius.circular(15.0),
|
|
),
|
|
),
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(
|
|
color: FlutterFlowTheme.of(context).error,
|
|
width: 0.5,
|
|
),
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(15.0),
|
|
bottomRight: Radius.circular(15.0),
|
|
topLeft: Radius.circular(15.0),
|
|
topRight: Radius.circular(15.0),
|
|
),
|
|
),
|
|
filled: true,
|
|
fillColor: FlutterFlowTheme.of(context).primaryBackground,
|
|
prefixIcon: Icon(
|
|
Icons.search_outlined,
|
|
color: FlutterFlowTheme.of(context).accent1,
|
|
),
|
|
),
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
),
|
|
keyboardType: TextInputType.number,
|
|
validator:
|
|
_model.textControllerValidator.asValidator(context),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 0.0, 0.0),
|
|
child: Text(
|
|
FFLocalizations.of(context).getText(
|
|
'9coywebh' /* Visitantes encontrados */,
|
|
),
|
|
style: 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),
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional.fromSTEB(4.0, 12.0, 16.0, 0.0),
|
|
child: Text(
|
|
FFLocalizations.of(context).getText(
|
|
'6f5p0fv6' /* 24 */,
|
|
),
|
|
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).bodyMediumFamily,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Expanded(
|
|
child: Builder(
|
|
builder: (context) {
|
|
if (_model.visitors.isNotEmpty) {
|
|
return Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional.fromSTEB(8.0, 8.0, 8.0, 0.0),
|
|
child: Builder(
|
|
builder: (context) {
|
|
final visitor =
|
|
_model.visitors.map((e) => e).toList();
|
|
|
|
return ListView.builder(
|
|
padding: EdgeInsets.zero,
|
|
scrollDirection: Axis.vertical,
|
|
itemCount: visitor.length,
|
|
itemBuilder: (context, visitorIndex) {
|
|
final visitorItem = visitor[visitorIndex];
|
|
return Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
|
0.0, 0.0, 0.0, 1.0),
|
|
child: InkWell(
|
|
splashColor: Colors.transparent,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
highlightColor: Colors.transparent,
|
|
onTap: () async {
|
|
await showModalBottomSheet(
|
|
isScrollControlled: true,
|
|
enableDrag: false,
|
|
context: context,
|
|
builder: (context) {
|
|
return Padding(
|
|
padding: MediaQuery.viewInsetsOf(
|
|
context),
|
|
child: const SizedBox(
|
|
height: 610.0,
|
|
child:
|
|
VisitorDetailsModalTemplateComponentWidget(),
|
|
),
|
|
);
|
|
},
|
|
).then((value) => safeSetState(() {}));
|
|
},
|
|
child: Container(
|
|
width: 100.0,
|
|
decoration: BoxDecoration(
|
|
color: FlutterFlowTheme.of(context)
|
|
.secondaryBackground,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
blurRadius: 0.0,
|
|
color: FlutterFlowTheme.of(context)
|
|
.alternate,
|
|
offset: const Offset(
|
|
0.0,
|
|
1.0,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.center,
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius:
|
|
BorderRadius.circular(40.0),
|
|
child: CachedNetworkImage(
|
|
fadeInDuration:
|
|
const Duration(milliseconds: 500),
|
|
fadeOutDuration:
|
|
const Duration(milliseconds: 500),
|
|
imageUrl:
|
|
valueOrDefault<String>(
|
|
'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',
|
|
'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg',
|
|
),
|
|
width: 60.0,
|
|
height: 60.0,
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment:
|
|
CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional
|
|
.fromSTEB(12.0, 0.0,
|
|
0.0, 0.0),
|
|
child: Text(
|
|
valueOrDefault<String>(
|
|
getJsonField(
|
|
visitorItem,
|
|
r'''$.VTE_NOME''',
|
|
)?.toString(),
|
|
'NOT FOUND',
|
|
),
|
|
style:
|
|
FlutterFlowTheme.of(
|
|
context)
|
|
.bodyLarge
|
|
.override(
|
|
fontFamily: FlutterFlowTheme.of(
|
|
context)
|
|
.bodyLargeFamily,
|
|
letterSpacing:
|
|
0.0,
|
|
useGoogleFonts: GoogleFonts
|
|
.asMap()
|
|
.containsKey(
|
|
FlutterFlowTheme.of(context)
|
|
.bodyLargeFamily),
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional
|
|
.fromSTEB(4.0, 4.0,
|
|
0.0, 0.0),
|
|
child: Row(
|
|
mainAxisSize:
|
|
MainAxisSize.max,
|
|
mainAxisAlignment:
|
|
MainAxisAlignment
|
|
.start,
|
|
children: [
|
|
Align(
|
|
alignment:
|
|
const AlignmentDirectional(
|
|
0.0, -1.0),
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsetsDirectional
|
|
.fromSTEB(
|
|
10.0,
|
|
0.0,
|
|
0.0,
|
|
0.0),
|
|
child: Text(
|
|
getJsonField(
|
|
visitorItem,
|
|
r'''$.VTE_TELEFONE''',
|
|
).toString(),
|
|
style: FlutterFlowTheme
|
|
.of(context)
|
|
.bodyMedium
|
|
.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context)
|
|
.bodyMediumFamily,
|
|
color: FlutterFlowTheme.of(
|
|
context)
|
|
.primary,
|
|
letterSpacing:
|
|
0.0,
|
|
useGoogleFonts: GoogleFonts
|
|
.asMap()
|
|
.containsKey(
|
|
FlutterFlowTheme.of(context).bodyMediumFamily),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
FlutterFlowIconButton(
|
|
borderRadius: 20.0,
|
|
borderWidth: 1.0,
|
|
buttonSize: 40.0,
|
|
icon: Icon(
|
|
Icons.restore_from_trash,
|
|
color:
|
|
FlutterFlowTheme.of(context)
|
|
.primary,
|
|
size: 20.0,
|
|
),
|
|
onPressed: () async {
|
|
_model.removeFromVisitors(
|
|
visitorItem);
|
|
setState(() {});
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
} else {
|
|
return Container(
|
|
width: 100.0,
|
|
height: 100.0,
|
|
decoration: BoxDecoration(
|
|
color:
|
|
FlutterFlowTheme.of(context).secondaryBackground,
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
FFButtonWidget(
|
|
onPressed: () async {
|
|
await widget.getVisitors?.call(
|
|
_model.visitors,
|
|
);
|
|
await widget.getDocs?.call(
|
|
_model.docs,
|
|
);
|
|
Navigator.pop(context);
|
|
},
|
|
text: FFLocalizations.of(context).getText(
|
|
'ug6qzyla' /* Adicionar */,
|
|
),
|
|
options: FFButtonOptions(
|
|
width: double.infinity,
|
|
height: 30.0,
|
|
padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0),
|
|
iconPadding:
|
|
const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0),
|
|
color: FlutterFlowTheme.of(context).primary,
|
|
textStyle: FlutterFlowTheme.of(context).titleSmall.override(
|
|
fontFamily:
|
|
FlutterFlowTheme.of(context).titleSmallFamily,
|
|
color: Colors.white,
|
|
letterSpacing: 0.0,
|
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
|
FlutterFlowTheme.of(context).titleSmallFamily),
|
|
),
|
|
elevation: 3.0,
|
|
borderSide: const BorderSide(
|
|
color: Colors.transparent,
|
|
width: 1.0,
|
|
),
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(0.0),
|
|
bottomRight: Radius.circular(0.0),
|
|
topLeft: Radius.circular(0.0),
|
|
topRight: Radius.circular(0.0),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|