-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix share extension navigation bar being transparent #19700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mokagio
merged 5 commits into
trunk
from
mokagio/remove-ios-13-available-share-extension
Dec 2, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6c4567f
Remove one redundant `#available(iOS 13, *)` check
mokagio 4dcd17a
Add note about `UINavigationBar.appearance()` usage
mokagio d00af63
Set the navigation bar background color for the share extension
mokagio 29cd627
Use `.overCurrentContext` to present both Share and Save to Draft
mokagio 237e5db
Add entry for #19700 to `RELEASE-NOTES.txt`
mokagio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| 21.4 | ||
| ----- | ||
|
|
||
| * [*] Share extension navigation bar is no longer transparent [#19700] | ||
|
|
||
| 21.3 | ||
| ----- | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,16 +72,35 @@ 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, | ||
| // but is acceptable here, given we are in an app extension. | ||
| let navigationBarAppearace = UINavigationBar.appearance() | ||
| navigationBarAppearace.isTranslucent = false | ||
| 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() { | ||
|
|
@@ -96,14 +115,8 @@ 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. | ||
| // 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 | ||
| } | ||
| // We need to make sure we don't end up with stacked modal view controllers by using this: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π notice the removal of the double space between "We" and "need" π€ |
||
| shareNavController.modalPresentationStyle = .overCurrentContext | ||
|
|
||
| present(shareNavController, animated: true) | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExtensionTransitioningManageris now unused. I didn't remove it in the context of this PR because removing it triggers a cascade of removals which felt more appropriate for a dedicated PR.