Implement .onPreferenceChange...
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 330
- Forks
- 76
- Avg merge
- 3h 6m
- Merged PRs (30d)
- 1
Description
I have a fairly complex layout scenario which would benefit from the following technique (scroll down to "Using a preference key"):
https://swiftbysundell.com/questions/syncing-the-width-or-height-of-two-swiftui-views/
I use this in my iOS code and it works well.
Unfortunately, while Skip does seem to support PreferenceKey generally, .onPreferenceChange is not supported. This prevents me from being able to get the CGSize of a view and use it for calculations as needed.
Would it be possible to implement .onPreferenceChange?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing PreferenceKey support and the entry point for SwiftUI view modifiers. Use the linked “Using a preference key” example as the behavioral reference, and verify that .onPreferenceChange can receive a CGSize value for layout calculations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100