1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 06:10:32 +05:30
yattee/Shared/Modifiers/UnsubscribeAlertModifier.swift

27 lines
834 B
Swift
Raw Normal View History

import Foundation
import SwiftUI
struct UnsubscribeAlertModifier: ViewModifier {
2021-09-25 13:48:22 +05:30
@EnvironmentObject<NavigationModel> private var navigation
@EnvironmentObject<SubscriptionsModel> private var subscriptions
func body(content: Content) -> some View {
content
2021-09-25 13:48:22 +05:30
.alert(unsubscribeAlertTitle, isPresented: $navigation.presentingUnsubscribeAlert) {
if let channel = navigation.channelToUnsubscribe {
Button("Unsubscribe", role: .destructive) {
2021-09-19 16:36:54 +05:30
subscriptions.unsubscribe(channel.id)
}
}
}
}
var unsubscribeAlertTitle: String {
2021-09-25 13:48:22 +05:30
if let channel = navigation.channelToUnsubscribe {
return "Unsubscribe from \(channel.name)"
}
return "Unknown channel"
}
}