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

Travis Griggs

02/21/2023, 9:09 PM
I want to prototype something like the Jetsnack example, own/modified theme, nav bar at the bottom. Unlike Jetsnack, I want to use a HorizontalPager from Accompanist to swap pages rather than the NavHost (unless its possible to configure a NavHost to animate changes by horizontal changes?). When I see the following about HorizontalPager--"Pager (Soon to be deprecated - Upstreamed in Compose 1.4)"--I'm a little confused how to proceed? I'm just using whatever Compose version is stock with the Eel version of Studio. Will whatever replaces it be similar? How far off is that?
b

Ben Trengrove [G]

02/21/2023, 9:14 PM
1.4 is in beta now and has a Pager composable. You can read the migration guide here, it hasn't been merged yet but is basically ready. https://github.com/google/accompanist/pull/1504/files?short_path=d2655bc#diff-d2655bc5fd7bd627a6bcd222b52b8fb919f5fd2a0c62f246414c7b08faefb4c1
i

Ian Lake

02/21/2023, 9:18 PM
unless its possible to configure a NavHost to animate changes by horizontal changes?
You can certainly use
slideInHorizontally
transitions with Accompanist Navigation Animation, but you won't get the swiping gesture part of HorizontalPager - you'd need to write your own
NavHost
implementation to do that (which is also possible and fully supported - that's how Wear Compose's
SwipeDismissableNavHost
works)
y

yschimke

02/21/2023, 11:26 PM
Just be aware there are some conceptual differences with pager. It has a loose assumption that the number of pages is fixed. And it doesn't have different viewmodel owners, so you'll need to manage screen state.
t

Travis Griggs

02/22/2023, 5:49 PM
@Ian Lake this is actually just want I want. I don't want the swipe. I just want my pages to transition side to side matching the direction of the selection on the bar at the bottom. I'll do some more research on nav stuff it looks like.
5 Views