From 6c4567fe86977c4800c3f58f25a21de8cdebd76e Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 1 Dec 2022 12:57:42 +0100 Subject: [PATCH 1/5] Remove one redundant `#available(iOS 13, *)` check It always return `true` since the deployment version is 13.0, and will soon become 14.0. --- .../WordPressShareExtension/MainShareViewController.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/WordPress/WordPressShareExtension/MainShareViewController.swift b/WordPress/WordPressShareExtension/MainShareViewController.swift index bb6ce79614ef..65723923efbe 100644 --- a/WordPress/WordPressShareExtension/MainShareViewController.swift +++ b/WordPress/WordPressShareExtension/MainShareViewController.swift @@ -96,8 +96,7 @@ private extension MainShareViewController { let shareNavController = UINavigationController(rootViewController: editorController) - if #available(iOS 13, *), editorController.originatingExtension == .saveToDraft { - // iOS 13 has proper animations and presentations for share and action sheets. So the `else` case should be removed when iOS 13 is minimum. + if editorController.originatingExtension == .saveToDraft { // We need to make sure we don't end up with stacked modal view controllers by using this: shareNavController.modalPresentationStyle = .overFullScreen } else { From 4dcd17a2be8f8f9bfeda51c90bcecc25c88ad737 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 1 Dec 2022 16:48:20 +0100 Subject: [PATCH 2/5] Add note about `UINavigationBar.appearance()` usage --- .../WordPressShareExtension/MainShareViewController.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPress/WordPressShareExtension/MainShareViewController.swift b/WordPress/WordPressShareExtension/MainShareViewController.swift index 65723923efbe..d6870c47590b 100644 --- a/WordPress/WordPressShareExtension/MainShareViewController.swift +++ b/WordPress/WordPressShareExtension/MainShareViewController.swift @@ -77,6 +77,10 @@ private extension MainShareViewController { view.backgroundColor = .basicBackground } + // Notice that this will set the apparence of _all_ `UINavigationBar` instances. + // + // Such a catch-all approach wouldn't be good in the context of a fully fledged application, + // but is acceptable here, given we are in an app extension. let navigationBarAppearace = UINavigationBar.appearance() navigationBarAppearace.isTranslucent = false navigationBarAppearace.tintColor = .appBarTint From d00af630146b5d2cb339f254259104bb24e9d617 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 1 Dec 2022 16:54:38 +0100 Subject: [PATCH 3/5] Set the navigation bar background color for the share extension --- .../MainShareViewController.swift | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/WordPress/WordPressShareExtension/MainShareViewController.swift b/WordPress/WordPressShareExtension/MainShareViewController.swift index d6870c47590b..591c09c7a364 100644 --- a/WordPress/WordPressShareExtension/MainShareViewController.swift +++ b/WordPress/WordPressShareExtension/MainShareViewController.swift @@ -72,11 +72,6 @@ class MainShareViewController: UIViewController { private extension MainShareViewController { func setupAppearance() { - if editorController.originatingExtension == .saveToDraft { - // This should probably be showing over current context but this just matches previous behavior - view.backgroundColor = .basicBackground - } - // Notice that this will set the apparence of _all_ `UINavigationBar` instances. // // Such a catch-all approach wouldn't be good in the context of a fully fledged application, @@ -86,6 +81,26 @@ private extension MainShareViewController { navigationBarAppearace.tintColor = .appBarTint navigationBarAppearace.barTintColor = .appBarBackground navigationBarAppearace.barStyle = .default + + // Extension-specif settings + // + // This view controller is shared via target membership by multiple extensions, resulting + // in the need to apply some extension-specific settings. + // + // If we had the time, it would be great to extract all this logic in a standalone + // framework or package, and then make the individual extensions import it, and instantiate + // and configure the view controller to their liking, without making the code more complex + // with branch-logic such as this. + switch editorController.originatingExtension { + case .saveToDraft: + // This should probably be showing over current context but this just matches previous + // behavior. + view.backgroundColor = .basicBackground + case .share: + // Without this, the modal view controller will have a semi-transparent bar with a + // very low alpha, making it close to fully transparent. + navigationBarAppearace.backgroundColor = .basicBackground + } } func loadAndPresentNavigationVC() { @@ -103,9 +118,6 @@ private extension MainShareViewController { if editorController.originatingExtension == .saveToDraft { // We need to make sure we don't end up with stacked modal view controllers by using this: shareNavController.modalPresentationStyle = .overFullScreen - } else { - shareNavController.transitioningDelegate = extensionTransitioningManager - shareNavController.modalPresentationStyle = .custom } present(shareNavController, animated: true) From 29cd6274eb67a86441fdc6091a78779cd1e8db6e Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 1 Dec 2022 17:27:21 +0100 Subject: [PATCH 4/5] Use `.overCurrentContext` to present both Share and Save to Draft Using `.overFullScreen` or leaving `.automatic` resulted in Share being dismissable via swipe but that didn't restore Safari to the share menu, leaving it instead blocked as if the presented VC was still there. `.overCurrentContext` has no effect on the Save to Draft behavior, leaving it the same as when using `.overFullScreen`. On iPad, this setting result in both extensions not being full screen. Otherwise, Share would have been full screen while Save to Draft wouldn't. --- .../WordPressShareExtension/MainShareViewController.swift | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/WordPress/WordPressShareExtension/MainShareViewController.swift b/WordPress/WordPressShareExtension/MainShareViewController.swift index 591c09c7a364..95524a2b7ce6 100644 --- a/WordPress/WordPressShareExtension/MainShareViewController.swift +++ b/WordPress/WordPressShareExtension/MainShareViewController.swift @@ -115,10 +115,8 @@ private extension MainShareViewController { let shareNavController = UINavigationController(rootViewController: editorController) - if editorController.originatingExtension == .saveToDraft { - // We need to make sure we don't end up with stacked modal view controllers by using this: - shareNavController.modalPresentationStyle = .overFullScreen - } + // We need to make sure we don't end up with stacked modal view controllers by using this: + shareNavController.modalPresentationStyle = .overCurrentContext present(shareNavController, animated: true) } From 237e5db73decc820ce3ed8e8f418312fb29cacab Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 1 Dec 2022 17:47:01 +0100 Subject: [PATCH 5/5] Add entry for #19700 to `RELEASE-NOTES.txt` --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index e5f3947817ee..94458d87bd8b 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,6 +1,6 @@ 21.4 ----- - +* [*] Share extension navigation bar is no longer transparent [#19700] 21.3 -----