// // RecipeToolSection.swift // Nextcloud Cookbook iOS Client // // Created by Vincent Meilinger on 01.03.24. // import Foundation import SwiftUI // MARK: - RecipeView Tool Section struct RecipeToolSection: View { @ObservedObject var viewModel: RecipeView.ViewModel var body: some View { VStack(alignment: .leading) { HStack { SecondaryLabel(text: "Tools") Spacer() } RecipeListSection(list: $viewModel.observableRecipeDetail.tool) }.padding() } } // MARK: - Recipe Edit Tool Section (Form-based) struct RecipeEditToolSection: View { @Binding var tools: [String] var body: some View { Section { ForEach(tools.indices, id: \.self) { index in HStack { TextField("Tool", text: $tools[index]) Image(systemName: "line.3.horizontal") .foregroundStyle(.tertiary) } } .onDelete { indexSet in tools.remove(atOffsets: indexSet) } .onMove { from, to in tools.move(fromOffsets: from, toOffset: to) } Button { tools.append("") } label: { Label("Add Tool", systemImage: "plus.circle.fill") } } header: { Text("Tools") } } }