-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pager-indicator] Support indicator of looping page with infinite page size #1158
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
Review needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I left a few comments
@@ -61,6 +66,8 @@ import androidx.compose.ui.unit.dp | |||
fun HorizontalPagerIndicator( | |||
pagerState: PagerState, | |||
modifier: Modifier = Modifier, | |||
size: Int = pagerState.pageCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename "size" to pageCount
and "pageMapper" to "pageIndexMapping"
@@ -48,6 +50,9 @@ import androidx.compose.ui.unit.dp | |||
* | |||
* @param pagerState the state object of your [Pager] to be used to observe the list's state. | |||
* @param modifier the modifier to apply to this layout. | |||
* @param size the size of indicators should be displayed, defaults to [PagerState.pageCount]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to also mention the use case when it is usually needed, I mean this looping scrollable pager
Box(indicatorModifier) | ||
} | ||
} | ||
|
||
val position = pageMapper(pagerState.currentPage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move all those calculations in the offset block. previously we only need to relayout when the currentPageOffset changes, now we also need to recompose. You can learn more about that here: https://youtu.be/EOQB8PTLkpY?t=434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, recompose is always a hard part for me to figure out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
The CI is complaining that there are some format violations in HorizontalPagerLoopingIndicatorSample file. Run './gradlew :sample:spotlessApply' to fix these violations. |
This might be a bug of I put the arguments in seperate lines, not following the change of |
Currently pager-indicator use
PagerState.pageCount
as the size of indicators. When I follow the guide of HorizontalPagerLoopingSample, passing aInt.MAX_VALUE
as page count, the indicator crashed, with no doubt.I add a param
size
for user who needs to declare a specific page size to show indicators, and apageMapper
lambda to map from giving page index to a proper index.