Nat Strangerweather
05/21/2023, 4:07 PMLazyListState
has firstVisibleItemIndex
, but it seems as if ScalingLazyListState
doesn't.yschimke
05/21/2023, 4:21 PMrememberScalingLazyListState()
will do it. I think it's positioned from the center, but raise a bug if you find it's not restoring position.Nat Strangerweather
05/22/2023, 11:17 AMscalingLazyList
. I can't seem to do it without the firstVisibleItemIndex
. Is there an example that I could use, or could you please point me in the right direction?yschimke
05/22/2023, 11:33 AMyschimke
05/22/2023, 11:34 AMNat Strangerweather
05/22/2023, 12:58 PMNat Strangerweather
05/22/2023, 8:09 PMScalingLazyColumn
like this:
columnState: ScalingLazyColumnState = ScalingLazyColumnDefaults.belowTimeText().create()
If I use the ordinary ScalingLazyColumn, it works out of the box.
So I am stuck now.yschimke
05/22/2023, 8:12 PMNat Strangerweather
05/22/2023, 8:12 PMyschimke
05/23/2023, 10:54 AM@Composable
public fun rememberColumnState(factory: ScalingLazyColumnState.Factory = ScalingLazyColumnDefaults.belowTimeText()): ScalingLazyColumnState {
val columnState = factory.create()
columnState.state = rememberSaveable(saver = ScalingLazyListState.Saver) {
columnState.state
}
return columnState
}
yschimke
05/23/2023, 10:54 AMval columnState = rememberColumnState(
ScalingLazyColumnDefaults.scalingLazyColumnDefaults(
initialCenterIndex = initialOffset.index,
initialCenterOffset = initialOffset.offset,
autoCentering = autoCentering,
anchorType = anchorType
)
)
Nat Strangerweather
05/23/2023, 6:43 PM