I have implemented a viewmodifier to Swiftui's scrollview in order to disable the built-in scrolling, to allow a custom drag gesture to apply. The modifier works great.
The thing is the viewmodifier is being applied to other scrollviews in the app, not just those targeted with the .modifier! I've tried simple possible solutions such as unique id's for the scrollviews to no avail.
Does anyone know whether this behaviour can be fixed?
ScrollViewReader { (proxy: ScrollViewProxy) in
ScrollView(.horizontal) {
LazyHGrid(rows: rows, alignment: .center, spacing: cellSpacing) {
ForEach(Assets, id: \.self) { asset in
AssetView(asset)
}
}.transition(.asymmetric(insertion: .identity, removal: .identity))
.offset(x: initialOffset.width + x.width)
}
.id("AssetDetail")
.modifier(DetailScrollViewModifier())
.gesture(DragGesture(minimumDistance: 30, coordinateSpace: .local)......
}
struct DetailScrollViewModifier: ViewModifier {
init() {
UIScrollView.appearance().isUserInteractionEnabled = false
UIScrollView.appearance().isScrollEnabled = false
}
func body(content: Content) -> some View {
return content
}
}
Many Thanks