-
-
Save sturdysturge/cb94f91f117d472f798bac245d13081e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import SwiftUI | |
| struct ContentView: View { | |
| @State var displayedText: String? | |
| @State var inputText: String = "" | |
| var body: some View { | |
| Form { | |
| Section("Input") { | |
| TextField("Write here", text: $inputText) | |
| Button("Set text") { | |
| displayedText = inputText | |
| } | |
| } | |
| Section("Displayed Text") { | |
| if let displayedText { | |
| Text(displayedText) | |
| } else { | |
| Color.clear | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment