From baf923527536a092d0566145a50830dc38b46141 Mon Sep 17 00:00:00 2001 From: Michael-128 Date: Tue, 4 Feb 2025 07:38:26 +0100 Subject: [PATCH] Add 'add category' button --- .../Localizations/Localizable.xcstrings | 9 ++++++++ .../Components/ChangeCategoryView.swift | 22 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Localization/Localizations/Localizable.xcstrings b/Localization/Localizations/Localizable.xcstrings index 2730b1a..7b2bc4d 100644 --- a/Localization/Localizations/Localizable.xcstrings +++ b/Localization/Localizations/Localizable.xcstrings @@ -560,6 +560,9 @@ } } } + }, + "Add Category" : { + }, "Add Feed" : { "localizations" : { @@ -640,6 +643,9 @@ } } } + }, + "Add New Category" : { + }, "Add Server" : { "localizations" : { @@ -1222,6 +1228,9 @@ } } } + }, + "Category Name" : { + }, "Check Connection" : { "localizations" : { diff --git a/qBitControl/Components/ChangeCategoryView.swift b/qBitControl/Components/ChangeCategoryView.swift index 1e1b42f..70e55b5 100644 --- a/qBitControl/Components/ChangeCategoryView.swift +++ b/qBitControl/Components/ChangeCategoryView.swift @@ -7,11 +7,31 @@ struct ChangeCategoryView: View { @State private var categories: [Category] = [] @State var category: String - + + @State private var showAddCategoryAlert = false + @State private var newCategoryName = "" var body: some View { VStack { Form { + Section(header: Text("Add Category")) { + Button { + showAddCategoryAlert = true + } label: { + Label("Add Category", systemImage: "plus.circle") + }.alert("Add New Category", isPresented: $showAddCategoryAlert, actions: { + TextField("Category Name", text: $newCategoryName) + Button("Add", action: { + // Add category + print(newCategoryName) + newCategoryName = "" + }) + Button("Cancel", role: .cancel, action: { + newCategoryName = "" + }) + }) + } + if categories.count > 1 { Picker("Categories", selection: $category) { Text("Uncategorized").tag("")