I have this code below, how do I remove the scroll bounce in only one horizontal subview…
- User
I have this code below, how do I remove the scroll bounce in only one horizontal subview located in the body of SphereGroupSectionView without affecting the top hierarchy of the View
import SwiftUI import EvoUIKit
@MainActor protocol SphereGroupsViewModeling: ObservableObject { associatedtype ViewState
var viewState: ViewState { get } func onAppear()}
struct SphereGroupsView<ViewModel: SphereGroupsViewModeling>: View where ViewModel.ViewState == SphereGroupsVM.ViewState {
struct HeaderDisplayValues { var opacity: Double = 1.0 var segmentYOffset: CGFloat = 0.0 var height: CGFloat = 90.0 } @ObservedObject var viewModel: ViewModel @State private var isScrolling: Bool = false @State private var selectedSegment: SegmentHeaderView.Segment = .conscious @State private var segments: [SegmentHeaderView.Segment] = .segments @State private var isInfoExpanded: Bool = false @State private var scrollYoffset: CGFloat = .zero @State private var headerValues: HeaderDisplayValues = .init() init(viewModel: ViewModel) { self.viewModel = viewModel } var body: some View { VStack { content() } .navigationBarConfig { NavigationBarConfig.Item.hideLeading } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(VideoBackgroundView()) .overlay(alignment: .top, content: headerView) .compositingGroup() .onAppear(perform: viewModel.onAppear) } @ViewBuilder private func content() -> some View { switch viewModel.viewState { case .loading: EmptyView() case .content(let profile): EmptyView() ScrollViewReader { scroll in ScrollView(showsIndicators: false) { VStack { SegmentInfoView( isInfoExpanded: $isInfoExpanded, subtitle: selectedSegment.subtitle ) .padding(.top, 112) .padding(.horizontal, 24) ForEach(profile.sphereGroups, id: \.title) { group in SphereGroupSectionView( title: group.title, segments: segments, selectedSegmentTitle: selectedSegment.title, spheres: group.spheres, onTalent: { $0.broadcast() } ) } } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(scrollCoordinatorView()) .padding(.bottom, 80) } .coordinateSpace(name: "scroll") } } } @ViewBuilder private func scrollCoordinatorView() -> some View { GeometryReader { proxy in Color.clear .frame(maxWidth: .infinity, maxHeight: .infinity) .onChange(of: proxy.frame(in: .named("scroll")).minY) { newValue in scrollYoffset = newValue adjustedYOffset(scrollYOffset: newValue) withAnimation { isScrolling = newValue < 0 } } } } private func adjustedYOffset(scrollYOffset: CGFloat) { let minYOffset: CGFloat = 35 let maxYOffset: CGFloat = 90 let minScrollOffset: CGFloat = -80 let maxScrollOffset: CGFloat = 0 let clampedOffset = min(max(scrollYOffset, minScrollOffset), maxScrollOffset) let headerHeightValue = minYOffset + ((clampedOffset + 80) / 80) * (maxYOffset - minYOffset) let opacity = (headerHeightValue - minYOffset) / (maxYOffset - minYOffset) let segmentYOffSet = -25 + ((headerHeightValue - minYOffset) / (maxYOffset - minYOffset)) * 25 headerValues.height = headerHeightValue headerValues.opacity = opacity headerValues.segmentYOffset = segmentYOffSet } @ViewBuilder private func headerView() -> some View { Color.white .opacity(isScrolling ? 0.08 : 0) .background(BackdropBlurView(radius: 8)) .roundedCorners([.bottomLeft, .bottomRight]) .edgesIgnoringSafeArea(.top) .frame(height: 0) .safeAreaInset(edge: .top) { VStack { Text(S.myTalent.localized) .typography(.H1.bold) .foregroundColor(.palette.primary800) .frame(maxWidth: .infinity, alignment: .leading) .opacity(headerValues.opacity) .padding(.top, 16) .padding(.bottom, 8) HStack(spacing: 6) { ForEach(segments, id: \.title) { SegmentHeaderView( selectedSegment: $selectedSegment, segment: $0 ) } } .padding(.bottom, 8) .offset(y: headerValues.segmentYOffset) } .frame(height: headerValues.height) .padding(.horizontal, 24) } } private func onExpandInfo() { withAnimation(.spring) { isInfoExpanded.toggle() } } - Assistant