Created
September 12, 2022 16:25
-
-
Save Anik0808/ebe282db255d99dba227c8ccbd52bc5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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