Files
Nextcloud-Cookbook-iOS/Nextcloud Cookbook iOS Client/Views/CategoryDetailView.swift
2023-09-17 16:37:08 +02:00

38 lines
1.1 KiB
Swift

//
// CategoryDetailView.swift
// Nextcloud Cookbook iOS Client
//
// Created by Vincent Meilinger on 15.09.23.
//
import Foundation
import SwiftUI
struct RecipeBookView: View {
@State var categoryName: String
@ObservedObject var viewModel: MainViewModel
var body: some View {
ScrollView(showsIndicators: false) {
LazyVStack {
if let recipes = viewModel.recipes[categoryName] {
ForEach(recipes, id: \.recipe_id) { recipe in
NavigationLink(destination: RecipeDetailView(viewModel: viewModel, recipe: recipe)) {
RecipeCardView(viewModel: viewModel, recipe: recipe)
}
.buttonStyle(.plain)
}
}
}
}
.navigationTitle(categoryName)
.task {
await viewModel.loadRecipeList(categoryName: categoryName)
}
.refreshable {
await viewModel.loadRecipeList(categoryName: categoryName, needsUpdate: true)
}
}
}