I want to make protocol like this :
protocol SubscriptionManagerView: View {
var subscriptionManager: EnvironmentObject<SubscriptionManager> { get set }
}
To use in view like this for exemple :
struct Shop: View, SubscriptionManager {
@EnvironmentObject var subscriptionManager: SubscriptionManager
First problem is that property wrapper @EnvironmentObject can't make me respond to protocol SubscriptionManagerView.
Finally I want to use for a custom modifier like this :
extension View where Self : SubscriptionManagerView {
func subscriptionManagerAlert() -> some View {
self.alert(isPresented: self.$subscriptionManager.stateShowAlert) {
Alert(title: Text(self.subscriptionManager.transactionStateTitle)
...
}))
}
}
}
Any idea to work in this way ?