I am trying to write a basic UI of a form to capture details about a restaurant. I will capture details like:
"NAME", placeHolder: "Fill in the restaurant name", "TYPE", placeHolder: "Fill in the restaurant type", "ADDRESS", placeHolder: "Fill in the restaurant address", "PHONE", placeHolder: "Fill in the restaurant phone", "DESCRIPTION", placeHolder: "Fill in the restaurant description",
I have designed the basic TextField model, stylised it and since I will have to reuse this style across all the entries in the form (as mentioned above) I decided to put the code in a Struct in a different SwiftUI file. Till here it is all fine and dandy now since the data is in a different file, I am getting struck at re-using this Struct data in ContentView. Any help or guidance will help me immensely.
Also, perhaps a silly question but is there any way to create a TextField without using a @State variable?
import Foundation
import SwiftUI
struct LabelTextField: View {
@State private var restaurant: String = ""
var label: String
var placeHolder: String
var body: some View {
VStack(alignment: .leading){
Text("NAME")
.font(.headline)
TextField("Enter Restaurant Name", text: $restaurant)
.padding(.all)
.background(Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0))
.cornerRadius (5.0)
} .padding(.horizontal, 15)
}
}