mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
27 lines
834 B
Swift
27 lines
834 B
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
struct UnsubscribeAlertModifier: ViewModifier {
|
|
@EnvironmentObject<NavigationModel> private var navigation
|
|
@EnvironmentObject<SubscriptionsModel> private var subscriptions
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.alert(unsubscribeAlertTitle, isPresented: $navigation.presentingUnsubscribeAlert) {
|
|
if let channel = navigation.channelToUnsubscribe {
|
|
Button("Unsubscribe", role: .destructive) {
|
|
subscriptions.unsubscribe(channel.id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var unsubscribeAlertTitle: String {
|
|
if let channel = navigation.channelToUnsubscribe {
|
|
return "Unsubscribe from \(channel.name)"
|
|
}
|
|
|
|
return "Unknown channel"
|
|
}
|
|
}
|