From 3feafc153c3d318bd1b70db79c7d5cb1c6a42572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Mon, 27 Nov 2023 13:34:18 +0100 Subject: [PATCH] remove toggle for vertical chapters --- .../Player/Video Details/ChaptersView.swift | 1 - .../Player/Video Details/VideoDetails.swift | 64 +++++++++++-------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/Shared/Player/Video Details/ChaptersView.swift b/Shared/Player/Video Details/ChaptersView.swift index 8aa2251f..cabaabe0 100644 --- a/Shared/Player/Video Details/ChaptersView.swift +++ b/Shared/Player/Video Details/ChaptersView.swift @@ -37,7 +37,6 @@ struct ChaptersView: View { } .padding(.horizontal, 15) } - .frame(minHeight: ChapterView.thumbnailHeight + 100) } else { contents } diff --git a/Shared/Player/Video Details/VideoDetails.swift b/Shared/Player/Video Details/VideoDetails.swift index 9cb125e7..43a23600 100644 --- a/Shared/Player/Video Details/VideoDetails.swift +++ b/Shared/Player/Video Details/VideoDetails.swift @@ -441,34 +441,48 @@ struct VideoDetails: View { #endif } + var chaptersHaveImages: Bool { + player.videoForDisplay?.chapters.allSatisfy { $0.image != nil } ?? false + } + var chaptersHeader: some View { - #if canImport(UIKit) - Button(action: { - chaptersExpanded.toggle() - }) { - HStack { - Text("Chapters".localized()) - Spacer() - Image(systemName: chaptersExpanded ? "chevron.up" : "chevron.down") - .imageScale(.small) - } - .padding(.horizontal) - .font(.caption) - .foregroundColor(.secondary) - } - #elseif canImport(AppKit) - HStack { + Group { + if !chaptersHaveImages { + #if canImport(UIKit) + Button(action: { + chaptersExpanded.toggle() + }) { + HStack { + Text("Chapters".localized()) + Spacer() + Image(systemName: chaptersExpanded ? "chevron.up" : "chevron.down") + .imageScale(.small) + } + .padding(.horizontal) + .font(.caption) + .foregroundColor(.secondary) + } + #elseif canImport(AppKit) + HStack { + Text("Chapters".localized()) + Spacer() + Button(action: { chaptersExpanded.toggle() }) { + Image(systemName: chaptersExpanded ? "chevron.up" : "chevron.down") + .imageScale(.small) + } + } + .padding(.horizontal) + .font(.caption) + .foregroundColor(.secondary) + #endif + } else { + // No button, just the title when there are images Text("Chapters".localized()) - Spacer() - Button(action: { chaptersExpanded.toggle() }) { - Image(systemName: chaptersExpanded ? "chevron.up" : "chevron.down") - .imageScale(.small) - } + .font(.caption) + .foregroundColor(.secondary) + .padding(.horizontal) } - .padding(.horizontal) - .font(.caption) - .foregroundColor(.secondary) - #endif + } } }