Skip to content

Instantly share code, notes, and snippets.

@Anik0808
Created September 12, 2022 16:25
Show Gist options
  • Save Anik0808/ebe282db255d99dba227c8ccbd52bc5f to your computer and use it in GitHub Desktop.
Save Anik0808/ebe282db255d99dba227c8ccbd52bc5f to your computer and use it in GitHub Desktop.
struct HomeView: View {
@EnvironmentObject var subscription: Subscription
var body: some View {
VStack{
if subscription.isSubscribed{
Text("Welcome Premium User.")
}
else{
Text("Welcome to the App.")
}
}
}
}
struct SubscriptionView: View {
@EnvironmentObject var subscription: Subscription
var body: some View{
Button {
subscription.isSubscribed.toggle()
} label: {
if subscription.isSubscribed{
Text("Press to Unsubscribe")
}
else{
Text("Press to Subscribe")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment