Is there any Example of using ViewPager2 with Comp...
# compose
s
Is there any Example of using ViewPager2 with Compose?
t
You can not use ViewPager. There is BottomNavigation and Tab which you can use.
n
Do you know if it’s already possible to swap between the tabs using gesture in compose?
t
Not out of the box as far as i know. But attach a modifier to detect swipes and change the tab should be easy.
Of course if you want animation it is a little bit harder.
👍 1
c
yeah i tried to that and uh...gave up for now 😅
s
@Cyril Find What problems you faced? I was thinking of using AndroidView for that?
c
oh I mean I tried doing the swipe modifier thing and it was quite complicated...but it shouldn't be too hard using interoperability (I think you're gonna use
ComposeView
inside your view pager fragments, not
AndroidView
though)
s
@Cyril Find "`ComposeView` inside your view pager fragments" is good option also, but I'm not using Fragments in my app, i was thinking to create a composable for native ViewPager2 and each View Pager item will be composeView.
c
oh ok yeah i usually use it with fragments but i guess that works too !
d
There is a swipe pager implementation in Jetcaster sample
It worked up to alpha-11, but got totally broken in alpha 12
c
ah, well thanks anyways !
a
The one in the main branch works: https://github.com/android/compose-samples/blob/main/Jetcaster/app/src/main/java/com/example/jetcaster/util/Pager.kt But it doesn't have any state saving it seems