WD: penguin view navigation to clinic id added and username modified.

merge-update-with-lab-changes
taha.alam 1 year ago
parent 7ca806571f
commit ae7fbbfb98

@ -37,6 +37,7 @@ class PenguinInPlatformBridge(
args,
flutterEngine.dartExecutor.binaryMessenger,
activity = mainActivity,
channel
)
}
}

@ -0,0 +1,13 @@
package com.cloud.diplomaticquarterapp.penguin
enum class PenguinMethod {
// initializePenguin("initializePenguin"),
// configurePenguin("configurePenguin"),
// showPenguinUI("showPenguinUI"),
// onPenNavUIDismiss("onPenNavUIDismiss"),
// onReportIssue("onReportIssue"),
// onPenNavSuccess("onPenNavSuccess"),
onPenNavInitializationError // onLocationOffCampus("onLocationOffCampus"),
// navigateToPOI("navigateToPOI"),
// openSharedLocation("openSharedLocation");
}

@ -41,7 +41,8 @@ internal class PenguinView(
id: Int,
val creationParams: Map<String, Any>,
messenger: BinaryMessenger,
activity: MainActivity
activity: MainActivity,
val channel: MethodChannel
) : PlatformView, MethodChannel.MethodCallHandler, PenNavUIDelegate {
// The layout for displaying the Penguin UI
private val mapLayout: RelativeLayout = RelativeLayout(context)
@ -200,7 +201,7 @@ internal class PenguinView(
.setLanguageID(language)
.setSimulationModeEnabled(creationParams["isSimulationModeEnabled"] as Boolean)
.setEnableBackButton(true)
.setDeepLinkData("deeplink")
// .setDeepLinkData("deeplink")
.setCustomizeColor("#2CA0AF")
.setDeepLinkSchema("")
.build()
@ -238,7 +239,7 @@ internal class PenguinView(
// referenceId = refID
navigator.navigateTo(mContext, "",object : RefIdDelegate {
navigator.navigateTo(mContext, refID,object : RefIdDelegate {
override fun onRefByIDSuccess(PoiId: String?) {
Log.e("navigateTo", "PoiId is penguin view+++++++ $PoiId")
@ -273,19 +274,11 @@ internal class PenguinView(
* @param warningCode Optional warning code received from the SDK.
*/
override fun onPenNavSuccess(warningCode: String?) {
val clinicId = creationParams["clinic_id"] as String
navigateTo("123")
// if (_context is Activity) {
// _context.runOnUiThread {
// Toast.makeText(_context, "Success Info: $warningCode", Toast.LENGTH_SHORT).show()
// }
// } else {
// println("the warming is presented $$warningCode")
//// val handler = Handler(Looper.getMainLooper())
//// handler.post {
//// Toast.makeText(_context, "Success Info: $warningCode", Toast.LENGTH_SHORT).show()
//// }
// }
if(clinicId.isEmpty()) return
navigateTo(clinicId)
}
/**
@ -298,6 +291,12 @@ internal class PenguinView(
description: String?,
errorType: InitializationErrorType?
) {
val arguments: Map<String, Any?> = mapOf(
"description" to description,
"type" to errorType?.name
)
channel.invokeMethod(PenguinMethod.onPenNavInitializationError.name, arguments)
Toast.makeText(mContext, "Navigation Error: $description", Toast.LENGTH_SHORT).show()
}

@ -16,7 +16,7 @@ class PenguinMethodChannel {
"dataServiceName": "api",
"positionServiceName": "pe",
"clientID": "PIF",
"username": "Test",
"username": "test",
"isSimulationModeEnabled": true,
"isShowUserName": false,
"isUpdateUserLocationSmoothly": true,
@ -32,6 +32,61 @@ class PenguinMethodChannel {
print("Failed to launch PenguinIn: '${e.message}'.");
}
}
void setMethodCallHandler(){
_channel.setMethodCallHandler((MethodCall call) async {
try {
print(call.method);
switch (call.method) {
case PenguinMethodNames.onPenNavInitializationError:
_handleInitializationError(call.arguments); // Handle onPenNavInitializationError errors.
break;
case PenguinMethodNames.onPenNavUIDismiss:
//todo handle pen dismissable
// _handlePenNavUIDismiss(); // Handle UI dismissal event.
break;
case PenguinMethodNames.onReportIssue:
// Handle the report issue event.
_handleInitializationError(call.arguments);
break;
default:
_handleUnknownMethod(call.method); // Handle unknown method calls.
}
} catch (e) {
print("Error handling method call '${call.method}': $e");
// Optionally, log this error to an external service
}
});
}
static void _handleUnknownMethod(String method) {
print("Unknown method: $method");
// Optionally, handle this unknown method case, such as reporting or ignoring it
}
static void _handleInitializationError(Map<dynamic, dynamic> error) {
final type = error['type'] as String?;
final description = error['description'] as String?;
print("Initialization Error: ${type ?? 'Unknown Type'}, ${description ?? 'No Description'}");
}
}
// Define constants for method names
class PenguinMethodNames {
static const String showPenguinUI = 'showPenguinUI';
static const String openSharedLocation = 'openSharedLocation';
// ---- Handler Method
static const String onPenNavSuccess = 'onPenNavSuccess'; // Tested Android,iOS
static const String onPenNavInitializationError = 'onPenNavInitializationError'; // Tested Android,iOS
static const String onPenNavUIDismiss = 'onPenNavUIDismiss'; //Tested Android,iOS
static const String onReportIssue = 'onReportIssue'; // Tested Android,iOS
static const String onLocationOffCampus = 'onLocationOffCampus'; // Tested iOS,Android
static const String navigateToPOI = 'navigateToPOI'; // Tested Android,iOS
}

Loading…
Cancel
Save