2021-11-05 04:55:51 +05:30
|
|
|
import Defaults
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct BrowsingSettings: View {
|
2022-01-03 01:04:50 +05:30
|
|
|
#if !os(tvOS)
|
|
|
|
@Default(.accountPickerDisplaysUsername) private var accountPickerDisplaysUsername
|
2022-01-06 20:26:59 +05:30
|
|
|
@Default(.roundedThumbnails) private var roundedThumbnails
|
2022-01-03 01:04:50 +05:30
|
|
|
#endif
|
2022-08-26 05:06:46 +05:30
|
|
|
@Default(.accountPickerDisplaysAnonymousAccounts) private var accountPickerDisplaysAnonymousAccounts
|
2023-03-01 01:47:12 +05:30
|
|
|
@Default(.showUnwatchedFeedBadges) private var showUnwatchedFeedBadges
|
2022-01-03 01:11:04 +05:30
|
|
|
#if os(iOS)
|
2022-11-19 04:09:52 +05:30
|
|
|
@Default(.homeRecentDocumentsItems) private var homeRecentDocumentsItems
|
2022-01-03 01:11:04 +05:30
|
|
|
@Default(.lockPortraitWhenBrowsing) private var lockPortraitWhenBrowsing
|
2022-11-19 05:08:32 +05:30
|
|
|
@Default(.showDocuments) private var showDocuments
|
2022-01-03 01:11:04 +05:30
|
|
|
#endif
|
2022-06-26 17:55:54 +05:30
|
|
|
@Default(.thumbnailsQuality) private var thumbnailsQuality
|
2021-11-05 04:55:51 +05:30
|
|
|
@Default(.channelOnThumbnail) private var channelOnThumbnail
|
|
|
|
@Default(.timeOnThumbnail) private var timeOnThumbnail
|
2022-11-12 01:58:40 +05:30
|
|
|
@Default(.showHome) private var showHome
|
|
|
|
@Default(.showFavoritesInHome) private var showFavoritesInHome
|
2022-12-19 06:07:09 +05:30
|
|
|
@Default(.showQueueInHome) private var showQueueInHome
|
2022-11-12 01:58:40 +05:30
|
|
|
@Default(.showOpenActionsInHome) private var showOpenActionsInHome
|
|
|
|
@Default(.showOpenActionsToolbarItem) private var showOpenActionsToolbarItem
|
|
|
|
@Default(.homeHistoryItems) private var homeHistoryItems
|
2021-12-01 16:52:19 +05:30
|
|
|
@Default(.visibleSections) private var visibleSections
|
2022-12-18 00:05:07 +05:30
|
|
|
@Default(.playerButtonSingleTapGesture) private var playerButtonSingleTapGesture
|
|
|
|
@Default(.playerButtonDoubleTapGesture) private var playerButtonDoubleTapGesture
|
|
|
|
@Default(.playerButtonShowsControlButtonsWhenMinimized) private var playerButtonShowsControlButtonsWhenMinimized
|
2022-12-19 06:07:09 +05:30
|
|
|
@Default(.playerButtonIsExpanded) private var playerButtonIsExpanded
|
|
|
|
@Default(.playerBarMaxWidth) private var playerBarMaxWidth
|
|
|
|
@Default(.expandChannelDescription) private var expandChannelDescription
|
2021-11-05 04:55:51 +05:30
|
|
|
|
2022-11-25 02:06:05 +05:30
|
|
|
@ObservedObject private var accounts = AccountsModel.shared
|
2022-11-12 01:58:40 +05:30
|
|
|
|
|
|
|
@State private var homeHistoryItemsText = ""
|
2022-11-19 04:09:52 +05:30
|
|
|
#if os(iOS)
|
|
|
|
@State private var homeRecentDocumentsItemsText = ""
|
|
|
|
#endif
|
2022-11-12 06:17:31 +05:30
|
|
|
#if os(macOS)
|
|
|
|
@State private var presentingEditFavoritesSheet = false
|
|
|
|
#endif
|
2022-11-12 01:58:40 +05:30
|
|
|
|
2021-11-05 04:55:51 +05:30
|
|
|
var body: some View {
|
2021-12-01 16:52:19 +05:30
|
|
|
Group {
|
2022-01-06 20:26:59 +05:30
|
|
|
#if os(macOS)
|
2022-11-12 01:58:40 +05:30
|
|
|
VStack(alignment: .leading) {
|
|
|
|
sections
|
|
|
|
Spacer()
|
|
|
|
}
|
2022-01-06 20:26:59 +05:30
|
|
|
#else
|
|
|
|
List {
|
|
|
|
sections
|
|
|
|
}
|
2022-01-03 01:11:04 +05:30
|
|
|
#if os(iOS)
|
2022-01-06 20:26:59 +05:30
|
|
|
.listStyle(.insetGrouped)
|
2022-01-03 01:11:04 +05:30
|
|
|
#endif
|
2022-01-06 20:26:59 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#if os(tvOS)
|
|
|
|
.frame(maxWidth: 1000)
|
|
|
|
#else
|
|
|
|
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
|
|
|
#endif
|
|
|
|
.navigationTitle("Browsing")
|
|
|
|
}
|
|
|
|
|
|
|
|
private var sections: some View {
|
|
|
|
Group {
|
2022-11-12 01:58:40 +05:30
|
|
|
homeSettings
|
2022-11-19 05:08:32 +05:30
|
|
|
let interface = interfaceSettings
|
|
|
|
#if os(tvOS)
|
|
|
|
if !accounts.isEmpty {
|
|
|
|
interface
|
|
|
|
}
|
|
|
|
#else
|
2022-12-18 00:05:07 +05:30
|
|
|
playerBarSettings
|
2022-11-19 05:08:32 +05:30
|
|
|
interface
|
|
|
|
#endif
|
2022-11-12 01:58:40 +05:30
|
|
|
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)
|
2022-12-19 06:07:09 +05:30
|
|
|
Toggle("Show Next in Queue", isOn: $showQueueInHome)
|
2022-11-13 04:31:04 +05:30
|
|
|
|
2022-11-19 05:08:32 +05:30
|
|
|
#if os(iOS)
|
|
|
|
HStack {
|
|
|
|
Text("Recent Documents")
|
|
|
|
TextField("Recent Documents", text: $homeRecentDocumentsItemsText)
|
2022-11-19 17:24:37 +05:30
|
|
|
.multilineTextAlignment(.trailing)
|
2022-11-19 05:08:32 +05:30
|
|
|
.labelsHidden()
|
|
|
|
#if !os(macOS)
|
|
|
|
.keyboardType(.numberPad)
|
|
|
|
#endif
|
|
|
|
.onAppear {
|
|
|
|
homeRecentDocumentsItemsText = String(homeRecentDocumentsItems)
|
|
|
|
}
|
|
|
|
.onChange(of: homeRecentDocumentsItemsText) { newValue in
|
|
|
|
homeRecentDocumentsItems = Int(newValue) ?? 3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2022-11-19 04:09:52 +05:30
|
|
|
|
2022-11-19 17:24:37 +05:30
|
|
|
HStack {
|
|
|
|
Text("Recent History")
|
|
|
|
TextField("Recent History", text: $homeHistoryItemsText)
|
|
|
|
.multilineTextAlignment(.trailing)
|
|
|
|
.labelsHidden()
|
|
|
|
#if !os(macOS)
|
|
|
|
.keyboardType(.numberPad)
|
|
|
|
#endif
|
|
|
|
.onAppear {
|
|
|
|
homeHistoryItemsText = String(homeHistoryItems)
|
|
|
|
}
|
|
|
|
.onChange(of: homeHistoryItemsText) { newValue in
|
|
|
|
homeHistoryItems = Int(newValue) ?? 10
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-12 06:17:31 +05:30
|
|
|
if !accounts.isEmpty {
|
|
|
|
Toggle("Show Favorites", isOn: $showFavoritesInHome)
|
|
|
|
|
|
|
|
Group {
|
|
|
|
#if os(macOS)
|
|
|
|
Button {
|
|
|
|
presentingEditFavoritesSheet = true
|
|
|
|
} label: {
|
2022-11-19 05:08:32 +05:30
|
|
|
Text("Edit Favorites…")
|
2022-11-12 06:17:31 +05:30
|
|
|
}
|
|
|
|
.sheet(isPresented: $presentingEditFavoritesSheet) {
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Button("Done") {
|
|
|
|
presentingEditFavoritesSheet = false
|
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
.keyboardShortcut(.cancelAction)
|
|
|
|
|
|
|
|
EditFavorites()
|
|
|
|
}
|
|
|
|
.frame(width: 500, height: 300)
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NavigationLink(destination: LazyView(EditFavorites())) {
|
2022-11-19 04:36:13 +05:30
|
|
|
Text("Edit Favorites…")
|
2022-11-12 06:17:31 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
.disabled(!showFavoritesInHome)
|
|
|
|
}
|
2022-01-06 20:26:59 +05:30
|
|
|
}
|
|
|
|
}
|
2021-11-08 02:21:22 +05:30
|
|
|
|
2022-12-18 00:05:07 +05:30
|
|
|
#if !os(tvOS)
|
|
|
|
private var playerBarSettings: some View {
|
|
|
|
Section(header: SettingsHeader(text: "Player Bar".localized()), footer: playerBarFooter) {
|
2022-12-19 06:07:09 +05:30
|
|
|
Toggle("Open expanded", isOn: $playerButtonIsExpanded)
|
2022-12-18 00:05:07 +05:30
|
|
|
Toggle("Always show controls buttons", isOn: $playerButtonShowsControlButtonsWhenMinimized)
|
|
|
|
playerBarGesturePicker("Single tap gesture", selection: $playerButtonSingleTapGesture)
|
|
|
|
playerBarGesturePicker("Double tap gesture", selection: $playerButtonDoubleTapGesture)
|
2022-12-19 06:07:09 +05:30
|
|
|
HStack {
|
|
|
|
Text("Maximum width expanded")
|
|
|
|
Spacer()
|
|
|
|
TextField("Maximum width expanded", text: $playerBarMaxWidth)
|
|
|
|
.frame(maxWidth: 100, alignment: .trailing)
|
|
|
|
.multilineTextAlignment(.trailing)
|
|
|
|
.labelsHidden()
|
|
|
|
#if !os(macOS)
|
|
|
|
.keyboardType(.numberPad)
|
|
|
|
#endif
|
|
|
|
}
|
2022-12-18 00:05:07 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func playerBarGesturePicker(_ label: String, selection: Binding<PlayerTapGestureAction>) -> some View {
|
|
|
|
Picker(label, selection: selection) {
|
|
|
|
ForEach(PlayerTapGestureAction.allCases, id: \.rawValue) { action in
|
|
|
|
Text(action.label).tag(action)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var playerBarFooter: some View {
|
|
|
|
#if os(iOS)
|
|
|
|
Text("Tap and hold channel thumbnail to open context menu with more actions")
|
|
|
|
#elseif os(macOS)
|
|
|
|
Text("Right click channel thumbnail to open context menu with more actions")
|
2022-12-19 18:05:37 +05:30
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.padding(.bottom, 10)
|
2022-12-18 00:05:07 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-01-06 20:26:59 +05:30
|
|
|
private var interfaceSettings: some View {
|
2022-09-04 20:58:30 +05:30
|
|
|
Section(header: SettingsHeader(text: "Interface".localized())) {
|
2022-11-12 07:09:44 +05:30
|
|
|
#if !os(tvOS)
|
|
|
|
Toggle("Show Open Videos toolbar button", isOn: $showOpenActionsToolbarItem)
|
|
|
|
#endif
|
2022-01-06 20:26:59 +05:30
|
|
|
#if os(iOS)
|
2022-11-13 04:31:04 +05:30
|
|
|
Toggle("Show Documents", isOn: $showDocuments)
|
|
|
|
|
2022-01-06 20:26:59 +05:30
|
|
|
Toggle("Lock portrait mode", isOn: $lockPortraitWhenBrowsing)
|
|
|
|
.onChange(of: lockPortraitWhenBrowsing) { lock in
|
|
|
|
if lock {
|
|
|
|
Orientation.lockOrientation(.portrait, andRotateTo: .portrait)
|
2021-12-01 16:52:19 +05:30
|
|
|
} else {
|
2022-01-06 20:26:59 +05:30
|
|
|
Orientation.lockOrientation(.allButUpsideDown)
|
2021-12-01 16:52:19 +05:30
|
|
|
}
|
2022-01-06 20:26:59 +05:30
|
|
|
}
|
|
|
|
#endif
|
2021-12-03 00:52:55 +05:30
|
|
|
|
2022-11-12 01:58:40 +05:30
|
|
|
if !accounts.isEmpty {
|
|
|
|
#if !os(tvOS)
|
|
|
|
Toggle("Show account username", isOn: $accountPickerDisplaysUsername)
|
|
|
|
#endif
|
2022-08-26 05:06:46 +05:30
|
|
|
|
2022-11-12 01:58:40 +05:30
|
|
|
Toggle("Show anonymous accounts", isOn: $accountPickerDisplaysAnonymousAccounts)
|
2023-03-01 01:47:12 +05:30
|
|
|
Toggle("Show unwatched feed badges", isOn: $showUnwatchedFeedBadges)
|
|
|
|
.onChange(of: showUnwatchedFeedBadges) { newValue in
|
|
|
|
if newValue {
|
|
|
|
FeedModel.shared.calculateUnwatchedFeed()
|
|
|
|
}
|
|
|
|
}
|
2022-11-12 01:58:40 +05:30
|
|
|
}
|
2022-12-19 06:07:09 +05:30
|
|
|
|
|
|
|
Toggle("Open channels with description expanded", isOn: $expandChannelDescription)
|
2022-01-06 20:26:59 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private var thumbnailsSettings: some View {
|
2022-09-04 20:58:30 +05:30
|
|
|
Section(header: SettingsHeader(text: "Thumbnails".localized())) {
|
2022-06-26 17:55:54 +05:30
|
|
|
thumbnailsQualityPicker
|
2022-01-06 20:26:59 +05:30
|
|
|
#if !os(tvOS)
|
|
|
|
Toggle("Round corners", isOn: $roundedThumbnails)
|
|
|
|
#endif
|
|
|
|
Toggle("Show channel name", isOn: $channelOnThumbnail)
|
|
|
|
Toggle("Show video length", isOn: $timeOnThumbnail)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-26 17:55:54 +05:30
|
|
|
private var thumbnailsQualityPicker: some View {
|
|
|
|
Picker("Quality", selection: $thumbnailsQuality) {
|
|
|
|
ForEach(ThumbnailsQuality.allCases, id: \.self) { quality in
|
2022-09-04 20:58:30 +05:30
|
|
|
Text(quality.description)
|
2022-06-26 17:55:54 +05:30
|
|
|
}
|
|
|
|
}
|
2022-08-06 19:58:05 +05:30
|
|
|
.modifier(SettingsPickerModifier())
|
2022-06-26 17:55:54 +05:30
|
|
|
}
|
|
|
|
|
2022-01-06 20:26:59 +05:30
|
|
|
private var visibleSectionsSettings: some View {
|
2022-09-04 20:58:30 +05:30
|
|
|
Section(header: SettingsHeader(text: "Sections".localized())) {
|
2022-01-06 20:26:59 +05:30
|
|
|
#if os(macOS)
|
|
|
|
let list = ForEach(VisibleSection.allCases, id: \.self) { section in
|
2022-11-12 00:23:52 +05:30
|
|
|
MultiselectRow(
|
2022-01-06 20:26:59 +05:30
|
|
|
title: section.title,
|
|
|
|
selected: visibleSections.contains(section)
|
|
|
|
) { value in
|
|
|
|
toggleSection(section, value: value)
|
2021-12-01 16:52:19 +05:30
|
|
|
}
|
2022-01-06 20:26:59 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
Group {
|
|
|
|
if #available(macOS 12.0, *) {
|
|
|
|
list
|
|
|
|
.listStyle(.inset(alternatesRowBackgrounds: true))
|
|
|
|
} else {
|
|
|
|
list
|
|
|
|
.listStyle(.inset)
|
2021-12-01 16:52:19 +05:30
|
|
|
}
|
2022-01-06 20:26:59 +05:30
|
|
|
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
ForEach(VisibleSection.allCases, id: \.self) { section in
|
2022-11-12 00:23:52 +05:30
|
|
|
MultiselectRow(
|
2022-01-06 20:26:59 +05:30
|
|
|
title: section.title,
|
|
|
|
selected: visibleSections.contains(section)
|
|
|
|
) { value in
|
|
|
|
toggleSection(section, value: value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2021-11-05 04:55:51 +05:30
|
|
|
}
|
|
|
|
}
|
2021-11-08 02:21:22 +05:30
|
|
|
|
2022-01-06 20:26:59 +05:30
|
|
|
private func toggleSection(_ section: VisibleSection, value: Bool) {
|
2021-12-01 16:52:19 +05:30
|
|
|
if value {
|
|
|
|
visibleSections.insert(section)
|
|
|
|
} else {
|
|
|
|
visibleSections.remove(section)
|
|
|
|
}
|
2021-11-08 02:21:22 +05:30
|
|
|
}
|
2021-11-05 04:55:51 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
struct BrowsingSettings_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2022-11-12 00:23:52 +05:30
|
|
|
VStack {
|
|
|
|
BrowsingSettings()
|
|
|
|
}
|
|
|
|
.injectFixtureEnvironmentObjects()
|
2021-11-05 04:55:51 +05:30
|
|
|
}
|
|
|
|
}
|