My code below is setup so that I can press and hold my button to trigger an action and then stop that action when releasing the hold. How can I stop the user from triggering the gesture multiple times with different touches/fingers? In UIKit you can just disable multi-touch on an element but I could not find any equivalent syntax for SwiftUI.
struct playButton: View {
@EnvironmentObject var settings: TestParameters
@State var isDown: Bool = false
var db: Double
var dbString: String
var body: some View {
let g = DragGesture(minimumDistance: 0, coordinateSpace: .local).onChanged({
print("DOWN: \($0)")
self.isDown = true
}).onEnded({
print("UP: \($0)")
self.isDown = false
})
return ZStack{
Rectangle()
.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity)
.gesture(g)
.foregroundColor(isDown ? Color.init(hex: "6ca659"): Color.init(hex: "666699"))
Text(dbString)
.fontWeight(.bold)
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
}
}
}