Add Play/Shuffle All for playlists (fixes #39)

Add Remove All from queue button on tvOS
This commit is contained in:
Arkadiusz Fal
2022-01-02 19:59:57 +01:00
parent ba21583a95
commit 04df9551ba
5 changed files with 125 additions and 36 deletions

View File

@@ -100,12 +100,12 @@ struct PlaylistsView: View {
Text("No Playlists")
.foregroundColor(.secondary)
} else {
Text("Current Playlist")
.foregroundColor(.secondary)
selectPlaylistButton
}
playButton
shuffleButton
Spacer()
newPlaylistButton
@@ -142,23 +142,14 @@ struct PlaylistsView: View {
selectPlaylistButton
}
Button {
player.playAll(items.compactMap(\.video))
player.show()
} label: {
HStack(spacing: 15) {
Image(systemName: "play.fill")
Text("Play All")
}
}
if currentPlaylist != nil {
editPlaylistButton
}
if let playlist = currentPlaylist {
editPlaylistButton
FavoriteButton(item: FavoriteItem(section: .playlist(playlist.id)))
.labelStyle(.iconOnly)
playButton
shuffleButton
}
Spacer()
@@ -265,6 +256,22 @@ struct PlaylistsView: View {
}
}
private var playButton: some View {
Button {
player.play(items.compactMap(\.video))
} label: {
Image(systemName: "play")
}
}
private var shuffleButton: some View {
Button {
player.play(items.compactMap(\.video), shuffling: true)
} label: {
Image(systemName: "shuffle")
}
}
private var currentPlaylist: Playlist? {
model.find(id: selectedPlaylistID) ?? model.all.first
}