CategoryHome.swift


  1. import SwiftUI
  2. struct CategoryHome: View {
  3. @EnvironmentObject var modelData: ModelData
  4. var body: some View {
  5. NavigationView {
  6. List {
  7. ForEach(modelData.categories.keys.sorted(), id: \.self) { key in
  8. CategoryRow(categoryName: key, items: modelData.categories[key]!)
  9. }
  10. }
  11. .navigationTitle("Featured")
  12. }
  13. }
  14. }
  15. struct CategoryHome_Previews: PreviewProvider {
  16. static var previews: some View {
  17. CategoryHome()
  18. .environmentObject(ModelData())
  19. }
  20. }