Closed es0329 closed 1 year ago
Just a guess while I triage this issue, try deleting any import for HorizontalPagerIndictor and also I think you have to include a pageCount in the foundation compatible version
Thanks @bentrengrove, these items were completed. The param pageCount
was present since my prior (Accompanist) implementation, and the indicator was brought in via import com.google.accompanist.pager.HorizontalPagerIndicator
.
Just a guess while I triage this issue, try deleting any import for HorizontalPagerIndictor and also I think you have to include a pageCount in the foundation compatible version
Can confirm this worked. I've deleted the import of the HorizontalPagerIndictor and the HorizontalPagerIndictor function, then the new variation appeared.
I don't understand, how to solve this problem of inconsistent state types?
Required:com.google.accompanist.pager.PagerState
Found:androidx.compose.foundation.pager.PagerState
I don't understand, how to solve this problem of inconsistent state types?
Required:com.google.accompanist.pager.PagerState
Found:androidx.compose.foundation.pager.PagerState
androidx.compose.foundation.pager.PagerState
as a pager type (hint: it's the one that doesn't have a strikethrough)My apologies @bentrengrove, I misunderstood your guidance. It was my HorizontalPager
that had a pre-existing pageCount
param, but you were directing me to also add that param to HorizontalPagerIndicator
.
Adding that newly required param to HorizontalPagerIndicator
does indeed resolve its overloaded signature, which works with the Compose PagerState
. Closing this issue; thank you for taking a look. 🙌🏽
@kostascollctiv What I need to address is the HorizontalPagerIndicator
@kostascollctiv What I need to address is the
HorizontalPagerIndicator
Ah, apologies! The solution is the same but replace HorizontalPager with HorizontalPagerIndicator.
@gaohomway We had the same mistake. HorizontalPagerIndicator
now needs a pageCount
param for the overload we want to resolve. This differs slightly from the prior way you and I had done it.
The legacy method defaults pageCount by accessing pagerState.pageCount
.
The new method worked for me after I explicitly supply the pageCount param.
HorizontalPagerIndicator(
pagerState = pagerState,
pageCount = viewModel.data.size,
modifier = Modifier.padding(0.dp, 8.dp)
)
@es0329 You are right. I have solved this problem. Thank you for replying to me. Thank you also to @kostascollctiv
Description Type mismatch at
pagerState
param when attempting to useHorizontalPagerIndicator
.Steps to reproduce
HorizontalPager
andHorizontalPagerIndicator
.Pager
migration guidance.rememberPagerState()
to pass aandroidx.compose.foundation.pager.PagerState
param into Accompanist'sHorizontalPagerIndicator
.Expected behavior Overloaded support for AndroidX
PagerState
according to migration table.Additional context
androidx.compose.foundation:foundation:1.4.0
com.google.accompanist:accompanist-pager-indicators:0.30.0