doing it without longpress and just draggesture

This commit is contained in:
talksik
2021-12-12 19:48:49 -08:00
parent ba9401d605
commit 189f884e41
@@ -18,54 +18,32 @@ struct FooterControlsView: View {
DragGesture(minimumDistance: 0, coordinateSpace: .local) DragGesture(minimumDistance: 0, coordinateSpace: .local)
.onChanged {_ in .onChanged {_ in
self.isHolding = true self.isHolding = true
print("started drag")
} }
.onEnded {_ in .onEnded {_ in
self.isHolding = false self.isHolding = false
print("ended drag")
} }
} }
var longPress: some Gesture {
LongPressGesture(minimumDuration: 1)
.updating($isLongPressingRecord) { currentState, gestureState,
transaction in
gestureState = currentState
transaction.animation = Animation.easeIn(duration: 2.0)
self.isHolding = true
print("started long press")
}
.onEnded { finished in
print(finished)
self.completedLongPress = finished
self.isHolding = false
print("ended long press")
}
}
var body: some View { var body: some View {
HStack(alignment: .center) { HStack(alignment: .center) {
Spacer() Spacer()
Image(systemName: self.isHolding ? "waveform" : "mic.fill") Button(action: {
.foregroundColor(.white)
.padding() }, label: {
.background(NirvanaColor.teal) Image(systemName: self.isHolding ? "waveform" : "mic.fill")
.clipShape(Circle()) .foregroundColor(.white)
.shadow(radius: 10) .padding()
.gesture(longPress) .background(NirvanaColor.teal)
.simultaneousGesture(dragGesture) .clipShape(Circle())
.scaleEffect(x: self.isHolding ? 1.2: 1, .shadow(radius: 10)
y: self.isHolding ? 1.2: 1, .scaleEffect(x: self.isHolding ? 1.2: 1,
anchor: .center) y: self.isHolding ? 1.2: 1,
anchor: .center)
.simultaneousGesture(dragGesture)
})
Text("currently is \(self.isHolding ? "recording": "not recording")") Text("currently is \(self.isHolding ? "recording": "not recording")")
} }