Skip to content

Commit

Permalink
Added debounce 300ms for all buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
potvik committed Nov 13, 2023
1 parent 59aa134 commit fd27a2c
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 fd27a2c

Please sign in to comment.