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