https://kotlinlang.org logo
#compose
Title
# compose
g

Garret Yoder

03/06/2024, 7:43 PM
Hey guys - looking for some feedback and thoughts on something I spent this morning tweaking. https://gist.github.com/garretyoder/d1d533f84fc591c6042d586bfce6b498 this is a multiplatform implementation for the old style material collapsing app bar w/ enterAlwaysCollapsed. The current M3 toolbar implementation doesn't have support for this, you can do a collapsing app bar but you just pick the size you want. Having a massive LargeAppBar appear on scroll is less than ideal. This implements a lazycolumn w/ a decorator toolbar that is large initially, shrinks to small when scrolled, and hides/shows on scroll. It grows back to the full height when you hit the top. The reason I'm asking for feedback is I feel like it's a little hacky due to me making this multiplatform. I was unable to just mimic natural scrolling like seen here(

https://raw.githubusercontent.com/onebone/compose-collapsing-toolbar/master/img/enter-always.gif

). This is because on desktop the nested scroll events can easily have enough velocity that you can never really detect when the list reaches the top in preScroll - only in postScroll. You also can't use the drag event to make it scroll smoothly to the top without stopping line other implementations do. What I opted for was to just animate the toolbar expand when you hit the top of the list, and I think it feels pretty okay. Anyone have any feedback or has done something similar better than I just did?