yattee/Shared/Navigation/AppSidebarSubscriptions.swift

35 lines
1.1 KiB
Swift
Raw Normal View History

2021-08-29 21:36:18 +00:00
import SwiftUI
struct AppSidebarSubscriptions: View {
@EnvironmentObject<NavigationState> private var navigationState
@EnvironmentObject<Subscriptions> private var subscriptions
@Binding var selection: TabSelection?
var body: some View {
Section(header: Text("Subscriptions")) {
ForEach(subscriptions.all) { channel in
NavigationLink(tag: TabSelection.channel(channel.id), selection: $selection) {
2021-09-13 20:41:16 +00:00
LazyView(ChannelVideosView(channel))
2021-08-29 21:36:18 +00:00
} label: {
Label(channel.name, systemImage: AppSidebarNavigation.symbolSystemImage(channel.name))
}
.contextMenu {
Button("Unsubscribe") {
navigationState.presentUnsubscribeAlert(channel)
}
}
.modifier(UnsubscribeAlertModifier())
2021-08-29 21:36:18 +00:00
}
}
}
var unsubscribeAlertTitle: String {
if let channel = navigationState.channelToUnsubscribe {
return "Unsubscribe from \(channel.name)"
}
return "Unknown channel"
}
}