2021-09-25 08:18:22 +00:00
|
|
|
import Defaults
|
2021-08-29 21:36:18 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct AppSidebarSubscriptions: View {
|
2021-09-25 08:18:22 +00:00
|
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
|
|
|
@EnvironmentObject<SubscriptionsModel> private var subscriptions
|
2021-08-29 21:36:18 +00:00
|
|
|
|
|
|
|
@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-25 08:18:22 +00:00
|
|
|
LazyView(ChannelVideosView(channel: channel))
|
2021-08-29 21:36:18 +00:00
|
|
|
} label: {
|
|
|
|
Label(channel.name, systemImage: AppSidebarNavigation.symbolSystemImage(channel.name))
|
|
|
|
}
|
|
|
|
.contextMenu {
|
|
|
|
Button("Unsubscribe") {
|
2021-09-25 08:18:22 +00:00
|
|
|
navigation.presentUnsubscribeAlert(channel)
|
2021-08-29 21:36:18 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-31 21:17:50 +00:00
|
|
|
.modifier(UnsubscribeAlertModifier())
|
2021-08-29 21:36:18 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-25 08:18:22 +00:00
|
|
|
.onAppear {
|
|
|
|
subscriptions.load()
|
|
|
|
}
|
2021-08-29 21:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var unsubscribeAlertTitle: String {
|
2021-09-25 08:18:22 +00:00
|
|
|
if let channel = navigation.channelToUnsubscribe {
|
2021-08-29 21:36:18 +00:00
|
|
|
return "Unsubscribe from \(channel.name)"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "Unknown channel"
|
|
|
|
}
|
|
|
|
}
|