From 77fde219e0a2ec6f8936dce09ee3111c57c352b6 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 24 Apr 2023 12:08:58 +0200 Subject: [PATCH] Fix chapters layout --- .../Player/Video Details/ChaptersView.swift | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Shared/Player/Video Details/ChaptersView.swift b/Shared/Player/Video Details/ChaptersView.swift index 6cd6f553..1bf266a9 100644 --- a/Shared/Player/Video Details/ChaptersView.swift +++ b/Shared/Player/Video Details/ChaptersView.swift @@ -9,6 +9,10 @@ struct ChaptersView: View { player.videoForDisplay?.chapters ?? [] } + var chaptersHaveImages: Bool { + chapters.allSatisfy { $0.image != nil } + } + var body: some View { if !chapters.isEmpty { #if os(tvOS) @@ -22,15 +26,24 @@ struct ChaptersView: View { } .listStyle(.plain) #else - ScrollView(.horizontal) { - LazyHStack(spacing: 20) { + if chaptersHaveImages { + ScrollView(.horizontal) { + LazyHStack(spacing: 20) { + ForEach(chapters) { chapter in + ChapterView(chapter: chapter) + } + } + .padding(.horizontal, 15) + } + .frame(minHeight: ChapterView.thumbnailHeight + 100) + } else { + Section { ForEach(chapters) { chapter in ChapterView(chapter: chapter) } } - .padding(.horizontal, 15) + .padding(.horizontal) } - .frame(minHeight: ChapterView.thumbnailHeight + 100) #endif } else { NoCommentsView(text: "No chapters information available".localized(), systemImage: "xmark.circle.fill")