Simple SwiftUI

I’ve decided to try and tackle SwiftUI, and was immediately greeted by not knowing how to take the text from a textbox, format it as name components, and then update a label, ALL from a button push.

This took me way too long and too many searches to come up with 😂

    @State private var fullName = PersonNameComponents()
    @State private var enteredName: String = "Johnny Bazookatone"
    @State private var personName: String = ""
    
    
    var body: some View {
        VStack {
            TextField("Proper Name", text: $enteredName)
            
            Button("Go") {
                let formatter = PersonNameComponentsFormatter()
                self.fullName = formatter.personNameComponents(from: enteredName)!
                self.personName = fullName.formatted()
            }
          
            Text("Hello, \(self.personName)")
        }
        .padding()
    }
}

I don’t even have a use for this code, but here it is.