From 1c663510110e5f9012d27498dabd1e2fb31dfbfc Mon Sep 17 00:00:00 2001 From: Haroon Amjad <> Date: Sun, 15 Sep 2024 20:20:16 +0300 Subject: [PATCH] Updates & fixes --- ios/Runner/Penguin/PenguinView.swift | 44 ++++++++++++++----- .../widgets/AppointmentActions.dart | 3 +- lib/pages/ToDoList/ToDo.dart | 3 +- lib/uitl/penguin_method_channel.dart | 1 + 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ios/Runner/Penguin/PenguinView.swift b/ios/Runner/Penguin/PenguinView.swift index 4af186ae..81377f7b 100644 --- a/ios/Runner/Penguin/PenguinView.swift +++ b/ios/Runner/Penguin/PenguinView.swift @@ -151,35 +151,55 @@ class PenguinView: NSObject, FlutterPlatformView print("====== after present onPenNavSuccess =========") guard let config = self.model else { - print("Error: Config Model is nil") - return - } + print("Error: Config Model is nil") + return + } + + guard let clinicID = self.model?.clinicID, + let clientID = self.model?.clientID, !clientID.isEmpty else { + print("Error: Config Client ID is nil or empty") + return + } - let navigator = PenguinNavigator(config: config) - + PenNavUIManager.shared.getToken(clientID: config.clientID, clientKey: config.clientKey) { [weak self] token, error in if let error = error { let errorMessage = "Token error while getting the for Navigate to method" - // completion(false, "Failed to get token: \(errorMessage)") print("Failed to get token: \(errorMessage)") return } - + guard let token = token else { - // completion(false, "Token is nil") print("Token is nil") return } print("Token Generated") print(token); - PenNavUIManager.shared.setToken(token: token) - + self?.handleNavigation(clinicID: clinicID, token: token) { success, errorMessage in + if success { + print("Navigation successful") + } else { + print("Navigation failed: \(errorMessage ?? "Unknown error")") + } + + } + + print("====== after Token onPenNavSuccess =========") } - PenNavUIManager.shared.navigate(to: config.clinicID) - print("====== after Token onPenNavSuccess =========") + + } + + + + private func handleNavigation(clinicID: String, token: String, completion: @escaping (Bool, String?) -> Void) { + DispatchQueue.main.async { + PenNavUIManager.shared.setToken(token: token) + PenNavUIManager.shared.navigate(to: clinicID) + completion(true,nil) } + } diff --git a/lib/pages/MyAppointments/widgets/AppointmentActions.dart b/lib/pages/MyAppointments/widgets/AppointmentActions.dart index d7d50847..fcb698b3 100644 --- a/lib/pages/MyAppointments/widgets/AppointmentActions.dart +++ b/lib/pages/MyAppointments/widgets/AppointmentActions.dart @@ -191,7 +191,8 @@ class _AppointmentActionsState extends State { initPenguinSDK() async { NavigationClinicDetails data = NavigationClinicDetails(); - data.clinicId = widget.appo.clinicID.toString(); + // data.clinicId = widget.appo.clinicID.toString(); + data.clinicId = "49"; data.patientId = widget.appo.patientID.toString(); data.projectId = widget.appo.projectID.toString(); final bool permited = await AppPermission.askPenguinPermissions(); diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 981fd36f..a7747ceb 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -381,7 +381,8 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { InkWell( onTap: () { NavigationClinicDetails data = NavigationClinicDetails(); - data.clinicId = appoList[index].clinicID.toString(); + // data.clinicId = appoList[index].clinicID.toString(); + data.clinicId = "46"; data.patientId = appoList[index].patientID.toString(); data.projectId = appoList[index].projectID.toString(); initPenguinSDK(data); diff --git a/lib/uitl/penguin_method_channel.dart b/lib/uitl/penguin_method_channel.dart index 985b1e42..5033bfb1 100644 --- a/lib/uitl/penguin_method_channel.dart +++ b/lib/uitl/penguin_method_channel.dart @@ -23,6 +23,7 @@ class PenguinMethodChannel { "languageCode": languageCode, "clientKey": "UGVuZ3VpbklOX1Blbk5hdl9QSUY=", "mapBoxKey": "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg", + // "clinicID": details?.clinicId ?? "", "clinicID": details?.clinicId ?? "", "patientID": details?.patientId ?? "", "projectID": details?.projectId ?? "",