Nextcloud Login refactoring
This commit is contained in:
@@ -7,6 +7,53 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
|
||||
struct RecipeListView: View {
|
||||
@Environment(\.modelContext) var modelContext
|
||||
@Query var recipes: [Recipe]
|
||||
@Binding var selectedRecipe: Recipe?
|
||||
@Binding var selectedCategory: String?
|
||||
|
||||
init(selectedCategory: Binding<String?>, selectedRecipe: Binding<Recipe?>) {
|
||||
var predicate: Predicate<Recipe>? = nil
|
||||
|
||||
if let category = selectedCategory.wrappedValue, category != "*" {
|
||||
predicate = #Predicate<Recipe> {
|
||||
$0.category == category
|
||||
}
|
||||
}
|
||||
_recipes = Query(filter: predicate, sort: \.name)
|
||||
_selectedRecipe = selectedRecipe
|
||||
_selectedCategory = selectedCategory
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
List(selection: $selectedRecipe) {
|
||||
ForEach(recipes) { recipe in
|
||||
RecipeCardView(recipe: recipe)
|
||||
.shadow(radius: 2)
|
||||
.background(
|
||||
NavigationLink(value: recipe) {
|
||||
EmptyView()
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.opacity(0)
|
||||
)
|
||||
.frame(height: 85)
|
||||
.listRowInsets(EdgeInsets(top: 5, leading: 15, bottom: 5, trailing: 15))
|
||||
.listRowSeparatorTint(.clear)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("Recipes")
|
||||
.toolbar {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user