Factory

fun interface Factory(source)

A factory that creates Ui's for a given Screen.

Note that individual UIs should just be top-level ui function calls that factories simply call into. This allows easily standing up composable preview functions.

class FavoritesUiFactory @Inject constructor() : Ui.Factory {
override fun create(
screen: Screen,
context: CircuitContext
): Ui<*>? {
return when (screen) {
is AddFavorites -> addFavoritesUi()
else -> null
}
}
}

private fun addFavoritesUi() =
ui<AddFavorites.State> { state, modifier -> Favorites(state, modifier) }

@Composable private fun Favorites(state: State, modifier: Modifier = Modifier) {...}

Functions

Link copied to clipboard
abstract fun create(screen: Screen, context: CircuitContext): Ui<*>?