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

70 lines
2.7 KiB
Swift
Raw Normal View History

import Defaults
2021-11-03 04:32:02 +05:30
import SwiftUI
struct RelatedView: View {
@EnvironmentObject<AccountsModel> private var accounts
@EnvironmentObject<NavigationModel> private var navigation
2021-11-03 04:32:02 +05:30
@EnvironmentObject<PlayerModel> private var player
@EnvironmentObject<PlaylistsModel> private var playlists
2021-11-03 04:32:02 +05:30
var body: some View {
List {
if let related = player.currentVideo?.related {
2021-11-03 04:32:02 +05:30
Section(header: Text("Related")) {
ForEach(related) { video in
PlayerQueueRow(item: PlayerQueueItem(video))
2022-07-10 23:21:46 +05:30
.listRowBackground(Color.clear)
.contextMenu {
Section {
Button {
player.playNext(video)
} label: {
Label("Play Next", systemImage: "text.insert")
}
Button {
player.enqueueVideo(video)
} label: {
Label("Play Last", systemImage: "text.append")
}
}
if accounts.app.supportsUserPlaylists && accounts.signedIn {
Section {
Button {
navigation.presentAddToPlaylist(video)
} label: {
Label("Add to playlist...", systemImage: "text.badge.plus")
}
if let playlist = playlists.lastUsed {
Button {
playlists.addVideo(playlistID: playlist.id, videoID: video.videoID, navigation: navigation)
} label: {
Label("Add to \(playlist.title)", systemImage: "text.badge.star")
}
}
}
}
}
2021-11-03 04:32:02 +05:30
}
}
}
}
#if os(macOS)
2021-11-08 21:59:35 +05:30
.listStyle(.inset)
2021-11-03 04:32:02 +05:30
#elseif os(iOS)
2021-11-08 21:59:35 +05:30
.listStyle(.grouped)
2022-07-10 23:21:46 +05:30
.backport
.scrollContentBackground(false)
2021-11-03 04:32:02 +05:30
#else
2021-11-08 21:59:35 +05:30
.listStyle(.plain)
2021-11-03 04:32:02 +05:30
#endif
}
}
struct RelatedView_Previews: PreviewProvider {
static var previews: some View {
RelatedView()
}
}