Add View.onPreferenceChange support#937
Conversation
🤖 Augment PR SummarySummary: This PR completes Changes:
Technical Notes: Action dispatch is enqueued via 🤖 Was this summary useful? React with 👍 or 👎 |
| @_exported import SwiftUI | ||
|
|
||
| @available(iOS 18.2, macOS 15.2, *) | ||
| @frozen public struct TransactionalPreferenceActionModifier<Key> : SwiftUI.ViewModifier where Key : SwiftUI.PreferenceKey, Key.Value : Swift.Equatable { |
There was a problem hiding this comment.
@available(iOS 18.2, macOS 15.2, *) makes this symbol effectively available on tvOS/watchOS/visionOS at all versions; consider adding explicit availability for the other Apple platforms (or marking them unavailable) to avoid cross-platform build mismatches. (Also applies to the similar availability usage in the transactional example/test in this PR.)
Severity: medium
Other Locations
Example/Shared/ViewModifier/TransactionalPreferenceActionModifierExample.swift:14Example/OpenSwiftUIUITests/Modifier/ViewModifier/PreferenceActionModifierUITests.swift:50
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #937 +/- ##
==========================================
- Coverage 25.92% 25.87% -0.05%
==========================================
Files 721 723 +2
Lines 50788 50878 +90
==========================================
- Hits 13165 13163 -2
- Misses 37623 37715 +92 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
View.onPreferenceChange(_:perform:)with preference value-change tracking and cycle handlingTransactionThis supersedes #926 and incorporates the initial implementation by @Dark-Existed.
Closes #925
Validation
xcodebuild build -workspace Example/Example.xcworkspace -scheme OSUI_Example -configuration OpenSwiftUIDebug -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NOxcodebuild build -workspace Example/Example.xcworkspace -scheme SUI_Example -configuration SwiftUIDebug -destination 'generic/platform=iOS Simulator' CODE_SIGNING_ALLOWED=NO