iDineNavigation.swift

Home   »   iDineNavigation.swift

struct MainMenuView: View {

    @EnvironmentObject var menu: MenuService

    var body: some View {
        NavigationView {
            List {
                if menu.sections.isEmpty {
                    Text("Loading...")
                        .foregroundColor(.gray)
                        .onAppear {
                            self.menu.load()
                        }
                } else {
                    ForEach(menu.sections) { section in
                        Section(header: Text(section.name)) {
                            ForEach(section.items) { item in
                                NavigationLink(destination: DetailView(item: item)) {
                                    Text(item.name)
                                        .font(.headline)
                                }
                            }
                        }
                    }
                }
            }
            .navigationBarTitle("iDine Menu")
        }
        .navigationViewStyle(StackNavigationViewStyle())
    }
    
}

Leave a Reply

Your email address will not be published. Required fields are marked *