Open morluna opened 1 year ago
@morluna I think that maybe the stretch should be disabled altogether when being presented in a sheet. Do you know if it's possible to detect whether or not the view is in a sheet?
@danielsaidi On the parent view, you could just use .presentationDetents(:selection:)
and a state property to know when it changed.
There isn't a way for nested views (like the scroll view with sticky header) to know what presentation detent it's on out of the box, but maybe you can created a custom environment property for it?
struct PresentationDetentPreferenceKey: PreferenceKey {
static var defaultValue: PresentationDetent = .large
static func reduce(value: inout PresentationDetent, nextValue: () -> PresentationDetent) {
value = nextValue()
}
}
struct PresentationDetentEnvironmentKey: EnvironmentKey {
static let defaultValue: PresentationDetent = .large
}
extension EnvironmentValues {
var presentationDetent: PresentationDetent {
get { self[PresentationDetentEnvironmentKey.self] }
set { self[PresentationDetentEnvironmentKey.self] = newValue }
}
}
I will fix this the next time I use the view in a way that causes this problem, but I'll be happy to review any PRs that fixes it.
When presenting a sheet with presentation detents, the sticky header functionality breaks a bit because the header tries to grow to the top of the screen, but the presentationDetent cuts it off.
The stretchiness functionality doesn't necessarily need to work on small detents, but would be nice for the header to stick to the top.
https://user-images.githubusercontent.com/8826948/225060529-23c33686-3175-42c4-9839-867d77423f33.MP4