// // SidebarMainItem.swift // Yattee // // Configurable sidebar main navigation item definitions. // import Foundation /// Represents a configurable main navigation item in the sidebar. enum SidebarMainItem: String, CaseIterable, Codable, Identifiable, Sendable { case search case home case subscriptions case bookmarks case history case downloads case channels case sources case settings var id: String { rawValue } /// Default order for sidebar main items. static var defaultOrder: [SidebarMainItem] { [.search, .home, .subscriptions, .bookmarks, .history, .channels, .sources, .downloads, .settings] } /// Default visibility (all visible except subscriptions and channels). static var defaultVisibility: [SidebarMainItem: Bool] { [ .search: true, .home: true, .subscriptions: false, .bookmarks: false, .history: false, .downloads: true, .channels: false, .sources: true, .settings: true ] } /// SF Symbol icon name. var icon: String { switch self { case .search: "magnifyingglass" case .home: "house.fill" case .subscriptions: "play.square.stack.fill" case .bookmarks: "bookmark.fill" case .history: "clock" case .downloads: "arrow.down.circle" case .channels: "person.2" case .sources: "server.rack" case .settings: "gear" } } /// Localized display title. var localizedTitle: String { switch self { case .search: String(localized: "sidebar.mainItem.search") case .home: String(localized: "sidebar.mainItem.home") case .subscriptions: String(localized: "sidebar.mainItem.subscriptions") case .bookmarks: String(localized: "sidebar.mainItem.bookmarks") case .history: String(localized: "sidebar.mainItem.history") case .downloads: String(localized: "sidebar.mainItem.downloads") case .channels: String(localized: "sidebar.mainItem.channels") case .sources: String(localized: "sidebar.mainItem.sources") case .settings: String(localized: "sidebar.mainItem.settings") } } /// Whether this item is required and cannot be hidden. var isRequired: Bool { switch self { case .search, .home: return true default: return false } } /// Whether this item is available on the current platform. var isAvailableOnCurrentPlatform: Bool { switch self { case .downloads: #if os(tvOS) return false #else return true #endif default: return true } } // MARK: - Tab Value Mappings /// Tab value for CompactTabView (String-based). /// Fixed tabs use "home" and "search", configurable tabs use TabBarItem.rawValue. var compactTabValue: String { switch self { case .search: return "search" case .home: return "home" case .subscriptions: return TabBarItem.subscriptions.rawValue case .bookmarks: return TabBarItem.bookmarks.rawValue case .history: return TabBarItem.history.rawValue case .downloads: return TabBarItem.downloads.rawValue case .channels: return TabBarItem.channels.rawValue case .sources: return TabBarItem.sources.rawValue case .settings: return TabBarItem.settings.rawValue } } /// SidebarItem value for UnifiedTabView. var sidebarItem: SidebarItem { switch self { case .search: return .search case .home: return .home case .subscriptions: return .subscriptionsFeed case .bookmarks: return .bookmarks case .history: return .history case .downloads: return .downloads case .channels: return .manageChannels case .sources: return .sources case .settings: return .settings } } /// Initialize from TabBarItem (for reverse mapping). init?(tabBarItem: TabBarItem) { switch tabBarItem { case .subscriptions: self = .subscriptions case .channels: self = .channels case .bookmarks: self = .bookmarks case .playlists: return nil // No direct mapping - playlists isn't a SidebarMainItem case .history: self = .history case .downloads: self = .downloads case .sources: self = .sources case .settings: self = .settings } } }