David Bureš on Nostr: Just discovered a weird SwiftUI quirk: When you have a `ScrollView` with the ...
Just discovered a weird SwiftUI quirk:
When you have a `ScrollView` with the `.refreshable` modifier, and then have another `ScrollView` in a `.safeAreaInset` on the `ScrollView` parent, the `ScrollView` in `.safeAreaInset` still triggers a refresh
Code example:
`var body: some View {`
`VStack {`
`ScrollView {`
`(code)`
`}`
`.refreshable {`
`(code)`
`}`
`}`
`.safeAreaInset(edge: .bottom) {`
`ScrollView {`
`(this also triggers the refresh)`
`}`
`}`
`}`
#SwiftUI #swift
Published at
2023-05-31 11:14:49Event JSON
{
"id": "1825fb8b60b9845d23bc3e59c71f12937c8e3957a483087210447a5f5fceb8fa",
"pubkey": "17ca545e6a302644a7898dc6862e512bb987c80b13d07bf3f5c2448e24db9b5f",
"created_at": 1685531689,
"kind": 1,
"tags": [
[
"t",
"swift"
],
[
"t",
"SwiftUI"
],
[
"mostr",
"https://mstdn.social/users/davidbures/statuses/110463004806710690"
]
],
"content": "Just discovered a weird SwiftUI quirk:\n\nWhen you have a `ScrollView` with the `.refreshable` modifier, and then have another `ScrollView` in a `.safeAreaInset` on the `ScrollView` parent, the `ScrollView` in `.safeAreaInset` still triggers a refresh\n\nCode example:\n`var body: some View {`\n `VStack {`\n `ScrollView {`\n `(code)`\n `}`\n `.refreshable {`\n `(code)`\n `}`\n `}`\n `.safeAreaInset(edge: .bottom) {`\n `ScrollView {`\n `(this also triggers the refresh)`\n `}`\n `}`\n`}`\n\n#SwiftUI #swift",
"sig": "37a17f628cea8a1bf8dc17973e0add81cd32c55ab811c9c0dc787e8bb449a2ad3efa6a52a0814b29d2e36c6f8f6d9f386c01dea136897c23b63208cc6832f5d8"
}