2022-02-16 20:23:11 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct PlayerGestures: View {
|
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
|
|
|
@EnvironmentObject<PlayerControlsModel> private var model
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack(spacing: 0) {
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
|
|
|
singleTapAction: {
|
2022-07-05 17:21:01 +00:00
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
model.presentingControls = true
|
|
|
|
model.resetTimer()
|
|
|
|
withAnimation {
|
|
|
|
model.presentingControlsOverlay = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
2022-02-16 20:23:11 +00:00
|
|
|
},
|
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(-10))
|
2022-03-27 19:24:32 +00:00
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
|
|
|
singleTapAction: {
|
2022-07-05 17:21:01 +00:00
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
model.presentingControls = true
|
|
|
|
model.resetTimer()
|
|
|
|
withAnimation {
|
|
|
|
model.presentingControlsOverlay = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
2022-02-16 20:23:11 +00:00
|
|
|
},
|
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.togglePlay()
|
2022-03-27 19:24:32 +00:00
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
|
|
|
singleTapAction: {
|
2022-07-05 17:21:01 +00:00
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
model.presentingControls = true
|
|
|
|
model.resetTimer()
|
|
|
|
withAnimation {
|
|
|
|
model.presentingControlsOverlay = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
2022-02-16 20:23:11 +00:00
|
|
|
},
|
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(10))
|
2022-03-27 19:24:32 +00:00
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var gestureRectangle: some View {
|
|
|
|
Color.clear
|
|
|
|
.contentShape(Rectangle())
|
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PlayerGestures_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
PlayerGestures()
|
|
|
|
}
|
|
|
|
}
|