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