mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Home settings
This commit is contained in:
@@ -13,12 +13,24 @@ struct BrowsingSettings: View {
|
||||
@Default(.thumbnailsQuality) private var thumbnailsQuality
|
||||
@Default(.channelOnThumbnail) private var channelOnThumbnail
|
||||
@Default(.timeOnThumbnail) private var timeOnThumbnail
|
||||
@Default(.showHome) private var showHome
|
||||
@Default(.showFavoritesInHome) private var showFavoritesInHome
|
||||
@Default(.showOpenActionsInHome) private var showOpenActionsInHome
|
||||
@Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem
|
||||
@Default(.homeHistoryItems) private var homeHistoryItems
|
||||
@Default(.visibleSections) private var visibleSections
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
|
||||
@State private var homeHistoryItemsText = ""
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
#if os(macOS)
|
||||
sections
|
||||
VStack(alignment: .leading) {
|
||||
sections
|
||||
Spacer()
|
||||
}
|
||||
#else
|
||||
List {
|
||||
sections
|
||||
@@ -38,14 +50,45 @@ struct BrowsingSettings: View {
|
||||
|
||||
private var sections: some View {
|
||||
Group {
|
||||
homeSettings
|
||||
interfaceSettings
|
||||
thumbnailsSettings
|
||||
visibleSectionsSettings
|
||||
if !accounts.isEmpty {
|
||||
thumbnailsSettings
|
||||
visibleSectionsSettings
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var homeSettings: some View {
|
||||
Section(header: SettingsHeader(text: "Home".localized())) {
|
||||
#if !os(tvOS)
|
||||
if !accounts.isEmpty {
|
||||
Toggle("Show Home", isOn: $showHome)
|
||||
}
|
||||
#endif
|
||||
Toggle("Show Open Videos quick actions", isOn: $showOpenActionsInHome)
|
||||
if !accounts.isEmpty {
|
||||
Toggle("Show Favorites", isOn: $showFavoritesInHome)
|
||||
}
|
||||
HStack {
|
||||
TextField("Recent history items", text: $homeHistoryItemsText)
|
||||
#if !os(macOS)
|
||||
.keyboardType(.URL)
|
||||
#endif
|
||||
.onAppear {
|
||||
homeHistoryItemsText = String(homeHistoryItems)
|
||||
}
|
||||
.onChange(of: homeHistoryItemsText) { newValue in
|
||||
homeHistoryItems = Int(newValue) ?? 10
|
||||
}
|
||||
}
|
||||
.multilineTextAlignment(.trailing)
|
||||
}
|
||||
}
|
||||
|
||||
private var interfaceSettings: some View {
|
||||
Section(header: SettingsHeader(text: "Interface".localized())) {
|
||||
Toggle("Show Open Videos toolbar button", isOn: $showOpenActionsToolbarItem)
|
||||
#if os(iOS)
|
||||
Toggle("Lock portrait mode", isOn: $lockPortraitWhenBrowsing)
|
||||
.onChange(of: lockPortraitWhenBrowsing) { lock in
|
||||
@@ -57,11 +100,13 @@ struct BrowsingSettings: View {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(tvOS)
|
||||
Toggle("Show account username", isOn: $accountPickerDisplaysUsername)
|
||||
#endif
|
||||
if !accounts.isEmpty {
|
||||
#if !os(tvOS)
|
||||
Toggle("Show account username", isOn: $accountPickerDisplaysUsername)
|
||||
#endif
|
||||
|
||||
Toggle("Show anonymous accounts", isOn: $accountPickerDisplaysAnonymousAccounts)
|
||||
Toggle("Show anonymous accounts", isOn: $accountPickerDisplaysAnonymousAccounts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -34,15 +34,13 @@ struct SettingsView: View {
|
||||
var settings: some View {
|
||||
#if os(macOS)
|
||||
TabView(selection: $selection) {
|
||||
if !accounts.isEmpty {
|
||||
Form {
|
||||
BrowsingSettings()
|
||||
}
|
||||
.tabItem {
|
||||
Label("Browsing", systemImage: "list.and.film")
|
||||
}
|
||||
.tag(Optional(Tabs.browsing))
|
||||
Form {
|
||||
BrowsingSettings()
|
||||
}
|
||||
.tabItem {
|
||||
Label("Browsing", systemImage: "list.and.film")
|
||||
}
|
||||
.tag(Optional(Tabs.browsing))
|
||||
|
||||
Form {
|
||||
PlayerSettings()
|
||||
@@ -125,12 +123,10 @@ struct SettingsView: View {
|
||||
}
|
||||
#endif
|
||||
|
||||
if !accounts.isEmpty {
|
||||
NavigationLink {
|
||||
BrowsingSettings()
|
||||
} label: {
|
||||
Label("Browsing", systemImage: "list.and.film")
|
||||
}
|
||||
NavigationLink {
|
||||
BrowsingSettings()
|
||||
} label: {
|
||||
Label("Browsing", systemImage: "list.and.film")
|
||||
}
|
||||
|
||||
NavigationLink {
|
||||
@@ -221,9 +217,9 @@ struct SettingsView: View {
|
||||
private var windowHeight: Double {
|
||||
switch selection {
|
||||
case nil:
|
||||
return accounts.isEmpty ? 680 : 400
|
||||
return accounts.isEmpty ? 680 : 520
|
||||
case .browsing:
|
||||
return 400
|
||||
return 520
|
||||
case .player:
|
||||
return 680
|
||||
case .quality:
|
||||
@@ -233,7 +229,7 @@ struct SettingsView: View {
|
||||
case .sponsorBlock:
|
||||
return 700
|
||||
case .advanced:
|
||||
return 650
|
||||
return 750
|
||||
case .help:
|
||||
return 600
|
||||
}
|
||||
|
Reference in New Issue
Block a user