Last active
September 15, 2021 22:42
-
-
Save dheerajn/8040445b98e85134d083cdf8b0e8fd85 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 ContentView: View { | |
@State private var shouldShowAlert1 = false | |
var body: some View { | |
VStack { | |
IndependentView() | |
Button("Tap here to present Alert - 1") { | |
shouldShowAlert1 = true | |
} | |
.alert(isPresented: $shouldShowAlert1) { | |
Alert(title: Text("Showing Alert 1"), message: nil, dismissButton: .cancel()) | |
} | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} | |
struct IndependentView: View { | |
var body: some View { | |
Text("Random int - \(Int.random(in: 0...1000))") | |
.font(.largeTitle) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment