mirror of
https://github.com/yattee/yattee.git
synced 2026-10-29 16:07:20 +00:00
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:
@@ -24,6 +24,9 @@ struct ContentView: View {
|
||||
ProgressView(String(localized: "common.loading"))
|
||||
}
|
||||
}
|
||||
// Shared sheets for the main window. The expanded player hosts its own,
|
||||
// and takes global requests while it is up.
|
||||
.appSheetHost(isTopLevel: appEnvironment?.navigationCoordinator.isPlayerExpanded != true)
|
||||
.toastOverlay()
|
||||
}
|
||||
|
||||
@@ -101,20 +104,6 @@ struct ContentView: View {
|
||||
appEnvironment.settingsManager.macPlayerSeparateWindow else { return }
|
||||
ExpandedPlayerWindowManager.shared.updateWindowLevel(floating: floating)
|
||||
}
|
||||
.sheet(isPresented: Binding(
|
||||
get: { appEnvironment.navigationCoordinator.isMiniPlayerQueueSheetPresented },
|
||||
set: { appEnvironment.navigationCoordinator.isMiniPlayerQueueSheetPresented = $0 }
|
||||
)) {
|
||||
QueueManagementSheet()
|
||||
}
|
||||
.sheet(isPresented: Binding(
|
||||
get: { appEnvironment.navigationCoordinator.isMiniPlayerPlaylistSheetPresented },
|
||||
set: { appEnvironment.navigationCoordinator.isMiniPlayerPlaylistSheetPresented = $0 }
|
||||
)) {
|
||||
if let video = appEnvironment.playerService.state.currentVideo {
|
||||
PlaylistSelectorSheet(video: video)
|
||||
}
|
||||
}
|
||||
#elseif os(tvOS)
|
||||
.fullScreenCover(isPresented: Binding(
|
||||
get: { appEnvironment.navigationCoordinator.isPlayerExpanded },
|
||||
@@ -178,8 +167,6 @@ struct AdaptiveTabView: View {
|
||||
|
||||
let appEnvironment: AppEnvironment
|
||||
|
||||
@State private var showingMiniPlayerQueueSheet = false
|
||||
@State private var showingMiniPlayerPlaylistSheet = false
|
||||
|
||||
/// Whether to show the black overlay that covers scaled content when player is expanded
|
||||
private var shouldShowExpandedOverlay: Bool {
|
||||
@@ -243,26 +230,6 @@ struct AdaptiveTabView: View {
|
||||
ExpandedPlayerWindowManager.shared.hide()
|
||||
}
|
||||
}
|
||||
.onChange(of: appEnvironment.navigationCoordinator.isMiniPlayerQueueSheetPresented, initial: true) { _, newValue in
|
||||
showingMiniPlayerQueueSheet = newValue
|
||||
}
|
||||
.onChange(of: appEnvironment.navigationCoordinator.isMiniPlayerPlaylistSheetPresented, initial: true) { _, newValue in
|
||||
showingMiniPlayerPlaylistSheet = newValue
|
||||
}
|
||||
.sheet(isPresented: $showingMiniPlayerQueueSheet, onDismiss: {
|
||||
appEnvironment.navigationCoordinator.isMiniPlayerQueueSheetPresented = false
|
||||
}) {
|
||||
QueueManagementSheet()
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
.sheet(isPresented: $showingMiniPlayerPlaylistSheet, onDismiss: {
|
||||
appEnvironment.navigationCoordinator.isMiniPlayerPlaylistSheetPresented = false
|
||||
}) {
|
||||
if let video = appEnvironment.playerService.state.currentVideo {
|
||||
PlaylistSelectorSheet(video: video)
|
||||
.presentationDetents([.medium, .large])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var usesSidebar: Bool {
|
||||
|
||||
Reference in New Issue
Block a user