I implemented a vertical ScrollView in SwiftUI, and then gave each row horizontal drag gesture. Somehow implementing this stopped the ScrollView drag when dragging inside a row (as to see the rest of the list) from working, i tried replacing ScrollView with List but the problem persisted.
Here's the code:
struct MyView: View {
var MyArray: [String] = ["Foo", "bar","foobar"]
var body: some View {
ScrollView{
ForEach(MyArray, id:\.self)
{ _ in
Cell()
}
}
}
}
Cell:
struct Cell: View{
@State var draggedOffset = CGSize.zero
var body: some View {
HStack {
Text("Test")
}.animation(.linear)
.offset(x: self.draggedOffset.width)
.gesture(DragGesture()
.onChanged{ value in
self.draggedOffset.width = value.translation.width
}
.onEnded { value in
self.draggedOffset = CGSize.zero
})
}
}