Added default category in settings
This commit is contained in:
@@ -31,7 +31,7 @@ struct CategoryDetailView: View {
|
|||||||
}
|
}
|
||||||
.navigationTitle(categoryName == "*" ? "Other" : categoryName)
|
.navigationTitle(categoryName == "*" ? "Other" : categoryName)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Menu {
|
Menu {
|
||||||
Button {
|
Button {
|
||||||
print("Downloading all recipes in category \(categoryName) ...")
|
print("Downloading all recipes in category \(categoryName) ...")
|
||||||
|
|||||||
@@ -85,6 +85,17 @@ struct MainView: View {
|
|||||||
}
|
}
|
||||||
.task {
|
.task {
|
||||||
await viewModel.loadCategoryList()
|
await viewModel.loadCategoryList()
|
||||||
|
if userSettings.defaultCategory != "" {
|
||||||
|
if let cat = viewModel.categories.first(where: { c in
|
||||||
|
if c.name == userSettings.defaultCategory {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}) {
|
||||||
|
self.selectedCategory = cat
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.refreshable {
|
.refreshable {
|
||||||
await viewModel.loadCategoryList(needsUpdate: true)
|
await viewModel.loadCategoryList(needsUpdate: true)
|
||||||
|
|||||||
@@ -39,6 +39,23 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
Section {
|
||||||
|
Picker("Select a cookbook", selection: $userSettings.defaultCategory) {
|
||||||
|
Text("")
|
||||||
|
ForEach(viewModel.categories, id: \.name) { category in
|
||||||
|
Text(category.name == "*" ? "Other" : category.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Button {
|
||||||
|
userSettings.defaultCategory = ""
|
||||||
|
} label: {
|
||||||
|
Text("Clear default category")
|
||||||
|
}
|
||||||
|
} header: {
|
||||||
|
Text("Default cookbook")
|
||||||
|
} footer: {
|
||||||
|
Text("The selected cookbook will be opened on app launch by default.")
|
||||||
|
}
|
||||||
Section() {
|
Section() {
|
||||||
Link("Visit the GitHub page", destination: URL(string: "https://github.com/VincentMeilinger/Nextcloud-Cookbook-iOS")!)
|
Link("Visit the GitHub page", destination: URL(string: "https://github.com/VincentMeilinger/Nextcloud-Cookbook-iOS")!)
|
||||||
} header: {
|
} header: {
|
||||||
|
|||||||
Reference in New Issue
Block a user