1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 22:30:32 +05:30

Use unified video context menu

This commit is contained in:
Arkadiusz Fal 2022-08-14 19:01:22 +02:00
parent 08c62c1125
commit 601523ab1b
2 changed files with 9 additions and 70 deletions

View File

@ -96,6 +96,10 @@ struct PlayerQueueView: View {
.contextMenu { .contextMenu {
removeButton(item) removeButton(item)
removeAllButton() removeAllButton()
if let video = item.video {
VideoContextMenuView(video: video)
}
} }
} }
} }
@ -119,7 +123,7 @@ struct PlayerQueueView: View {
player.loadHistoryVideoDetails(watch.videoID) player.loadHistoryVideoDetails(watch.videoID)
} }
.contextMenu { .contextMenu {
removeHistoryButton(watch) VideoContextMenuView(video: watch.video)
} }
} }
} }
@ -134,35 +138,7 @@ struct PlayerQueueView: View {
ForEach(player.currentVideo!.related) { video in ForEach(player.currentVideo!.related) { video in
PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: $fullScreen) PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: $fullScreen)
.contextMenu { .contextMenu {
Button { VideoContextMenuView(video: video)
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")
}
}
}
}
} }
} }
} }
@ -174,7 +150,7 @@ struct PlayerQueueView: View {
Button { Button {
player.remove(item) player.remove(item)
} label: { } label: {
Label("Remove", systemImage: "trash") Label("Remove from the queue", systemImage: "trash")
} }
} }
@ -182,15 +158,7 @@ struct PlayerQueueView: View {
Button { Button {
player.removeQueueItems() player.removeQueueItems()
} label: { } label: {
Label("Remove All", systemImage: "trash.fill") Label("Clear the queue", systemImage: "trash.fill")
}
}
private func removeHistoryButton(_ watch: Watch) -> some View {
Button {
player.removeWatch(watch)
} label: {
Label("Remove", systemImage: "trash")
} }
} }
} }

View File

@ -15,36 +15,7 @@ struct RelatedView: View {
PlayerQueueRow(item: PlayerQueueItem(video)) PlayerQueueRow(item: PlayerQueueItem(video))
.listRowBackground(Color.clear) .listRowBackground(Color.clear)
.contextMenu { .contextMenu {
Section { VideoContextMenuView(video: video)
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")
}
}
}
}
} }
} }
} }