converted to navigationpath
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
12ff7b0e8a
commit
aef8a079ff
@ -10,6 +10,7 @@ import SwiftUI
|
||||
@MainActor
|
||||
struct EmployeeListView: View {
|
||||
@StateObject public var viewModel: EmployeesViewModel
|
||||
@State private var path = NavigationPath()
|
||||
|
||||
// Dependency injection via the initializer.
|
||||
init(viewModel: EmployeesViewModel? = nil) {
|
||||
@ -17,15 +18,16 @@ struct EmployeeListView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
NavigationStack(path: $path) {
|
||||
List {
|
||||
//build out dynamic rows first
|
||||
ForEach(viewModel.employees, id: \.id) { employee in
|
||||
NavigationLink(destination: EmployeeDetailsView(viewModel: .init(employee: employee))) {
|
||||
EmployeeRowView(viewModel: .init(employee: employee))
|
||||
}
|
||||
.listRowInsets(.none)
|
||||
.listRowSeparator(.hidden)
|
||||
EmployeeRowView(viewModel: .init(employee: employee))
|
||||
.onTapGesture {
|
||||
path.append(employee)
|
||||
}
|
||||
.listRowInsets(.none)
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
|
||||
//add static row if there is a next page
|
||||
@ -38,6 +40,9 @@ struct EmployeeListView: View {
|
||||
}
|
||||
}
|
||||
.navigationTitle("Employees")
|
||||
.navigationDestination(for: Employee.self, destination: { employee in
|
||||
EmployeeDetailsView(viewModel: .init(employee: employee))
|
||||
})
|
||||
.listStyle(.insetGrouped)
|
||||
}
|
||||
.task {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user