Skip to content

How to do navigation in a master/detail kind of UI? #47

Answered by arkivanov
plusmobileapps asked this question in Q&A
Discussion options

You must be logged in to vote

I will provide solutions for both.

So first of all let's decompose it. We can create separate components for Items and Details parts.

Items

data class Item(
    val id: String,
    val text: String
)

interface ItemsComponent {
    val models: Value<Model>

    fun onItemClicked(id: String)

    data class Model(
        val items: List<Item>
    )

    sealed class Output {
        data class ItemSelected(val id: String) : Output()
    }
}

class ItemsComponentImpl(
    private val output: (ItemsComponent.Output) -> Unit
) : ItemsComponent {

    override val models: Value<ItemsComponent.Model> =
        MutableValue(
            ItemsComponent.Model(
                items = listOf(
    …

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@plusmobileapps
Comment options

@arkivanov
Comment options

@arkivanov
Comment options

@plusmobileapps
Comment options

Comment options

You must be logged in to vote
2 replies
@Shahriyar13
Comment options

@arkivanov
Comment options

Answer selected by plusmobileapps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants