WIP
This commit is contained in:
parent
13b3c8f8ca
commit
092d122c3b
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:hub/components/molecular_components/visitor_not_found_component/visitor_not_found_component_model.dart';
|
import 'package:hub/components/molecular_components/visitor_not_found_component/visitor_not_found_component_model.dart';
|
||||||
import 'package:hub/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart';
|
import 'package:hub/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart';
|
||||||
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
|
||||||
|
@ -9,8 +11,9 @@ 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';
|
||||||
|
|
||||||
class VisitorNotFoundComponentWidget extends StatefulWidget {
|
class VisitorNotFoundComponentWidget extends StatefulWidget {
|
||||||
const VisitorNotFoundComponentWidget({super.key});
|
const VisitorNotFoundComponentWidget({this.doc, Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
final String? doc;
|
||||||
@override
|
@override
|
||||||
State<VisitorNotFoundComponentWidget> createState() =>
|
State<VisitorNotFoundComponentWidget> createState() =>
|
||||||
_VisitorNotFoundComponentWidgetState();
|
_VisitorNotFoundComponentWidgetState();
|
||||||
|
@ -42,7 +45,7 @@ class _VisitorNotFoundComponentWidgetState
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
width: MediaQuery.of(context).size.height * 0.5,
|
width: MediaQuery.of(context).size.width,
|
||||||
height: MediaQuery.of(context).size.height * 0.4,
|
height: MediaQuery.of(context).size.height * 0.4,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: FlutterFlowTheme.of(context).primaryBackground,
|
color: FlutterFlowTheme.of(context).primaryBackground,
|
||||||
|
@ -54,7 +57,6 @@ class _VisitorNotFoundComponentWidgetState
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Align(
|
Align(
|
||||||
|
@ -113,12 +115,12 @@ class _VisitorNotFoundComponentWidgetState
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: const AlignmentDirectional(0.0, 1.0),
|
alignment: const AlignmentDirectional(0.0, 1.0),
|
||||||
child: FFButtonWidget(
|
child: FFButtonWidget(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.pop(context);
|
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
|
@ -132,17 +134,18 @@ class _VisitorNotFoundComponentWidgetState
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: MediaQuery.of(context).size.height * 0.9,
|
height: MediaQuery.of(context).size.height * 0.9,
|
||||||
child: const RegisiterVistorTemplateComponentWidget(
|
child: RegisiterVistorTemplateComponentWidget(
|
||||||
source: 'VisitorNotFoundComponent',
|
source: 'VisitorNotFoundComponent',
|
||||||
)),
|
doc: _model.widget?.doc,
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).then((value) => safeSetState(() {}));
|
).then((value) => Navigator.pop(context, value));
|
||||||
},
|
},
|
||||||
text: FFLocalizations.of(context)
|
text: FFLocalizations.of(context)
|
||||||
.getVariableText(enText: 'Add', ptText: 'Adicionar'),
|
.getVariableText(enText: 'Add', ptText: 'Adicionar'),
|
||||||
options: FFButtonOptions(
|
options: FFButtonOptions(
|
||||||
width: double.infinity,
|
|
||||||
height: 30.0,
|
height: 30.0,
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||||
24.0, 0.0, 24.0, 0.0),
|
24.0, 0.0, 24.0, 0.0),
|
||||||
|
@ -165,8 +168,8 @@ class _VisitorNotFoundComponentWidgetState
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
bottomLeft: Radius.circular(25.0),
|
bottomLeft: Radius.circular(25.0),
|
||||||
bottomRight: Radius.circular(25.0),
|
bottomRight: Radius.circular(25.0),
|
||||||
topLeft: Radius.circular(15.0),
|
topLeft: Radius.circular(25.0),
|
||||||
topRight: Radius.circular(15.0),
|
topRight: Radius.circular(25.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -23,9 +23,10 @@ export 'regisiter_vistor_template_component_model.dart';
|
||||||
|
|
||||||
class RegisiterVistorTemplateComponentWidget extends StatefulWidget {
|
class RegisiterVistorTemplateComponentWidget extends StatefulWidget {
|
||||||
final String source;
|
final String source;
|
||||||
|
final String? doc;
|
||||||
|
|
||||||
const RegisiterVistorTemplateComponentWidget(
|
const RegisiterVistorTemplateComponentWidget(
|
||||||
{super.key, required this.source});
|
{super.key, required this.source, this.doc});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RegisiterVistorTemplateComponentWidget> createState() =>
|
State<RegisiterVistorTemplateComponentWidget> createState() =>
|
||||||
|
@ -53,6 +54,7 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
_model.textController1 ??= TextEditingController();
|
_model.textController1 ??= TextEditingController();
|
||||||
_model.textFieldFocusNode1 ??= FocusNode();
|
_model.textFieldFocusNode1 ??= FocusNode();
|
||||||
|
|
||||||
|
log('doc: ${widget.doc}');
|
||||||
_model.textController2 ??= TextEditingController();
|
_model.textController2 ??= TextEditingController();
|
||||||
_model.textFieldFocusNode2 ??= FocusNode();
|
_model.textFieldFocusNode2 ??= FocusNode();
|
||||||
_model.textController2?.addListener(_onTextChanged);
|
_model.textController2?.addListener(_onTextChanged);
|
||||||
|
@ -62,6 +64,10 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
|
|
||||||
_model.textController4 ??= TextEditingController();
|
_model.textController4 ??= TextEditingController();
|
||||||
_model.textFieldFocusNode4 ??= FocusNode();
|
_model.textFieldFocusNode4 ??= FocusNode();
|
||||||
|
|
||||||
|
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||||
|
_model.textController2.text = widget.doc ?? '';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -882,7 +888,7 @@ class _RegisiterVistorTemplateComponentWidgetState
|
||||||
);
|
);
|
||||||
if (widget.source ==
|
if (widget.source ==
|
||||||
'VisitorNotFoundComponent') {
|
'VisitorNotFoundComponent') {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:hub/backend/api_requests/api_calls.dart';
|
import 'package:hub/backend/api_requests/api_calls.dart';
|
||||||
import 'package:hub/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart';
|
import 'package:hub/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart';
|
||||||
import 'package:hub/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart';
|
import 'package:hub/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart';
|
||||||
|
@ -11,6 +15,7 @@ import 'package:hub/flutter_flow/internationalization.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:hub/shared/utils/dialog_util.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class VisitorSearchModalTemplateComponentWidget extends StatefulWidget {
|
class VisitorSearchModalTemplateComponentWidget extends StatefulWidget {
|
||||||
|
@ -84,50 +89,7 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
controller: _model.textController,
|
controller: _model.textController,
|
||||||
focusNode: _model.textFieldFocusNode,
|
focusNode: _model.textFieldFocusNode,
|
||||||
onFieldSubmitted: (_) async {
|
onFieldSubmitted: (_) async {
|
||||||
setState(() {
|
await addVisitor(context);
|
||||||
_model.textController?.text = _model.textController.text;
|
|
||||||
_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 showAdaptiveDialog(
|
|
||||||
useSafeArea: true,
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return Dialog(
|
|
||||||
child: Padding(
|
|
||||||
padding: MediaQuery.viewInsetsOf(context),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.transparent,
|
|
||||||
// width: MediaQuery.of(context).size.height * 0.1,
|
|
||||||
// height:
|
|
||||||
// MediaQuery.of(context).size.height * 0.4,
|
|
||||||
child: const VisitorNotFoundComponentWidget()),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).then((value) => safeSetState(() {}));
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
|
@ -146,9 +108,6 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
useGoogleFonts: GoogleFonts.asMap().containsKey(
|
||||||
FlutterFlowTheme.of(context).labelMediumFamily),
|
FlutterFlowTheme.of(context).labelMediumFamily),
|
||||||
),
|
),
|
||||||
hintText: FFLocalizations.of(context).getText(
|
|
||||||
'8i1qszba' /* test */,
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
enabledBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
color: FlutterFlowTheme.of(context).accent1,
|
color: FlutterFlowTheme.of(context).accent1,
|
||||||
|
@ -212,6 +171,9 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
validator: _model.textControllerValidator.asValidator(context),
|
validator: _model.textControllerValidator.asValidator(context),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.allow(RegExp('[0-9]')),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (_model.visitors.isNotEmpty && _model.visitors.length > 0)
|
if (_model.visitors.isNotEmpty && _model.visitors.length > 0)
|
||||||
|
@ -427,18 +389,23 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
FFButtonWidget(
|
FFButtonWidget(
|
||||||
onPressed: () async {
|
onPressed: MediaQuery.of(context).viewInsets.bottom > 0
|
||||||
await widget.getVisitors?.call(
|
? () async {
|
||||||
_model.visitors,
|
await addVisitor(context);
|
||||||
);
|
|
||||||
await widget.getDocs?.call(
|
setState(() {});
|
||||||
_model.docs,
|
}
|
||||||
);
|
: () async {
|
||||||
Navigator.pop(context);
|
await sendVisitors(context);
|
||||||
},
|
},
|
||||||
text: FFLocalizations.of(context).getVariableText(
|
text: MediaQuery.of(context).viewInsets.bottom > 0
|
||||||
|
? FFLocalizations.of(context).getVariableText(
|
||||||
enText: 'Add',
|
enText: 'Add',
|
||||||
ptText: 'Adicionar',
|
ptText: 'Adicionar',
|
||||||
|
)
|
||||||
|
: FFLocalizations.of(context).getVariableText(
|
||||||
|
enText: 'Submit',
|
||||||
|
ptText: 'Enviar',
|
||||||
),
|
),
|
||||||
options: FFButtonOptions(
|
options: FFButtonOptions(
|
||||||
width: MediaQuery.of(context).size.width * 0.3,
|
width: MediaQuery.of(context).size.width * 0.3,
|
||||||
|
@ -479,4 +446,70 @@ class _VisitorSearchModalTemplateComponentWidgetState
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> sendVisitors(BuildContext context) async {
|
||||||
|
await widget.getVisitors?.call(
|
||||||
|
_model.visitors,
|
||||||
|
);
|
||||||
|
await widget.getDocs?.call(
|
||||||
|
_model.docs,
|
||||||
|
);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addVisitor(BuildContext context) async {
|
||||||
|
setState(() {
|
||||||
|
_model.textController?.text = _model.textController.text;
|
||||||
|
_model.textController?.selection =
|
||||||
|
TextSelection.collapsed(offset: _model.textController!.text.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
var connectivityResult = await (Connectivity().checkConnectivity());
|
||||||
|
if (connectivityResult == ConnectivityResult.none) {
|
||||||
|
DialogUtil.error(context, 'Sem conexão com a internet');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_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 showAdaptiveDialog(
|
||||||
|
useSafeArea: true,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return Dialog(
|
||||||
|
child: Padding(
|
||||||
|
padding: MediaQuery.viewInsetsOf(context),
|
||||||
|
child: Container(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: VisitorNotFoundComponentWidget(
|
||||||
|
doc: _model.textController.text,
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).then((value) => safeSetState(() {
|
||||||
|
log('value: $value');
|
||||||
|
if (value != null) {
|
||||||
|
addVisitor(context);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
24
pubspec.lock
24
pubspec.lock
|
@ -137,6 +137,22 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.18.0"
|
||||||
|
connectivity_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: connectivity_plus
|
||||||
|
sha256: "2056db5241f96cdc0126bd94459fc4cdc13876753768fc7a31c425e50a7177d0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.5"
|
||||||
|
connectivity_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: connectivity_plus_platform_interface
|
||||||
|
sha256: "42657c1715d48b167930d5f34d00222ac100475f73d10162ddf43e714932f204"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
crop_your_image:
|
crop_your_image:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -941,6 +957,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
nm:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: nm
|
||||||
|
sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.0"
|
||||||
octo_image:
|
octo_image:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -48,6 +48,7 @@ dependencies:
|
||||||
flutter_cache_manager: 3.3.2
|
flutter_cache_manager: 3.3.2
|
||||||
flutter_plugin_android_lifecycle: 2.0.20
|
flutter_plugin_android_lifecycle: 2.0.20
|
||||||
share_plus: ^9.0.0
|
share_plus: ^9.0.0
|
||||||
|
connectivity_plus: ^6.0.5
|
||||||
flutter_secure_storage: 9.2.2
|
flutter_secure_storage: 9.2.2
|
||||||
flutter_secure_storage_linux: 1.2.1
|
flutter_secure_storage_linux: 1.2.1
|
||||||
flutter_secure_storage_macos: 3.1.2
|
flutter_secure_storage_macos: 3.1.2
|
||||||
|
|
Loading…
Reference in New Issue