From f55158e99e5c590ba5118b3bde5af856cd28e519 Mon Sep 17 00:00:00 2001 From: Vicnet <35202538+VincentMeilinger@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:21:22 +0200 Subject: [PATCH] Create new recipes from CategoryDetailView --- .../Localizable.xcstrings | 16 ++++++++++++++++ .../Views/CategoryDetailView.swift | 12 +++++++++++- .../Views/MainView.swift | 6 +++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Nextcloud Cookbook iOS Client/Localizable.xcstrings b/Nextcloud Cookbook iOS Client/Localizable.xcstrings index 51be928..8a70fae 100644 --- a/Nextcloud Cookbook iOS Client/Localizable.xcstrings +++ b/Nextcloud Cookbook iOS Client/Localizable.xcstrings @@ -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." : { "localizations" : { "de" : { diff --git a/Nextcloud Cookbook iOS Client/Views/CategoryDetailView.swift b/Nextcloud Cookbook iOS Client/Views/CategoryDetailView.swift index 302514b..31127f3 100644 --- a/Nextcloud Cookbook iOS Client/Views/CategoryDetailView.swift +++ b/Nextcloud Cookbook iOS Client/Views/CategoryDetailView.swift @@ -14,7 +14,8 @@ struct CategoryDetailView: View { @State var categoryName: String @State var searchText: String = "" @ObservedObject var viewModel: MainViewModel - + @Binding var showEditView: Bool + var body: some View { ScrollView(showsIndicators: false) { LazyVStack { @@ -33,6 +34,15 @@ struct CategoryDetailView: View { .toolbar { ToolbarItem(placement: .topBarTrailing) { Menu { + Button { + print("Add new recipe") + showEditView = true + } label: { + HStack { + Text("Add new recipe") + Image(systemName: "plus.circle.fill") + } + } Button { print("Downloading all recipes in category \(categoryName) ...") downloadRecipes() diff --git a/Nextcloud Cookbook iOS Client/Views/MainView.swift b/Nextcloud Cookbook iOS Client/Views/MainView.swift index 0591173..8719975 100644 --- a/Nextcloud Cookbook iOS Client/Views/MainView.swift +++ b/Nextcloud Cookbook iOS Client/Views/MainView.swift @@ -63,14 +63,13 @@ struct MainView: View { } ToolbarItem(placement: .topBarTrailing) { Button { - print("Create recipe") + print("Add new recipe") showEditView = true } label: { HStack { Image(systemName: "plus.circle.fill") } } - } } } detail: { @@ -78,7 +77,8 @@ struct MainView: View { if let category = selectedCategory { CategoryDetailView( 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 }