Hello everyone, recently I started to learn the SwiftUI. Now I have this code but I don't understand how can I call a view in canvas? At the first case I have error which says that argument is missing.
import SwiftUI
struct EmployeeDetails: View {
var employee: Employee
var body: some View {
VStack(alignment: .leading) {
Text(employee.name)
.font(.largeTitle)
.foregroundColor(.primary)
Text(employee.jobTitle)
.foregroundColor(.secondary)
EmailAddress(address: employee.emailAddress)
}
}
}
struct EmployeeDetails_Previews: PreviewProvider {
static var previews: some View {
EmployeeDetails()
}
}
And when I use "employee" like argument in brackets, I have another error - can't find employee in scope.
struct EmployeeDetails_Previews: PreviewProvider {
static var previews: some View {
EmployeeDetails(employee)
}
}
Please, help me to understand how can I call that view?