Skip to content
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] Deprecate PagerState.targetPage #1196

Merged
merged 1 commit into from Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pager/api/current.api
Expand Up @@ -37,7 +37,7 @@ package com.google.accompanist.pager {
method public float getCurrentPageOffset();
method public androidx.compose.foundation.interaction.InteractionSource getInteractionSource();
method @IntRange(from=0) public int getPageCount();
method public int getTargetPage();
method @Deprecated public int getTargetPage();
method public boolean isScrollInProgress();
method public suspend Object? scroll(androidx.compose.foundation.MutatePriority scrollPriority, kotlin.jvm.functions.Function2<? super androidx.compose.foundation.gestures.ScrollScope,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> block, kotlin.coroutines.Continuation<? super kotlin.Unit> p);
method public suspend Object? scrollToPage(@IntRange(from=0) int page, optional @FloatRange(from=-1.0, to=1.0) float pageOffset, optional kotlin.coroutines.Continuation<? super kotlin.Unit> p);
Expand All @@ -46,7 +46,7 @@ package com.google.accompanist.pager {
property public final androidx.compose.foundation.interaction.InteractionSource interactionSource;
property public boolean isScrollInProgress;
property @IntRange(from=0) public final int pageCount;
property public final int targetPage;
property @Deprecated public final int targetPage;
field public static final com.google.accompanist.pager.PagerState.Companion Companion;
}

Expand Down
Expand Up @@ -155,6 +155,13 @@ class PagerState(
* The target page for any on-going animations or scrolls by the user.
* Returns the current page if a scroll or animation is not currently in progress.
*/
@Deprecated(
"targetPage is deprecated in favor of currentPage as currentPage property is" +
"now being updated right after we over scrolled the half of the previous current page." +
"If you still think that you need targetPage, not currentPage please file a bug as " +
"we are planning to remove this property in future.",
ReplaceWith("currentPage")
)
val targetPage: Int
get() = animationTargetPage
?: flingAnimationTarget?.invoke()
Expand Down
Expand Up @@ -159,6 +159,7 @@ abstract class PagerTest {
assertPagerLayout(0, pagerState.pageCount)
}

@Suppress("DEPRECATION")
@Test
fun mediumDistance_fastSwipe_toFling() {
composeTestRule.mainClock.autoAdvance = false
Expand Down Expand Up @@ -190,6 +191,7 @@ abstract class PagerTest {
assertPagerLayout(1, pagerState.pageCount)
}

@Suppress("DEPRECATION")
@Test
fun mediumDistance_slowSwipe_toSnapForward() {
composeTestRule.mainClock.autoAdvance = false
Expand Down Expand Up @@ -221,6 +223,7 @@ abstract class PagerTest {
assertPagerLayout(1, pagerState.pageCount)
}

@Suppress("DEPRECATION")
@Test
fun shortDistance_fastSwipe_toFling() {
composeTestRule.mainClock.autoAdvance = false
Expand Down Expand Up @@ -252,6 +255,7 @@ abstract class PagerTest {
assertPagerLayout(1, pagerState.pageCount)
}

@Suppress("DEPRECATION")
@Test
fun shortDistance_slowSwipe_toSnapBack() {
composeTestRule.mainClock.autoAdvance = false
Expand Down