-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove redundant #available(iOS 13, *) checks
#19513
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
Changes from 1 commit
d209f93
da7bd21
220efe0
6d49db7
cd07203
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -93,12 +93,7 @@ class GutenGhostView: UIView { | |||||
| } | ||||||
|
|
||||||
| private extension UIColor { | ||||||
| static var ghostToolbarBackground: UIColor { | ||||||
| if #available(iOS 13, *) { | ||||||
| return UIColor(light: .clear, dark: UIColor.colorFromHex("2e2e2e")) | ||||||
| } | ||||||
| return .clear | ||||||
| } | ||||||
| static var ghostToolbarBackground: UIColor = UIColor(light: .clear, dark: UIColor.colorFromHex("2e2e2e")) | ||||||
|
||||||
| static var ghostToolbarBackground: UIColor = UIColor(light: .clear, dark: UIColor.colorFromHex("2e2e2e")) | |
| static let ghostToolbarBackground: UIColor = UIColor(light: .clear, dark: UIColor.colorFromHex("2e2e2e")) |
PS: I'm surprised that you can do that in an extension as you can't add instance variable / storage in extension… but not sure about add static ones on the type, so maybe that's ok because of static? (I must be rusty in Swift already…)
If that's not allowed, I'd assume that restriction applies equally to static let and static var storages, and so neither code would compile, and the solution would be to go back to a computed variable static var ghostToolbarBackground: UIColor { .init(…) } instead. But CI seems to be compiling the code happily, so, that's probably ok after all?
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.
Yes, it is allowed.
I wouldn't be surprised if it was a recent Swift change though, because I remember running into the constraint of not being able to add stored properties in extension in the past. Or, maybe I never tried to do it with static.
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.
I wouldn't be surprised if it was a recent Swift change though, because I remember running into the constraint of not being able to add stored properties in extension in the past. Or, maybe I never tried to do it with
static.
Might actually be a case of me never running into this with static or always assuming it worked the same as with instance. There is at least one StackOverflow answer using static left in an extension, dated 2014.
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.
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.
Ah, yeah, that makes sense I guess.
I totally get why there is this limitation for var instance variables. But given that let are constants, and thus not taking storage space on the instance and thus not modifying the underlying memory layout of an instance of the type, I wonder why instance constants let are not allowed tbh (after all, they could be seen as synonyms to var potato: String { "potato" }, at least in behavior…).
Maybe this will be allowed in a future version of Swift though?
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -96,14 +96,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 | ||||
|
Contributor
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. @mokagio you still need to keep 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. See why I need tests?!?!
Contributor
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. Oh wait, and now I just read the So maybe you were right to remove the Though that comment still begs the question, if we remove that @bjtitus, as the author of that code back in #13146 (even if this was 3 years ago and you moved to other products since…), maybe you remember?
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. The release notes in that PR list
Skimming the PR description, I think the I'll verify the behavior for the two extensions and in both versions of the code and report. Stay tuned.
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. With the code at Save as Draft Share Share doesn't look right. Might need more work. The first thing I'll try will be removing the
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.
|
||||
| } | ||||
| // We need to make sure we don't end up with stacked modal view controllers by using this: | ||||
| shareNavController.modalPresentationStyle = .overFullScreen | ||||
|
||||
|
|
||||
| present(shareNavController, animated: true) | ||||
| } | ||||
|
|
||||

Uh oh!
There was an error while loading. Please reload this page.