So, if i'm using the accompanist pager library, an...
# compose
m
So, if i'm using the accompanist pager library, and I have a horizontal pager, I would like to add some sort of callback to know when the user actually swiped to change pages (as opposed to just a general change of pages which could also be triggered programmatically as say a response to a button click). I'm not sure how i'd do that, but my first instinct was a custom FlingBehavior, but that doesn't really seem to be the right thing. Is it even possible to get a callback like this? I also thought of setting a flag or something in the onClick callback to indicate if the button was clicked so that as i collect the changes in the pageState, i would know if it was a swipe or click.
y
I have a
LaunchedEffect(key1 = pagerState.currentPage)
in my code for this. Whenever the current page changes it runs.
m
@YASAN That's simple enough and it's what i already do to detect page changes but doesn't really satisfy what i'm looking for. I'm being asked if we can actually log a SWIPE event on the pager, so that we can tell the user triggered the page change with a swipe, as opposed to something like a button click.