Fix chapters layout

This commit is contained in:
Arkadiusz Fal 2023-04-24 12:08:58 +02:00
parent 383bb32215
commit 77fde219e0

View File

@ -9,6 +9,10 @@ struct ChaptersView: View {
player.videoForDisplay?.chapters ?? [] player.videoForDisplay?.chapters ?? []
} }
var chaptersHaveImages: Bool {
chapters.allSatisfy { $0.image != nil }
}
var body: some View { var body: some View {
if !chapters.isEmpty { if !chapters.isEmpty {
#if os(tvOS) #if os(tvOS)
@ -22,15 +26,24 @@ struct ChaptersView: View {
} }
.listStyle(.plain) .listStyle(.plain)
#else #else
ScrollView(.horizontal) { if chaptersHaveImages {
LazyHStack(spacing: 20) { 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 ForEach(chapters) { chapter in
ChapterView(chapter: chapter) ChapterView(chapter: chapter)
} }
} }
.padding(.horizontal, 15) .padding(.horizontal)
} }
.frame(minHeight: ChapterView.thumbnailHeight + 100)
#endif #endif
} else { } else {
NoCommentsView(text: "No chapters information available".localized(), systemImage: "xmark.circle.fill") NoCommentsView(text: "No chapters information available".localized(), systemImage: "xmark.circle.fill")