Working on a project where view are aligned like this
- HeaderView
- TabView
- Views with each tab
- List and other items in each view
Relevant code is
struct Home: View {
@StateObject var manageScrollPosition = ManageScrollPosition()
var body: some View {
GeometryReader { gReader in
ScrollView {
VStack {
EntityHeaderView(bottomViewPopupData: $bottomViewPopupData)
EntityTabView(manageScrollPosition: manageScrollPosition)
.frame(height: gReader.size.height)
}
.background(GeometryReader {
Color.clear.preference(key: ViewOffsetKey.self,
value: -$0.frame(in: .named("scroll")).origin.y)
})
.onPreferenceChange(ViewOffsetKey.self) {
if $0 == 238.0 {
manageScrollPosition.isScrollEnable = false
}
}
}
.coordinateSpace(name: "scroll")
.introspectScrollView { scrollView in
scrollView.bounces = manageScrollPosition.isScrollEnable
scrollView.isScrollEnabled = manageScrollPosition.isScrollEnable
}
}
}
I have to disable the scrolling of main scrollview once tab is reaches to top and enable the scrolling of list from child View.
Right now I'm able to achive this with static height of header View
if $0 == 238.0 {
manageScrollPosition.isScrollEnable = false
}
want to replace this static value with actual height of header or some other solution. I'm new in SwiftUI, Very thank full for your solutiuon in advance.