Throttle controls bar gestures

This commit is contained in:
Arkadiusz Fal 2022-12-20 23:41:21 +01:00
parent c432aa3b9a
commit a32f417776

View File

@ -13,6 +13,8 @@ struct ControlsBar: View {
@State private var shareURL: URL? @State private var shareURL: URL?
@Binding var expansionState: ExpansionState @Binding var expansionState: ExpansionState
@State internal var gestureThrottle = Throttle(interval: 0.25)
var presentingControls = true var presentingControls = true
var backgroundEnabled = true var backgroundEnabled = true
var borderTop = true var borderTop = true
@ -244,18 +246,20 @@ struct ControlsBar: View {
} }
func gestureAction(_ action: PlayerTapGestureAction) { func gestureAction(_ action: PlayerTapGestureAction) {
switch action { gestureThrottle.execute {
case .togglePlayer: switch action {
model.togglePlayer() case .togglePlayer:
case .openChannel: self.model.togglePlayer()
guard let channel = model.videoForDisplay?.channel else { return } case .openChannel:
navigation.openChannel(channel, navigationStyle: navigationStyle) guard let channel = self.model.videoForDisplay?.channel else { return }
case .togglePlayerVisibility: self.navigation.openChannel(channel, navigationStyle: self.navigationStyle)
withAnimation(.spring(response: 0.25)) { case .togglePlayerVisibility:
expansionState = expansionState == .full ? .mini : .full withAnimation(.spring(response: 0.25)) {
self.expansionState = self.expansionState == .full ? .mini : .full
}
default:
return
} }
default:
return
} }
} }
#endif #endif