Fix "Please adopt containerBackgroundAPI" for iOS 17 Widgets - #21705
Conversation
|
This is not a high priority but I wanted to at least conform to these APIs so we wouldn't need to make quick beta fixes when CI is updated to Xcode 15. |
|
| App Name | WordPress Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21705-1e80d49 | |
| Version | 23.9 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | 1e80d49 | |
| App Center Build | WPiOS - One-Offs #8354 |
|
@guarani review is not necessary right now. CI throws an issue:
It means that we cannot make these changes until Xcode is updated on CI, so we cannot merge it right now. |
guarani
left a comment
There was a problem hiding this comment.
To summarize what we discussed in Slack, p1697208501951699/1697187055.060939-slack-C441E3YTS, oncecontainerBackground was implemented, Lock Screen widgets no longer showed the Please adopt containerBackground API, but Home Screen widgets still do, despite implementing containerBackgroundRemovable and passing in false.
|
My plan is as follows:
|
75c2d00 to
dbb2b6b
Compare
Conforming by implementing containerBackground API. For now, Lock Screen Widgets keep using AccessoryWidgetBackground(), since this background is not supported by removable background.
Home Screen widgets require layout adjustment to support background removal
…ground Small Home Screen Widget can be shown in iPad lock screen on horizontal orientation: - Change the order of title and value - Increase font size of value
dbb2b6b to
7130ef2
Compare
|
FYI: The PR that updates CI to Xcode 15 is targeting Monday's 24.0 release: #21921 We could spend some time this week to get necessary widget changes done for Monday's beta cut. Wdyt? I haven't been focusing on these PRs but I think it makes sense to do so now. |
@guarani, thanks for making a note! Yes, I followed it but I wasn't sure if it would make it on time for 24.0.
Yes, once they merge Xcode 15 updates we'll need to get this PR merged for 24.0 as well. It would be good to build it with Xcode 15 locally and review it so it would be ready. 👍 |
mokagio
left a comment
There was a problem hiding this comment.
I'll start by saying that I haven't looked at the whole code, so apologies if the question has an easy answer. But I wonder if any of this could go into JetpackStatsWidgetsCore.
Great question, @mokagio. I'll check! I made this PR 3 months ago to prepare for Xcode 15 updates when this module didn't exist. |
…or-widgets-xcode-15-ios-17
I checked the affected files and I don't think any of them needs to go to |
| init(viewData: GroupedViewData) { | ||
| self.title = viewData.widgetTitle | ||
| self.description = viewData.siteName | ||
| self.valueTitle = viewData.upperLeftTitle | ||
| self.value = viewData.upperLeftValue | ||
| } |
There was a problem hiding this comment.
Did you consider delegating to self.init(title:...?
There was a problem hiding this comment.
Good observation. I'll use self.init..
| .configurationDisplayName(config.displayName) | ||
| .description(config.description) | ||
| .supportedFamilies(config.supportFamilies) | ||
| .iOS17ContentMarginsDisabled() /// Temporarily disable additional iOS17 margins for widgets |
There was a problem hiding this comment.
Super nitpick, /// is a documentation comment, as opposed to the standard //. With /// Xcode and other tools will render the comment as documentation reading tags and markdown. However, the comment needs to be on a type or method declaration. We don't need to "document" method calls. I just wanted to point it out but I don't expect this to be addressed. 👍 😄
…-widgets-xcode-15-ios-17 This is necessary to get up to date with a CI configuration change that requires running on Xcode 15.1. See #22270
| .fontWeight(fontWeight) | ||
| .foregroundColor(foregroundColor) | ||
| .lineLimit(lineLimit) | ||
| .minimumScaleFactor(0.5) |
There was a problem hiding this comment.
0.5 is an arbitrary value, could be smaller or a bit larget as well.
Previously created rectangular widgets can now appear without a background on iPadOS Horizontal Lock Screen. Since they appear without a background, I increased font sizes to have less space and resemble the look of other widgets without a background.
However, when numbers become large, I want font to Value font to shrink, to be fully displayed.
|
@staskus thank you for looking into whether some files could go into the module.
Yes, and also any kind of standalone logic that we might want (ought to!) unit test. We can't run unit tests on app extension targets, so anything we want to test should go into that Swift Package. As far as I can see, this PR is all about SwiftUI configurations so there's nothing that fits that criteria either 👍 |
|
| App Name | Jetpack Alpha |
|
| Configuration | Release-Alpha | |
| Build Number | pr21705-1e80d49 | |
| Version | 23.9 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | 1e80d49 | |
| App Center Build | jetpack-installable-builds #7377 |
| .accessibilityElement(children: .combine) | ||
| } else { | ||
| Text("Not implemented for widget family \(family.debugDescription)") | ||
| .removableWidgetBackground() |
There was a problem hiding this comment.
Just curious about the Swift UI architecture, which is not my strong suit. Would it have been possible to group the conditional logic, e.g. in an *Stack, to only write the removableWidgetBackground() transformation once?
There was a problem hiding this comment.
Good question. I think it would be possible 👍
mokagio
left a comment
There was a problem hiding this comment.
Run it on the Simulator with Xcode 15.1 after merging trunk into this branch. Everything looks good as far as I can see, but I have little context around the expected widgets look and feel.
Let's merge this so it's part of 24.0, get feedback from @osullivanchris (Chris has already commented on the widgets, see pc8eDl-14z-p2), and address possible tweaks as beta fixes.
iPhone
|
|
|
iPad
|
|
|
Thanks for the review, @mokagio! I can merge it to 24.0. This PR was all about basic iOS 17 support. It meant supporting I agree we can make other tweaks after we merge this PR. |
|
I think the fact the latest build on this branch was cancelled made all the CI checks go "Errored" I started a new one so we can merge this ASAP. @staskus what do you mean with "I can merge it to 24.0." and with the "[Status] Blocked" label? I read this as "there's a reason why we shouldn't merge it to |
Okay. Sorry, there was a bit of a misunderstanding. I missed the fact you already merged it with trunk. Yes, we can merge it whenever CI succeeds. 👍 |
|
I forgot to review on Friday 🙈 Thanks for handling this folks! |
















Partially addresses #21672
The goal of this PR is to conform to the new iOS 17 Widget APIs to avoid "Please adopt containerBackgroundAPI" message:
containerBackgroundfor conformance. This API does not support the usage ofAccessoryWidgetBackground, therefore I decided to remove the background altogether to fit the current design guidelinesI want to make even better iOS 17 support in the short-term future. Plus, we probably should make naming changes, given HomeScreen widgets work on iPadOS Lock Screen as well.
To test:
Regression Notes
Should be none, Widgets should work and appear as before
Manual testing
PR submission checklist:
RELEASE-NOTES.txtif necessary.UI Changes testing checklist: