SidebarSection.swift 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. /// Soulseek downloads — shows DownloadsView in center.
  13. case downloads
  14. /// A user playlist — shows PlaylistView in center.
  15. case playlist(Playlist)
  16. }
  17. /// Which library view to show in the center area.
  18. enum LibraryDestination: String, Hashable, CaseIterable {
  19. case browse // root category grid
  20. case albums
  21. case artists
  22. case genres
  23. case years
  24. case search
  25. /// Map to CloudBrowserView's internal navigation.
  26. var initialNavStack: [CloudNavDestination] {
  27. switch self {
  28. case .browse: return []
  29. case .albums: return [.category(.album)]
  30. case .artists: return [.category(.artist)]
  31. case .genres: return [.category(.genre)]
  32. case .years: return [.category(.year)]
  33. case .search: return [.search(query: "")]
  34. }
  35. }
  36. var displayName: String {
  37. switch self {
  38. case .browse: return "Browse"
  39. case .albums: return "Albums"
  40. case .artists: return "Artists"
  41. case .genres: return "Genres"
  42. case .years: return "Years"
  43. case .search: return "Search"
  44. }
  45. }
  46. var icon: String {
  47. switch self {
  48. case .browse: return "globe"
  49. case .albums: return "square.stack"
  50. case .artists: return "music.mic"
  51. case .genres: return "guitars"
  52. case .years: return "calendar"
  53. case .search: return "magnifyingglass"
  54. }
  55. }
  56. }