mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
New actions buttons
This commit is contained in:
@@ -329,7 +329,7 @@ struct PlayerControls: View {
|
||||
var fullscreenButton: some View {
|
||||
button(
|
||||
"Fullscreen",
|
||||
systemImage: player.playingFullScreen ? "arrow.down.right.and.arrow.up.left" : "arrow.up.left.and.arrow.down.right"
|
||||
systemImage: player.fullscreenImage
|
||||
) {
|
||||
player.toggleFullscreen(player.playingFullScreen, showControls: false)
|
||||
}
|
||||
@@ -367,28 +367,13 @@ struct PlayerControls: View {
|
||||
}
|
||||
|
||||
private var pipButton: some View {
|
||||
let image = player.transitioningToPiP ? "pip.fill" : player.pipController?.isPictureInPictureActive ?? false ? "pip.exit" : "pip.enter"
|
||||
return button("PiP", systemImage: image) {
|
||||
(player.pipController?.isPictureInPictureActive ?? false) ? player.closePiP() : player.startPiP()
|
||||
}
|
||||
.disabled(!player.pipPossible)
|
||||
button("PiP", systemImage: player.pipImage, action: player.togglePiPAction)
|
||||
.disabled(!player.pipPossible)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private var lockOrientationButton: some View {
|
||||
button("Lock Rotation", systemImage: player.lockedOrientation.isNil ? "lock.rotation.open" : "lock.rotation", active: !player.lockedOrientation.isNil) {
|
||||
if player.lockedOrientation.isNil {
|
||||
let orientationMask = OrientationTracker.shared.currentInterfaceOrientationMask
|
||||
player.lockedOrientation = orientationMask
|
||||
let orientation = OrientationTracker.shared.currentInterfaceOrientation
|
||||
Orientation.lockOrientation(orientationMask, andRotateTo: .landscapeLeft)
|
||||
// iOS 16 workaround
|
||||
Orientation.lockOrientation(orientationMask, andRotateTo: orientation)
|
||||
} else {
|
||||
player.lockedOrientation = nil
|
||||
Orientation.lockOrientation(.allButUpsideDown, andRotateTo: OrientationTracker.shared.currentInterfaceOrientation)
|
||||
}
|
||||
}
|
||||
button("Lock Rotation", systemImage: player.lockOrientationImage, active: !player.lockedOrientation.isNil, action: player.lockOrientationAction)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -456,9 +441,7 @@ struct PlayerControls: View {
|
||||
}
|
||||
|
||||
private var restartVideoButton: some View {
|
||||
button("Restart video", systemImage: "backward.end.fill", cornerRadius: 5) {
|
||||
player.backend.seek(to: 0.0, seekType: .userInteracted)
|
||||
}
|
||||
button("Restart video", systemImage: "backward.end.fill", cornerRadius: 5, action: player.replayAction)
|
||||
}
|
||||
|
||||
private var togglePlayButton: some View {
|
||||
|
@@ -6,6 +6,14 @@ struct VideoActions: View {
|
||||
case share
|
||||
case addToPlaylist
|
||||
case subscribe
|
||||
case fullScreen
|
||||
case pip
|
||||
#if os(iOS)
|
||||
case lockOrientation
|
||||
#endif
|
||||
case restart
|
||||
case advanceToNextItem
|
||||
case musicMode
|
||||
case settings
|
||||
case hide
|
||||
case close
|
||||
@@ -24,6 +32,12 @@ struct VideoActions: View {
|
||||
@Default(.actionButtonAddToPlaylistEnabled) private var actionButtonAddToPlaylistEnabled
|
||||
@Default(.actionButtonSubscribeEnabled) private var actionButtonSubscribeEnabled
|
||||
@Default(.actionButtonSettingsEnabled) private var actionButtonSettingsEnabled
|
||||
@Default(.actionButtonFullScreenEnabled) private var actionButtonFullScreenEnabled
|
||||
@Default(.actionButtonPipEnabled) private var actionButtonPipEnabled
|
||||
@Default(.actionButtonLockOrientationEnabled) private var actionButtonLockOrientationEnabled
|
||||
@Default(.actionButtonRestartEnabled) private var actionButtonRestartEnabled
|
||||
@Default(.actionButtonAdvanceToNextItemEnabled) private var actionButtonAdvanceToNextItemEnabled
|
||||
@Default(.actionButtonMusicModeEnabled) private var actionButtonMusicModeEnabled
|
||||
@Default(.actionButtonHideEnabled) private var actionButtonHideEnabled
|
||||
@Default(.actionButtonCloseEnabled) private var actionButtonCloseEnabled
|
||||
|
||||
@@ -51,6 +65,20 @@ struct VideoActions: View {
|
||||
return actionButtonSubscribeEnabled
|
||||
case .settings:
|
||||
return actionButtonSettingsEnabled
|
||||
case .fullScreen:
|
||||
return actionButtonFullScreenEnabled
|
||||
case .pip:
|
||||
return actionButtonPipEnabled
|
||||
#if os(iOS)
|
||||
case .lockOrientation:
|
||||
return actionButtonLockOrientationEnabled
|
||||
#endif
|
||||
case .restart:
|
||||
return actionButtonRestartEnabled
|
||||
case .advanceToNextItem:
|
||||
return actionButtonAdvanceToNextItemEnabled
|
||||
case .musicMode:
|
||||
return actionButtonMusicModeEnabled
|
||||
case .hide:
|
||||
return actionButtonHideEnabled
|
||||
case .close:
|
||||
@@ -68,6 +96,8 @@ struct VideoActions: View {
|
||||
return !(video?.isLocal ?? true) && accounts.signedIn && accounts.app.supportsSubscriptions
|
||||
case .settings:
|
||||
return video != nil
|
||||
case .advanceToNextItem:
|
||||
return player.isAdvanceToNextItemAvailable
|
||||
default:
|
||||
return true
|
||||
}
|
||||
@@ -110,6 +140,23 @@ struct VideoActions: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
case .fullScreen:
|
||||
actionButton("Fullscreen", systemImage: player.fullscreenImage, action: player.toggleFullScreenAction)
|
||||
case .pip:
|
||||
actionButton("PiP", systemImage: player.pipImage, action: player.togglePiPAction)
|
||||
#if os(iOS)
|
||||
case .lockOrientation:
|
||||
actionButton("Lock", systemImage: player.lockOrientationImage, active: player.lockedOrientation != nil, action: player.lockOrientationAction)
|
||||
#endif
|
||||
case .restart:
|
||||
actionButton("Replay", systemImage: "backward.end.fill", action: player.replayAction)
|
||||
case .advanceToNextItem:
|
||||
actionButton("Next", systemImage: "forward.fill") {
|
||||
player.advanceToNextItem()
|
||||
}
|
||||
case .musicMode:
|
||||
actionButton("Music", systemImage: "music.note", active: player.musicMode, action: player.toggleMusicMode)
|
||||
|
||||
case .settings:
|
||||
actionButton("Settings", systemImage: "gear") {
|
||||
withAnimation(ControlOverlaysModel.animation) {
|
||||
@@ -138,15 +185,17 @@ struct VideoActions: View {
|
||||
func actionButton(
|
||||
_ name: String,
|
||||
systemImage: String,
|
||||
active: Bool = false,
|
||||
action: @escaping () -> Void = {}
|
||||
) -> some View {
|
||||
Button(action: action) {
|
||||
VStack(spacing: 3) {
|
||||
Image(systemName: systemImage)
|
||||
.frame(width: 20, height: 20)
|
||||
.foregroundColor(active ? Color("AppRedColor") : .accentColor)
|
||||
if playerActionsButtonLabelStyle.text {
|
||||
Text(name.localized())
|
||||
.foregroundColor(.secondary)
|
||||
.foregroundColor(active ? Color("AppRedColor") : .secondary)
|
||||
.font(.caption2)
|
||||
.allowsTightening(true)
|
||||
}
|
||||
|
@@ -257,7 +257,7 @@ struct VideoDetails: View {
|
||||
|
||||
switch page {
|
||||
case .queue:
|
||||
return !player.queue.isEmpty
|
||||
return !sidebarQueue && player.isAdvanceToNextItemAvailable
|
||||
default:
|
||||
return !video.isLocal
|
||||
}
|
||||
|
Reference in New Issue
Block a user