Skip to content

Instantly share code, notes, and snippets.

@hmlongco
Last active May 4, 2021 00:23
Show Gist options
  • Save hmlongco/c47bbf1f1b51a93c4861d44474c19fc8 to your computer and use it in GitHub Desktop.
Save hmlongco/c47bbf1f1b51a93c4861d44474c19fc8 to your computer and use it in GitHub Desktop.
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.items) { item in
NavigationLink(destination: DetailView(item: item)) {
Text(item.name)
.font(.headline)
}
}
}
}
.navigationBarTitle("iDine Menu")
}
.navigationViewStyle(StackNavigationViewStyle())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment