struct ContentView: View {
   @State private var name: String = ""
   @State private var openAlert: Bool = false

   var body: some View {
      VStack(spacing: 10) {
         TextField("Insert your Name", text: $name)
            .textFieldStyle(.roundedBorder)
         HStack {
            Spacer()
            Button("Save") {
               openAlert = name.isEmpty
            }
         }
         Spacer()
      }.padding()
      .alert("Error", isPresented: $openAlert, actions: {
         Button("Cancel", role: .cancel, action: {
            openAlert = false
         })
      }, message: { Text("Insert your name") })
   }
}