Custom Navigation
If you don't want to use the provided Mealz navigation, you can recreate the navigation yourself. We have documented a simple walkthrough, but feel free to implement your practice of Coordinators.
Steps
Embed directly into your app
You can add our Standalone Recipe Card into your code like it was any other View or UIView. We have three different inits, one for a recipeId, Recipe, & SuggestionCriteria.
RecipeId: String
When you are displaying one particular recipe & you have the recipeId, you can pass this in:
- UIKit
- SwiftUI
import MealziOSSDK
mealzStandaloneRecipeCard = MealzStandaloneRecipeCardUIKit(recipeId: /* your String recipe id */)
// then add it to whatever View you're currently inside
mealzStandaloneRecipeCard.view.addTo(cell, Pin(.all))
import MealziOSSDK
MealzStandaloneRecipeCardSwiftUI(recipeId: /* your String recipe id */)
recipe: Recipe
When you are displaying one particular recipe & you have the Recipe object, you can pass this in:
- UIKit
- SwiftUI
import MealziOSSDK
mealzStandaloneRecipeCard = MealzStandaloneRecipeCardUIKit(recipe: /* your Recipe object */)
// then add it to whatever View you're currently inside
mealzStandaloneRecipeCard.view.addTo(cell, Pin(.all))
import MealziOSSDK
MealzStandaloneRecipeCardSwiftUI(recipe: /* your Recipe object */)
criteria: SuggestionsCriteria
When you want recipes to be generated based on certain criteria, such as other products on the page or the products in your basket, you can use the SuggestionsCriteria. For example, if you are showing results for the search "Ham", you can take the productIds of the other search results & a recipe including Ham will be shown.
Here's an example of creating a SuggestionsCriteria
let criteria = SuggestionsCriteria(
shelfIngredientsIds: [firstProduct.productId ?? "", secondProduct.productId ?? ""], // pass in the productIds of the other items on the page
currentIngredientsIds: nil,
basketIngredientsIds: nil,
groupId: nil)
- UIKit
- SwiftUI
import MealziOSSDK
mealzStandaloneRecipeCard = MealzStandaloneRecipeCardUIKit(criteria: /* your SuggestionsCriteria object */)
// then add it to whatever View you're currently inside
mealzStandaloneRecipeCard.view.addTo(cell, Pin(.all))
import MealziOSSDK
MealzStandaloneRecipeCardSwiftUI(criteria: /* your SuggestionsCriteria object */)