diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart index 24ed29cc..40c9ce33 100644 --- a/lib/actions/actions.dart +++ b/lib/actions/actions.dart @@ -1,3 +1,5 @@ +import 'package:f_r_e_hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; +import 'package:f_r_e_hub/pages/home_page/home_page_widget.dart'; import 'package:flutter/material.dart'; import '/actions/actions.dart' as action_blocks; @@ -6,6 +8,8 @@ import '/components/molecular_components/throw_exception/throw_exception_widget. import '/custom_code/actions/index.dart' as actions; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; +import '/flutter_flow/flutter_flow_util.dart'; + import '/flutter_flow/random_data_util.dart' as random_data; Future repeatVisitScheduleAction( @@ -387,6 +391,58 @@ Future snackbar(BuildContext context, {required bool opt}) async { ); } +Future checkLocals({ + String? cliUUID, + required BuildContext context, + required HomePageModel model, + required void Function(void Function()) safeSetState, +}) async { + // A chamada para a API permanece a mesma, assumindo que é necessária sempre. + final response = await PhpGroup.getLocalsCall.call( + devUUID: FFAppState().devUUID, + userUUID: FFAppState().userUUID, + ); + + // Verificação rápida de erro para evitar processamento desnecessário. + if (response.jsonBody['error']) { + debugPrint("checkLocals => Erro encontrado na resposta"); + return false; + } + + // Uso eficiente de coleções para verificar a condição desejada. + final String uuid = cliUUID ?? FFAppState().cliUUID; + final bool itemFound = response.jsonBody['locais'].any( + (local) => local['CLI_ID'] == uuid && local['CLU_STATUS'] == "A", + ); + + // Log e retorno condicional baseado no resultado da busca. + if (itemFound) { + debugPrint("checkLocals => Item encontrado com CLI_ID $uuid e CLU_STATUS A"); + return true; + } else { + debugPrint("checkLocals => Item não encontrado com CLI_ID $uuid e CLU_STATUS A"); + // A chamada para showModalBottomSheet permanece, mas a atualização da UI é otimizada. + await showModalBottomSheet( + isScrollControlled: true, + backgroundColor: Colors.transparent, + enableDrag: false, + context: context, + builder: (context) => GestureDetector( + onTap: () => model.unfocusNode.canRequestFocus + ? FocusScope.of(context).requestFocus(model.unfocusNode) + : FocusScope.of(context).unfocus(), + child: Padding( + padding: MediaQuery.viewInsetsOf(context), + child: const BottomArrowLinkedLocalsComponentWidget(), + ), + ), + ); + safeSetState(() {}); // Chamada otimizada fora do then para evitar encadeamentos desnecessários. + return false; + } +} + + Future changeStatusAction( BuildContext context, String status, @@ -436,4 +492,6 @@ Future changeStatusAction( default: break; } + + } diff --git a/lib/components/molecular_components/opt_modal/opt_modal_widget.dart b/lib/components/molecular_components/opt_modal/opt_modal_widget.dart index fa1c2411..551004ef 100644 --- a/lib/components/molecular_components/opt_modal/opt_modal_widget.dart +++ b/lib/components/molecular_components/opt_modal/opt_modal_widget.dart @@ -222,7 +222,7 @@ class _OptModalWidgetState extends State { child: TextFormField( controller: _model.textController, focusNode: _model.textFieldFocusNode, - autofocus: true, + autofocus: false, obscureText: false, decoration: InputDecoration( isDense: true, diff --git a/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart b/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart index 2233fc5f..ef4993fe 100644 --- a/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart +++ b/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart @@ -1,3 +1,4 @@ +// import 'package:f_r_e_hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -93,8 +94,19 @@ class _OptionSelectionModalWidgetState extends State return GestureDetector( onTap: () async { Navigator.pop(context); - - context.pushNamed(widget.routesListStr![optionsListIndex]); + if (widget.routesListStr![optionsListIndex] == 'scheduleCompleteVisitPage') { + // Navegação para a página ScheduleCompleteVisitPage com queryParameters + context.pushNamed( + 'scheduleCompleteVisitPage', + queryParameters: { + 'visitStartDateStr': DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()), + 'visitEndDateStr': DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now().add(const Duration(days: 1))), + }, + ); + } else { + // Navegação para outras páginas + context.pushNamed(widget.routesListStr![optionsListIndex]); + } }, child: Padding( padding: const EdgeInsets.all(5.0), diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart index 276ba8ba..fe7f8703 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart @@ -96,12 +96,12 @@ class _BottomArrowLinkedLocalsComponentWidgetState ), ); } - final gridViewGetLocalsResponse = snapshot.data!; + final localsResponse = snapshot.data!; return Builder( builder: (context) { - final eachLocals = PhpGroup.getLocalsCall + final linkedLocals = PhpGroup.getLocalsCall .locais( - gridViewGetLocalsResponse.jsonBody, + localsResponse.jsonBody, ) ?.map((e) => e) .toList() @@ -117,32 +117,48 @@ class _BottomArrowLinkedLocalsComponentWidgetState childAspectRatio: 1.0, ), scrollDirection: Axis.horizontal, - itemCount: eachLocals.length, - itemBuilder: (context, eachLocalsIndex) { - final eachLocalsItem = - eachLocals[eachLocalsIndex]; + itemCount: linkedLocals.length, + itemBuilder: (context, index) { + final localItem = + linkedLocals[index]; return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, highlightColor: Colors.transparent, onTap: () async { + + if (linkedLocals.any((local) => + local['CLI_ID'] == FFAppState().cliUUID && + local['CLU_STATUS'] == "A")) { FFAppState().cliUUID = getJsonField( - eachLocalsItem, + localItem, r'''$.CLI_ID''', ).toString(); setState(() {}); FFAppState().local = getJsonField( - eachLocalsItem, + localItem, r'''$.CLI_NOME''', ).toString(); setState(() {}); FFAppState().ownerUUID = getJsonField( - eachLocalsItem, + localItem, r'''$.CLU_OWNER_ID''', ).toString(); setState(() {}); + debugPrint('Local: ${FFAppState().local}'); Navigator.pop(context); + } else { + debugPrint('Local não disponível'); + // ScaffoldMessenger.of(context).showSnackBar( + // SnackBar( + // content: Text( + // 'Local não disponível', + // ), + // ), + // ); + } + }, child: Container( width: 50.0, @@ -187,7 +203,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState ), child: Image.network( 'https://freaccess.com.br/freaccess/Images/Clients/${getJsonField( - eachLocalsItem, + localItem, r'''$.CLI_ID''', ).toString()}.png', width: double.infinity, @@ -203,7 +219,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState .fromSTEB(0.0, 10.0, 0.0, 0.0), child: Text( getJsonField( - eachLocalsItem, + localItem, r'''$.CLI_NOME''', ).toString(), style: FlutterFlowTheme.of(context) diff --git a/lib/components/organism_components/menu_component/menu_component_model.dart b/lib/components/organism_components/menu_component/menu_component_model.dart index 3db649cc..31d0b45c 100644 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ b/lib/components/organism_components/menu_component/menu_component_model.dart @@ -40,18 +40,15 @@ class MenuComponentModel extends FlutterFlowModel { } Future scheduleVisitOptAction(BuildContext context) async { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, + await showAdaptiveDialog( context: context, builder: (context) { return Padding( padding: MediaQuery.viewInsetsOf(context), child: OptionSelectionModalWidget( routesListStr: [ - 'scheduleProvisionalVisitPage', 'scheduleCompleteVisitPage', + 'scheduleProvisionalVisitPage', 'fastPassPage', ], iconsListIcon: [ @@ -118,10 +115,10 @@ class MenuComponentModel extends FlutterFlowModel { } Future liberationHistoryOptAction(BuildContext context) async { - await showModalBottomSheet( - isScrollControlled: true, - backgroundColor: Colors.transparent, - enableDrag: false, + await showAdaptiveDialog( + // isScrollControlled: true, + // backgroundColor: Colors.transparent, + // enableDrag: false, context: context, builder: (context) { return Padding( diff --git a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart index 3ecbeee8..e5c8c4d4 100644 --- a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart +++ b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart @@ -860,22 +860,42 @@ Propriedade */ ), ), ), - Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 50.0, - fillColor: const Color(0x00FFFFFF), - icon: Icon( - Icons.keyboard_arrow_down_outlined, - color: FlutterFlowTheme.of(context).primary, + Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + FFLocalizations.of(context).getVariableText( + enText: 'Expand', + ptText: 'Expandir', + ), + style: FlutterFlowTheme.of(context).title1.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 12.0, + fontWeight: FontWeight.w600, + fontStyle: FontStyle.normal, + ), ), - onPressed: () async { - await widget.changeMenuStyle?.call(); - }, - ), + Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 20.0, + borderWidth: 0.0, + buttonSize: 50.0, + fillColor: const Color(0x00FFFFFF), + icon: Icon( + Icons.keyboard_arrow_down_outlined, + color: FlutterFlowTheme.of(context).primary, + ), + onPressed: () async { + await widget.changeMenuStyle?.call(); + }, + ), + ), + ], ), ], ); diff --git a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart index 96c065f9..78486ab4 100644 --- a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart +++ b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart @@ -904,22 +904,42 @@ Propriedade */ ), ), alignment: const AlignmentDirectional(0.0, 0.0), - child: Align( - alignment: const AlignmentDirectional(0.0, 0.0), - child: FlutterFlowIconButton( - borderColor: Colors.transparent, - borderRadius: 20.0, - borderWidth: 1.0, - buttonSize: 50.0, - fillColor: const Color(0x00FFFFFF), - icon: Icon( - Icons.keyboard_arrow_up_sharp, - color: FlutterFlowTheme.of(context).primary, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Text( + FFLocalizations.of(context).getVariableText( + enText: 'Minimize', + ptText: 'Minimizar', + ), + style: FlutterFlowTheme.of(context).title1.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 12.0, + fontWeight: FontWeight.w600, + fontStyle: FontStyle.normal, + ), ), - onPressed: () async { - await widget.changeMenuStyleAction?.call(); - }, - ), + Align( + alignment: const AlignmentDirectional(0.0, 0.0), + child: FlutterFlowIconButton( + borderColor: Colors.transparent, + borderRadius: 20.0, + borderWidth: 1.0, + buttonSize: 50.0, + fillColor: const Color(0x00FFFFFF), + icon: Icon( + Icons.keyboard_arrow_up_sharp, + color: FlutterFlowTheme.of(context).primary, + ), + onPressed: () async { + await widget.changeMenuStyleAction?.call(); + }, + ), + ), + ], ), ), ), diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index adde80eb..7ff66f3b 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -88,6 +88,10 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) => GoRouter( name: 'scheduleCompleteVisitPage', path: '/scheduleCompleteVisitPage', builder: (context, params) => ScheduleCompleteVisitPageWidget( + // get current datatime picker dd/mm/aaaa hh:mm:ss + // visitStartDateStr: DateTime.now().toString(), + // post 1 day + // visitEndDateStr: DateTime.now().add(const Duration(days: 1)).toString(), visitorStrList: params.getParam( 'visitorStrList', ParamType.String, diff --git a/lib/pages/acess_history_page/acess_history_page_widget.dart b/lib/pages/acess_history_page/acess_history_page_widget.dart index 7592b13c..e14cc3dd 100644 --- a/lib/pages/acess_history_page/acess_history_page_widget.dart +++ b/lib/pages/acess_history_page/acess_history_page_widget.dart @@ -306,6 +306,7 @@ class _AcessHistoryPageWidgetState extends State { Widget _accessHistoryCardMoleculeWidget( BuildContext context, dynamic accessHistoryItem) { + debugPrint('Access History Item: $accessHistoryItem'); return CardItemTemplateComponentWidget( imageHashMap: Map.from({ 'key': accessHistoryItem['PES_ID'] ?? '', @@ -313,28 +314,28 @@ class _AcessHistoryPageWidgetState extends State { }), labelsHashMap: Map.from({ 'Nome:': accessHistoryItem['PES_NOME'] ?? '', - 'Entrada:': accessHistoryItem['ACE_DATAHORA'] ?? '', - 'Setor:': accessHistoryItem['ACI_DESCRICAO'] ?? '', + 'Acesso:': accessHistoryItem['ACE_DATAHORA'] ?? '', + 'Setor:': accessHistoryItem['SET_DESCRICAO'] ?? '', }), - statusHashMap: accessHistoryItem['NOT_STATUS'] == 'L' + statusHashMap: accessHistoryItem['PES_TIPO'] == 'O' ? Map.from({ FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active', + ptText: 'Visitado', + enText: 'Visited', ): FlutterFlowTheme.of(context).success, }) - : accessHistoryItem['NOT_STATUS'] == 'B' + : accessHistoryItem['PES_TIPO'] == 'E' ? Map.from({ FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked', - ): FlutterFlowTheme.of(context).error, + ptText: 'Visitante', + enText: 'Visitor', + ): FlutterFlowTheme.of(context).warning, }) : Map.from({ FFLocalizations.of(context).getVariableText( - ptText: 'Pendente', - enText: 'Pending', - ): FlutterFlowTheme.of(context).warning, + ptText: 'Desconhecido', + enText: 'Unknown', + ): FlutterFlowTheme.of(context).error, }), onTapCardItemAction: () async {}); } diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/pages/home_page/home_page_widget.dart index ab475387..c5ae5a0b 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/pages/home_page/home_page_widget.dart @@ -1,4 +1,5 @@ // import 'package:f_r_e_hub/backend/push_notification/pushNotification.dart'; +import 'package:f_r_e_hub/actions/actions.dart'; import 'package:f_r_e_hub/backend/push_notification/pushNotificationService.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; @@ -35,14 +36,24 @@ class _HomePageWidgetState extends State { super.initState(); _model = createModel(context, () => HomePageModel()); + + SchedulerBinding.instance.addPostFrameCallback((_) async { + + await PushNotificationService().initialize(context); + await checkLocals( + context: context, + model: _model, + safeSetState: safeSetState, + ); if (FFAppState().cliUUID == null || FFAppState().cliUUID.isEmpty) { showModalBottomSheet( - isScrollControlled: true, + isScrollControlled: false, backgroundColor: Colors.transparent, enableDrag: false, + isDismissible: false, context: context, builder: (context) { return GestureDetector( diff --git a/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart b/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart index 81244b0f..84009a3d 100644 --- a/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart +++ b/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart @@ -136,13 +136,7 @@ class _PeopleOnThePropertyPageWidgetState child: CachedNetworkImage( fadeInDuration: const Duration(milliseconds: 500), fadeOutDuration: const Duration(milliseconds: 500), - imageUrl: valueOrDefault( - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${FFAppState().devUUID}&userUUID=${FFAppState().userUUID}&cliID=${FFAppState().cliUUID}&atividade=getFoto&Documento=&tipo=E&Email=${getJsonField( - getPoeplePropertyItem, - r'''$.USU_EMAIL''', - ).toString()}', - 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', - ), + imageUrl: 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', fit: BoxFit.cover, ), ), diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart index 0ebe90b2..7b837b20 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart @@ -100,6 +100,35 @@ class _ScheduleCompleteVisitPageWidgetState _model.switchValue = true; _model.textController3 ??= TextEditingController(); _model.textFieldFocusNode3 ??= FocusNode(); + + + debugPrint('widget.visitStartDateStr: ${DateTime.parse(widget.visitStartDateStr!)}'); + debugPrint('widget.visitEndDateStr: ${DateTime.parse(widget.visitEndDateStr!)}'); + if (widget.visitEndDateStr != null && widget.visitStartDateStr != null) { + _model.datePicked1 = DateTime.parse(widget.visitStartDateStr!); + _model.datePicked2 = DateTime.parse(widget.visitEndDateStr!); + _model.textController1?.text = DateFormat('dd-MM-yyyy HH:mm:ss').format(DateFormat('yyyy-MM-dd HH:mm:ss').parse(widget.visitStartDateStr!)); + _model.textController2?.text = DateFormat('dd-MM-yyyy HH:mm:ss').format(DateFormat('yyyy-MM-dd HH:mm:ss').parse(widget.visitEndDateStr!));; + // _model.textController1?.selection = TextSelection.collapsed( + + // _model.textController1?.text = + // dateTimeFormat( + // 'd/M/y H:mm:ss', + // _model.datePicked1, + // locale: + // FFLocalizations.of(context) + // .languageCode, + // ); + // _model.textController1 + // ?.selection = + // TextSelection.collapsed( + // offset: _model + // .textController1! + // .text + // .length); + // }); + } + } void _loadMoreVisitHistory() async {