Ingredients in ingredient lists can now be checked off.

This commit is contained in:
Vicnet
2023-10-10 14:10:40 +02:00
parent 9270c61df5
commit f2cad63bc0
2 changed files with 29 additions and 8 deletions

View File

@@ -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 {