diff --git a/android/app/build.gradle b/android/app/build.gradle
index 378b3674..4fb2c5e6 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -30,6 +30,7 @@ if (keystorePropertiesFile.exists()) {
android {
compileSdkVersion 34
+ compileSdk 34
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@@ -46,8 +47,19 @@ android {
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
+ multiDexEnabled true
+
}
+ compileOptions {
+ // Flag to enable support for the new language APIs
+ coreLibraryDesugaringEnabled true
+ // Sets Java compatibility to Java 8
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
@@ -57,6 +69,10 @@ android {
}
}
+ dependencies {
+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
+ }
+
buildTypes {
release {
signingConfig signingConfigs.debug
@@ -71,9 +87,12 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10"
// id "org.jetbrains.kotlin.android" version "1.8.10" apply false
-
+
implementation 'com.android.support:multidex:1.0.3' // Se necessário, adicione suporte ao multidex
// Adicione outras dependências do seu aplicativo aqui
+
+ implementation 'androidx.window:window:1.0.0'
+ implementation 'androidx.window:window-java:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 87d8dd6f..bc60e9ce 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,13 +1,14 @@
-
-
+
+
-
-
-
+
+
+
+
+ android:windowSoftInputMode="adjustResize"
+ android:showWhenLocked="true"
+ android:turnScreenOn="true">
+
+
+ android:name="io.flutter.embedding.android.NormalTheme"
+ android:resource="@style/NormalTheme"
+ />
+ android:name="io.flutter.embedding.android.SplashScreenDrawable"
+ android:resource="@drawable/launch_background"
+ />
-
-
+
+
+ android:name="com.google.firebase.messaging.ic_fre_black"
+ android:resource="@drawable/ic_fre_black" />
+
@@ -67,6 +73,17 @@
android:value="2" />
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/android/build.gradle b/android/build.gradle
index 70c46d39..c67c3834 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -5,13 +5,13 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.0.2' // Use a versão do Gradle que corresponde à sua configuração
+ classpath 'com.android.tools.build:gradle:7.3.1' // Use a versão do Gradle que corresponde à sua configuração
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10' // Kotlin Gradle plugin
classpath 'com.google.gms:google-services:4.4.2' // Google Services plugin
// Certifique-se de adicionar outras dependências do classpath aqui, se necessário.
}
}
-
+
allprojects {
repositories {
google()
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index affaa086..50832291 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sat Jun 15 18:23:23 BRT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
+networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/ios/Podfile b/ios/Podfile
index 8f4bfd94..fa109b46 100644
--- a/ios/Podfile
+++ b/ios/Podfile
@@ -42,4 +42,12 @@ post_install do |installer|
end
end
+
+ awesome_pod_file = File.expand_path(File.join('plugins', 'awesome_notifications', 'ios', 'Scripts', 'AwesomePodFile'), '.symlinks')
+ require awesome_pod_file
+ update_awesome_pod_build_settings(installer)
end
+
+ awesome_pod_file = File.expand_path(File.join('plugins', 'awesome_notifications', 'ios', 'Scripts', 'AwesomePodFile'), '.symlinks')
+ require awesome_pod_file
+ update_awesome_main_target_settings('Runner', File.dirname(File.realpath(__FILE__)), flutter_root)
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index acfbf591..e75cf60e 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -1,4 +1,7 @@
PODS:
+ - awesome_notifications (0.9.3):
+ - Flutter
+ - IosAwnCore (~> 0.9.3)
- connectivity_plus (0.0.1):
- Flutter
- FlutterMacOS
@@ -133,8 +136,6 @@ PODS:
- flutter_inappwebview_ios/Core (0.0.1):
- Flutter
- OrderedSet (~> 5.0)
- - flutter_local_notifications (0.0.1):
- - Flutter
- flutter_secure_storage (6.0.0):
- Flutter
- GoogleAppMeasurement (10.27.0):
@@ -191,8 +192,10 @@ PODS:
- GoogleUtilities/Privacy
- image_picker_ios (0.0.1):
- Flutter
+ - IosAwnCore (0.9.3)
- local_auth_darwin (0.0.1):
- Flutter
+ - FlutterMacOS
- nanopb (2.30910.0):
- nanopb/decode (= 2.30910.0)
- nanopb/encode (= 2.30910.0)
@@ -228,6 +231,7 @@ PODS:
- Flutter
DEPENDENCIES:
+ - awesome_notifications (from `.symlinks/plugins/awesome_notifications/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
@@ -237,7 +241,6 @@ DEPENDENCIES:
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- - flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- local_auth_darwin (from `.symlinks/plugins/local_auth_darwin/darwin`)
@@ -267,6 +270,7 @@ SPEC REPOS:
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleUtilities
+ - IosAwnCore
- nanopb
- OrderedSet
- PromisesObjC
@@ -275,6 +279,8 @@ SPEC REPOS:
- SwiftyGif
EXTERNAL SOURCES:
+ awesome_notifications:
+ :path: ".symlinks/plugins/awesome_notifications/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/darwin"
device_info_plus:
@@ -293,8 +299,6 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_inappwebview_ios:
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
- flutter_local_notifications:
- :path: ".symlinks/plugins/flutter_local_notifications/ios"
flutter_secure_storage:
:path: ".symlinks/plugins/flutter_secure_storage/ios"
image_picker_ios:
@@ -319,6 +323,7 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
SPEC CHECKSUMS:
+ awesome_notifications: 66d28ab7174ca2823b04d275cb043e0a4a3eb9cf
connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c
@@ -340,13 +345,13 @@ SPEC CHECKSUMS:
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
- flutter_local_notifications: 4cde75091f6327eb8517fa068a0a5950212d2086
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
GoogleAppMeasurement: f65fc137531af9ad647f1c0a42f3b6a4d3a98049
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
- local_auth_darwin: 4d56c90c2683319835a61274b57620df9c4520ab
+ IosAwnCore: b8601fbb37f7b3560f31b84ebf55a72f65812e05
+ local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3
nanopb: 438bc412db1928dac798aa6fd75726007be04262
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
@@ -360,8 +365,8 @@ SPEC CHECKSUMS:
SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
- webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36
+ webview_flutter_wkwebview: 2a23822e9039b7b1bc52e5add778e5d89ad488d1
-PODFILE CHECKSUM: d7f4d1b71f8c708247c1078c4aec33a28c763405
+PODFILE CHECKSUM: 3bb356a4513d56583f2f2461d3d8eefb4cd4c3a4
COCOAPODS: 1.15.2
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 77985801..8e5d3b01 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -41,8 +41,8 @@
4C588A6A63D12FBFE8C3D586 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; };
4C7A2C30DCF835BA60FAD235 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
50BE974D08F66282C0031620 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
- 6436409127A31CDB00820AF7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
- 6436409227A31CD800820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; };
+ 6436409227A31CDD00820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; };
+ 6436409B27A31CD600820AF7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
@@ -53,8 +53,6 @@
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
- 6436409227A31CDD00820AF7 /* pt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pt; path = pt.lproj/InfoPlist.strings; sourceTree = ""; };
- 6436409B27A31CD600820AF7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
C1B4A503715BC7B0F8826983 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
/* End PBXFileReference section */
@@ -382,8 +380,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
+ BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -528,8 +528,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
+ BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -568,8 +570,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
+ APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
+ BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index d1887b8a..f52eb22e 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,7 +1,6 @@
import UIKit
import Flutter
-import flutter_local_notifications
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
@@ -9,15 +8,6 @@ import flutter_local_notifications
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
-
- FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
- GeneratedPluginRegistrant.register(with: registry)
- }
-
- if #available(iOS 10.0, *) {
- UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
- }
-
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
diff --git a/lib/actions/actions.dart b/lib/actions/actions.dart
index 653512ad..1d454af9 100644
--- a/lib/actions/actions.dart
+++ b/lib/actions/actions.dart
@@ -1,22 +1,16 @@
-import 'dart:developer';
-
+import 'package:flutter/material.dart';
// import 'package:hub/components/organisms/bottom_arrow_linked_locals/bottom_arrow_linked_locals_component_widget.dart';
import 'package:hub/backend/api_requests/api_calls.dart';
-import 'package:hub/backend/api_requests/api_manager.dart';
import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
-import 'package:hub/components/molecular_components/throw_exception/throw_exception_widget.dart';
import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart';
import 'package:hub/custom_code/actions/get_dev_u_u_i_d.dart';
import 'package:hub/flutter_flow/flutter_flow_theme.dart';
import 'package:hub/flutter_flow/flutter_flow_util.dart';
import 'package:hub/flutter_flow/nav/nav.dart';
-
-import 'package:flutter/material.dart';
import 'package:hub/flutter_flow/random_data_util.dart';
import 'package:hub/pages/home_page/home_page_model.dart';
import 'package:hub/shared/utils/dialog_util.dart';
import 'package:qr_flutter/qr_flutter.dart';
-
import 'package:url_launcher/url_launcher.dart';
import '../shared/utils/log_util.dart';
@@ -112,23 +106,23 @@ Future singInLoginAction(
await Future.wait([
Future(() async {
- FFAppState().email = emailAdress!;
+ AppState().email = emailAdress!;
}),
Future(() async {
- FFAppState().passwd = password!;
+ AppState().passwd = password!;
}),
]);
- if ((FFAppState().email != '') && (FFAppState().passwd != '')) {
+ if ((AppState().email != '') && (AppState().passwd != '')) {
devUUID = await getDevUUID();
- FFAppState().devUUID = devUUID!;
+ AppState().devUUID = devUUID!;
loginCall = await PhpGroup.loginCall.call(
- email: FFAppState().email,
- password: FFAppState().passwd,
- uuid: FFAppState().devUUID,
- type: FFAppState().device,
+ email: AppState().email,
+ password: AppState().passwd,
+ uuid: AppState().devUUID,
+ type: AppState().device,
description: randomString(
10,
10,
@@ -139,30 +133,30 @@ Future singInLoginAction(
);
if (PhpGroup.loginCall.error((loginCall.jsonBody ?? '')) == false) {
- FFAppState().userUUID = PhpGroup.loginCall.userUUID(
+ AppState().userUUID = PhpGroup.loginCall.userUUID(
(loginCall.jsonBody ?? ''),
)!;
- FFAppState().createdAt = dateTimeFormat(
+ AppState().createdAt = dateTimeFormat(
'd/M/y H:mm:ss',
getCurrentTimestamp,
locale: FFLocalizations.of(context).languageCode,
);
- FFAppState().updatedAt = '00/00/0000 00:00:00';
+ AppState().updatedAt = '00/00/0000 00:00:00';
- FFAppState().status =
+ AppState().status =
PhpGroup.loginCall.userStatus((loginCall.jsonBody ?? ''))!;
- FFAppState().userDevUUID =
+ AppState().userDevUUID =
PhpGroup.loginCall.userDeviceId((loginCall.jsonBody ?? ''))!;
- FFAppState().name =
+ AppState().name =
PhpGroup.loginCall.userName((loginCall.jsonBody ?? ''))!;
- FFAppState().serialNumber = await getSerialNumber() ?? '';
+ AppState().serialNumber = await getSerialNumber() ?? '';
- FFAppState().isLogged = true;
+ AppState().isLogged = true;
await toggleHomePage(context);
} else {
@@ -173,13 +167,13 @@ Future singInLoginAction(
PhpGroup.loginCall.msg((loginCall?.jsonBody ?? '')).toString());
}
- FFAppState().deleteEmail();
- FFAppState().email = '';
+ AppState().deleteEmail();
+ AppState().email = '';
- FFAppState().deletePasswd();
- FFAppState().passwd = '';
+ AppState().deletePasswd();
+ AppState().passwd = '';
- FFAppState().update(() {});
+ AppState().update(() {});
}
}
@@ -271,15 +265,15 @@ Future forgotPasswdAction(
}
Future cachingLoginActionApp(BuildContext context) async {
- if (FFAppState().isLogged == true) {
+ if (AppState().isLogged == true) {
context.pushNamed('homePage');
} else {
if (isAndroid == true) {
- FFAppState().device = 'Android';
+ AppState().device = 'Android';
} else if (isiOS == true) {
- FFAppState().device = 'iOS';
+ AppState().device = 'iOS';
} else {
- FFAppState().device = 'Web';
+ AppState().device = 'Web';
}
}
}
@@ -328,9 +322,9 @@ Future visitCancelAction(BuildContext context,
ApiCallResponse? apiCallResponse;
apiCallResponse = await PhpGroup.cancelaVisita.call(
- userUUID: FFAppState().userUUID,
- devUUID: FFAppState().devUUID,
- cliID: FFAppState().cliUUID,
+ userUUID: AppState().userUUID,
+ devUUID: AppState().devUUID,
+ cliID: AppState().cliUUID,
atividade: 'cancelaVisita',
idDestino: idDestino,
idVisita: idVisita,
@@ -381,8 +375,8 @@ Future checkLocals({
}) 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,
+ devUUID: AppState().devUUID,
+ userUUID: AppState().userUUID,
);
// Verificação rápida de erro para evitar processamento desnecessário.
@@ -391,7 +385,7 @@ Future checkLocals({
}
// Uso eficiente de coleções para verificar a condição desejada.
- final String uuid = cliUUID ?? FFAppState().cliUUID;
+ final String uuid = cliUUID ?? AppState().cliUUID;
final bool itemFound = response.jsonBody['locais'].any(
(local) => local['CLI_ID'] == uuid && local['CLU_STATUS'] == "A",
);
@@ -422,33 +416,25 @@ Future checkLocals({
}
}
-Future answersRequest(BuildContext context, String? ref, String? task, String? response, String? id) async {
- try {
- ApiCallResponse? respondeSolicitacaoCall;
+Future answersRequest(BuildContext context, String? ref, String? task,
+ String? response, String? id) async {
+ ApiCallResponse? respondeSolicitacaoCall;
- respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call(
- userUUID: FFAppState().userUUID,
- devUUID: FFAppState().devUUID,
- cliUUID: FFAppState().cliUUID,
- atividade: 'respondeSolicitacao',
- referencia: ref,
- tarefa: task,
- resposta: response,
- idVisitante: id,
- );
+ respondeSolicitacaoCall = await PhpGroup.respondeSolicitacaoCall.call(
+ userUUID: AppState().userUUID,
+ devUUID: AppState().devUUID,
+ cliUUID: AppState().cliUUID,
+ atividade: 'respondeSolicitacao',
+ referencia: ref,
+ tarefa: task,
+ resposta: response,
+ idVisitante: id,
+ );
-
- if (respondeSolicitacaoCall.statusCode == 200) {
- if (!respondeSolicitacaoCall.jsonBody['error']) {
- return '';
- } else {
- return respondeSolicitacaoCall.jsonBody['error_msg'].toString();
- }
- } else {
- return FFLocalizations.of(context).getVariableText(ptText: 'Falha ao Responder Solicitação', enText: 'Failed to Response Request');
- }
- } catch (e, s) {
- return FFLocalizations.of(context).getVariableText(ptText: 'Falha ao Responder Solicitação', enText: 'Failed to Response Request');
+ if (respondeSolicitacaoCall.statusCode == 200) {
+ return !respondeSolicitacaoCall.jsonBody['error'];
+ } else {
+ return false;
}
}
diff --git a/lib/app_state.dart b/lib/app_state.dart
index c3a91e95..7d2a5df8 100644
--- a/lib/app_state.dart
+++ b/lib/app_state.dart
@@ -1,12 +1,12 @@
// import 'dart:ffi';
+import 'package:csv/csv.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
-import 'package:csv/csv.dart';
import 'package:local_auth/local_auth.dart';
import 'package:synchronized/synchronized.dart';
-class FFAppState extends ChangeNotifier {
+class AppState extends ChangeNotifier {
// Adiciona a variável para controle de autenticação biométrica
bool _isBiometricAuthenticated = false;
bool get isBiometricAuthenticated => _isBiometricAuthenticated;
@@ -57,16 +57,16 @@ class FFAppState extends ChangeNotifier {
// Limpar a informação salva, se necessário
}
- static FFAppState _instance = FFAppState._internal();
+ static AppState _instance = AppState._internal();
- factory FFAppState() {
+ factory AppState() {
return _instance;
}
- FFAppState._internal();
+ AppState._internal();
static void reset() {
- _instance = FFAppState._internal();
+ _instance = AppState._internal();
}
Future initializePersistedState() async {
@@ -150,6 +150,9 @@ class FFAppState extends ChangeNotifier {
_fingerprintPass =
await secureStorage.getString('fingerprintPass') ?? _fingerprintPass;
});
+ await _safeInitAsync(() async {
+ _context = await secureStorage.getObject('ff_context') ?? _context;
+ });
}
void update(VoidCallback callback) {
@@ -159,6 +162,17 @@ class FFAppState extends ChangeNotifier {
late FlutterSecureStorage secureStorage;
+ BuildContext? _context;
+ BuildContext? get context => _context;
+ set context(BuildContext? value) {
+ _context = value;
+ secureStorage.setString('ff_context', value.toString());
+ }
+
+ void deleteContext() {
+ secureStorage.delete(key: 'ff_context');
+ }
+
bool _panicOPT = false;
bool get panic => _panicOPT;
set panic(bool value) {
@@ -481,6 +495,14 @@ extension FlutterSecureStorageExtensions on FlutterSecureStorage {
Future setDouble(String key, double value) async =>
await writeSync(key: key, value: value.toString());
+ Future getObject(String key) async {
+ final value = await read(key: key);
+ if (value == null || value.isEmpty) {
+ return null;
+ }
+ return value as BuildContext;
+ }
+
Future?> getStringList(String key) async =>
await read(key: key).then((result) {
if (result == null || result.isEmpty) {
diff --git a/lib/backend/api_requests/api_manager.dart b/lib/backend/api_requests/api_manager.dart
index 8c2cd6ea..14124b70 100644
--- a/lib/backend/api_requests/api_manager.dart
+++ b/lib/backend/api_requests/api_manager.dart
@@ -7,13 +7,12 @@ import 'dart:io';
import 'dart:typed_data';
import 'package:collection/collection.dart';
-import 'package:http/http.dart' as http;
import 'package:equatable/equatable.dart';
+import 'package:http/http.dart' as http;
import 'package:http_parser/http_parser.dart';
import 'package:mime_type/mime_type.dart';
import '/flutter_flow/uploaded_file.dart';
-
import 'get_streamed_response.dart';
enum ApiCallType {
@@ -411,7 +410,6 @@ class ApiManager {
ApiCallOptions? options,
http.Client? client,
}) async {
-
final callOptions = options ??
ApiCallOptions(
callName: callName,
@@ -512,6 +510,8 @@ class ApiManager {
result = ApiCallResponse(null, {}, -1, exception: e);
}
+ log('Params: $params');
+ log('JsonBody: ${result.jsonBody}');
return result;
}
}
diff --git a/lib/backend/notifications/firebase_messaging_service.dart b/lib/backend/notifications/firebase_messaging_service.dart
new file mode 100644
index 00000000..727c9762
--- /dev/null
+++ b/lib/backend/notifications/firebase_messaging_service.dart
@@ -0,0 +1,73 @@
+import 'dart:developer';
+
+import 'package:firebase_messaging/firebase_messaging.dart';
+import 'package:hub/app_state.dart';
+import 'package:hub/backend/api_requests/api_calls.dart';
+import 'package:hub/shared/utils/log_util.dart';
+
+import 'notification_service.dart';
+
+Future handleMessage(RemoteMessage message) async {
+ NotificationService.show(
+ title: message.notification!.title!,
+ body: message.notification!.body!,
+ payload: Map.from(message.data));
+}
+
+class FirebaseMessagingService {
+ // Singleton instance
+ static final FirebaseMessagingService _instance =
+ FirebaseMessagingService._internal();
+
+ // Factory constructor
+ factory FirebaseMessagingService() => _instance;
+
+ // Private constructor
+ FirebaseMessagingService._internal();
+
+ final _firebaseMessaging = FirebaseMessaging.instance;
+
+ Future initNotifications() async {
+ await _firebaseMessaging.requestPermission();
+
+ _refreshToken();
+
+ _firebaseMessaging.setAutoInitEnabled(false);
+ _firebaseMessaging.pluginConstants;
+
+ FirebaseMessaging.onBackgroundMessage(handleMessage);
+
+ FirebaseMessaging.onMessage.listen((RemoteMessage message) {
+ handleMessage(message);
+ });
+ }
+
+ Future updateDeviceToken() async {
+ try {
+ final String? deviceToken = await _firebaseMessaging.getToken();
+
+ if (deviceToken != null) {
+ AppState().token = deviceToken;
+
+ final ApiCallResponse? response = await PhpGroup.updToken.call(
+ token: AppState().token,
+ devid: AppState().devUUID,
+ useruuid: AppState().userUUID);
+
+ if (PhpGroup.updToken.error((response?.jsonBody ?? '')) == false) {
+ log('Token Atualizado com Sucesso!');
+ } else {
+ log('Falha ao Atualizar Token: ${response?.jsonBody}');
+ }
+ } else {
+ log('Falha ao Pegar Token do Firebase');
+ }
+ } catch (e, s) {
+ LogUtil.requestAPIFailed("updToken.php", "", "Atualizar Token", e, s);
+ }
+ }
+
+ void _refreshToken() {
+ _firebaseMessaging.onTokenRefresh.listen((token) => updateDeviceToken);
+ }
+}
diff --git a/lib/backend/notifications/notification_service.dart b/lib/backend/notifications/notification_service.dart
new file mode 100644
index 00000000..f99e8f99
--- /dev/null
+++ b/lib/backend/notifications/notification_service.dart
@@ -0,0 +1,369 @@
+import 'dart:developer';
+
+import 'package:awesome_notifications/awesome_notifications.dart';
+import 'package:flutter/material.dart';
+import 'package:hub/actions/actions.dart';
+import 'package:hub/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart';
+import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
+import 'package:hub/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart';
+import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
+import 'package:hub/flutter_flow/flutter_flow_theme.dart';
+import 'package:hub/flutter_flow/flutter_flow_util.dart';
+import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
+import 'package:hub/shared/utils/dialog_util.dart';
+
+class NotificationService {
+ static Future initialize() async {
+ await AwesomeNotifications().initialize(
+ null,
+ [
+ NotificationChannel(
+ channelKey: 'basic_channel',
+ channelGroupKey: 'basic_channel',
+ channelName: 'Basic notifications',
+ channelDescription: 'Notification channel for tests',
+ importance: NotificationImportance.Max,
+ channelShowBadge: true,
+ playSound: true,
+ criticalAlerts: true,
+ onlyAlertOnce: true,
+ defaultColor: const Color(0xFF9D58D0),
+ ledColor: Colors.white)
+ ],
+ channelGroups: [
+ NotificationChannelGroup(
+ channelGroupKey: 'basic_channel_group',
+ channelGroupName: 'group_1')
+ ],
+ debug: true);
+ await AwesomeNotifications()
+ .isNotificationAllowed()
+ .then((isAllowed) async {
+ if (!isAllowed) {
+ await AwesomeNotifications().requestPermissionToSendNotifications();
+ }
+ });
+
+ await AwesomeNotifications().setListeners(
+ onActionReceivedMethod: onActionReceivedMethod,
+ onNotificationCreatedMethod: onNotificationCreatedMethod,
+ onNotificationDisplayedMethod: onNotificationDisplayedMethod,
+ onDismissActionReceivedMethod: onDismissActionReceivedMethod);
+ }
+
+ static Future onActionReceivedMethod(
+ ReceivedAction receivedAction) async {
+ // debugPrint('onActionReceivedMethod');
+ // final payload = receivedAction.payload ?? {};
+ // if (payload['navigate'] == 'true') {
+ // locator().navigateToWithParams(notificationRoute, {'title': payload['title']!, 'body': payload['body']!});
+ // }
+ final payload = receivedAction.payload ?? {};
+ final extra = receivedAction.body;
+ final handleClick = payload['click_action'];
+
+ final localId = jsonDecode(payload['local']!)['CLI_ID'];
+ // try {
+ // localId = jsonDecode(payload['local']!)['CLI_ID'];
+ // } catch (e) {
+ // localId = payload['local']['CLI_ID'].toString();
+ // }
+
+ log('payload: $payload');
+ log('extra: $extra');
+ switch (handleClick) {
+ case 'visit_request':
+ showDialog(
+ context: AppState().context!,
+ barrierColor: Colors.transparent,
+ barrierDismissible: true,
+ builder: (BuildContext context) {
+ return Dialog(
+ child: SizedBox(
+ width: MediaQuery.of(context).size.width * 0.8,
+ height: MediaQuery.of(context).size.height * 0.6,
+ child: DetailsComponentWidget(
+ buttons: [
+ FlutterFlowIconButton(
+ icon: const Icon(Icons.done),
+ onPressed: () async {
+ showDialog(
+ context: context,
+ builder: (context) {
+ return AlertDialog(
+ title: Text(
+ FFLocalizations.of(context).getVariableText(
+ ptText: 'Aprovar Visita',
+ enText: 'Approve Visit',
+ ),
+ ),
+ content: Text(
+ FFLocalizations.of(context).getVariableText(
+ ptText:
+ 'Você tem certeza que deseja aprovar essa visita?',
+ enText:
+ 'Are you sure you want to approve this visit?',
+ ),
+ ),
+ backgroundColor: FlutterFlowTheme.of(context)
+ .primaryBackground,
+ actions: [
+ FFButtonWidget(
+ text: FFLocalizations.of(context)
+ .getVariableText(
+ enText: 'No',
+ ptText: 'Não',
+ ),
+ onPressed: () {
+ Navigator.pop(context);
+ },
+ options: FFButtonOptions(
+ width: 100,
+ height: 40,
+ color: FlutterFlowTheme.of(context)
+ .primaryBackground,
+ textStyle: TextStyle(
+ color: FlutterFlowTheme.of(context)
+ .primaryText,
+ ),
+ borderSide: BorderSide(
+ color: FlutterFlowTheme.of(context)
+ .primaryBackground,
+ width: 1,
+ ),
+ borderRadius:
+ BorderRadius.circular(10)),
+ ),
+ FFButtonWidget(
+ text: FFLocalizations.of(context)
+ .getVariableText(
+ enText: 'Yes',
+ ptText: 'Sim',
+ ),
+ onPressed: () async {
+ log("payload: $payload");
+ await answersRequest
+ .call(
+ context,
+ payload['referencia'].toString(),
+ 'L',
+ 'Mensagem',
+ payload['idVisitante'].toString(),
+ )
+ .then((value) {
+ if (value) {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ } else {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ DialogUtil.errorDefault(context);
+ }
+ }).catchError((e) {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ DialogUtil.errorDefault(context);
+ });
+ },
+ options: FFButtonOptions(
+ width: 100,
+ height: 40,
+ color: FlutterFlowTheme.of(context)
+ .primaryBackground,
+ textStyle: TextStyle(
+ color: FlutterFlowTheme.of(context)
+ .primaryText,
+ ),
+ borderSide: BorderSide(
+ color: FlutterFlowTheme.of(context)
+ .primaryBackground,
+ width: 1,
+ ),
+ borderRadius: BorderRadius.circular(10),
+ ),
+ ),
+ ],
+ );
+ });
+ },
+ ),
+ FlutterFlowIconButton(
+ icon: const Icon(Icons.close),
+ onPressed: () async {
+ showAlertDialog(
+ context,
+ FFLocalizations.of(context).getVariableText(
+ ptText: 'Bloquear Visita',
+ enText: 'Block Visit',
+ ),
+ FFLocalizations.of(context).getVariableText(
+ ptText:
+ 'Você tem certeza que deseja bloquear essa visita?',
+ enText:
+ 'Are you sure you want to block this visit?',
+ ), () async {
+ await answersRequest
+ .call(
+ context,
+ payload['referencia'].toString(),
+ 'B',
+ 'Mensagem',
+ payload['idVisitante'].toString(),
+ )
+ .then((value) {
+ if (value) {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ } else {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ DialogUtil.errorDefault(context);
+ }
+ }).catchError((e) {
+ Navigator.pop(context);
+ Navigator.pop(context);
+ DialogUtil.errorDefault(context);
+ });
+ });
+ },
+ ),
+ ],
+ labelsHashMap: Map.from({
+ FFLocalizations.of(context).getVariableText(
+ enText: 'Visitor',
+ ptText: 'Visitante',
+ ): payload['nomevisita'],
+ FFLocalizations.of(context).getVariableText(
+ enText: 'Reason',
+ ptText: 'Motivo',
+ ): payload['motivo'],
+ FFLocalizations.of(context).getVariableText(
+ enText: 'Message',
+ ptText: 'Mensagem',
+ ): payload['mensagem'],
+ }),
+ imagePath:
+ 'https://freaccess.com.br/freaccess/getImage.php?cliID=${AppState().cliUUID}&atividade=getFoto&Documento=${payload['documento'] ?? ''}&tipo=E',
+ statusHashMap: [
+ {
+ FFLocalizations.of(context).getVariableText(
+ enText: 'Active',
+ ptText: 'Ativo',
+ ): FlutterFlowTheme.of(context).warning,
+ },
+ ],
+ ),
+ ),
+ );
+ });
+
+ break;
+ case 'access':
+ showDialog(
+ context: AppState().context!,
+ barrierColor: Colors.transparent,
+ barrierDismissible: true,
+ builder: (BuildContext context) {
+ return Dialog(
+ backgroundColor: Colors.transparent,
+ child: AccessNotificationModalTemplateComponentWidget(
+ datetime: payload['ACE_DATAHORA'].toString(),
+ drive: payload['ACI_DESCRICAO'].toString(),
+ id: payload['USR_TIPO'].toString() == 'O'
+ ? payload['USR_ID'].toString() == ''
+ ? '0'
+ : payload['USR_ID'].toString()
+ : payload['USR_DOCUMENTO'].toString() == ''
+ ? '0'
+ : payload['USR_DOCUMENTO'].toString(),
+ name: payload['PES_NOME'].toString(),
+ type: payload['USR_TIPO'],
+ ),
+ );
+ });
+ break;
+ case 'mensagem':
+ showDialog(
+ context: AppState().context!,
+ barrierColor: Colors.transparent,
+ barrierDismissible: true,
+ builder: (BuildContext context) {
+ return Dialog(
+ child: SizedBox(
+ width: MediaQuery.of(context).size.width * 0.3,
+ height: MediaQuery.of(context).size.height * 0.3,
+ child: MessageNotificationModalTemplateComponentWidget(
+ id: localId,
+ from: payload['remetente'].toString(),
+ to: payload['destinatario'].toString() == 'O'
+ ? 'Morador'
+ : 'Visitante',
+ message:
+ extra.toString().isEmpty ? 'Unknown' : extra.toString(),
+ ),
+ ),
+ );
+ });
+
+ break;
+ default:
+ log('default');
+ break;
+ }
+
+ log("onActionReceivedMethod");
+ // showAlertDialog(AppState().context!, 'Test', 'Test', () async {});
+ }
+
+ static Future onNotificationCreatedMethod(
+ ReceivedNotification receivedNotification) async {
+ log('onNotificationCreatedMethod');
+ }
+
+ static Future onNotificationDisplayedMethod(
+ ReceivedNotification receivedNotification) async {
+ log('onNotificationDisplayedMethod');
+ }
+
+ static Future onDismissActionReceivedMethod(
+ ReceivedAction receivedAction) async {
+ log('onDismissActionReceivedMethod');
+ }
+
+ static Future show({
+ required final String title,
+ required final String body,
+ final String? summary,
+ final Map? payload,
+ final ActionType actionType = ActionType.Default,
+ final NotificationLayout notificationLayout = NotificationLayout.Default,
+ final NotificationCategory? category,
+ final String? bigPicture,
+ final List? actionButtons,
+ final bool scheduled = false,
+ final int? interval,
+ }) async {
+ assert(!scheduled || (scheduled && interval != null));
+ await AwesomeNotifications().createNotification(
+ content: NotificationContent(
+ id: 0,
+ channelKey: 'basic_channel',
+ title: title,
+ body: body,
+ actionType: actionType,
+ notificationLayout: notificationLayout,
+ summary: summary,
+ category: category,
+ payload: payload,
+ bigPicture: bigPicture,
+ ),
+ actionButtons: actionButtons,
+ schedule: scheduled
+ ? NotificationInterval(
+ interval: interval,
+ timeZone:
+ await AwesomeNotifications().getLocalTimeZoneIdentifier(),
+ preciseAlarm: true)
+ : null);
+ }
+}
diff --git a/lib/backend/push_notification/pushNotificationService.dart b/lib/backend/push_notification/pushNotificationService.dart
deleted file mode 100644
index 91410a17..00000000
--- a/lib/backend/push_notification/pushNotificationService.dart
+++ /dev/null
@@ -1,571 +0,0 @@
-import 'dart:async';
-import 'dart:convert';
-import 'dart:developer';
-import 'dart:io';
-import 'dart:math' as math;
-
-import 'package:firebase_messaging/firebase_messaging.dart';
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_local_notifications/flutter_local_notifications.dart';
-import 'package:hub/actions/actions.dart';
-import 'package:hub/app_state.dart';
-import 'package:hub/backend/api_requests/api_calls.dart';
-import 'package:hub/backend/api_requests/api_manager.dart';
-import 'package:hub/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart';
-import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
-import 'package:hub/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart';
-import 'package:hub/components/templates_components/details_component/details_component_widget.dart';
-import 'package:hub/flutter_flow/flutter_flow_icon_button.dart';
-import 'package:hub/flutter_flow/flutter_flow_theme.dart';
-import 'package:hub/flutter_flow/flutter_flow_util.dart';
-import 'package:hub/flutter_flow/flutter_flow_widgets.dart';
-import 'package:hub/flutter_flow/internationalization.dart';
-import 'package:rxdart/rxdart.dart';
-
-//
-
-class PushNotificationService {
- final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance;
- final FlutterLocalNotificationsPlugin _flutterLocalNotificationsPlugin =
- FlutterLocalNotificationsPlugin();
- final Subject _onMessage = BehaviorSubject();
- final BehaviorSubject _context =
- BehaviorSubject();
- final BehaviorSubject