Skip to content

Fix "Please adopt containerBackgroundAPI" for iOS 17 Widgets - #21705

Merged
staskus merged 14 commits into
trunkfrom
fix/please-adopt-container-background-api-for-widgets-xcode-15-ios-17
Jan 8, 2024
Merged

Fix "Please adopt containerBackgroundAPI" for iOS 17 Widgets#21705
staskus merged 14 commits into
trunkfrom
fix/please-adopt-container-background-api-for-widgets-xcode-15-ios-17

Conversation

@staskus

@staskus staskus commented Oct 9, 2023

Copy link
Copy Markdown
Contributor

Partially addresses #21672

The goal of this PR is to conform to the new iOS 17 Widget APIs to avoid "Please adopt containerBackgroundAPI" message:

  • Implement an empty containerBackground for conformance. This API does not support the usage of AccessoryWidgetBackground, therefore I decided to remove the background altogether to fit the current design guidelines
  • Update UI of HomeScreenWidget to support removable background
  • Temporarily disabled iOS 17 margins to support StandBy mode

I 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:

  • Lock Screen and Home screen widgets should work as before
  • Home Screen widgets and Lock Screen Widgets should now be available on iPadOS Lock Screen vertical and horizontal versions

image

Regression Notes

  1. Potential unintended areas of impact

Should be none, Widgets should work and appear as before

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

Manual testing

  1. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

UI Changes testing checklist:

  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@staskus staskus added [Type] Task Widgets Anything related to Home Screen widgets labels Oct 9, 2023
@staskus
staskus requested a review from guarani October 9, 2023 15:15
@staskus

staskus commented Oct 9, 2023

Copy link
Copy Markdown
Contributor Author

@guarani

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.

@wpmobilebot

wpmobilebot commented Oct 9, 2023

Copy link
Copy Markdown
Contributor
WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr21705-1e80d49
Version23.9
Bundle IDorg.wordpress.alpha
Commit1e80d49
App Center BuildWPiOS - One-Offs #8354
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@staskus staskus added this to the 23.5 milestone Oct 9, 2023
@staskus
staskus removed the request for review from guarani October 10, 2023 08:20
@staskus

staskus commented Oct 10, 2023

Copy link
Copy Markdown
Contributor Author

@guarani review is not necessary right now.

CI throws an issue:

value of type 'some WidgetConfiguration' has no member 'contentMarginsDisabled'

It means that we cannot make these changes until Xcode is updated on CI, so we cannot merge it right now.

@staskus staskus modified the milestones: 23.5, Pending Oct 12, 2023
@staskus
staskus requested a review from guarani October 13, 2023 13:39
Comment thread WordPress/JetpackStatsWidgets/Widgets/HomeWidgetAllTime.swift Outdated

@guarani guarani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@staskus

staskus commented Oct 18, 2023

Copy link
Copy Markdown
Contributor Author

Home Widgets (System Small)

I added to support background removal APIs to Small Home Screen Widgets. For them to appear nicely, I changed the order of value title and value and made the value font larger. They can be added on the iPad Lock Screen with a Horizontal Orientation.

These are the 2 variations that system small widgets can be presented in:

Small (Lock Screen) Small (Home Screen)

The inspiration was a weather widget example:

weather 2 Weather Beforre

Lock Screen Widgets (Accessory Rectangular)

To make the selection consistent with iOS 17 design guidelines and newest widgets, I think the best option is to remove the background altogether:

IMG_1040

Now all these widgets can be displayed together on the iPad Lock Screen:

Simulator Screenshot - iPad Air (5th generation) - 2023-10-18 at 11 34 01

@staskus

staskus commented Oct 19, 2023

Copy link
Copy Markdown
Contributor Author

@guarani

My plan is as follows:

  1. Get feedback from designers about widgets without background pc8eDl-14z-p2#comment-935
  2. Split this PR into two: 1) Widget Lock Screen Widget UI updates without a background and 2) iOS 17 APIs conformance
  3. Review, test & merge PR 1) since it would not require Xcode changes, mostly it would remove background from lock screen widgets
  4. Review, test & merge Lock Screen Widgets: This Week Chart Widget #21514, since it would be counter-productive to test it while this PR is still ongoing
  5. Ideally, we would ship lock screen widget background updates and this week widget with 23.6
  6. Once we enable Xcode 15, merge 2) iOS 17 APIs conformance PR.

