Bugfixes, manual grocery list entries
This commit is contained in:
Binary file not shown.
@@ -170,6 +170,9 @@ import UIKit
|
|||||||
}
|
}
|
||||||
var allRecipes: [Recipe] = []
|
var allRecipes: [Recipe] = []
|
||||||
for category in categories {
|
for category in categories {
|
||||||
|
if self.recipes[category.name] == nil {
|
||||||
|
await getCategory(named: category.name, fetchMode: .preferLocal)
|
||||||
|
}
|
||||||
if let recipeArray = self.recipes[category.name] {
|
if let recipeArray = self.recipes[category.name] {
|
||||||
allRecipes.append(contentsOf: recipeArray)
|
allRecipes.append(contentsOf: recipeArray)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,7 +485,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Add" : {
|
"Add" : {
|
||||||
"extractionState" : "stale",
|
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"de" : {
|
"de" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
@@ -3832,6 +3831,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"To add grocieries manually, type them in the box below and press the button. To add multiple items at once, separate them by a new line." : {
|
||||||
|
"localizations" : {
|
||||||
|
"de" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Durch das Feld unten können Einkäufe manuell hinzugefügt werden. Durch Zeilenumbrüche können mehrere Artikel auf einmal hinzugefügt werden."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Para añadir comestibles manualmente, escríbelos en el cuadro de abajo y pulsa el botón.\nPara añadir varios artículos a la vez, sepáralos con una nueva línea."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fr" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Pour ajouter des courses manuellement, tape-les dans la case ci-dessous et appuie sur le bouton.\nPour ajouter plusieurs articles à la fois, sépare-les par un saut de ligne."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Tool" : {
|
"Tool" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"de" : {
|
"de" : {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ struct EditableText: View {
|
|||||||
.textFieldStyle(.roundedBorder)
|
.textFieldStyle(.roundedBorder)
|
||||||
.lineLimit(lineLimit)
|
.lineLimit(lineLimit)
|
||||||
} else {
|
} else {
|
||||||
Text(text)
|
Text(ObservableRecipeDetail.applyMarkdownStyling(text))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,34 @@ import SwiftUI
|
|||||||
|
|
||||||
struct GroceryListTabView: View {
|
struct GroceryListTabView: View {
|
||||||
@EnvironmentObject var groceryList: GroceryList
|
@EnvironmentObject var groceryList: GroceryList
|
||||||
|
@State var newGroceries: String = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
if groceryList.groceryDict.isEmpty {
|
if groceryList.groceryDict.isEmpty {
|
||||||
EmptyGroceryListView()
|
EmptyGroceryListView(newGroceries: $newGroceries)
|
||||||
} else {
|
} else {
|
||||||
List {
|
List {
|
||||||
|
HStack(alignment: .top) {
|
||||||
|
TextEditor(text: $newGroceries)
|
||||||
|
.padding(4)
|
||||||
|
.overlay(RoundedRectangle(cornerRadius: 8)
|
||||||
|
.stroke(Color.secondary).opacity(0.5))
|
||||||
|
Button {
|
||||||
|
if !newGroceries.isEmpty {
|
||||||
|
let items = newGroceries
|
||||||
|
.split(separator: "\n")
|
||||||
|
.compactMap { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||||
|
.filter { !$0.isEmpty }
|
||||||
|
groceryList.addItems(items, toRecipe: "Other", recipeName: String(localized: "Other"))
|
||||||
|
}
|
||||||
|
newGroceries = ""
|
||||||
|
} label: {
|
||||||
|
Text("Add")
|
||||||
|
}
|
||||||
|
.buttonStyle(.borderedProminent)
|
||||||
|
}
|
||||||
|
|
||||||
ForEach(groceryList.groceryDict.keys.sorted(), id: \.self) { key in
|
ForEach(groceryList.groceryDict.keys.sorted(), id: \.self) { key in
|
||||||
Section {
|
Section {
|
||||||
ForEach(groceryList.groceryDict[key]!.items) { item in
|
ForEach(groceryList.groceryDict[key]!.items) { item in
|
||||||
@@ -97,6 +118,9 @@ fileprivate struct GroceryListItemView: View {
|
|||||||
|
|
||||||
|
|
||||||
fileprivate struct EmptyGroceryListView: View {
|
fileprivate struct EmptyGroceryListView: View {
|
||||||
|
@EnvironmentObject var groceryList: GroceryList
|
||||||
|
@Binding var newGroceries: String
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
List {
|
List {
|
||||||
Text("You're all set for cooking 🍓")
|
Text("You're all set for cooking 🍓")
|
||||||
@@ -105,6 +129,28 @@ fileprivate struct EmptyGroceryListView: View {
|
|||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
Text("Your grocery list is stored locally and therefore not synchronized across your devices.")
|
Text("Your grocery list is stored locally and therefore not synchronized across your devices.")
|
||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
|
Text("To add grocieries manually, type them in the box below and press the button. To add multiple items at once, separate them by a new line.")
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
HStack(alignment: .top) {
|
||||||
|
TextEditor(text: $newGroceries)
|
||||||
|
.padding(4)
|
||||||
|
.overlay(RoundedRectangle(cornerRadius: 8)
|
||||||
|
.stroke(Color.secondary).opacity(0.5))
|
||||||
|
Button {
|
||||||
|
if !newGroceries.isEmpty {
|
||||||
|
let items = newGroceries
|
||||||
|
.split(separator: "\n")
|
||||||
|
.compactMap { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||||
|
.filter { !$0.isEmpty }
|
||||||
|
groceryList.addItems(items, toRecipe: "Other", recipeName: String(localized: "Other"))
|
||||||
|
}
|
||||||
|
newGroceries = ""
|
||||||
|
} label: {
|
||||||
|
Text("Add")
|
||||||
|
}
|
||||||
|
.buttonStyle(.borderedProminent)
|
||||||
|
}
|
||||||
|
.padding(.bottom, 4)
|
||||||
}
|
}
|
||||||
.navigationTitle("Grocery List")
|
.navigationTitle("Grocery List")
|
||||||
}
|
}
|
||||||
@@ -169,7 +215,7 @@ class GroceryRecipeItem: Identifiable, Codable {
|
|||||||
for item in items {
|
for item in items {
|
||||||
addItem(item, toRecipe: recipeId, recipeName: recipeName, saveGroceryDict: false)
|
addItem(item, toRecipe: recipeId, recipeName: recipeName, saveGroceryDict: false)
|
||||||
}
|
}
|
||||||
save()
|
self.save()
|
||||||
objectWillChange.send()
|
objectWillChange.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user