mirror of
https://github.com/yattee/yattee.git
synced 2026-07-21 06:42:01 +00:00
Present view options and search filters as popovers on macOS
Plain-Form sheets rendered as columns-style content floating inside oversized fixed frames on macOS. Anchor these panels to their toolbar buttons as popovers instead, sized to content; iOS/tvOS keep sheets. - Search and PeerTube explore filters apply live (Cancel never reverted anything anyway) and dismiss on outside click - Subscriptions/Manage Channels "Subscriptions Data" opens as a sheet from the popover's onDisappear via a pending flag, since presenting while the popover dismisses gets swallowed - Media browser view options drop navigation chrome on macOS
This commit is contained in:
@@ -59,6 +59,15 @@ struct MediaBrowserView: View {
|
||||
return sortedFiles(result)
|
||||
}
|
||||
|
||||
private var viewOptionsSheetContent: some View {
|
||||
MediaBrowserViewOptionsSheet(
|
||||
sourceType: source.type,
|
||||
sortOrder: $sortOrder,
|
||||
sortAscending: $sortAscending,
|
||||
showOnlyPlayable: $showOnlyPlayable
|
||||
)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
content
|
||||
#if !os(tvOS)
|
||||
@@ -91,18 +100,20 @@ struct MediaBrowserView: View {
|
||||
)
|
||||
}
|
||||
.liquidGlassTransitionSource(id: "mediaBrowserViewOptions", in: sheetTransition)
|
||||
#if os(macOS)
|
||||
.popover(isPresented: $showViewOptions, arrowEdge: .bottom) {
|
||||
viewOptionsSheetContent
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if !os(macOS)
|
||||
.sheet(isPresented: $showViewOptions) {
|
||||
MediaBrowserViewOptionsSheet(
|
||||
sourceType: source.type,
|
||||
sortOrder: $sortOrder,
|
||||
sortAscending: $sortAscending,
|
||||
showOnlyPlayable: $showOnlyPlayable
|
||||
)
|
||||
.liquidGlassSheetContent(sourceID: "mediaBrowserViewOptions", in: sheetTransition)
|
||||
viewOptionsSheetContent
|
||||
.liquidGlassSheetContent(sourceID: "mediaBrowserViewOptions", in: sheetTransition)
|
||||
}
|
||||
#endif
|
||||
.task {
|
||||
await loadFiles()
|
||||
}
|
||||
|
||||
@@ -21,26 +21,43 @@ struct MediaBrowserViewOptionsSheet: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
#if os(macOS)
|
||||
// Popover content: no navigation chrome, click-outside dismisses.
|
||||
formContent
|
||||
.padding()
|
||||
.frame(width: 300)
|
||||
.onAppear {
|
||||
// Reset sort order if current selection is not available for this source type
|
||||
if !availableSortOptions.contains(sortOrder) {
|
||||
sortOrder = .name
|
||||
}
|
||||
}
|
||||
#else
|
||||
NavigationStack {
|
||||
#if os(tvOS)
|
||||
listContent
|
||||
#else
|
||||
formContent
|
||||
.navigationTitle("mediaBrowser.viewOptions.title")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.toolbar {
|
||||
sheetCloseToolbarItem { dismiss() }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if os(iOS)
|
||||
.presentationDetents([.height(280)])
|
||||
.presentationDragIndicator(.visible)
|
||||
#endif
|
||||
#if os(macOS)
|
||||
.frame(minWidth: 420, minHeight: 320)
|
||||
#endif
|
||||
.onAppear {
|
||||
// Reset sort order if current selection is not available for this source type
|
||||
if !availableSortOptions.contains(sortOrder) {
|
||||
sortOrder = .name
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -83,13 +100,6 @@ struct MediaBrowserViewOptionsSheet: View {
|
||||
sharedOptions
|
||||
}
|
||||
}
|
||||
.navigationTitle("mediaBrowser.viewOptions.title")
|
||||
#if os(iOS)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
#endif
|
||||
.toolbar {
|
||||
sheetCloseToolbarItem { dismiss() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user