I played with it a bit more.
In fact, animation is not needed.
Idem, you don't need all the effect (even though they may provide interesting feedback in your case)
And the parameter to adjust is minimum duration, with a large value:
var body: some View {
return configuration.label
.foregroundColor(.white)
.padding(15)
.background(RoundedRectangle(cornerRadius: 5).fill(color))
.compositingGroup()
.shadow(color: .black, radius: 3)
.opacity(self.pressed ? 0.5 : 1.0)
.scaleEffect(self.pressed ? 0.8 : 1.0)
.onLongPressGesture(minimumDuration: 100.0, maximumDistance: .infinity, pressing: { pressing in
self.pressed = pressing
if pressing {
print("My long pressed starts")
print(" I can initiate any action on start")
} else {
print("My long pressed ends")
print(" I can initiate any action on end")
}
}, perform: { })
}
is it possible to pass callback functions to the primitive style?
What type of callback do you think of ?