SidebarSection.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import Foundation
  2. import SwiftData
  3. /// Which section of the sidebar is selected — drives the central content area.
  4. ///
  5. /// A single `@State var sidebarSelection: SidebarSection?` in ContentView replaces
  6. /// the old triple-state model (selectedPlaylist + isBrowsePanelOpen + browsePanelTab).
  7. enum SidebarSection: Hashable {
  8. /// Cloud library browsing — shows CloudBrowserView in center.
  9. case library(LibraryDestination)
  10. /// Playback queue — shows QueueView in center.
  11. case queue
  12. /// A user playlist — shows PlaylistView in center.
  13. case playlist(Playlist)
  14. }
  15. /// Which library view to show in the center area.
  16. enum LibraryDestination: String, Hashable, CaseIterable {
  17. case browse // root category grid
  18. case albums
  19. case artists
  20. case genres
  21. case years
  22. case search
  23. /// Map to CloudBrowserView's internal navigation.
  24. var initialNavStack: [CloudNavDestination] {
  25. switch self {
  26. case .browse: return []
  27. case .albums: return [.category(.album)]
  28. case .artists: return [.category(.artist)]
  29. case .genres: return [.category(.genre)]
  30. case .years: return [.category(.year)]
  31. case .search: return [.search(query: "")]
  32. }
  33. }
  34. var displayName: String {
  35. switch self {
  36. case .browse: return "Browse"
  37. case .albums: return "Albums"
  38. case .artists: return "Artists"
  39. case .genres: return "Genres"
  40. case .years: return "Years"
  41. case .search: return "Search"
  42. }
  43. }
  44. var icon: String {
  45. switch self {
  46. case .browse: return "globe"
  47. case .albums: return "square.stack"
  48. case .artists: return "music.mic"
  49. case .genres: return "guitars"
  50. case .years: return "calendar"
  51. case .search: return "magnifyingglass"
  52. }
  53. }
  54. }