2022-06-18 12:39:49 +00:00
|
|
|
import Foundation
|
|
|
|
import SDWebImageSwiftUI
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ChaptersView: View {
|
2022-11-24 20:36:05 +00:00
|
|
|
@ObservedObject private var player = PlayerModel.shared
|
2022-06-18 12:39:49 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2022-06-24 23:39:29 +00:00
|
|
|
if let chapters = player.currentVideo?.chapters, !chapters.isEmpty {
|
|
|
|
List {
|
2022-12-18 21:34:22 +00:00
|
|
|
Section {
|
2022-06-18 12:39:49 +00:00
|
|
|
ForEach(chapters) { chapter in
|
2022-08-20 21:05:40 +00:00
|
|
|
ChapterView(chapter: chapter)
|
2022-06-18 12:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-09 17:28:16 +00:00
|
|
|
.listRowBackground(Color.clear)
|
2022-06-18 12:39:49 +00:00
|
|
|
}
|
2022-06-24 23:39:29 +00:00
|
|
|
#if os(macOS)
|
2022-06-18 12:39:49 +00:00
|
|
|
.listStyle(.inset)
|
2022-06-24 23:39:29 +00:00
|
|
|
#elseif os(iOS)
|
2022-06-18 12:39:49 +00:00
|
|
|
.listStyle(.grouped)
|
2022-08-09 17:28:16 +00:00
|
|
|
.backport
|
|
|
|
.scrollContentBackground(false)
|
2022-06-24 23:39:29 +00:00
|
|
|
#else
|
2022-06-18 12:39:49 +00:00
|
|
|
.listStyle(.plain)
|
2022-06-24 23:39:29 +00:00
|
|
|
#endif
|
|
|
|
} else {
|
2022-09-28 15:45:05 +00:00
|
|
|
NoCommentsView(text: "No chapters information available".localized(), systemImage: "xmark.circle.fill")
|
2022-06-24 23:39:29 +00:00
|
|
|
}
|
2022-06-18 12:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-20 21:05:40 +00:00
|
|
|
struct ChaptersView_Previews: PreviewProvider {
|
2022-06-18 12:39:49 +00:00
|
|
|
static var previews: some View {
|
|
|
|
ChaptersView()
|
|
|
|
.injectFixtureEnvironmentObjects()
|
|
|
|
}
|
|
|
|
}
|