Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Kiel] Support for nested recyclerview #63

Closed
rainboy93 opened this issue Aug 26, 2020 · 4 comments
Closed

[Kiel] Support for nested recyclerview #63

rainboy93 opened this issue Aug 26, 2020 · 4 comments
Assignees

Comments

@rainboy93
Copy link

Hi @ibrahimyilmaz,
There is a common case that we will have a child list of items as a row of recyclerview just like Google Play did.
Is there any solution for this case in Kiel?

@ibrahimyilmaz
Copy link
Owner

Hi @rainboy93,

Thanks for your question. When we check kiel, it does not provide something special than Android's RecyclerView.Adapter.
It just declarative way of defining RecyclerView.Adapter.

for example this is kind of nested recycler view example:

 val recyclerViewAdapter = adapterOf<MessageViewState> {
            register(
                layoutResource = R.layout.adapter_message_text_item,
                viewHolder = ::TextMessageViewHolder,
                onBindViewHolder = { vh, _, text ->
                    vh.messageText.text = text.text
                    vh.sentAt.text = text.sentAt
                }
            )

            register(
                layoutResource = R.layout.adapter_message_image_item,
                viewHolder = ::ImageMessageViewHolder,
                onBindViewHolder = { vh, _, item ->
                    vh.messageText.text = item.text
                    vh.sentAt.text = item.sentAt

                    Glide.with(vh.messageImage)
                        .load(item.imageUrl)
                        .into(vh.messageImage)
                }
            )

            register(
                layoutResource = R.layout.adapter_message_poll_item,
                viewHolder = ::PollMessageViewHolder,
                onBindViewHolder = { vh, _, poll ->
                    vh.pollTitle.text = poll.text
                    vh.sentAt.text = poll.sentAt

                    val pollOptionsAdapter = adapterOf<PollOption> {
                        register(
                            layoutResource = R.layout.adapter_poll_option_item,
                            viewHolder = ::PollOptionViewHolder,
                            onBindViewHolder = { pollOptionViewHolder, _, pollOption ->
                                pollOptionViewHolder.pollOption.text = pollOption.text
                            }
                        )
                    }

                    vh.pollOptionsRecyclerView.adapter = pollOptionsAdapter

                    pollOptionsAdapter.submitList(poll.options)
                }
            )
        }

What do you think? If you want, you can implement an simple example looks like Google Play and open PR.
This will be great for Kiel and everybody will appreciate you.

Sincerely

@MahmoudMabrok
Copy link
Contributor

i will try it and share it with you @ibrahimyilmaz

@rainboy93
Copy link
Author

@ibrahimyilmaz sorry for late response.
I will try it and notify you soon.

@rainboy93
Copy link
Author

@ibrahimyilmaz I just make a PR for nested horizontal list example.
Please check it out.

Brgs,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants