Add a Currently Playing toggle to the queue panel page

Below Previously Played in the queue page settings; off by default, so
the queue page lists history and up next without the playing video.
With it off the page opens scrolled to Up Next.
This commit is contained in:
Arkadiusz Fal
2026-10-12 19:45:02 +02:00
parent e71bb76f13
commit 4a9a92d140
5 changed files with 45 additions and 7 deletions

View File

@@ -8149,7 +8149,18 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Show videos played earlier in this session above the queue."
"value" : "Previously Played shows videos played earlier in this session above the queue. Currently Playing shows the video playing now."
}
}
}
},
"panel.settings.queue.showNowPlaying" : {
"comment" : "Queue page element toggle",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Currently Playing"
}
}
}

View File

@@ -260,8 +260,12 @@ struct RelatedPageSettings: Codable, Hashable, Sendable {
/// Element toggles for the queue page.
struct QueuePageSettings: Codable, Hashable, Sendable {
var showHistory: Bool?
/// Whether the playing video is listed between history and the queue.
/// Off by default: the player itself already shows it.
var showNowPlaying: Bool?
var effectiveShowHistory: Bool { showHistory ?? true }
var effectiveShowNowPlaying: Bool { showNowPlaying ?? false }
}
/// Element toggles for the chapters page.

View File

@@ -119,6 +119,9 @@ struct QueueListView: View {
/// When false, hides the previously-played section (queue page setting).
var showHistory: Bool = true
/// When false, hides the now-playing section (queue page setting).
var showNowPlaying: Bool = true
private var queueManager: QueueManager? { appEnvironment?.queueManager }
private var playerState: PlayerState? { appEnvironment?.playerService.state }
@@ -158,7 +161,7 @@ struct QueueListView: View {
}
// Now Playing section - show the currently playing video from playerState
if let currentVideo = playerState?.currentVideo {
if showNowPlaying, let currentVideo = playerState?.currentVideo {
Section {
// Create a temporary QueuedVideo for display
let nowPlayingItem = QueuedVideo(
@@ -234,6 +237,7 @@ struct QueueListView: View {
.foregroundStyle(.secondary)
}
}
.id("up-next")
}
}
#if os(iOS)
@@ -244,9 +248,14 @@ struct QueueListView: View {
})
#endif
.onAppear {
// Scroll to now playing section (no animation for instant positioning)
// Scroll past history to the now playing section, or to the
// queue when that is hidden (no animation for instant positioning)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
proxy.scrollTo("now-playing", anchor: .center)
if showNowPlaying {
proxy.scrollTo("now-playing", anchor: .center)
} else {
proxy.scrollTo("up-next", anchor: .top)
}
}
}
}

View File

@@ -14,9 +14,12 @@ struct QueuePanelPage: View {
var bottomInset: CGFloat = 0
var body: some View {
QueueListView(showHistory: settings.effectiveShowHistory)
.safeAreaPadding(.bottom, bottomInset)
.panelListLeadingMargin()
QueueListView(
showHistory: settings.effectiveShowHistory,
showNowPlaying: settings.effectiveShowNowPlaying
)
.safeAreaPadding(.bottom, bottomInset)
.panelListLeadingMargin()
}
}

View File

@@ -27,6 +27,7 @@ struct PanelPageEditorView: View {
@State private var showChapterThumbnails: Bool = true
@State private var chaptersExpandedByDefault: Bool = true
@State private var showHistory: Bool = true
@State private var showNowPlaying: Bool = false
private var configuration: PanelPageConfiguration? {
viewModel.panelSettings.configuration(for: pageType)
@@ -292,6 +293,15 @@ struct PanelPageEditorView: View {
guard newValue != queueSettings.effectiveShowHistory else { return }
viewModel.updatePanelQueueSettingsSync { $0.showHistory = newValue }
}
Toggle(
String(localized: "panel.settings.queue.showNowPlaying"),
isOn: $showNowPlaying
)
.onChange(of: showNowPlaying) { _, newValue in
guard newValue != queueSettings.effectiveShowNowPlaying else { return }
viewModel.updatePanelQueueSettingsSync { $0.showNowPlaying = newValue }
}
} header: {
Text(String(localized: "panel.settings.elements.header"))
} footer: {
@@ -337,6 +347,7 @@ struct PanelPageEditorView: View {
showChapterThumbnails = chaptersSettings.effectiveShowThumbnails
chaptersExpandedByDefault = chaptersSettings.effectiveExpandedByDefault
showHistory = queueSettings.effectiveShowHistory
showNowPlaying = queueSettings.effectiveShowNowPlaying
}
}