Skip to content

[WCiOS17] Update .onchange() usage to iOS17 API #16002

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

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Aug 12, 2025

Part of WOOMOB-1003

Description

This PR addresses ~50 warnings related to the .onChange usage across Order creation and POS, by moving them to use the new iOS17+ API.

The previous API has been updated and deprecated from forcing us to use 1 parameter, to instead:

  • Use a zero-parameter closure when we don’t care about the value.
  • Use a two-parameter closure (oldValue, newValue) if we need at least one of them.

All changes are a refactor, so no behavior should be changed. Most of times we either don't care about the value and just react to it, or we care about newValue only.

Testing information

Changes affect multiple files, but superficial smoke testing Order Creation and POS flows should be sufficient, ie:

  • In the app, create an order, use the product filters, add a coupon, use the stepper to increase/decrease quantity, expand the totals view, process a payment via TTP, send a receipt. Do this via single selection in mobile, and multi-select in tablet.
  • In POS, setup scanner, go through payment flow, and send a receipt. At some point also move to split view and reduce POS view until is not eligible to use.

Screenshots

N/A


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@dangermattic
Copy link
Collaborator

dangermattic commented Aug 12, 2025

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

@iamgabrielma iamgabrielma added type: task An internally driven task. type: technical debt Represents or solves tech debt of the project. labels Aug 12, 2025
@iamgabrielma iamgabrielma added this to the 23.1 milestone Aug 12, 2025
@@ -79,7 +79,7 @@ struct ExpandableBottomSheet<AlwaysVisibleContent, ExpandableContent>: View wher
// Always visible content
alwaysVisibleContent()
.trackSize(size: $fixedContentSize)
.onChange(of: fixedContentSize, perform: { [fixedContentSize] _ in
.onChange(of: fixedContentSize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't seem we need the capture list here: .onChange(of: fixedContentSize) already re-runs the closure every time fixedContentSize changes, so capturing it when created serves no purpose as it will always have the latest value when the closure runs anyway

@iamgabrielma iamgabrielma marked this pull request as ready for review August 12, 2025 03:04
@@ -276,11 +276,11 @@ private struct CartScrollViewContent: View {
.onAppear {
updateItemImageVisibility(cartListWidth: geometry.size.width)
}
.onChange(of: geometry.size.width) {
updateItemImageVisibility(cartListWidth: $0)
.onChange(of: geometry.size.width) { _, newValue in
Copy link
Contributor Author

@iamgabrielma iamgabrielma Aug 12, 2025

Choose a reason for hiding this comment

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

Passing it implicitly as $0 is no longer something we can do, since we're using the new value inside the closure, we need to be declare it explicitly in .onChange before using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task An internally driven task. type: technical debt Represents or solves tech debt of the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants