CategoryHome.swift


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