Я хотел бы узнать, как получить продолжительность LongPressGesture.
Моя цель - иметь возможность изменять переменную пропорционально этому LongGesture.
Я попытался ввести переменную @State, чтобы получить значение с помощью метода .onChanged / .onEnded, но этот возвращает логическое значение для LongGesture
Вот мой код (который делает не компилируется):
struct ContentView: View {
// Well, this var @State is a CGFloat because I think that the duration is of this type (based on the minimumDuration)
@State var timeLongGesture: CGFloat = 0
@State var value: Int = 1
var body: some View {
// Some stuff here
Text("Increase the value")
.onTapGesture { value += 1 }
.gesture(
LongPressGesture(minimumDuration: 0.4)
.onEnded { valueLongPress in
// Here the error, because the value of "valueLongPress" is a Bool (as the doc mentionned)
timeLongGesture = valueLongPress
})
Я чувствую, что это сложно. Так что, если у кого-то есть идеи, я возьму их :-) Спасибо за вашу помощь.