Closed andreymosin closed 1 year ago
@andreymosin
I've found fix for this issue.
Each sheet view should contain var sheetResizeAction: (() -> Void)?
that will be called after view size pref key changed:
VStack {
}
.readSize(onChange: { _ in
sheetResizeAction?()
})
This action should only update intrinsic view height
***
let sheetController = SheetViewController(controller: hostingController, sizes: getSheetViewSizes(), options: getSheetViewOptions())
view.sheetResizeAction = {
sheetController.updateIntrinsicHeight()
}
***
import SwiftUI
public struct SizePreferenceKey: PreferenceKey {
public typealias Value = CGSize
public static var defaultValue = CGSize.zero
public static func reduce(value: inout CGSize, nextValue: () -> CGSize) {
value = nextValue()
}
}
public struct ViewGeometry: View {
public init(){}
public var body: some View {
GeometryReader { proxy in
Color.clear
.preference(key: SizePreferenceKey.self,
value: proxy.size)
}
}
}
public extension View {
func readSize(onChange: @escaping (CGSize) -> Void) -> some View {
overlay(ViewGeometry())
.onPreferenceChange(SizePreferenceKey.self, perform: onChange)
}
}
This seems to have solved the issue, thank you
I'm having an issue when SwiftUI views are unresponsive in Intrinsic Size mode. However if I have pulling up enabled and drag the sheet a bit up, it becomes responsive and buttons work. Doesn't occur on iOS 17 tho Thank you!
Code is simple: