diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index cfe9b4d3..75ff382b 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -185,6 +185,7 @@ extension Defaults.Keys { static let trendingCountry = Key("trendingCountry", default: .us) static let visibleSections = Key>("visibleSections", default: [.subscriptions, .trending, .playlists]) + static let startupSection = Key("startupSection", default: .home) #if os(iOS) static let honorSystemOrientationLock = Key("honorSystemOrientationLock", default: true) @@ -340,6 +341,31 @@ enum VisibleSection: String, CaseIterable, Comparable, Defaults.Serializable { } } +enum StartupSection: String, CaseIterable, Defaults.Serializable { + case home, subscriptions, popular, trending, playlists, search + + var label: String { + rawValue.capitalized.localized() + } + + var tabSelection: TabSelection { + switch self { + case .home: + return .home + case .subscriptions: + return .subscriptions + case .popular: + return .popular + case .trending: + return .trending + case .playlists: + return .playlists + case .search: + return .search + } + } +} + enum WatchedVideoStyle: String, Defaults.Serializable { case nothing, badge, decreasedOpacity, both diff --git a/Shared/Settings/BrowsingSettings.swift b/Shared/Settings/BrowsingSettings.swift index cabb140a..4cd7d00d 100644 --- a/Shared/Settings/BrowsingSettings.swift +++ b/Shared/Settings/BrowsingSettings.swift @@ -17,6 +17,7 @@ struct BrowsingSettings: View { @Default(.timeOnThumbnail) private var timeOnThumbnail @Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem @Default(.visibleSections) private var visibleSections + @Default(.startupSection) private var startupSection @Default(.playerButtonSingleTapGesture) private var playerButtonSingleTapGesture @Default(.playerButtonDoubleTapGesture) private var playerButtonDoubleTapGesture @Default(.playerButtonShowsControlButtonsWhenMinimized) private var playerButtonShowsControlButtonsWhenMinimized @@ -50,7 +51,7 @@ struct BrowsingSettings: View { #endif } #if os(tvOS) - .frame(maxWidth: 1000) + .frame(maxWidth: 1200) #else .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading) #endif @@ -60,25 +61,28 @@ struct BrowsingSettings: View { private var sections: some View { Group { homeSettings + if !accounts.isEmpty { + startupSectionPicker + visibleSectionsSettings + } let interface = interfaceSettings #if os(tvOS) if !accounts.isEmpty { interface } #else - playerBarSettings interface + playerBarSettings #endif if !accounts.isEmpty { thumbnailsSettings - visibleSectionsSettings } } } @ViewBuilder private var homeSettings: some View { if !accounts.isEmpty { - Section(header: SettingsHeader(text: "Home".localized())) { + Section { #if os(macOS) Button { presentingHomeSettingsSheet = true @@ -204,37 +208,28 @@ struct BrowsingSettings: View { private var visibleSectionsSettings: some View { Section(header: SettingsHeader(text: "Sections".localized())) { - #if os(macOS) - let list = ForEach(VisibleSection.allCases, id: \.self) { section in - MultiselectRow( - title: section.title, - selected: visibleSections.contains(section) - ) { value in - toggleSection(section, value: value) - } + ForEach(VisibleSection.allCases, id: \.self) { section in + MultiselectRow( + title: section.title, + selected: visibleSections.contains(section) + ) { value in + toggleSection(section, value: value) } + } + } + } - Group { - if #available(macOS 12.0, *) { - list - .listStyle(.inset(alternatesRowBackgrounds: true)) - } else { - list - .listStyle(.inset) - } - - Spacer() - } - #else - ForEach(VisibleSection.allCases, id: \.self) { section in - MultiselectRow( - title: section.title, - selected: visibleSections.contains(section) - ) { value in - toggleSection(section, value: value) - } - } + private var startupSectionPicker: some View { + Group { + #if os(tvOS) + SettingsHeader(text: "Startup section".localized()) #endif + Picker("Startup section", selection: $startupSection) { + ForEach(StartupSection.allCases, id: \.rawValue) { section in + Text(section.label).tag(section) + } + } + .modifier(SettingsPickerModifier()) } } diff --git a/Shared/Settings/SettingsView.swift b/Shared/Settings/SettingsView.swift index 28a061f4..036794ba 100644 --- a/Shared/Settings/SettingsView.swift +++ b/Shared/Settings/SettingsView.swift @@ -243,7 +243,7 @@ struct SettingsView: View { private var windowHeight: Double { switch selection { case .browsing: - return 880 + return 720 case .player: return 480 case .controls: diff --git a/Shared/YatteeApp.swift b/Shared/YatteeApp.swift index 48dc409c..31bf3ee1 100644 --- a/Shared/YatteeApp.swift +++ b/Shared/YatteeApp.swift @@ -152,7 +152,8 @@ struct YatteeApp: App { recents.clear() } - var section = Defaults[.showHome] ? TabSelection.home : Defaults[.visibleSections].min()?.tabSelection + let startupSection = Defaults[.startupSection] + var section: TabSelection? = startupSection.tabSelection #if os(macOS) if section == .playlists {