Nextcloud Login refactoring
This commit is contained in:
@@ -8,89 +8,58 @@
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
struct MainView: View {
|
||||
//@State var cookbookState: CookbookState = CookbookState()
|
||||
@Environment(\.modelContext) var modelContext
|
||||
@Query var recipes: [Recipe] = []
|
||||
|
||||
struct MainView: View {
|
||||
// Tab ViewModels
|
||||
enum Tab {
|
||||
case recipes, settings, groceryList
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List {
|
||||
ForEach(recipes) { recipe in
|
||||
Text(recipe.name)
|
||||
TabView {
|
||||
RecipeTabView()
|
||||
.tabItem {
|
||||
Label("Recipes", systemImage: "book.closed.fill")
|
||||
}
|
||||
}
|
||||
Button("New") {
|
||||
let recipe = Recipe(id: UUID().uuidString, name: "Neues Rezept", keywords: [], prepTime: "", cookTime: "", totalTime: "", recipeDescription: "", yield: 0, category: "", tools: [], ingredients: [], instructions: [], nutrition: [:], ingredientMultiplier: 0)
|
||||
modelContext.insert(recipe)
|
||||
}
|
||||
.tag(Tab.recipes)
|
||||
|
||||
GroceryListTabView()
|
||||
.tabItem {
|
||||
if #available(iOS 17.0, *) {
|
||||
Label("Grocery List", systemImage: "storefront")
|
||||
} else {
|
||||
Label("Grocery List", systemImage: "heart.text.square")
|
||||
}
|
||||
}
|
||||
.tag(Tab.groceryList)
|
||||
|
||||
SettingsTabView()
|
||||
.tabItem {
|
||||
Label("Settings", systemImage: "gear")
|
||||
}
|
||||
.tag(Tab.settings)
|
||||
|
||||
}
|
||||
/*NavigationSplitView {
|
||||
VStack {
|
||||
List(selection: $cookbookState.selectedCategory) {
|
||||
ForEach(cookbookState.categories) { category in
|
||||
Text(category.name)
|
||||
.tag(category)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.onAppear {
|
||||
Task {
|
||||
await cookbookState.loadCategories()
|
||||
.task {
|
||||
/*
|
||||
recipeViewModel.presentLoadingIndicator = true
|
||||
await appState.getCategories()
|
||||
await appState.updateAllRecipeDetails()
|
||||
|
||||
// Open detail view for default category
|
||||
if UserSettings.shared.defaultCategory != "" {
|
||||
if let cat = appState.categories.first(where: { c in
|
||||
if c.name == UserSettings.shared.defaultCategory {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}) {
|
||||
recipeViewModel.selectedCategory = cat
|
||||
}
|
||||
}
|
||||
} content: {
|
||||
if let selectedCategory = cookbookState.selectedCategory {
|
||||
List(selection: $cookbookState.selectedRecipeStub) {
|
||||
ForEach(cookbookState.recipeStubs[selectedCategory.name] ?? [], id: \.id) { recipeStub in
|
||||
Text(recipeStub.title)
|
||||
.tag(recipeStub)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
Task {
|
||||
await cookbookState.loadRecipeStubs(category: selectedCategory.name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("Please select a category.")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
} detail: {
|
||||
if let selectedRecipe = cookbookState.selectedRecipe {
|
||||
if let recipe = cookbookState.recipes[selectedRecipe.id] {
|
||||
RecipeView(recipe: recipe)
|
||||
} else {
|
||||
ProgressView()
|
||||
.onAppear {
|
||||
Task {
|
||||
await cookbookState.loadRecipe(id: selectedRecipe.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text("Please select a recipe.")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
await groceryList.load()
|
||||
recipeViewModel.presentLoadingIndicator = false
|
||||
*/
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .bottomBar) {
|
||||
Button(action: {
|
||||
cookbookState.showGroceries = true
|
||||
}) {
|
||||
Label("Grocery List", systemImage: "cart")
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .topBarLeading) {
|
||||
Button(action: {
|
||||
cookbookState.showSettings = true
|
||||
}) {
|
||||
Label("Settings", systemImage: "gearshape")
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user