1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 14:50:32 +05:30
yattee/Shared/Player/Video Details/ChaptersView.swift

47 lines
1.3 KiB
Swift
Raw Normal View History

import Foundation
import SDWebImageSwiftUI
import SwiftUI
struct ChaptersView: View {
@ObservedObject private var player = PlayerModel.shared
2023-04-22 23:36:30 +05:30
var chapters: [Chapter] {
player.videoForDisplay?.chapters ?? []
}
var body: some View {
2023-04-22 23:36:30 +05:30
if !chapters.isEmpty {
#if os(tvOS)
List {
Section {
ForEach(chapters) { chapter in
ChapterView(chapter: chapter)
}
}
2023-04-22 23:36:30 +05:30
.listRowBackground(Color.clear)
}
2023-04-22 23:36:30 +05:30
.listStyle(.plain)
2022-06-25 05:09:29 +05:30
#else
2023-04-22 23:36:30 +05:30
ScrollView(.horizontal) {
LazyHStack(spacing: 20) {
ForEach(chapters) { chapter in
ChapterView(chapter: chapter)
}
}
.padding(.horizontal, 15)
}
.frame(minHeight: ChapterView.thumbnailHeight + 100)
2022-06-25 05:09:29 +05:30
#endif
} else {
2022-09-28 21:15:05 +05:30
NoCommentsView(text: "No chapters information available".localized(), systemImage: "xmark.circle.fill")
2022-06-25 05:09:29 +05:30
}
}
}
2022-08-21 02:35:40 +05:30
struct ChaptersView_Previews: PreviewProvider {
static var previews: some View {
ChaptersView()
.injectFixtureEnvironmentObjects()
}
}