Redesign search tab, add category cards, recent recipes, and complete German translations

Overhaul SearchTabView with search history, empty/no-results states, and dynamic
navigation title. Extract CategoryCardView and RecentRecipesSection into standalone
views. Update RecipeTabView, RecipeListView, RecipeCardView, and MainView for the
modernized UI. Add all 12 missing German translations in Localizable.xcstrings.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 01:47:16 +01:00
parent 7c824b492e
commit c8ddb098d1
11 changed files with 792 additions and 121 deletions

View File

@@ -16,6 +16,8 @@ import UIKit
@Published var recipes: [String: [Recipe]] = [:]
@Published var recipeDetails: [Int: RecipeDetail] = [:]
@Published var timers: [String: RecipeTimer] = [:]
@Published var categoryImages: [String: UIImage] = [:]
@Published var recentRecipes: [Recipe] = []
var recipeImages: [Int: [String: UIImage]] = [:]
var imagesNeedUpdate: [Int: [String: Bool]] = [:]
var lastUpdates: [String: Date] = [:]
@@ -304,6 +306,47 @@ import UIKit
return []
}
// MARK: - Category images
func getCategoryImage(for categoryName: String) async {
guard categoryImages[categoryName] == nil else { return }
// Ensure recipes for this category are loaded
if self.recipes[categoryName] == nil || self.recipes[categoryName]!.isEmpty {
await getCategory(named: categoryName, fetchMode: .preferLocal)
}
guard let recipes = self.recipes[categoryName], !recipes.isEmpty else { return }
for recipe in recipes {
if let image = await getImage(id: recipe.recipe_id, size: .THUMB, fetchMode: .preferLocal) {
self.categoryImages[categoryName] = image
return
}
}
}
// MARK: - Recent recipes
func addToRecentRecipes(_ recipe: Recipe) {
recentRecipes.removeAll { $0.recipe_id == recipe.recipe_id }
recentRecipes.insert(recipe, at: 0)
if recentRecipes.count > 10 {
recentRecipes = Array(recentRecipes.prefix(10))
}
Task {
await saveLocal(recentRecipes, path: "recent_recipes.data")
}
}
func loadRecentRecipes() async {
if let loaded: [Recipe] = await loadLocal(path: "recent_recipes.data") {
self.recentRecipes = loaded
}
}
func clearRecentRecipes() {
recentRecipes = []
dataStore.delete(path: "recent_recipes.data")
}
// MARK: - Data management
func deleteAllData() {