mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 05:53:41 +00:00
Throttle controls bar gestures
This commit is contained in:
parent
c432aa3b9a
commit
a32f417776
@ -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,20 +246,22 @@ struct ControlsBar: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func gestureAction(_ action: PlayerTapGestureAction) {
|
func gestureAction(_ action: PlayerTapGestureAction) {
|
||||||
|
gestureThrottle.execute {
|
||||||
switch action {
|
switch action {
|
||||||
case .togglePlayer:
|
case .togglePlayer:
|
||||||
model.togglePlayer()
|
self.model.togglePlayer()
|
||||||
case .openChannel:
|
case .openChannel:
|
||||||
guard let channel = model.videoForDisplay?.channel else { return }
|
guard let channel = self.model.videoForDisplay?.channel else { return }
|
||||||
navigation.openChannel(channel, navigationStyle: navigationStyle)
|
self.navigation.openChannel(channel, navigationStyle: self.navigationStyle)
|
||||||
case .togglePlayerVisibility:
|
case .togglePlayerVisibility:
|
||||||
withAnimation(.spring(response: 0.25)) {
|
withAnimation(.spring(response: 0.25)) {
|
||||||
expansionState = expansionState == .full ? .mini : .full
|
self.expansionState = self.expansionState == .full ? .mini : .full
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@ViewBuilder var contextMenu: some View {
|
@ViewBuilder var contextMenu: some View {
|
||||||
if let video = model.videoForDisplay {
|
if let video = model.videoForDisplay {
|
||||||
|
Loading…
Reference in New Issue
Block a user