Present shared sheets through one host per window

The add-to-playlist, download options and queue sheets were declared in
every view that could open them: the root view (twice, mirrored from
coordinator flags), the expanded player, its portrait and floating
panels, the player controls and the video info view.

AppSheet lists the shared sheets, and .appSheetHost() declares them
once. The app root and the expanded player each host them, and every
presented sheet hosts the next level. Views present through the
presentAppSheet environment action, which reaches the nearest host;
code without a view (and the expanded player itself, whose host sits
in its own body) uses PresentationRouter.request, taken by the
top-most host: the player while it is up, the root otherwise.

The mini player's queue and playlist sheets now go through the host,
replacing the isMiniPlayer*SheetPresented flags.
This commit is contained in:
Arkadiusz Fal
2026-10-03 23:45:08 +02:00
parent c0495f3174
commit 28a75792e8
13 changed files with 241 additions and 151 deletions

View File

@@ -11,6 +11,7 @@ import SwiftUI
struct PlayerPillButtonView: View {
@Environment(\.appEnvironment) private var appEnvironment
@Environment(\.presentAppSheet) private var presentAppSheet
let configuration: ControlButtonConfiguration
let isPlaying: Bool
@@ -24,7 +25,6 @@ struct PlayerPillButtonView: View {
// Context for special buttons
let video: Video?
let playbackRate: PlaybackRate
@Binding var showingPlaylistSheet: Bool
// Callbacks
let onAction: () -> Void
@@ -263,7 +263,9 @@ struct PlayerPillButtonView: View {
private var addToPlaylistButton: some View {
Button {
showingPlaylistSheet = true
if let video {
presentAppSheet(.addToPlaylist(video))
}
} label: {
genericButtonLabel
}
@@ -326,7 +328,6 @@ struct PlayerPillButtonView: View {
isOrientationLocked: false,
video: nil,
playbackRate: .x1,
showingPlaylistSheet: .constant(false),
onAction: {},
onRateChanged: { _ in },
onTogglePiP: {}
@@ -348,7 +349,6 @@ struct PlayerPillButtonView: View {
isOrientationLocked: false,
video: nil,
playbackRate: .x1,
showingPlaylistSheet: .constant(false),
onAction: {},
onRateChanged: { _ in },
onTogglePiP: {}
@@ -364,7 +364,6 @@ struct PlayerPillButtonView: View {
isOrientationLocked: false,
video: nil,
playbackRate: .x1,
showingPlaylistSheet: .constant(false),
onAction: {},
onRateChanged: { _ in },
onTogglePiP: {}