diff --git a/ios/Runner/Helper/HMGPenguinInPlatformBridge.swift b/ios/Runner/Helper/HMGPenguinInPlatformBridge.swift index c4a44243..999447ae 100644 --- a/ios/Runner/Helper/HMGPenguinInPlatformBridge.swift +++ b/ios/Runner/Helper/HMGPenguinInPlatformBridge.swift @@ -1,6 +1,6 @@ import Foundation import FLAnimatedImage - +import PenNavUI var flutterMethodChannelPenguinIn:FlutterMethodChannel? = nil fileprivate var mainViewController:MainFlutterVC! @@ -72,6 +72,7 @@ class HMGPenguinInPlatformBridge{ gifImageView.center = loadingOverlay.center gifImageView.contentMode = .scaleAspectFit loadingOverlay.addSubview(gifImageView) + PenNavUIManager.shared.setBackButtonVisibility(true) if let window = UIApplication.shared.windows.first { @@ -88,6 +89,31 @@ class HMGPenguinInPlatformBridge{ } } + + penguinView.onBackPress = { + let areYouSure : String + let exit : String + let yes : String + let no : String + + areYouSure = NSLocalizedString("are_you_sure", comment: "") + exit = NSLocalizedString("exit", comment: "") + yes = NSLocalizedString("yes", comment: "") + no = NSLocalizedString("no", comment: "") + + // Implement custom behavior, such as displaying a confirmation dialog. + let alert = UIAlertController( + title: String(localized:"exit"), + message: String(localized:"are_you_sure"), + preferredStyle: .alert + ) + alert.addAction(UIAlertAction(title: String(localized: "yes"), style: .default) { _ in + PenNavUIManager.shared.dismiss() + penguinUIView.removeFromSuperview() + }) + alert.addAction(UIAlertAction(title: String(localized: "no"), style: .cancel, handler: nil)) + mainViewController.present(alert, animated: true, completion: nil) + } result(nil) } diff --git a/ios/Runner/Penguin/PenguinView.swift b/ios/Runner/Penguin/PenguinView.swift index b5161eb0..06516d1c 100644 --- a/ios/Runner/Penguin/PenguinView.swift +++ b/ios/Runner/Penguin/PenguinView.swift @@ -43,6 +43,8 @@ class PenguinView: NSObject, FlutterPlatformView, PIEventsDelegate, PenNavInitia private var methodChannel: FlutterMethodChannel var onSuccess: (() -> Void)? + + var onBackPress : (()->Void)? @@ -210,7 +212,9 @@ class PenguinView: NSObject, FlutterPlatformView, PIEventsDelegate, PenNavInitia // MARK: - PIEventsDelegate Methods - + func onBackButtonPressed() { + onBackPress?() + } diff --git a/ios/en.lproj/Localizable.strings b/ios/en.lproj/Localizable.strings new file mode 100644 index 00000000..9784f58f --- /dev/null +++ b/ios/en.lproj/Localizable.strings @@ -0,0 +1,11 @@ +/* + Localizable.strings + Runner + + Created by User on 02/02/2025. + +*/ +"are_you_sure" = "Are you sure you want to close"; +"exit" = "Exit"; +"yes" = "Yes"; +"no" = "No";