Skip to content

Commit

Permalink
Merge pull request #170 from harmony-one/buttons_debounce
Browse files Browse the repository at this point in the history
Added debounce 300ms for all buttons
  • Loading branch information
theofandrich authored Nov 13, 2023
2 parents b77b504 + fd27a2c commit 674a4ab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion voice/voice-ai/x/Actions/GridButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ struct GridButton: View {
let imageTextSpacing: CGFloat = 40
@Environment(\.verticalSizeClass) var verticalSizeClass
@Environment(\.horizontalSizeClass) var horizontalSizeClass
@State private var debounce_timer:Timer?

var body: some View {
Button(action: {
action()
self.debounce_timer?.invalidate()
self.debounce_timer = Timer.scheduledTimer(withTimeInterval: 0.3, repeats: false) { _ in
action()
}
}) {
VStack(spacing: imageTextSpacing) {
Image(pressEffectButtonImage()) // button.image)
Expand Down

0 comments on commit 674a4ab

Please sign in to comment.