Create new recipes from CategoryDetailView
This commit is contained in:
@@ -161,6 +161,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Add new recipe" : {
|
||||||
|
"localizations" : {
|
||||||
|
"de" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Neues Rezept"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es" : {
|
||||||
|
"stringUnit" : {
|
||||||
|
"state" : "translated",
|
||||||
|
"value" : "Nueva Receta"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"An unknown error occured." : {
|
"An unknown error occured." : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"de" : {
|
"de" : {
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ struct CategoryDetailView: View {
|
|||||||
@State var categoryName: String
|
@State var categoryName: String
|
||||||
@State var searchText: String = ""
|
@State var searchText: String = ""
|
||||||
@ObservedObject var viewModel: MainViewModel
|
@ObservedObject var viewModel: MainViewModel
|
||||||
|
@Binding var showEditView: Bool
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView(showsIndicators: false) {
|
ScrollView(showsIndicators: false) {
|
||||||
LazyVStack {
|
LazyVStack {
|
||||||
@@ -33,6 +34,15 @@ struct CategoryDetailView: View {
|
|||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Menu {
|
Menu {
|
||||||
|
Button {
|
||||||
|
print("Add new recipe")
|
||||||
|
showEditView = true
|
||||||
|
} label: {
|
||||||
|
HStack {
|
||||||
|
Text("Add new recipe")
|
||||||
|
Image(systemName: "plus.circle.fill")
|
||||||
|
}
|
||||||
|
}
|
||||||
Button {
|
Button {
|
||||||
print("Downloading all recipes in category \(categoryName) ...")
|
print("Downloading all recipes in category \(categoryName) ...")
|
||||||
downloadRecipes()
|
downloadRecipes()
|
||||||
|
|||||||
@@ -63,14 +63,13 @@ struct MainView: View {
|
|||||||
}
|
}
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Button {
|
Button {
|
||||||
print("Create recipe")
|
print("Add new recipe")
|
||||||
showEditView = true
|
showEditView = true
|
||||||
} label: {
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "plus.circle.fill")
|
Image(systemName: "plus.circle.fill")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} detail: {
|
} detail: {
|
||||||
@@ -78,7 +77,8 @@ struct MainView: View {
|
|||||||
if let category = selectedCategory {
|
if let category = selectedCategory {
|
||||||
CategoryDetailView(
|
CategoryDetailView(
|
||||||
categoryName: category.name,
|
categoryName: category.name,
|
||||||
viewModel: viewModel
|
viewModel: viewModel,
|
||||||
|
showEditView: $showEditView
|
||||||
)
|
)
|
||||||
.id(category.id) // Workaround: This is needed to update the detail view when the selection changes
|
.id(category.id) // Workaround: This is needed to update the detail view when the selection changes
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user