WIP - Complete App refactoring
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/*
|
||||
struct SearchTabView: View {
|
||||
@EnvironmentObject var viewModel: SearchTabView.ViewModel
|
||||
@EnvironmentObject var appState: AppState
|
||||
@@ -30,7 +30,7 @@ struct SearchTabView: View {
|
||||
.listRowSeparatorTint(.clear)
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.navigationDestination(for: Recipe.self) { recipe in
|
||||
.navigationDestination(for: CookbookApiRecipeV1.self) { recipe in
|
||||
RecipeView(viewModel: RecipeView.ViewModel(recipe: recipe))
|
||||
}
|
||||
.searchable(text: $viewModel.searchText, prompt: "Search recipes/keywords")
|
||||
@@ -48,7 +48,7 @@ struct SearchTabView: View {
|
||||
}
|
||||
|
||||
class ViewModel: ObservableObject {
|
||||
@Published var allRecipes: [Recipe] = []
|
||||
@Published var allRecipes: [CookbookApiRecipeV1] = []
|
||||
@Published var searchText: String = ""
|
||||
@Published var searchMode: SearchMode = .name
|
||||
|
||||
@@ -58,7 +58,7 @@ struct SearchTabView: View {
|
||||
case name = "Name & Keywords", ingredient = "Ingredients"
|
||||
}
|
||||
|
||||
func recipesFiltered() -> [Recipe] {
|
||||
func recipesFiltered() -> [CookbookApiRecipeV1] {
|
||||
if searchMode == .name {
|
||||
guard searchText != "" else { return allRecipes }
|
||||
return allRecipes.filter { recipe in
|
||||
@@ -72,3 +72,4 @@ struct SearchTabView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user