-
Notifications
You must be signed in to change notification settings - Fork 121
[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
Conversation
Generated by 🚫 Danger |
| alwaysVisibleContent() | ||
| .trackSize(size: $fixedContentSize) | ||
| .onChange(of: fixedContentSize, perform: { [fixedContentSize] _ in | ||
| .onChange(of: fixedContentSize) { |
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.
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
| } | ||
| .onChange(of: geometry.size.width) { | ||
| updateItemImageVisibility(cartListWidth: $0) | ||
| .onChange(of: geometry.size.width) { _, newValue in |
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.
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.
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.
Can't you use $1 instead? This is fine though.
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.
Oh, ... that's right 🤦
|
Version |
# Conflicts: # WooCommerce/Classes/POS/Presentation/Reusable Views/POSModalViewModifier.swift # WooCommerce/Classes/POS/Presentation/Reusable Views/POSSheet.swift
|
|
joshheald
left a comment
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.
Works well. Have you stuck to Peacock's areas only? I see there's still 24 of these warnings not fixed here... that's fine but might be worth a heads up to Kiwi.
WooCommerce
woocommerce-ios/WooCommerce/Classes/Authentication/Jetpack Setup/Native Jetpack Setup/JetpackSetupView.swift
woocommerce-ios/WooCommerce/Classes/Authentication/Jetpack Setup/Native Jetpack Setup/JetpackSetupView.swift:291:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift
woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:17:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:35:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:51:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/View Modifiers/View+Measurements.swift:54:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/AdDestination/BlazeAddParameterView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/AdDestination/BlazeAddParameterView.swift:24:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/AdDestination/BlazeAddParameterView.swift:34:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/CampaignCreation/BlazeCampaignCreationForm.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/CampaignCreation/BlazeCampaignCreationForm.swift:225:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/BlazeCampaignList/BlazeCampaignListView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Blaze/BlazeCampaignList/BlazeCampaignListView.swift:158:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Authentication/AccountCreationForm.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Authentication/AccountCreationForm.swift:128:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift:175:46 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift:197:30 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/TopTabView.swift:238:34 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/FormattableAmountTextField.swift:21:18 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Package and Rate Selection/WooAddCustomPackageView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Package and Rate Selection/WooAddCustomPackageView.swift:152:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShipping Package and Rate Selection/WooAddCustomPackageView.swift:155:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingAddresses/WooShippingEditAddressView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingAddresses/WooShippingEditAddressView.swift:88:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Orders/Order Details/Shipping Labels/WooShipping Create Shipping Labels/WooShippingAddresses/WooShippingEditAddressView.swift:265:22 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/ProductCreationAIStartingInfoView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/ProductCreationAIStartingInfoView.swift:105:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/ProductCreationAIStartingInfoView.swift:109:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/PromptProgressBar/ProductCreationAIPromptProgressBar.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/StartingInfo/PromptProgressBar/ProductCreationAIPromptProgressBar.swift:32:10 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewView.swift
woocommerce-ios/WooCommerce/Classes/ViewRelated/Products/Add Product/AddProductWithAI/Preview/ProductDetailPreviewView.swift:137:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/POS/Presentation/Reusable Views/POSFullScreenCover.swift
woocommerce-ios/WooCommerce/Classes/POS/Presentation/Reusable Views/POSFullScreenCover.swift:80:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
woocommerce-ios/WooCommerce/Classes/POS/Presentation/Reusable Views/POSFullScreenCover.swift:107:14 'onChange(of:perform:)' was deprecated in iOS 17.0: Use `onChange` with a two or zero parameter action closure instead.
Yeah, at the moment I loosely split the work in batches around features/files by each team in WOOMOB-1003 so it's easier for testing. Depending on priorities and if they are unable to get to it, then we can do another pass. I'll ping with a reminder to the leads again in any case, as it seems the issue stalls if it doesn't go through proper triage. |

Part of WOOMOB-1003
Description
This PR addresses ~50 warnings related to the
.onChangeusage 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:
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
newValueonly.Testing information
Changes affect multiple files, but superficial smoke testing Order Creation and POS flows should be sufficient, ie:
Screenshots
N/A
RELEASE-NOTES.txtif necessary.