From 56f16d29342b5184d9fb8e1cdb8e60b3015019cc Mon Sep 17 00:00:00 2001 From: jantunesmessias Date: Mon, 10 Feb 2025 17:58:53 -0300 Subject: [PATCH] WIP --- integration_test/utils_test.dart | 4 +- ..._arrow_linked_locals_component_widget.dart | 5 +- .../schedule_visit_detail_widget.dart | 7 +- ..._arrow_linked_locals_component_widget.dart | 4 +- ...cation_modal_template_component_model.dart | 4 +- .../provisional_shcedule_template_widget.dart | 12 +- ...siter_vistor_template_component_model.dart | 2 +- ...iter_vistor_template_component_widget.dart | 11 +- .../view_visit_detail_widget.dart | 4 +- ...earch_modal_template_component_widget.dart | 10 +- lib/features/auth/authentication_service.dart | 15 +- .../backend/api_requests/api_calls.dart | 235 ++++++++++++------ .../documents/document_item_component.dart | 4 +- .../documents/document_manager_screen.dart | 19 +- .../documents/document_page_widget.dart | 1 - .../pages/acess_history_page_widget.dart | 2 +- .../pages/provisional_history_page.dart | 4 +- .../locals_remote_data_source.dart | 15 +- lib/features/local/utils/local_util.dart | 2 +- .../menu/presentation/blocs/menu_bloc.dart | 3 +- .../repositories/license_repository_impl.dart | 2 +- .../firebase_messaging_service.dart | 2 +- .../notification/notification_service.dart | 3 +- .../liberation_history_model.dart | 3 +- .../liberation_history_widget.dart | 2 +- .../message_history_page_widget.dart | 2 +- .../package_order_page.dart | 4 +- .../people_on_the_property_page_widget.dart | 4 +- .../pets_history_screen.dart | 2 +- lib/pages/pets_page/pets_page_model.dart | 6 +- .../preferences_settings_model.dart | 8 +- .../reception_page/reception_page_widget.dart | 2 +- .../residents_on_the_property_screen.dart | 4 +- .../schedule_complete_visit_page_model.dart | 2 +- .../schedule_complete_visit_page_widget.dart | 32 +-- .../visit_history_page_widget.dart | 2 +- .../vehicles_on_the_property.dart | 4 +- .../visits_on_the_property_screen.dart | 2 +- lib/shared/mixins/pegeable_mixin.dart | 120 +++++++++ lib/shared/utils/log_util.dart | 2 +- lib/shared/widgets/view/search_view.dart | 165 ++++++++---- lib/shared/widgets/widgets.dart | 6 + pubspec.yaml | 1 + 43 files changed, 515 insertions(+), 228 deletions(-) create mode 100644 lib/shared/mixins/pegeable_mixin.dart diff --git a/integration_test/utils_test.dart b/integration_test/utils_test.dart index cce351a2..1fb39e07 100644 --- a/integration_test/utils_test.dart +++ b/integration_test/utils_test.dart @@ -25,7 +25,7 @@ Future _loggedWithMultiLocalsAccount( .set(ProfileStorageKey.ownerUUID.key, '7'); await StorageHelper() // .set(ProfileStorageKey.clientName.key, 'FRE ACCESS DEMO'); - await PhpGroup // + await FreAccessWSGlobal // .resopndeVinculo .call(tarefa: 'A'); await LicenseRepositoryImpl() // @@ -58,7 +58,7 @@ Future _loggedWithSomeoneLocalAccount( .set(ProfileStorageKey.ownerUUID.key, '7'); await StorageHelper() // .set(ProfileStorageKey.clientName.key, 'FRE ACCESS DEMO'); - await PhpGroup // + await FreAccessWSGlobal // .resopndeVinculo .call(tarefa: 'A'); await LicenseRepositoryImpl() // 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 00f5922e..a5db861f 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 @@ -77,7 +77,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState Future _fetchLocals() async { try { setState(() => _loading = true); - widget.response = await PhpGroup.getLocalsCall.call(); + widget.response = await FreAccessWSGlobal.getLocalsCall.call(); final bool isError = widget.response?.jsonBody['error']; if (isError) { @@ -149,7 +149,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState Future _fetchResponseLink(String status, String cliID) async { try { await StorageHelper().set(ProfileStorageKey.clientUUID.key, cliID); - var response = await PhpGroup.resopndeVinculo.call(tarefa: status); + var response = + await FreAccessWSGlobal.resopndeVinculo.call(tarefa: status); if (response.jsonBody['error'] == false) { return { diff --git a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart index 0baeea54..3810f5bb 100644 --- a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart +++ b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart @@ -781,7 +781,7 @@ class _ScheduleVisitDetailWidgetState extends State { IconButton( onPressed: () async { _model.postScheduleVisit = - await PhpGroup.postScheduleVisitCall.call( + await FreAccessWSGlobal.postScheduleVisitCall.call( devDesc: widget.visitObsStr, idVisitante: widget.visitorStrList, dtInicio: @@ -793,13 +793,14 @@ class _ScheduleVisitDetailWidgetState extends State { obs: widget.visitObsStr, ); - if (PhpGroup.postScheduleVisitCall.error( + if (FreAccessWSGlobal.postScheduleVisitCall.error( (_model.postScheduleVisit?.jsonBody ?? ''), ) == false) { context.pop(); } else { - final String? msg = PhpGroup.postScheduleVisitCall.errorMsg( + final String? msg = + FreAccessWSGlobal.postScheduleVisitCall.errorMsg( (_model.postScheduleVisit?.jsonBody ?? ''), ); await DialogUtil.error(context, msg!) diff --git a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart index d1ad656e..6ddc5984 100644 --- a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart @@ -75,7 +75,7 @@ class _UpArrowLinkedLocalsComponentWidgetState ), ), child: FutureBuilder( - future: PhpGroup.getLocalsCall.call(), + future: FreAccessWSGlobal.getLocalsCall.call(), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { @@ -94,7 +94,7 @@ class _UpArrowLinkedLocalsComponentWidgetState return Builder( builder: (context) { - final eachLocals = (PhpGroup.getLocalsCall + final eachLocals = (FreAccessWSGlobal.getLocalsCall .locais( gridViewGetLocalsResponse.jsonBody, ) diff --git a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart index 03352151..69e93268 100644 --- a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart +++ b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart @@ -63,14 +63,14 @@ class AccessNotificationModalTemplateComponentModel }) async { ApiCallResponse? visitRequest; - visitRequest = await PhpGroup.respondeSolicitacaoCall.call( + visitRequest = await FreAccessWSGlobal.respondeSolicitacaoCall.call( referencia: refUUID, tarefa: actionValue, resposta: responseValue, idVisitante: vteUUID, ); - if (PhpGroup.respondeSolicitacaoCall.error( + if (FreAccessWSGlobal.respondeSolicitacaoCall.error( (visitRequest.jsonBody ?? ''), ) == false) { diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart index 54e96540..783c114d 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart @@ -951,9 +951,10 @@ class _ScheduleProvisionalVisitPageWidgetState ? null : () async { try { - model.provVisitSchedule = await PhpGroup - .postProvVisitSchedulingCall - .call( + model.provVisitSchedule = + await FreAccessWSGlobal + .postProvVisitSchedulingCall + .call( data: DateFormat('dd/MM/yyyy HH:mm:ss') .format(DateFormat( 'dd/MM/yyyy HH:mm:ss') @@ -964,7 +965,8 @@ class _ScheduleProvisionalVisitPageWidgetState nome: model.personNameTextController.text, proID: model.ownerUUID, ); - if (PhpGroup.postProvVisitSchedulingCall + if (FreAccessWSGlobal + .postProvVisitSchedulingCall .error((model.provVisitSchedule ?.jsonBody ?? '')) == @@ -982,7 +984,7 @@ class _ScheduleProvisionalVisitPageWidgetState model.notesTextController?.clear(); }); } else { - var message = PhpGroup + var message = FreAccessWSGlobal .postProvVisitSchedulingCall .msg((model.provVisitSchedule ?.jsonBody ?? diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart index acff7931..1c427c65 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart @@ -46,7 +46,7 @@ class RegisiterVistorTemplateComponentModel Future getVisitanteByDocument( String document, BuildContext context) async { - final response = await PhpGroup.getVisitorByDocCall.call( + final response = await FreAccessWSGlobal.getVisitorByDocCall.call( documento: document, ); diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart index e17b808b..3ebb0c26 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart @@ -760,7 +760,7 @@ class _RegisiterVistorTemplateComponentWidgetState _model.uploadedLocalFile, ); _model.scheduleVisitor = - await PhpGroup.postScheduleVisitorCall + await FreAccessWSGlobal.postScheduleVisitorCall .call( documento: _model.textController2.text, nome: _model.textController1.text, @@ -775,7 +775,7 @@ class _RegisiterVistorTemplateComponentWidgetState .onError((e, s) async { return await DialogUtil.errorDefault(context); }); - if (PhpGroup.postScheduleVisitorCall.error( + if (FreAccessWSGlobal.postScheduleVisitorCall.error( (_model.scheduleVisitor?.jsonBody ?? ''), ) == false) { @@ -822,8 +822,8 @@ class _RegisiterVistorTemplateComponentWidgetState } else { return await DialogUtil.error( context, - PhpGroup.postScheduleVisitorCall.errorMsg( - _model + FreAccessWSGlobal.postScheduleVisitorCall + .errorMsg(_model .scheduleVisitor?.jsonBody) == null ? FFLocalizations.of(context) @@ -832,7 +832,8 @@ class _RegisiterVistorTemplateComponentWidgetState 'Erro ao se conectar com o servidor', enText: 'Error connecting to server', ) - : PhpGroup.postScheduleVisitorCall + : FreAccessWSGlobal + .postScheduleVisitorCall .errorMsg( _model.scheduleVisitor?.jsonBody) .toString()); diff --git a/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart b/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart index 41f38054..0104c183 100644 --- a/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart +++ b/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart @@ -818,11 +818,11 @@ class _ViewVisitDetailWidgetState extends State { ), onPressed: () async { _model.deleteVisit = - await PhpGroup.deleteVisitCall.call( + await FreAccessWSGlobal.deleteVisitCall.call( idVisita: widget.visitIdStr, ); - if (PhpGroup.deleteVisitCall.error( + if (FreAccessWSGlobal.deleteVisitCall.error( (_model.deleteVisit?.jsonBody ?? ''), ) == false) { diff --git a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart index 41fe84e8..a6b016c8 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart @@ -406,23 +406,23 @@ class _VisitorSearchModalTemplateComponentWidgetState _model.textController?.selection = TextSelection.collapsed(offset: _model.textController!.text.length); }); - _model.getVisitorByDoc = await PhpGroup.getVisitorByDocCall.call( + _model.getVisitorByDoc = await FreAccessWSGlobal.getVisitorByDocCall.call( documento: _model.textController.text.replaceFirst(RegExp(r'^0+'), '')); - if (PhpGroup.getVisitorByDocCall + if (FreAccessWSGlobal.getVisitorByDocCall .vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != '0' && - PhpGroup.getVisitorByDocCall + FreAccessWSGlobal.getVisitorByDocCall .error((_model.getVisitorByDoc?.jsonBody ?? '')) == false && - PhpGroup.getVisitorByDocCall + FreAccessWSGlobal.getVisitorByDocCall .vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != null) { String newDoc = _model.textController.text.replaceFirst(RegExp(r'^0+'), ''); bool existDoc = _model.docs.contains(newDoc); if (existDoc == false) { - _model.addToVisitors(PhpGroup.getVisitorByDocCall + _model.addToVisitors(FreAccessWSGlobal.getVisitorByDocCall .visitante((_model.getVisitorByDoc?.jsonBody ?? ''))); safeSetState(() {}); _model.addToDocs( diff --git a/lib/features/auth/authentication_service.dart b/lib/features/auth/authentication_service.dart index 24f5c0c9..88f3acf7 100644 --- a/lib/features/auth/authentication_service.dart +++ b/lib/features/auth/authentication_service.dart @@ -14,7 +14,7 @@ import '../../../flutter_flow/random_data_util.dart'; class AuthenticationService { static Future login(BuildContext context) async { try { - final GetLocalsCall callback = PhpGroup.getLocalsCall; + final GetLocalsCall callback = FreAccessWSGlobal.getLocalsCall; final response = await callback.call(); if (response.jsonBody['error']) { @@ -46,7 +46,7 @@ class AuthenticationService { }) async { try { final ApiCallResponse? response; - final LoginCall callback = PhpGroup.loginCall; + final LoginCall callback = FreAccessWSGlobal.loginCall; String deviceDescription = randomString(10, 10, true, false, false); await StorageHelper() .set(SecureStorageKey.deviceDescription.value, deviceDescription); @@ -111,7 +111,7 @@ class AuthenticationService { if ((email != null && email != '') && (passwd != null && passwd != '' && passwd.length > 7) && (name != null && name != '')) { - response = await PhpGroup.registerCall.call( + response = await FreAccessWSGlobal.registerCall.call( name: name, password: passwd, email: email, @@ -137,7 +137,7 @@ class AuthenticationService { } static Future signOut(BuildContext context) async { - await PhpGroup.unregisterDevice.call(); + await FreAccessWSGlobal.unregisterDevice.call(); final Map extra = { kTransitionInfoKey: const TransitionInfo( hasTransition: true, @@ -158,7 +158,7 @@ class AuthenticationService { static Future forgotPassword(BuildContext context, String email) async { try { final ApiCallResponse? response; - final ForgotPasswordCall callback = PhpGroup.forgotPasswordCall; + final ForgotPasswordCall callback = FreAccessWSGlobal.forgotPasswordCall; final String message = FFLocalizations.of(context).getVariableText( enText: "Send E-mail Successful!", ptText: "E-mail Enviado com Sucesso!"); @@ -183,7 +183,8 @@ class AuthenticationService { static Future changePassword( BuildContext context, String email, String password, String token) async { try { - final ApiCallResponse response = await PhpGroup.changePasswordCall + final ApiCallResponse response = await FreAccessWSGlobal + .changePasswordCall .call(email: email, psswd: password, token: token); if (response.jsonBody['error'] == false) { @@ -209,7 +210,7 @@ class AuthenticationService { static Future deleteAccount(BuildContext context) async { String content; try { - await PhpGroup.deleteAccount.call().then((value) async { + await FreAccessWSGlobal.deleteAccount.call().then((value) async { if (value.jsonBody['error'] == false) { content = FFLocalizations.of(context).getVariableText( enText: 'Account deleted successfully', diff --git a/lib/features/backend/api_requests/api_calls.dart b/lib/features/backend/api_requests/api_calls.dart index e4bdd4fc..d9fce908 100644 --- a/lib/features/backend/api_requests/api_calls.dart +++ b/lib/features/backend/api_requests/api_calls.dart @@ -24,7 +24,9 @@ abstract class Api { GetLicense getLicense = GetLicense(); } -class PhpGroup extends Api { +abstract class Endpoint {} + +class FreAccessWSGlobal extends Api { static String getBaseUrl() => 'https://freaccess.com.br/freaccess'; static Map headers = {}; static LoginCall loginCall = LoginCall(); @@ -70,11 +72,86 @@ class PhpGroup extends Api { static GetOpenedVisits getOpenedVisits = GetOpenedVisits(); GetLicense getLicense = GetLicense(); static GetProvSchedules getProvSchedules = GetProvSchedules(); + static GetCategories getCategories = GetCategories(); + static GetDocuments getDocuments = GetDocuments(); } -class GetProvSchedules { +class GetCategories extends Endpoint { + Future call() async { + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); + final String devUUID = + (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = + (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = + (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + const String atividade = 'listaCategoriasDocumentos'; + const String pageSize = '10'; + // final bool isFiltered = filter != '' && filter != '.*'; + return await ApiManager.instance.makeApiCall( + callName: 'listaCategoriasDocumentos', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + params: { + // if (isFiltered) 'filter': filter, + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'atividade': atividade, + 'pageSize': pageSize, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } +} + +class GetDocuments extends Endpoint { + Future call(final String page) async { + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); + final String devUUID = + (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = + (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = + (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + const String atividade = 'listaDocumentos'; + const String pageSize = '10'; + // final bool isFiltered = filter != '' && filter != '.*'; + return await ApiManager.instance.makeApiCall( + callName: 'listaDocumentos', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + params: { + // if (isFiltered) 'filter': filter, + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliID, + 'atividade': atividade, + 'page': page, + 'pageSize': pageSize, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } +} + +class GetProvSchedules extends Endpoint { Future call(final String page, final String status) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -110,9 +187,9 @@ class GetProvSchedules { } } -class GetOpenedVisits { +class GetOpenedVisits extends Endpoint { Future call(final String page) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -145,9 +222,9 @@ class GetOpenedVisits { } } -class GetResidentsByProperty { +class GetResidentsByProperty extends Endpoint { Future call(final String page) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = await StorageHelper().get(ProfileStorageKey.devUUID.key) ?? ''; final String userUUID = @@ -179,9 +256,9 @@ class GetResidentsByProperty { } } -class GetVehiclesByProperty { +class GetVehiclesByProperty extends Endpoint { Future call(final String page) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -215,9 +292,9 @@ class GetVehiclesByProperty { static GetLicense getLicense = GetLicense(); } -class GetLicense { +class GetLicense extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -249,9 +326,9 @@ class GetLicense { } } -class UnregisterDevice { +class UnregisterDevice extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -279,9 +356,9 @@ class UnregisterDevice { } } -class DeletePet { +class DeletePet extends Endpoint { Future call({final int? petID = 0}) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -315,7 +392,7 @@ class DeletePet { } } -class UpdatePet { +class UpdatePet extends Endpoint { Future call({ final int? petID, final String? image, @@ -328,7 +405,7 @@ class UpdatePet { final String? size, final String? notes, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -374,12 +451,12 @@ class UpdatePet { } } -class GetPets { +class GetPets extends Endpoint { Future call({ final int? page, final int? pageSize, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -414,9 +491,9 @@ class GetPets { } } -class GetPetPhoto { +class GetPetPhoto extends Endpoint { Future call({final int? petId}) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -450,7 +527,7 @@ class GetPetPhoto { } } -class RegisterPet { +class RegisterPet extends Endpoint { Future call({ final String? image, final String? name, @@ -462,7 +539,7 @@ class RegisterPet { final String? size, final String? notes, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -507,7 +584,7 @@ class RegisterPet { } } -class BuscaEnconcomendas { +class BuscaEnconcomendas extends Endpoint { Future call({ final String? page, final String? pageSize, @@ -522,7 +599,7 @@ class BuscaEnconcomendas { (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getEncomendas'; - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); return await ApiManager.instance.makeApiCall( callName: 'getEncomendas', @@ -551,7 +628,7 @@ class BuscaEnconcomendas { } } -class CancelaVisita { +class CancelaVisita extends Endpoint { Future call({ final int? idDestino, final int? idVisita, @@ -559,7 +636,7 @@ class CancelaVisita { final String? UsuEmail, final String? DevDesc, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -596,14 +673,14 @@ class CancelaVisita { } } -class DeleteAccount { +class DeleteAccount extends Endpoint { Future call() async { final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); return await ApiManager.instance.makeApiCall( callName: 'deleteAccount', apiUrl: '$baseUrl/deleteAccount.php', @@ -626,11 +703,11 @@ class DeleteAccount { } } -class ChangePanic { +class ChangePanic extends Endpoint { Future call({ final String? newSenhaPanico, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -665,11 +742,11 @@ class ChangePanic { } } -class ChangePass { +class ChangePass extends Endpoint { Future call({ final String? newSenha, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -704,11 +781,11 @@ class ChangePass { } } -class RespondeVinculo { +class RespondeVinculo extends Endpoint { Future call({ final String? tarefa, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -741,11 +818,11 @@ class RespondeVinculo { } } -class ChangeNotifica { +class ChangeNotifica extends Endpoint { Future call({ final String? notifica, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -780,9 +857,9 @@ class ChangeNotifica { } } -class UpdateIDE { +class UpdateIDE extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -819,9 +896,9 @@ class UpdateIDE { } } -class UpdToken { +class UpdToken extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -852,9 +929,9 @@ class UpdToken { } } -class LoginCall { +class LoginCall extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String email = @@ -902,7 +979,7 @@ class LoginCall { } } -class RegisterCall { +class RegisterCall extends Endpoint { Future call({ required final String name, required final String email, @@ -912,7 +989,7 @@ class RegisterCall { required final String tipo, required final String descricao, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); return await ApiManager.instance.makeApiCall( callName: 'register', @@ -941,13 +1018,13 @@ class RegisterCall { } } -class ChangePasswordCall { +class ChangePasswordCall extends Endpoint { Future call({ required final String email, required final String token, required final String psswd, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String userUUID = @@ -981,11 +1058,11 @@ class ChangePasswordCall { } } -class ForgotPasswordCall { +class ForgotPasswordCall extends Endpoint { Future call({ final String? email, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); return await ApiManager.instance.makeApiCall( callName: 'forgotPassword', @@ -1008,9 +1085,9 @@ class ForgotPasswordCall { } } -class GetLocalsCall { +class GetLocalsCall extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = await StorageHelper().get(ProfileStorageKey.devUUID.key) ?? ''; @@ -1047,14 +1124,14 @@ class GetLocalsCall { ) as List?; } -class PostScheduleVisitorCall { +class PostScheduleVisitorCall extends Endpoint { Future call({ required final String documento, required final String nome, required final String tipo, required final String foto, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1101,7 +1178,7 @@ class PostScheduleVisitorCall { )); } -class PostScheduleVisitCall { +class PostScheduleVisitCall extends Endpoint { Future call({ final String? devDesc, final String? idVisitante, @@ -1112,7 +1189,7 @@ class PostScheduleVisitCall { final int? idNAC, final String? obs, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1163,13 +1240,13 @@ class PostScheduleVisitCall { )); } -class GetScheduleVisitCall { +class GetScheduleVisitCall extends Endpoint { Future call({ final int? pageSize, final int? pageNumber, final String? chaveBusca, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1444,9 +1521,9 @@ class GetScheduleVisitCall { )); } -class GetDadosCall { +class GetDadosCall extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1690,11 +1767,11 @@ class GetDadosCall { )); } -class GetVisitorByDocCall { +class GetVisitorByDocCall extends Endpoint { Future call({ final String? documento, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1746,12 +1823,12 @@ class GetVisitorByDocCall { )); } -class GetFotoVisitanteCall { +class GetFotoVisitanteCall extends Endpoint { Future call({ final String? documento, final String? tipo, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1786,14 +1863,14 @@ class GetFotoVisitanteCall { } } -class PostProvVisitSchedulingCall { +class PostProvVisitSchedulingCall extends Endpoint { Future call({ final String? data, final String? motivo, final String? nome, final String? proID, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -1840,12 +1917,12 @@ class PostProvVisitSchedulingCall { )); } -class GetVisitsCall { +class GetVisitsCall extends Endpoint { Future call({ final int? pageSize, final int? pageNumber, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -2107,11 +2184,11 @@ class GetVisitsCall { .toList(); } -class DeleteVisitCall { +class DeleteVisitCall extends Endpoint { Future call({ final String? idVisita, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -2155,9 +2232,9 @@ class DeleteVisitCall { )); } -class GetPessoasLocalCall { +class GetPessoasLocalCall extends Endpoint { Future call() async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -2220,14 +2297,14 @@ class GetPessoasLocalCall { .toList(); } -class RespondeSolicitacaoCall { +class RespondeSolicitacaoCall extends Endpoint { Future call({ final String? referencia, final String? tarefa, final String? resposta, final String? idVisitante, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -2274,13 +2351,13 @@ class RespondeSolicitacaoCall { )); } -class GetAccessCall { +class GetAccessCall extends Endpoint { Future call({ final String? pageSize, final String? pageNumber, final String? pesTipo, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; @@ -2528,9 +2605,9 @@ class GetAccessCall { .toList(); } -class GetLiberationsCall { +class GetLiberationsCall extends Endpoint { Stream call() { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final StreamController controller = StreamController(); Future.microtask(() async { @@ -2721,13 +2798,13 @@ class GetLiberationsCall { .toList(); } -class GetMessagesCall { +class GetMessagesCall extends Endpoint { Future call({ final String? pageSize, final String? pageNumber, final String? tipoDestino, }) async { - final String baseUrl = PhpGroup.getBaseUrl(); + final String baseUrl = FreAccessWSGlobal.getBaseUrl(); final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; diff --git a/lib/features/documents/document_item_component.dart b/lib/features/documents/document_item_component.dart index 3c0ff117..963ada8f 100644 --- a/lib/features/documents/document_item_component.dart +++ b/lib/features/documents/document_item_component.dart @@ -12,7 +12,6 @@ interface class Category extends Entity { interface class Document extends Entity { final String title; - final String description; final Category category; final String to; final String from; @@ -20,13 +19,12 @@ interface class Document extends Entity { final String updatedAt; Document({ - required this.createdAt, + required this.createdAt, required this.updatedAt, required this.category, required this.to, required this.from, required this.title, - required this.description, }); } diff --git a/lib/features/documents/document_manager_screen.dart b/lib/features/documents/document_manager_screen.dart index 407a5427..0608e17e 100644 --- a/lib/features/documents/document_manager_screen.dart +++ b/lib/features/documents/document_manager_screen.dart @@ -26,7 +26,20 @@ class DocumentManagerScreen extends StatelessScreen { document.updatedAt.toLowerCase().contains(lowerQuery); } - DocumentItem itemBuilder(document) => DocumentItem(document: document); + DocumentItem itemBuilder(dynamic item) { + log('item: $item'); + + final doc = Document( + createdAt: '00/00/00', + updatedAt: '00/00/00', + category: Category(color: Colors.black, title: item['category']), + to: item['person'], + from: '', + title: item['description'], + ); + final docItem = DocumentItem(document: doc); + return docItem; + } void filterByCategory(Category query) { print('Test'); @@ -75,13 +88,15 @@ class DocumentManagerScreen extends StatelessScreen { return Column( children: [ Expanded( - child: LocalSearchView( + child: RemoteSearchListView( key: _listViewKey, header: header, onSearch: filterByString, list: documents, itemBuilder: itemBuilder, filter: filter, + title: '', + // fetchItems: (String ) { },, ), ), ] // diff --git a/lib/features/documents/document_page_widget.dart b/lib/features/documents/document_page_widget.dart index 99dc2849..a70f2775 100644 --- a/lib/features/documents/document_page_widget.dart +++ b/lib/features/documents/document_page_widget.dart @@ -8,7 +8,6 @@ List generateDocuments(int count) { count, (index) => Document( title: 'Lorem Ipsum et Cetera $index', - description: 'Description for document $index', category: Category(color: color(), title: str()), to: str(), from: str(), diff --git a/lib/features/history/presentation/pages/acess_history_page_widget.dart b/lib/features/history/presentation/pages/acess_history_page_widget.dart index 16708425..2d5253b1 100644 --- a/lib/features/history/presentation/pages/acess_history_page_widget.dart +++ b/lib/features/history/presentation/pages/acess_history_page_widget.dart @@ -198,7 +198,7 @@ class _AccessHistoryState extends State { Future fetchAccessHistoryService() async { try { setState(() => _loading = true); - var response = await PhpGroup.getAccessCall.call( + var response = await FreAccessWSGlobal.getAccessCall.call( pageSize: _pageSize.toString(), pageNumber: _pageNumber.toString(), pesTipo: _personType != 'E' && _personType != 'O' ? 'T' : _personType, diff --git a/lib/features/history/presentation/pages/provisional_history_page.dart b/lib/features/history/presentation/pages/provisional_history_page.dart index ae43ad8d..bfaca8cf 100644 --- a/lib/features/history/presentation/pages/provisional_history_page.dart +++ b/lib/features/history/presentation/pages/provisional_history_page.dart @@ -222,8 +222,8 @@ class ProvisionalHistoryState extends State { Future fetchHistoryService() async { try { setState(() => _loading = true); - var response = - await PhpGroup.getProvSchedules(_pageNumber.toString(), status); + var response = await FreAccessWSGlobal.getProvSchedules( + _pageNumber.toString(), status); final List history = response.jsonBody['agendamento']['value'] ?? []; diff --git a/lib/features/local/data/data_sources/locals_remote_data_source.dart b/lib/features/local/data/data_sources/locals_remote_data_source.dart index fbe41ff1..939976ad 100644 --- a/lib/features/local/data/data_sources/locals_remote_data_source.dart +++ b/lib/features/local/data/data_sources/locals_remote_data_source.dart @@ -32,7 +32,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @override Future linkLocal(BuildContext context) async { try { - final GetLocalsCall callback = PhpGroup.getLocalsCall; + final GetLocalsCall callback = FreAccessWSGlobal.getLocalsCall; var response = await callback.call(); final bool? isError = response.jsonBody['error']; @@ -72,7 +72,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { Future processLocals(BuildContext context) async { log('() => processLocals'); try { - final GetLocalsCall callback = PhpGroup.getLocalsCall; + final GetLocalsCall callback = FreAccessWSGlobal.getLocalsCall; final ApiCallResponse response = await callback.call(); final bool? isError = response.jsonBody['error']; @@ -163,10 +163,10 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @override Future processProperty(BuildContext context) async { try { - final GetDadosCall callback = PhpGroup.getDadosCall; + final GetDadosCall callback = FreAccessWSGlobal.getDadosCall; ApiCallResponse? response = await callback.call(); if (response.jsonBody == null) { - final GetLocalsCall callback = PhpGroup.getLocalsCall; + final GetLocalsCall callback = FreAccessWSGlobal.getLocalsCall; response = await callback.call(); // final String errorMsg = FFLocalizations.of(context).getVariableText( // enText: 'Verify your connection', @@ -178,7 +178,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { final bool? isError = response.jsonBody['error']; if (isError == true) { - final GetLocalsCall callback = PhpGroup.getLocalsCall; + final GetLocalsCall callback = FreAccessWSGlobal.getLocalsCall; response = await callback.call(); // final String errorMsg = // response.jsonBody['error_msg'] ?? 'Local indisponível'; @@ -231,8 +231,9 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { enText: 'Device unlinked successfully', ptText: 'Dispositivo desvinculado com sucesso', ); - final bool status = - await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { + final bool status = await FreAccessWSGlobal.resopndeVinculo + .call(tarefa: 'I') + .then((value) async { if (value.jsonBody['error'] == false) { await StorageHelper().set(ProfileStorageKey.clientName.key, ''); await StorageHelper().set(ProfileStorageKey.ownerName.key, ''); diff --git a/lib/features/local/utils/local_util.dart b/lib/features/local/utils/local_util.dart index 8de35b63..04a042da 100644 --- a/lib/features/local/utils/local_util.dart +++ b/lib/features/local/utils/local_util.dart @@ -52,7 +52,7 @@ class LocalUtil { await StorageHelper() .set(ProfileStorageKey.ownerName.key, locals[0]['CLU_OWNER_DSC']); - var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); + var response = await FreAccessWSGlobal.resopndeVinculo.call(tarefa: 'A'); if (response.jsonBody['error'] == true) { await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); await StorageHelper().set(ProfileStorageKey.ownerUUID.key, ''); diff --git a/lib/features/menu/presentation/blocs/menu_bloc.dart b/lib/features/menu/presentation/blocs/menu_bloc.dart index dc384bf0..c5eddf2d 100644 --- a/lib/features/menu/presentation/blocs/menu_bloc.dart +++ b/lib/features/menu/presentation/blocs/menu_bloc.dart @@ -37,7 +37,8 @@ class MenuBloc extends Bloc { } Future _onMenuEvent(MenuEvent event, Emitter emit) async { - await LicenseRemoteDataSourceImpl(PhpGroup()).waitForSaveCompletion(); + await LicenseRemoteDataSourceImpl(FreAccessWSGlobal()) + .waitForSaveCompletion(); final List newEntries = await MenuRepositoryImpl().entries2Items(entries, item); diff --git a/lib/features/module/data/repositories/license_repository_impl.dart b/lib/features/module/data/repositories/license_repository_impl.dart index c578608f..3d7068b4 100644 --- a/lib/features/module/data/repositories/license_repository_impl.dart +++ b/lib/features/module/data/repositories/license_repository_impl.dart @@ -17,7 +17,7 @@ class LicenseRepositoryImpl implements LicenseRepository { LicenseRepositoryImpl([Database? database, Api? api]) : database = database ?? DatabaseService.database, - api = api ?? PhpGroup() { + api = api ?? FreAccessWSGlobal() { localDataSource = LicenseLocalDataSourceImpl(this.database); remoteDataSource = LicenseRemoteDataSourceImpl(this.api); } diff --git a/lib/features/notification/firebase_messaging_service.dart b/lib/features/notification/firebase_messaging_service.dart index 68fc300a..60fb2fa3 100644 --- a/lib/features/notification/firebase_messaging_service.dart +++ b/lib/features/notification/firebase_messaging_service.dart @@ -48,7 +48,7 @@ class FirebaseMessagingService { await StorageHelper().set(SecureStorageKey.token.value, deviceToken); final ApiCallResponse? response; - response = await PhpGroup.updToken.call(); + response = await FreAccessWSGlobal.updToken.call(); if (response.jsonBody['error'] == false) { log('Token Atualizado com Sucesso!'); diff --git a/lib/features/notification/notification_service.dart b/lib/features/notification/notification_service.dart index 8c7b423c..610c83d4 100644 --- a/lib/features/notification/notification_service.dart +++ b/lib/features/notification/notification_service.dart @@ -25,7 +25,8 @@ Future onMessageReceived( required String? response, required String? id}) async { final ApiCallResponse? respondeSolicitacaoCall; - final RespondeSolicitacaoCall callback = PhpGroup.respondeSolicitacaoCall; + final RespondeSolicitacaoCall callback = + FreAccessWSGlobal.respondeSolicitacaoCall; respondeSolicitacaoCall = await callback.call( referencia: ref, diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index dc93f26b..044fd7a3 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -50,7 +50,8 @@ class LiberationHistoryModel extends FlutterFlowModel { required String? response, required String? id}) async { final ApiCallResponse? respondeSolicitacaoCall; - final RespondeSolicitacaoCall callback = PhpGroup.respondeSolicitacaoCall; + final RespondeSolicitacaoCall callback = + FreAccessWSGlobal.respondeSolicitacaoCall; respondeSolicitacaoCall = await callback.call( referencia: ref, diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index f69abdee..f596ff8f 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -333,7 +333,7 @@ class _LiberationHistoryWidgetState extends State { Future _fetchRequests() async { try { safeSetState(() => _loading = true); - var response = await PhpGroup.getLiberationsCall.call().first; + var response = await FreAccessWSGlobal.getLiberationsCall.call().first; final List requests = response.jsonBody['solicitacoes'] ?? []; diff --git a/lib/pages/message_history_page/message_history_page_widget.dart b/lib/pages/message_history_page/message_history_page_widget.dart index 3e72708b..4e0f64cc 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -97,7 +97,7 @@ class _MessageHistoryPageWidgetState extends State try { setState(() => _loading = true); - var response = await PhpGroup.getMessagesCall.call( + var response = await FreAccessWSGlobal.getMessagesCall.call( pageSize: _pageSize.toString(), pageNumber: _pageNumber.toString(), tipoDestino: _destinyType, diff --git a/lib/pages/package_order_page/package_order_page.dart b/lib/pages/package_order_page/package_order_page.dart index a8d04b60..e6af9962 100644 --- a/lib/pages/package_order_page/package_order_page.dart +++ b/lib/pages/package_order_page/package_order_page.dart @@ -97,7 +97,7 @@ class _PackageOrderPage extends State { try { setState(() => _loading = true); - var response = await PhpGroup.buscaEnconcomendas.call( + var response = await FreAccessWSGlobal.buscaEnconcomendas.call( pageSize: _pageSize.toString(), page: _pageNumber.toString(), adresseeType: _adresseeType == '.*' ? 'TOD' : _adresseeType, @@ -314,7 +314,7 @@ class _PackageOrderPage extends State { } String _imagePath(dynamic order) { - return '${PhpGroup.getBaseUrl()}/getImage.php?cliID=$cliUUID&atividade=getFotoEncomenda&orderId=${order['id'] ?? ''}'; + return '${FreAccessWSGlobal.getBaseUrl()}/getImage.php?cliID=$cliUUID&atividade=getFotoEncomenda&orderId=${order['id'] ?? ''}'; } Map _labelsHashMap(dynamic order) { 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 097f9090..9a802749 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 @@ -82,7 +82,7 @@ class _PeopleOnThePropertyPageState extends State { body: SafeArea( top: true, child: FutureBuilder( - future: PhpGroup.getPessoasLocalCall.call(), + future: FreAccessWSGlobal.getPessoasLocalCall.call(), builder: (context, snapshot) { // Customize what your widget looks like when it's loading. if (!snapshot.hasData) { @@ -123,7 +123,7 @@ class _PeopleOnThePropertyPageState extends State { } final columnGetPessoasLocalResponse = snapshot.data!; - final getPoepleProperty = PhpGroup.getPessoasLocalCall + final getPoepleProperty = FreAccessWSGlobal.getPessoasLocalCall .pessoas( columnGetPessoasLocalResponse.jsonBody, ) diff --git a/lib/pages/pets_on_the_property_page/pets_history_screen.dart b/lib/pages/pets_on_the_property_page/pets_history_screen.dart index 813c1158..f6eace39 100644 --- a/lib/pages/pets_on_the_property_page/pets_history_screen.dart +++ b/lib/pages/pets_on_the_property_page/pets_history_screen.dart @@ -100,7 +100,7 @@ class _PetsHistoryScreenState extends State try { setState(() => _loading = true); - var response = await PhpGroup.getPets.call( + var response = await FreAccessWSGlobal.getPets.call( pageSize: _pageSize, page: _pageNumber, ); diff --git a/lib/pages/pets_page/pets_page_model.dart b/lib/pages/pets_page/pets_page_model.dart index e7de27fe..d9e96e61 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -280,7 +280,7 @@ class PetsPageModel extends FlutterFlowModel { img = "base64;jpeg,$img"; final url = 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=$petId'; - final response = await PhpGroup.updatePet.call( + final response = await FreAccessWSGlobal.updatePet.call( petID: petId, image: img, birthdayDate: textControllerData!.text, @@ -323,7 +323,7 @@ class PetsPageModel extends FlutterFlowModel { Future registerPet() async { var img = await ImageUtils.convertImageFileToBase64(uploadedLocalFile!); img = "base64;jpeg,$img"; - final response = await PhpGroup.registerPet.call( + final response = await FreAccessWSGlobal.registerPet.call( image: img, birthdayDate: textControllerData!.text, color: textControllerColor!.text, @@ -464,7 +464,7 @@ class PetsPageModel extends FlutterFlowModel { enText: 'Are you sure you want to delete this pet?', ), () async { int id = item['id']; - await PhpGroup.deletePet + await FreAccessWSGlobal.deletePet .call( petID: id, ) diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 17e79b25..0f57850c 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -62,7 +62,7 @@ class PreferencesPageModel with ChangeNotifier { onConfirm() async { String content; String value = !isNotify ? 'S' : 'N'; - await PhpGroup.changeNotifica + await FreAccessWSGlobal.changeNotifica .call(notifica: value) .then((value) async { if (value.jsonBody['error'] == false) { @@ -109,7 +109,7 @@ class PreferencesPageModel with ChangeNotifier { ); onConfirm() async { String content; - await PhpGroup.updateIDE.call().then((value) async { + await FreAccessWSGlobal.updateIDE.call().then((value) async { if (value.jsonBody['error'] == false) { notifyListeners(); content = FFLocalizations.of(context).getVariableText( @@ -141,7 +141,7 @@ class PreferencesPageModel with ChangeNotifier { Future toggleAccess(BuildContext context) async { onChange(String key) async { await StorageHelper().set(SecureStorageKey.accessPass.value, key); - await PhpGroup.changePass + await FreAccessWSGlobal.changePass .call(newSenha: key) .then((value) async { final String content; @@ -180,7 +180,7 @@ class PreferencesPageModel with ChangeNotifier { Future togglePanic(BuildContext context) async { onChange(String key) async { await StorageHelper().set(SecureStorageKey.panicPass.value, key); - await PhpGroup.changePanic + await FreAccessWSGlobal.changePanic .call(newSenhaPanico: key) .then((value) async { final String content; diff --git a/lib/pages/reception_page/reception_page_widget.dart b/lib/pages/reception_page/reception_page_widget.dart index ddd1854a..98760970 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -180,7 +180,7 @@ class _ReceptionPageWidgetState extends State padding: const EdgeInsets.fromLTRB(60, 0, 60, 25), child: FFButtonWidget( onPressed: () async { - PhpGroup.unregisterDevice(); + FreAccessWSGlobal.unregisterDevice(); AuthenticationService.signOut(context); setState(() {}); }, diff --git a/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart b/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart index 8f63d8a2..515d556e 100644 --- a/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart +++ b/lib/pages/residents_on_the_property/residents_on_the_property_screen.dart @@ -175,8 +175,8 @@ class _ResidentsOnThePropertyState extends State try { setState(() => _loading = true); - var response = - await PhpGroup.getResidentsByProperty.call(_pageNumber.toString()); + var response = await FreAccessWSGlobal.getResidentsByProperty + .call(_pageNumber.toString()); final List residents = response.jsonBody['residents'] ?? []; safeSetState(() => count = response.jsonBody['total_rows'] ?? 0); diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart index f7248d93..18647b22 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart @@ -361,7 +361,7 @@ class ScheduleCompleteVisitPageModel required String? accessKey, required String? email}) async { final ApiCallResponse? response; - final CancelaVisita callback = PhpGroup.cancelaVisita; + final CancelaVisita callback = FreAccessWSGlobal.cancelaVisita; response = await callback.call( idDestino: idDestino, 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 ce4d41a3..bc34c8f6 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 @@ -1072,7 +1072,8 @@ class _ScheduleCompleteVisitPageWidgetState height: scaledSizedBoxSize * 0.5, decoration: const BoxDecoration(), child: FutureBuilder( - future: PhpGroup.getDadosCall.call(), + future: + FreAccessWSGlobal.getDadosCall.call(), builder: (context, snapshot) { if (!snapshot.hasData) { return Center( @@ -1089,13 +1090,14 @@ class _ScheduleCompleteVisitPageWidgetState ); } - final reasonsJsonList = - PhpGroup.getDadosCall.reasonsJsonList( - snapshot.data!.jsonBody); - final reasonsOptionLabels = PhpGroup + final reasonsJsonList = FreAccessWSGlobal .getDadosCall - .reasonsMotDescStrList( + .reasonsJsonList( snapshot.data!.jsonBody); + final reasonsOptionLabels = + FreAccessWSGlobal.getDadosCall + .reasonsMotDescStrList( + snapshot.data!.jsonBody); model.processDropDown1(reasonsJsonList!); @@ -1196,7 +1198,8 @@ class _ScheduleCompleteVisitPageWidgetState height: scaledSizedBoxSize * 0.5, decoration: const BoxDecoration(), child: FutureBuilder( - future: PhpGroup.getDadosCall.call(), + future: + FreAccessWSGlobal.getDadosCall.call(), builder: (context, snapshot) { if (!snapshot.hasData) { return Center( @@ -1213,13 +1216,14 @@ class _ScheduleCompleteVisitPageWidgetState ); } - final lavelsJsonList = - PhpGroup.getDadosCall.levelJsonList( - snapshot.data!.jsonBody); - final lavelsOptionLabels = PhpGroup + final lavelsJsonList = FreAccessWSGlobal .getDadosCall - .levelNACDescricaoStrList( + .levelJsonList( snapshot.data!.jsonBody); + final lavelsOptionLabels = + FreAccessWSGlobal.getDadosCall + .levelNACDescricaoStrList( + snapshot.data!.jsonBody); model.processDropDown2(lavelsJsonList!); return FlutterFlowDropDown( @@ -1557,7 +1561,7 @@ class _ScheduleCompleteVisitPageWidgetState onPressed: model.isValid() ? () async { Future scheduleVisit() async { - await PhpGroup.postScheduleVisitCall + await FreAccessWSGlobal.postScheduleVisitCall .call( devDesc: model.textController3.text, idVisitante: model.visitorStrList, @@ -1573,7 +1577,7 @@ class _ScheduleCompleteVisitPageWidgetState .catchError((e) async => await DialogUtil.errorDefault(context)) .then((value) async { - if (PhpGroup.postScheduleVisitCall.error( + if (FreAccessWSGlobal.postScheduleVisitCall.error( (value.jsonBody ?? ''), ) == false) { diff --git a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart index 0c4ddaf1..9c4f234e 100644 --- a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart @@ -76,7 +76,7 @@ class _VisitHistoryWidgetState extends State setState(() => _loading = true); var response = await ScheduleCompleteVisitPageModel().visitHistory( - requestFn: () => PhpGroup.getVisitsCall.call( + requestFn: () => FreAccessWSGlobal.getVisitsCall.call( pageSize: _pageSize, pageNumber: _pageNumber, ), diff --git a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart index c27a067e..f40576ce 100644 --- a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart +++ b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart @@ -170,8 +170,8 @@ class _VehicleOnThePropertyState extends State try { setState(() => _loading = true); - var response = - await PhpGroup.getVehiclesByProperty.call(_pageNumber.toString()); + var response = await FreAccessWSGlobal.getVehiclesByProperty + .call(_pageNumber.toString()); final List vehicles = response.jsonBody['vehicles'] ?? []; safeSetState(() => count = response.jsonBody['total_rows'] ?? 0); diff --git a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart index 65f9a039..ad1fae23 100644 --- a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart +++ b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart @@ -176,7 +176,7 @@ class _VisitsOnThePropertyState extends State setState(() => _loading = true); var response = - await PhpGroup.getOpenedVisits.call(_pageNumber.toString()); + await FreAccessWSGlobal.getOpenedVisits.call(_pageNumber.toString()); final List visits = response.jsonBody['visitas'] ?? []; safeSetState(() => count = response.jsonBody['total_rows'] ?? 0); diff --git a/lib/shared/mixins/pegeable_mixin.dart b/lib/shared/mixins/pegeable_mixin.dart new file mode 100644 index 00000000..1752244a --- /dev/null +++ b/lib/shared/mixins/pegeable_mixin.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/index.dart'; +import 'package:hub/shared/utils/limited_text_size.dart'; +import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; + +extension PagedListViewExtension + on PagedSliverList {} + +mixin Pageable on State { + Expanded buildPaginatedListView( + String noDataFound, + PagingController pg, + Widget Function(BuildContext, Y, int) itemBuilder) { + final theme = FlutterFlowTheme.of(context); + + return Expanded( + child: RefreshIndicator( + backgroundColor: theme.primaryBackground, + color: theme.primary, + onRefresh: () async => pg.refresh(), + child: PagedListView( + pagingController: pg, + builderDelegate: PagedChildBuilderDelegate( + animateTransitions: true, + itemBuilder: (context, item, index) => + itemBuilder(context, item, index), + // noMoreItemsIndicatorBuilder: , + newPageProgressIndicatorBuilder: (context) => + buildLoadingIndicator(context), + firstPageProgressIndicatorBuilder: (context) => + buildLoadingIndicator(context), + noItemsFoundIndicatorBuilder: (context) => + buildNoDataFound(context, noDataFound), + firstPageErrorIndicatorBuilder: (context) => const Placeholder(), + newPageErrorIndicatorBuilder: (context) => const Placeholder(), + ), + ), + ), + ); + } + + Future showError(PagingStatus status, PagingController pg) async { + if (status == PagingStatus.subsequentPageError) { + final message = FFLocalizations.of(context).getVariableText( + enText: 'Something went wrong while fetching a new page.', + ptText: 'Algo deu errado ao buscar uma nova página.', + ); + final retry = FFLocalizations.of(context).getVariableText( + enText: 'Retry', + ptText: 'Recarregar', + ); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + action: SnackBarAction( + label: retry, + onPressed: () => pg.retryLastFailedRequest(), + ), + ), + ); + } + } + + Future fetchPage({ + required Future<(bool, dynamic)> Function() dataProvider, + required void Function(dynamic data) onDataAvailable, + required void Function() onDataUnavailable, + required void Function(Object error, StackTrace stackTrace) onFetchError, + }) async { + try { + final (bool isDataAvailable, dynamic data) = await dataProvider(); + if (isDataAvailable) { + onDataAvailable(data); + } else { + onDataUnavailable(); + } + } catch (error, stackTrace) { + onFetchError(error, stackTrace); + } + } + + void showNoMoreDataSnackBar(BuildContext context) { + final message = FFLocalizations.of(context).getVariableText( + ptText: "Não há mais dados.", + enText: "No more data.", + ); + + showSnackbar(context, message, true); + } + + Widget buildNoDataFound(BuildContext context, String title) { + final headerFontSize = LimitedFontSizeUtil.getHeaderFontSize(context); + // final bodyFontSize = LimitedFontSizeUtil.getBodyFontSize(context); + return Expanded( + child: Center( + child: Text( + title, + style: TextStyle( + fontFamily: 'Nunito', + fontSize: headerFontSize, + ), + ), + ), + ); + } + + Widget buildLoadingIndicator(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 15), + child: Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, + ), + ), + ), + ); + } +} diff --git a/lib/shared/utils/log_util.dart b/lib/shared/utils/log_util.dart index c9c9526b..b6bfebf9 100644 --- a/lib/shared/utils/log_util.dart +++ b/lib/shared/utils/log_util.dart @@ -6,7 +6,7 @@ import 'package:hub/features/backend/index.dart'; class LogUtil { static void requestAPIFailed(String url, String body, String reason, dynamic error, StackTrace stack) async { - final fullUrl = "${PhpGroup.getBaseUrl()}/$url"; + final fullUrl = "${FreAccessWSGlobal.getBaseUrl()}/$url"; log("URL: $fullUrl"); log("Body: $body"); log("Reason: $reason"); diff --git a/lib/shared/widgets/view/search_view.dart b/lib/shared/widgets/view/search_view.dart index 89bec502..37a6b20e 100644 --- a/lib/shared/widgets/view/search_view.dart +++ b/lib/shared/widgets/view/search_view.dart @@ -109,92 +109,149 @@ class LocalSearchViewState extends State> { } class RemoteSearchListView extends SearchView { - final List items; + final List list; final String title; final Widget Function(T) itemBuilder; - final Future> Function(String) fetchItems; + // final Future> Function(String) fetchItems; + final bool Function(T, String) filter; + final Widget header; + final List Function(String)? onSearch; RemoteSearchListView({ Key? key, - required this.items, + // required this.fetchItems, required this.title, + required this.list, required this.itemBuilder, - required this.fetchItems, - }) : super(key: key); + required this.filter, + List Function(String)? onSearch, + Widget? header, + }) : header = header ?? const SizedBox.shrink(), + onSearch = onSearch ?? + ((String query) => + list.where((documents) => filter(documents, query)).toList()), + super(key: key); @override _RemoteSearchViewState createState() => _RemoteSearchViewState(); } -class _RemoteSearchViewState extends State> { +class _RemoteSearchViewState extends State> + with Pageable { TextEditingController editingController = TextEditingController(); late List filteredItems; bool isLoading = false; + final apiCall = FreAccessWSGlobal.getDocuments; + int count = 0; + final PagingController _pagingController = + PagingController(firstPageKey: 1); @override void initState() { - filteredItems = widget.items; + filteredItems = widget.list; + _pagingController.addPageRequestListener( + (dynamic pageKey) => fetchPage( + dataProvider: () async { + final newItems = await apiCall.call(pageKey.toString()); + if (newItems.jsonBody == null) return (false, null); + final List docs = + (newItems.jsonBody['value']['list'] as List?) ?? []; + _pagingController.nextPageKey = pageKey + 1; + + safeSetState(() { + count = newItems.jsonBody['value']['count'] ?? 0; + }); + return (docs.isNotEmpty, docs); + }, + onDataUnavailable: () { + setState(() {}); + showNoMoreDataSnackBar(context); + }, + onDataAvailable: (vehicles) { + setState(() {}); + _pagingController.appendLastPage(vehicles); + }, + onFetchError: (e, s) { + DialogUtil.errorDefault(context); + LogUtil.requestAPIFailed( + "proccessRequest.php", "", "Consulta de Veículo", e, s); + setState(() {}); + }, + ), + ); + _pagingController.addStatusListener(_showError); + super.initState(); } + Future _showError(PagingStatus status) async { + if (status == PagingStatus.subsequentPageError) { + final message = FFLocalizations.of(context).getVariableText( + enText: 'Something went wrong while fetching a new page.', + ptText: 'Algo deu errado ao buscar uma nova página.', + ); + final retry = FFLocalizations.of(context).getVariableText( + enText: 'Retry', + ptText: 'Recarregar', + ); + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + action: SnackBarAction( + label: retry, + onPressed: () => _pagingController.retryLastFailedRequest(), + ), + ), + ); + } + } + void filterSearchResults(String query) async { setState(() { isLoading = true; }); - final results = await widget.fetchItems(query); - setState(() { - filteredItems = results; - isLoading = false; - }); + // final results = await widget.fetchItems(query); + // setState(() { + // filteredItems = results; + // isLoading = false; + // }); } @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(widget.title), - ), - body: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: TextField( - onChanged: (value) { - filterSearchResults(value); - }, - controller: editingController, - decoration: InputDecoration( - labelText: "Search", - hintText: "Search", - prefixIcon: Icon(Icons.search), - border: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(25.0)), - ), - ), + final noDataFound = FFLocalizations.of(context).getVariableText( + ptText: "Nenhum veículo encontrado!", + enText: "No vehicle found", + ); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: TextField( + onChanged: (value) => filterSearchResults(value), + controller: editingController, + decoration: InputDecoration( + labelText: "Search", + hintText: "Search", + prefixIcon: Icon(Icons.search), + border: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(25.0)), ), ), - Padding( - padding: const EdgeInsets.fromLTRB(15, 0, 50, 0), - child: Text('Últimos Documentos'), - ), - isLoading - ? Center(child: CircularProgressIndicator()) - : Expanded( - child: ListView.builder( - shrinkWrap: true, - itemCount: filteredItems.length, - itemBuilder: (context, index) { - return widget.itemBuilder(filteredItems[index]); - }, - ), - ), - ], + ), ), - ), + widget.header, + buildPaginatedListView( + noDataFound, + _pagingController, + (BuildContext context, dynamic item, int index) => + widget.itemBuilder(item), + ), + ], ); } } diff --git a/lib/shared/widgets/widgets.dart b/lib/shared/widgets/widgets.dart index 7b240209..1ba34d40 100644 --- a/lib/shared/widgets/widgets.dart +++ b/lib/shared/widgets/widgets.dart @@ -1,8 +1,14 @@ +import 'dart:developer'; + import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/backend/api_requests/api_calls.dart'; import 'package:hub/features/documents/index.dart'; import 'package:hub/flutter_flow/index.dart'; +import 'package:hub/shared/mixins/pegeable_mixin.dart'; +import 'package:hub/shared/utils/index.dart'; +import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; part 'page.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 0a647c1b..455814dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -85,6 +85,7 @@ dependencies: url_launcher_android: ^6.3.12 url_launcher_ios: ^6.3.1 url_launcher_platform_interface: 2.3.2 + infinite_scroll_pagination: ^4.1.0 # video_player: 2.8.7 # video_player_android: 2.5.0 # video_player_avfoundation: 2.6.1