2022-02-17 01:53:11 +05:30
|
|
|
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 22:51:01 +05:30
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
model.presentingControls = true
|
|
|
|
model.resetTimer()
|
2022-07-07 04:00:42 +05:30
|
|
|
withAnimation(PlayerControls.animation) {
|
2022-07-05 22:51:01 +05:30
|
|
|
model.presentingControlsOverlay = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
},
|
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(-10))
|
2022-03-28 00:54:32 +05:30
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
|
|
|
singleTapAction: {
|
2022-07-05 22:51:01 +05:30
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
model.presentingControls = true
|
|
|
|
model.resetTimer()
|
2022-07-07 04:00:42 +05:30
|
|
|
withAnimation(PlayerControls.animation) {
|
2022-07-05 22:51:01 +05:30
|
|
|
model.presentingControlsOverlay = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
},
|
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.togglePlay()
|
2022-03-28 00:54:32 +05:30
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
|
|
|
singleTapAction: {
|
2022-07-05 22:51:01 +05:30
|
|
|
if model.presentingControlsOverlay {
|
|
|
|
model.presentingControls = true
|
|
|
|
model.resetTimer()
|
2022-07-07 04:00:42 +05:30
|
|
|
withAnimation(PlayerControls.animation) {
|
2022-07-05 22:51:01 +05:30
|
|
|
model.presentingControlsOverlay = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
2022-02-17 01:53:11 +05:30
|
|
|
},
|
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(10))
|
2022-03-28 00:54:32 +05:30
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-17 01:53:11 +05:30
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var gestureRectangle: some View {
|
|
|
|
Color.clear
|
|
|
|
.contentShape(Rectangle())
|
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PlayerGestures_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
PlayerGestures()
|
|
|
|
}
|
|
|
|
}
|