From f2cad63bc00015e14c9c37e8460f6ec11241950c Mon Sep 17 00:00:00 2001 From: Vicnet <35202538+VincentMeilinger@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:10:40 +0200 Subject: [PATCH] Ingredients in ingredient lists can now be checked off. --- .../Views/RecipeDetailView.swift | 30 +++++++++++++++---- .../Views/SettingsView.swift | 7 +++-- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Nextcloud Cookbook iOS Client/Views/RecipeDetailView.swift b/Nextcloud Cookbook iOS Client/Views/RecipeDetailView.swift index 1b54f5a..9cedebe 100644 --- a/Nextcloud Cookbook iOS Client/Views/RecipeDetailView.swift +++ b/Nextcloud Cookbook iOS Client/Views/RecipeDetailView.swift @@ -149,17 +149,37 @@ struct RecipeIngredientSection: View { Spacer() } ForEach(recipeDetail.recipeIngredient, id: \.self) { ingredient in - HStack(alignment: .top) { - Text("\u{2022}") - Text("\(ingredient)") - .multilineTextAlignment(.leading) - } + IngredientListItem(ingredient: ingredient) .padding(4) } }.padding() } } +struct IngredientListItem: View { + @State var ingredient: String + @State var isSelected: Bool = false + + var body: some View { + HStack(alignment: .top) { + if isSelected { + Image(systemName: "checkmark.circle") + } else { + //Text("\u{2022}") + Image(systemName: "circle") + } + Text("\(ingredient)") + .multilineTextAlignment(.leading) + .lineLimit(5) + } + .foregroundStyle(isSelected ? Color.secondary : Color.primary) + .onTapGesture { + isSelected.toggle() + } + .animation(.easeInOut, value: isSelected) + } +} + struct RecipeToolSection: View { @State var recipeDetail: RecipeDetail var body: some View { diff --git a/Nextcloud Cookbook iOS Client/Views/SettingsView.swift b/Nextcloud Cookbook iOS Client/Views/SettingsView.swift index 522b032..d7f7eb3 100644 --- a/Nextcloud Cookbook iOS Client/Views/SettingsView.swift +++ b/Nextcloud Cookbook iOS Client/Views/SettingsView.swift @@ -72,7 +72,8 @@ struct SettingsView: View { } footer: { Text("The selected cookbook will open on app launch by default.") } - Section() { + + Section { Link("Visit the GitHub page", destination: URL(string: "https://github.com/VincentMeilinger/Nextcloud-Cookbook-iOS")!) } header: { Text("About") @@ -80,7 +81,7 @@ struct SettingsView: View { Text("If you are interested in contributing to this project or simply wish to review its source code, we encourage you to visit the GitHub repository for this application.") } - Section() { + Section { Link("Get support", destination: URL(string: "https://vincentmeilinger.github.io/Nextcloud-Cookbook-Client-Support/")!) } header: { Text("Support") @@ -88,7 +89,7 @@ struct SettingsView: View { Text("If you have any inquiries, feedback, or require assistance, please refer to the support page for contact information.") } - Section() { + Section { Button("Log out") { print("Log out.") alertType = .LOG_OUT