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

40 lines
1.4 KiB
Swift
Raw Normal View History

2021-08-30 03:06:18 +05:30
import SwiftUI
struct AppSidebarPlaylists: View {
2021-09-25 13:48:22 +05:30
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<PlaylistsModel> private var playlists
2021-08-30 03:06:18 +05:30
var body: some View {
Section(header: Text("Playlists")) {
2021-09-25 13:48:22 +05:30
ForEach(playlists.playlists.sorted { $0.title.lowercased() < $1.title.lowercased() }) { playlist in
2021-09-29 04:31:49 +05:30
NavigationLink(tag: TabSelection.playlist(playlist.id), selection: $navigation.tabSelection) {
2021-09-14 02:11:16 +05:30
LazyView(PlaylistVideosView(playlist))
2021-08-30 03:06:18 +05:30
} label: {
Label(playlist.title, systemImage: AppSidebarNavigation.symbolSystemImage(playlist.title))
.badge(Text("\(playlist.videos.count)"))
}
.id(playlist.id)
2021-08-30 03:06:18 +05:30
.contextMenu {
Button("Edit") {
2021-09-25 13:48:22 +05:30
navigation.presentEditPlaylistForm(playlists.find(id: playlist.id))
2021-08-30 03:06:18 +05:30
}
}
}
newPlaylistButton
.padding(.top, 8)
}
2021-09-25 13:48:22 +05:30
.onAppear {
playlists.load()
}
2021-08-30 03:06:18 +05:30
}
var newPlaylistButton: some View {
2021-09-25 13:48:22 +05:30
Button(action: { navigation.presentNewPlaylistForm() }) {
Label("New Playlist", systemImage: "plus.circle")
2021-08-30 03:06:18 +05:30
}
.foregroundColor(.secondary)
.buttonStyle(.plain)
}
}