I have list item menu project in SwiftUI, my project work, but I have list icons, they are not shown in list view, even I was try to use system image, there is not any change on screen, any idea?
Model.swift:
Code Block struct MasterView: View { let view1 = Menu(name:"Home", image:"image_home", destination:.home) let view2 = Menu(name:"View 1", image:"image_view1", destination:.view1) let view3 = Menu(name:"View 3", image:"image_view2", destination:.view2) var body: some View { let menus: [Menu] = [view1, view2, view3] return List { ForEach(menus) { menu in self.destinationView(menu: menu) }}} func destinationView(menu: Menu) -> some View { switch menu.destination { case .view1: return NavigationLink( destination: AnyView(View1(menu: menu)) ) { Text("\(menu.name)") } case .view2: return NavigationLink( destination: AnyView(View2(menu: menu)) ) { Text("\(menu.name)") } default: return NavigationLink( destination: AnyView(HomeView(menu: menu)) ) { Text("\(menu.name)") }}}}
Model.swift:
Code Block /// Main menu item for the list struct Menu: Identifiable { var id = UUID() var name: String var image: String var destination: ViewType } enum ViewType { case home case view1 case view2 }