https://kotlinlang.org logo
y

Yingding Wang

12/27/2022, 1:07 PM
In
horologist==0.2.5
, the
NavGraphBuilder.scalingLazyColumnComposable
is deprecated, i shall use the
listComposable
Copy code
@Deprecated(
    "Use listComposable"
)
public fun NavGraphBuilder.scalingLazyColumnComposable(
In the nav example,
NavGraphBuilder.scrollable
has replaced
NavGraphBuilder.scalingLazyColumnComposable
, what is the difference between
listComposable
and
scrollable
? The only
listComposable
which I can find in
NavGraphBuilder
is
lazyListComposable
. Thanks for any hint in advance.
y

yschimke

12/27/2022, 9:21 PM
Sorry, I should have put better explanations in the kdocs.
The scalingLazyColumnComposable wasn't a good name, scrollable was much closer to existing navigation dsl.
These functions give you a state object that is linked to an existing position indicator.
So scrollable is ScalingLazyListState, listComposable is LazyListState.
I'll write up a cleaner sample of scrollable and post it here.
While documentation is sparse there are samples in the horologist/sample module for all of these
listComposable
is a typo! Should be
scrollable
, there is also
lazyListComposable
and
scrollStateComposable
Compared to scalingLazyColumnComposable, it lays out from the top, without providing a custom scrollStateBuilder. And configures the other params correctly.
Compared to composable, it also wires up PositionIndicator and TimeText scrollAway.
y

Yingding Wang

12/28/2022, 12:47 PM
@yschimke Thanks for your hint. This is fantastic, i got it now.
y

yschimke

12/29/2022, 1:23 AM
You can configure initial layout with a factory param.
Copy code
scrollable(
            route = "menu",
            // optional method to configure initial layout
            columnStateFactory = ScalingLazyColumnDefaults.belowTimeText(
                rotaryMode = Fling,
                firstItemIsFullWidth = false
            )
        ) {
            com.google.android.horologist.compose.layout.ScalingLazyColumn(
                modifier = Modifier.fillMaxSize(),
                columnState = it.columnState,
            ) {
23 Views