From 601523ab1b2d0c648d37141a0a11bcf2d0392efe Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 14 Aug 2022 19:01:22 +0200 Subject: [PATCH] Use unified video context menu --- Shared/Player/PlayerQueueView.swift | 48 +++++------------------------ Shared/Player/RelatedView.swift | 31 +------------------ 2 files changed, 9 insertions(+), 70 deletions(-) diff --git a/Shared/Player/PlayerQueueView.swift b/Shared/Player/PlayerQueueView.swift index e8cc4775..34ec0303 100644 --- a/Shared/Player/PlayerQueueView.swift +++ b/Shared/Player/PlayerQueueView.swift @@ -96,6 +96,10 @@ struct PlayerQueueView: View { .contextMenu { removeButton(item) removeAllButton() + + if let video = item.video { + VideoContextMenuView(video: video) + } } } } @@ -119,7 +123,7 @@ struct PlayerQueueView: View { player.loadHistoryVideoDetails(watch.videoID) } .contextMenu { - removeHistoryButton(watch) + VideoContextMenuView(video: watch.video) } } } @@ -134,35 +138,7 @@ struct PlayerQueueView: View { ForEach(player.currentVideo!.related) { video in PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: $fullScreen) .contextMenu { - 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") - } - } - } - } + VideoContextMenuView(video: video) } } } @@ -174,7 +150,7 @@ struct PlayerQueueView: View { Button { player.remove(item) } label: { - Label("Remove", systemImage: "trash") + Label("Remove from the queue", systemImage: "trash") } } @@ -182,15 +158,7 @@ struct PlayerQueueView: View { Button { player.removeQueueItems() } label: { - Label("Remove All", systemImage: "trash.fill") - } - } - - private func removeHistoryButton(_ watch: Watch) -> some View { - Button { - player.removeWatch(watch) - } label: { - Label("Remove", systemImage: "trash") + Label("Clear the queue", systemImage: "trash.fill") } } } diff --git a/Shared/Player/RelatedView.swift b/Shared/Player/RelatedView.swift index f5651430..18f1c0d3 100644 --- a/Shared/Player/RelatedView.swift +++ b/Shared/Player/RelatedView.swift @@ -15,36 +15,7 @@ struct RelatedView: View { PlayerQueueRow(item: PlayerQueueItem(video)) .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") - } - } - } - } + VideoContextMenuView(video: video) } } }