summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-05-12 15:30:49 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-05-18 10:48:13 +0200
commit9171f7633e6cbf686f0ddbe4aa2f126e2d634513 (patch)
tree9973c6a4a8d08cc80844abe437d102223ad95d5a
parent619b5d84e74aa60ba4eed254d3c991c1b7a3598d (diff)
downloadmullvadvpn-9171f7633e6cbf686f0ddbe4aa2f126e2d634513.tar.xz
mullvadvpn-9171f7633e6cbf686f0ddbe4aa2f126e2d634513.zip
AutomaticKeyboard: improve form sheet detection when contained inside of other controller
-rw-r--r--ios/MullvadVPN/AutomaticKeyboardResponder.swift20
1 files changed, 18 insertions, 2 deletions
diff --git a/ios/MullvadVPN/AutomaticKeyboardResponder.swift b/ios/MullvadVPN/AutomaticKeyboardResponder.swift
index 04518a40ef..eef063261d 100644
--- a/ios/MullvadVPN/AutomaticKeyboardResponder.swift
+++ b/ios/MullvadVPN/AutomaticKeyboardResponder.swift
@@ -111,8 +111,24 @@ class AutomaticKeyboardResponder {
}
private var isFormSheetPresentation: Bool {
- return UIDevice.current.userInterfaceIdiom == .pad &&
- parentViewController?.modalPresentationStyle == .formSheet
+ // Form sheet is only supported on iPad
+ guard UIDevice.current.userInterfaceIdiom == .pad else { return false }
+
+ // Find the parent controller holding the view
+ guard let parent = parentViewController else { return false }
+
+ // Determine presentation style within the context
+ let presentationStyle: UIModalPresentationStyle
+
+ // Use the presentation style of a presented controller when parent controller is being presented as a child of
+ // other modal controller.
+ if let presented = parent.presentingViewController?.presentedViewController {
+ presentationStyle = presented.modalPresentationStyle
+ } else {
+ presentationStyle = parent.modalPresentationStyle
+ }
+
+ return presentationStyle == .formSheet
}
private func adjustContentInsets(keyboardRect: CGRect) {