mirror of
https://github.com/yattee/yattee.git
synced 2026-05-12 18:35:05 +00:00
Fix macOS sidebar dynamic item switching
This commit is contained in:
@@ -879,8 +879,8 @@ extension UnifiedTabView {
|
|||||||
homePath.append(destination)
|
homePath.append(destination)
|
||||||
case .search:
|
case .search:
|
||||||
searchPath.append(destination)
|
searchPath.append(destination)
|
||||||
case .channel(let channelID, _, _):
|
case .channel:
|
||||||
channelPaths[channelID, default: NavigationPath()].append(destination)
|
channelPaths[selection.id, default: NavigationPath()].append(destination)
|
||||||
case .playlist(let id, _):
|
case .playlist(let id, _):
|
||||||
playlistPaths[id, default: NavigationPath()].append(destination)
|
playlistPaths[id, default: NavigationPath()].append(destination)
|
||||||
case .mediaSource(let id, _, _):
|
case .mediaSource(let id, _, _):
|
||||||
@@ -919,10 +919,10 @@ extension UnifiedTabView {
|
|||||||
|
|
||||||
// MARK: - Path Bindings
|
// MARK: - Path Bindings
|
||||||
|
|
||||||
func channelPathBinding(for channelID: String) -> Binding<NavigationPath> {
|
func channelPathBinding(for item: SidebarItem) -> Binding<NavigationPath> {
|
||||||
Binding(
|
Binding(
|
||||||
get: { channelPaths[channelID] ?? NavigationPath() },
|
get: { channelPaths[item.id] ?? NavigationPath() },
|
||||||
set: { channelPaths[channelID] = $0 }
|
set: { channelPaths[item.id] = $0 }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -952,10 +952,11 @@ extension UnifiedTabView {
|
|||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
func channelContent(for item: SidebarItem) -> some View {
|
func channelContent(for item: SidebarItem) -> some View {
|
||||||
if case .channel(let channelID, _, let source) = item {
|
if case .channel(let channelID, _, let source) = item {
|
||||||
NavigationStack(path: channelPathBinding(for: channelID)) {
|
NavigationStack(path: channelPathBinding(for: item)) {
|
||||||
ChannelView(channelID: channelID, source: source)
|
ChannelView(channelID: channelID, source: source)
|
||||||
.withNavigationDestinations()
|
.withNavigationDestinations()
|
||||||
}
|
}
|
||||||
|
.id(item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -983,6 +984,7 @@ extension UnifiedTabView {
|
|||||||
UnifiedPlaylistDetailView(source: .local(id))
|
UnifiedPlaylistDetailView(source: .local(id))
|
||||||
.withNavigationDestinations()
|
.withNavigationDestinations()
|
||||||
}
|
}
|
||||||
|
.id(item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1007,6 +1009,7 @@ extension UnifiedTabView {
|
|||||||
MediaBrowserView(source: source, path: "/")
|
MediaBrowserView(source: source, path: "/")
|
||||||
.withNavigationDestinations()
|
.withNavigationDestinations()
|
||||||
}
|
}
|
||||||
|
.id(item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1020,6 +1023,7 @@ extension UnifiedTabView {
|
|||||||
InstanceBrowseView(instance: instance)
|
InstanceBrowseView(instance: instance)
|
||||||
.withNavigationDestinations()
|
.withNavigationDestinations()
|
||||||
}
|
}
|
||||||
|
.id(item.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user