I want to prototype something like the Jetsnack ex...
# compose
t
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
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
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
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
@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.