Skip to content

Instantly share code, notes, and snippets.

@tieleman
Created February 26, 2020 11:59
Show Gist options
  • Save tieleman/652ff72d66e8956af8abdba90639d841 to your computer and use it in GitHub Desktop.
Save tieleman/652ff72d66e8956af8abdba90639d841 to your computer and use it in GitHub Desktop.
ContentView.swift v2
import SwiftUI
struct ContentView: View {
@State private var name: String = ""
private var greeterText: String {
name.isEmpty ? "" : "Nice to meet you, \(name)."
}
var body: some View {
VStack {
Text("Please enter your name below")
.accessibility(identifier: "enterNameLabel")
TextField("Your name", text: $name)
Text(greeterText)
.accessibility(identifier: "greetingTextLabel")
}.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment