How can I properly handle nested scrolling in VerticalViewPager with a LazyColumn inside?

63 Views Asked by At

I'm trying to simulate a launcher app. It has a main main screen and an apps drawer. I've implemented this with a VerticalViewPager: page 0 is the main page and page 1 is the app drawer. That way, I can swipe between both pages (as most launchers can do). The problem is that I want to display the installed apps on a list in the page 1 (drawer), and to do so I'm using a LazyColumn/LazyVerticalGrid. When going from page 0 to 1, everything goes OK. The problem comes when trying to swipe from page 1 to 0 (app drawer). It can't handle it properly and mixes LazyColumn overscroll with VerticalViewPager transition, ending in the UI getting stacked in the middle of the transition from page 0 to page 1.

I've tried using gestures listeners (such as Modifier.pointerInput(Unit) or NestedScrollConnection) but the logic becomes a mess soon and I couldn't make it work. I'm specting to work as follows: once you open the drawer, then you can scroll up and down on the LazyColumn to see the apps; but when the scroll position of the LazyColumn is 0 (not scrolled) and the user swipes down, it should close the drawer and show the homescreen, following the finger (normal behavior of a VerticalViewPager). This is basically how most launchers work. Maybe I need to use a different approach, but this is the only one I could think of. Any help would be welcomed!

EDIT: I've been going through this a little bit in depth and using a NavHost with a transition between homescreen and drawer might be useful. The transition state should follow the finger somehow. Anyone else thinks this might be useful?

0

There are 0 best solutions below