Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Migrate 'Discover' to Jetpack Compose #692

Merged
merged 15 commits into from
Sep 15, 2020
Merged

Migrate 'Discover' to Jetpack Compose #692

merged 15 commits into from
Sep 15, 2020

Conversation

chrisbanes
Copy link
Owner

@chrisbanes chrisbanes commented Sep 12, 2020

Line diff

You might see the line diff (+669, −633) and wonder why it increased 😲. Well, Tivi was (actually still is) a heavy user of the data-binding and Epoxy combo. They both code-generate lots of magic, but the line diff you see is only my code. I reckon if we included the generated code in there... 📈

Lazy* DSL

Instead of Epoxy + Data Binding, we're now using the new (experimental) Lazy[Column|Row] DSL. They make creating complex scrolling UIs much easier to build, and more efficient due to the windowing!

As a quick overview, it allows you to build complex scrolling UIs like so:

  • For rows with unique content, you can wrap them in an item { /* content */ } 😍. Content can be whatever you want:
item { Header(...) }
item { Carousel(...) }
items(list) { item ->
   MyItemRow(item)
}

To see it in action, checkout the root layout in this screen here.

Epoxy + Data Binding

I found it interesting how close the state paths from my old EpoxyController are to the new Compose implementation. Obviously there are differences, but the general structure is pretty close.

Migration notes

This has not quite been a 1:1 migration though:

  • It's now missing a swipe-to-refresh feature, due to the lack of nested scrolling in Compose.
  • Data-set updates in the LazyRows aren't animated (yet).

@chrisbanes chrisbanes marked this pull request as ready for review September 14, 2020 12:45
@chrisbanes chrisbanes merged commit 4330a30 into main Sep 15, 2020
@chrisbanes chrisbanes deleted the cb/discover-compose branch September 15, 2020 08:26
@chrisbanes chrisbanes changed the title Converting 'Discover' to Jetpack Compose Migrate 'Discover' to Jetpack Compose Sep 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants