mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
parent
ae144ea82f
commit
59f48c739a
@ -185,6 +185,7 @@ extension Defaults.Keys {
|
||||
static let trendingCountry = Key<Country>("trendingCountry", default: .us)
|
||||
|
||||
static let visibleSections = Key<Set<VisibleSection>>("visibleSections", default: [.subscriptions, .trending, .playlists])
|
||||
static let startupSection = Key<StartupSection>("startupSection", default: .home)
|
||||
|
||||
#if os(iOS)
|
||||
static let honorSystemOrientationLock = Key<Bool>("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
|
||||
|
||||
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user