I'm trying to extract my gesture out to a function for use within one of my Swift Packages. The issue I'm having is that when I attempt to use it on one of my views, it doesn't conform to View anymore.
The following code produces this error: Type 'any View' cannot conform to 'View'
struct ContentView: View {
var body: some View {
VStack {
Text("Placeholder")
}
.gesture(swipeDownGesture())
}
func swipeDownGesture() -> any Gesture {
DragGesture(minimumDistance: 0, coordinateSpace: .local).onEnded({ gesture in
if gesture.translation.height > 0 {
// Run some code
}
})
}
}