Chapters: allow user to disable thumbnails

Chapters have their own section is the settings. The users can decide if chapter thumbnails should be shown or not. Also they can decide to only show thumbnails if they are not the same.

The VideoDetailsView had to be modified, to avoid compiler type-checking errors.
This commit is contained in:
Toni Förster
2024-05-11 20:18:56 +02:00
parent d1cf45c6a1
commit 7c50db426f
5 changed files with 114 additions and 73 deletions

View File

@@ -32,6 +32,8 @@ struct PlayerSettings: View {
@Default(.showInspector) private var showInspector
@Default(.showChapters) private var showChapters
@Default(.showChapterThumbnails) private var showThumbnails
@Default(.showChapterThumbnailsOnlyWhenDifferent) private var showThumbnailsOnlyWhenDifferent
@Default(.expandChapters) private var expandChapters
@Default(.showRelated) private var showRelated
@@ -80,8 +82,6 @@ struct PlayerSettings: View {
Section(header: SettingsHeader(text: "Info".localized())) {
expandVideoDescriptionToggle
collapsedLineDescriptionStepper
showChaptersToggle
expandChaptersToggle
showRelatedToggle
#if os(macOS)
HStack {
@@ -93,6 +93,13 @@ struct PlayerSettings: View {
inspectorVisibilityPicker
#endif
}
Section(header: SettingsHeader(text: "Chapters".localized())) {
showChaptersToggle
showThumbnailsToggle
showThumbnailsWhenDifferentToggle
expandChaptersToggle
}
#endif
let interface = Section(header: SettingsHeader(text: "Interface".localized())) {
@@ -284,7 +291,19 @@ struct PlayerSettings: View {
}
private var showChaptersToggle: some View {
Toggle("Chapters (if available)", isOn: $showChapters)
Toggle("Show chapters", isOn: $showChapters)
}
private var showThumbnailsToggle: some View {
Toggle("Show thumbnails", isOn: $showThumbnails)
.disabled(!showChapters)
.foregroundColor(showChapters ? .primary : .secondary)
}
private var showThumbnailsWhenDifferentToggle: some View {
Toggle("Show thumbnails only when unique", isOn: $showThumbnailsOnlyWhenDifferent)
.disabled(!showChapters || !showThumbnails)
.foregroundColor(showChapters && showThumbnails ? .primary : .secondary)
}
private var expandChaptersToggle: some View {