diff --git a/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate b/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate index 2ece18d..5127168 100644 Binary files a/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate and b/Nextcloud Cookbook iOS Client.xcodeproj/project.xcworkspace/xcuserdata/vincie.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Nextcloud Cookbook iOS Client/Data/ObservableRecipeDetail.swift b/Nextcloud Cookbook iOS Client/Data/ObservableRecipeDetail.swift index 9a54123..bb8a66d 100644 --- a/Nextcloud Cookbook iOS Client/Data/ObservableRecipeDetail.swift +++ b/Nextcloud Cookbook iOS Client/Data/ObservableRecipeDetail.swift @@ -13,6 +13,7 @@ class ObservableRecipeDetail: ObservableObject { var id: String @Published var name: String @Published var keywords: [String] + @Published var image: String @Published var imageUrl: String @Published var prepTime: DurationComponents @Published var cookTime: DurationComponents @@ -35,6 +36,7 @@ class ObservableRecipeDetail: ObservableObject { id = "" name = String(localized: "New Recipe") keywords = [] + image = "" imageUrl = "" prepTime = DurationComponents() cookTime = DurationComponents() @@ -55,6 +57,7 @@ class ObservableRecipeDetail: ObservableObject { id = recipeDetail.id name = recipeDetail.name keywords = recipeDetail.keywords.isEmpty ? [] : recipeDetail.keywords.components(separatedBy: ",") + image = recipeDetail.image ?? "" imageUrl = recipeDetail.imageUrl ?? "" prepTime = DurationComponents.fromPTString(recipeDetail.prepTime ?? "") cookTime = DurationComponents.fromPTString(recipeDetail.cookTime ?? "") @@ -77,6 +80,7 @@ class ObservableRecipeDetail: ObservableObject { keywords: self.keywords.joined(separator: ","), dateCreated: "", dateModified: "", + image: self.image, imageUrl: self.imageUrl, id: self.id, prepTime: self.prepTime.toPTString(), diff --git a/Nextcloud Cookbook iOS Client/Data/RecipeModels.swift b/Nextcloud Cookbook iOS Client/Data/RecipeModels.swift index 828ced3..81926c8 100644 --- a/Nextcloud Cookbook iOS Client/Data/RecipeModels.swift +++ b/Nextcloud Cookbook iOS Client/Data/RecipeModels.swift @@ -38,6 +38,7 @@ struct RecipeDetail: Codable { var dateCreated: String? var dateModified: String? var imageUrl: String? + var image: String? var id: String var prepTime: String? var cookTime: String? @@ -51,11 +52,12 @@ struct RecipeDetail: Codable { var recipeInstructions: [String] var nutrition: [String:String] - init(name: String, keywords: String, dateCreated: String, dateModified: String, imageUrl: String, id: String, prepTime: String? = nil, cookTime: String? = nil, totalTime: String? = nil, description: String, url: String, recipeYield: Int, recipeCategory: String, tool: [String], recipeIngredient: [String], recipeInstructions: [String], nutrition: [String:String]) { + init(name: String, keywords: String, dateCreated: String, dateModified: String, image: String, imageUrl: String, id: String, prepTime: String? = nil, cookTime: String? = nil, totalTime: String? = nil, description: String, url: String, recipeYield: Int, recipeCategory: String, tool: [String], recipeIngredient: [String], recipeInstructions: [String], nutrition: [String:String]) { self.name = name self.keywords = keywords self.dateCreated = dateCreated self.dateModified = dateModified + self.image = image self.imageUrl = imageUrl self.id = id self.prepTime = prepTime @@ -76,6 +78,7 @@ struct RecipeDetail: Codable { keywords = "" dateCreated = "" dateModified = "" + image = "" imageUrl = "" id = "" prepTime = "" @@ -93,7 +96,7 @@ struct RecipeDetail: Codable { // Custom decoder to handle value type ambiguity private enum CodingKeys: String, CodingKey { - case name, keywords, dateCreated, dateModified, imageUrl, id, prepTime, cookTime, totalTime, description, url, recipeYield, recipeCategory, tool, recipeIngredient, recipeInstructions, nutrition + case name, keywords, dateCreated, dateModified, image, imageUrl, id, prepTime, cookTime, totalTime, description, url, recipeYield, recipeCategory, tool, recipeIngredient, recipeInstructions, nutrition } init(from decoder: Decoder) throws { @@ -102,6 +105,7 @@ struct RecipeDetail: Codable { keywords = try container.decode(String.self, forKey: .keywords) dateCreated = try container.decodeIfPresent(String.self, forKey: .dateCreated) dateModified = try container.decodeIfPresent(String.self, forKey: .dateModified) + image = try container.decodeIfPresent(String.self, forKey: .image) imageUrl = try container.decodeIfPresent(String.self, forKey: .imageUrl) id = try container.decode(String.self, forKey: .id) prepTime = try container.decodeIfPresent(String.self, forKey: .prepTime) @@ -116,6 +120,7 @@ struct RecipeDetail: Codable { recipeInstructions = try container.decode([String].self, forKey: .recipeInstructions) nutrition = try container.decode(Dictionary.self, forKey: .nutrition).mapValues { String(describing: $0.value) } + } } @@ -127,6 +132,7 @@ extension RecipeDetail { keywords: "", dateCreated: "", dateModified: "", + image: "", imageUrl: "", id: "", prepTime: "",