yattee/Shared/Player/RelatedView.swift

54 lines
1.5 KiB
Swift
Raw Normal View History

import Defaults
2021-11-02 23:02:02 +00:00
import SwiftUI
struct RelatedView: View {
@ObservedObject private var player = PlayerModel.shared
2021-11-02 23:02:02 +00:00
var body: some View {
LazyVStack {
if let related = player.videoForDisplay?.related {
Section(header: header) {
ForEach(related) { video in
PlayerQueueRow(item: PlayerQueueItem(video))
2022-07-10 17:51:46 +00:00
.listRowBackground(Color.clear)
.contextMenu {
2022-08-14 17:01:22 +00:00
VideoContextMenuView(video: video)
}
2021-11-02 23:02:02 +00:00
}
2022-11-18 21:27:13 +00:00
2022-11-13 20:52:29 +00:00
Color.clear.padding(.bottom, 50)
.listRowBackground(Color.clear)
.backport
.listRowSeparator(false)
2021-11-02 23:02:02 +00:00
}
}
}
2022-12-13 00:50:26 +00:00
.environment(\.inNavigationView, false)
2021-11-02 23:02:02 +00:00
#if os(macOS)
2022-12-13 00:50:26 +00:00
.listStyle(.inset)
2021-11-02 23:02:02 +00:00
#elseif os(iOS)
2022-12-13 00:50:26 +00:00
.listStyle(.grouped)
.backport
.scrollContentBackground(false)
2021-11-02 23:02:02 +00:00
#else
2022-12-13 00:50:26 +00:00
.listStyle(.plain)
2021-11-02 23:02:02 +00:00
#endif
}
var header: some View {
Text("Related")
#if !os(macOS)
.font(.caption)
.foregroundColor(.secondary)
.frame(maxWidth: .infinity, alignment: .leading)
#endif
}
2021-11-02 23:02:02 +00:00
}
struct RelatedView_Previews: PreviewProvider {
static var previews: some View {
RelatedView()
2022-11-18 21:27:13 +00:00
.injectFixtureEnvironmentObjects()
2021-11-02 23:02:02 +00:00
}
}