@staskus
staskus force-pushed the fix/please-adopt-container-background-api-for-widgets-xcode-15-ios-17 branch from 75c2d00 to dbb2b6b Compare October 20, 2023 08:49
@staskus
staskus marked this pull request as draft October 20, 2023 13:28
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
@staskus
staskus force-pushed the fix/please-adopt-container-background-api-for-widgets-xcode-15-ios-17 branch from dbb2b6b to 7130ef2 Compare October 23, 2023 10:34
@guarani

guarani commented Jan 2, 2024

Copy link
Copy Markdown
Contributor

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.

@staskus

staskus commented Jan 2, 2024

Copy link
Copy Markdown
Contributor Author

FYI: The PR that updates CI to Xcode 15 is targeting Monday's 24.0 release: #21921

@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.

Wdyt? I haven't been focusing on these PRs but I think it makes sense to do so now.

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. 👍

@staskus staskus mentioned this pull request Jan 3, 2024
4 tasks

@mokagio mokagio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@staskus

staskus commented Jan 3, 2024

Copy link
Copy Markdown
Contributor Author

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.

@staskus

staskus commented Jan 5, 2024

Copy link
Copy Markdown
Contributor Author

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.

I checked the affected files and I don't think any of them needs to go to JetpackStatsWidgetCore. Changes are only to Stats Widget UI code which can continue belonging to JetpackStatsWidgets. JetpackStatsWidgetCore should contain data types and functionality that needs to be reused between targets.

Comment on lines +12 to +17
init(viewData: GroupedViewData) {
self.title = viewData.widgetTitle
self.description = viewData.siteName
self.valueTitle = viewData.upperLeftTitle
self.value = viewData.upperLeftValue
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider delegating to self.init(title:...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation. I'll use self.init..

.configurationDisplayName(config.displayName)
.description(config.description)
.supportedFamilies(config.supportFamilies)
.iOS17ContentMarginsDisabled() /// Temporarily disable additional iOS17 margins for widgets

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 0.5?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Without minimumScaleFactor:
image

With minimumScaleFactor:
image

@mokagio

mokagio commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

@staskus thank you for looking into whether some files could go into the module.

JetpackStatsWidgetCore should contain data types and functionality that needs to be reused between targets.

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 👍

@wpmobilebot

wpmobilebot commented Jan 8, 2024

Copy link
Copy Markdown
Contributor
Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr21705-1e80d49
Version23.9
Bundle IDcom.jetpack.alpha
Commit1e80d49
App Center Buildjetpack-installable-builds #7377
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

.accessibilityElement(children: .combine)
} else {
Text("Not implemented for widget family \(family.debugDescription)")
.removableWidgetBackground()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I think it would be possible 👍

@mokagio mokagio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Screenshot 2024-01-08 at 16 37 04 image Screenshot 2024-01-08 at 16 43 45

iPad

Screenshot 2024-01-08 at 16 52 40 Screenshot 2024-01-08 at 16 53 38

@staskus

staskus commented Jan 8, 2024

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @mokagio!

I can merge it to 24.0.

This PR was all about basic iOS 17 support. It meant supporting removableWidgetBackground and also making sure existing medium and large widgets could appear without a background on the iPad OS Horizontal Lock Screen.

I agree we can make other tweaks after we merge this PR.

@staskus
staskus marked this pull request as ready for review January 8, 2024 06:31
@mokagio

mokagio commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

I think the fact the latest build on this branch was cancelled made all the CI checks go "Errored"

image

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 trunk right now" but I don't see what the reason is 🤔

@staskus

staskus commented Jan 8, 2024

Copy link
Copy Markdown
Contributor Author

I started a new one so we can merge this ASAP.

@mokagio

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. 👍

@staskus
staskus enabled auto-merge January 8, 2024 06:57
@staskus
staskus merged commit 6326dfc into trunk Jan 8, 2024
@staskus
staskus deleted the fix/please-adopt-container-background-api-for-widgets-xcode-15-ios-17 branch January 8, 2024 07:23
@guarani

guarani commented Jan 8, 2024

Copy link
Copy Markdown
Contributor

I forgot to review on Friday 🙈 Thanks for handling this folks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Task Widgets Anything related to Home Screen widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants