attempt at button click gesture for recording

This commit is contained in:
talksik
2021-12-12 12:12:56 -08:00
parent 4e52ab9625
commit 03cec7bb40
2 changed files with 42 additions and 12 deletions
@@ -9,22 +9,44 @@ 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!")
} label: {
var icon:String = viewModel.isRecording ? "waveform" : "mic.fill"
Image(systemName: icon)
.foregroundColor(.white) .foregroundColor(.white)
.padding() .padding()
.background(NirvanaColor.teal) .background(NirvanaColor.teal)
.clipShape(Circle()) .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")
// }
} }
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.padding() .padding()
@@ -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
}
} }