2021-08-29 21:36:18 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct AppSidebarPlaylists: View {
|
2021-09-25 08:18:22 +00:00
|
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
2021-10-05 20:20:09 +00:00
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
2021-09-25 08:18:22 +00:00
|
|
|
@EnvironmentObject<PlaylistsModel> private var playlists
|
2021-08-29 21:36:18 +00:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Section(header: Text("Playlists")) {
|
2021-09-25 08:18:22 +00:00
|
|
|
ForEach(playlists.playlists.sorted { $0.title.lowercased() < $1.title.lowercased() }) { playlist in
|
2021-09-28 23:01:49 +00:00
|
|
|
NavigationLink(tag: TabSelection.playlist(playlist.id), selection: $navigation.tabSelection) {
|
2021-09-13 20:41:16 +00:00
|
|
|
LazyView(PlaylistVideosView(playlist))
|
2021-08-29 21:36:18 +00:00
|
|
|
} label: {
|
|
|
|
Label(playlist.title, systemImage: AppSidebarNavigation.symbolSystemImage(playlist.title))
|
2021-11-28 14:37:55 +00:00
|
|
|
.backport
|
2021-08-29 21:36:18 +00:00
|
|
|
.badge(Text("\(playlist.videos.count)"))
|
|
|
|
}
|
2021-08-31 21:17:50 +00:00
|
|
|
.id(playlist.id)
|
2021-08-29 21:36:18 +00:00
|
|
|
.contextMenu {
|
2022-01-02 19:39:54 +00:00
|
|
|
Button("Play All") {
|
|
|
|
player.play(playlists.find(id: playlist.id)?.videos ?? [])
|
|
|
|
}
|
|
|
|
Button("Shuffle All") {
|
|
|
|
player.play(playlists.find(id: playlist.id)?.videos ?? [], shuffling: true)
|
2021-10-05 20:20:09 +00:00
|
|
|
}
|
2021-08-29 21:36:18 +00:00
|
|
|
Button("Edit") {
|
2021-09-25 08:18:22 +00:00
|
|
|
navigation.presentEditPlaylistForm(playlists.find(id: playlist.id))
|
2021-08-29 21:36:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
newPlaylistButton
|
|
|
|
.padding(.top, 8)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var newPlaylistButton: some View {
|
2021-09-25 08:18:22 +00:00
|
|
|
Button(action: { navigation.presentNewPlaylistForm() }) {
|
|
|
|
Label("New Playlist", systemImage: "plus.circle")
|
2021-08-29 21:36:18 +00:00
|
|
|
}
|
|
|
|
.foregroundColor(.secondary)
|
|
|
|
.buttonStyle(.plain)
|
|
|
|
}
|
|
|
|
}
|