attempt at button click gesture for recording
This commit is contained in:
@@ -9,26 +9,48 @@ import SwiftUI
|
|||||||
|
|
||||||
struct FooterControlsView: View {
|
struct FooterControlsView: View {
|
||||||
@StateObject var viewModel:FooterControlsViewModel = FooterControlsViewModel()
|
@StateObject var viewModel:FooterControlsViewModel = FooterControlsViewModel()
|
||||||
|
@State private var scaleValue = CGFloat(1)
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(alignment: .center) {
|
HStack(alignment: .center) {
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Button {
|
Image(systemName: viewModel.isRecording ? "waveform" : "mic.fill")
|
||||||
print("Button was pressed!")
|
.foregroundColor(.white)
|
||||||
} label: {
|
.padding()
|
||||||
var icon:String = viewModel.isRecording ? "waveform" : "mic.fill"
|
.background(NirvanaColor.teal)
|
||||||
|
.clipShape(Circle())
|
||||||
|
.shadow(radius: 10)
|
||||||
|
// .scaleEffect(self.scaleValue)
|
||||||
|
.onLongPressGesture {
|
||||||
|
|
||||||
|
}
|
||||||
|
.animation(.linear(duration:2), value: viewModel.isRecording)
|
||||||
|
.onTapGesture {
|
||||||
|
viewModel.onStartRecording()
|
||||||
|
print("tap gesture active")
|
||||||
|
}
|
||||||
|
// .onTapGesture(
|
||||||
|
// touchBegan: {
|
||||||
|
// withAnimation {
|
||||||
|
// self.scaleValue = 1.2
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// viewModel.onStartRecording()
|
||||||
|
//
|
||||||
|
// print("long press active")
|
||||||
|
// }, touchEnd: {_ in
|
||||||
|
// withAnimation {
|
||||||
|
// self.scaleValue = 1.0
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// print("long press not active anymore")
|
||||||
|
// }
|
||||||
|
|
||||||
Image(systemName: icon)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.padding()
|
|
||||||
.background(NirvanaColor.teal)
|
|
||||||
.clipShape(Circle())
|
|
||||||
}
|
}
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
|
.padding()
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity)
|
|
||||||
.padding()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FooterControlsView_Previews: PreviewProvider {
|
struct FooterControlsView_Previews: PreviewProvider {
|
||||||
|
|||||||
@@ -11,4 +11,12 @@ import Foundation
|
|||||||
final class FooterControlsViewModel: ObservableObject {
|
final class FooterControlsViewModel: ObservableObject {
|
||||||
@Published var isRecording: Bool = false
|
@Published var isRecording: Bool = false
|
||||||
|
|
||||||
|
init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func onStartRecording() {
|
||||||
|
self.isRecording = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user