Skip to main content
Version: 5.5

Link

Mealz provides a parameter categoryId on CatalogResults that show desired categories. It is design to be used with deeplinking. Just pass MEALZ_CATEGORY_ID & the title as parameters in your bind

Catalog(this@MainActivity).apply { bind(MEALZ_CATEGORY_ID) }.Content()
or
Catalog(this@MainActivity).apply { bind(MEALZ_CATEGORY_ID, MEALZ_TITLE) }.Content()

With XML

private var catalogView:Catalog
...
catalogView.bind(categoryId)
or
catalogView.bind(categoryId, title)
tip

You can find Mealz category IDs on our back office Mealz Partner

You can also use this feature directly in your application. To do so, you'll need to get current active catalog's categories. Here's how you can do that:

import ai.mealz.core.Mealz

Mealz.catalog.getCatalogCategories(::fetchCategory)
where
private fun fetchCategory(categories: List<CatalogCategory>) {
categoriesState.value = categories
}

An example of full implementation with compose :

class DeepLinkDropDownMenu(val navigateTo: (id: String) -> Unit) {

private val categoriesState: MutableState<List<CatalogCategory>> =
mutableStateOf(listOf())

init {
Mealz.catalog.getCatalogCategories(::fetchCategory)
}

private fun fetchCategory(categories: List<CatalogCategory>) {
categoriesState.value = categories
}

@Composable
fun Content() {

val expanded = remember { mutableStateOf(false) }

Box {
IconButton(onClick = {
expanded.value = true
}) {
Icon(
Icons.Filled.MoreVert,
contentDescription = "More Menu"
)
}
DropdownMenu(
expanded = expanded.value,
onDismissRequest = { expanded.value = false }
) {
categoriesState.value.forEach {
DropdownMenuItem(onClick = {
navigateTo(it.id)
expanded.value = false
}) {
Text(it.title)
}
}
}
}
}
}
tip

You can find some examples with the Demo App XML here in order to simulate deep links and use them.