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

Documentation for rotaryWithScroll #2457

Open
jeantuffier opened this issue Nov 12, 2024 · 3 comments
Open

Documentation for rotaryWithScroll #2457

jeantuffier opened this issue Nov 12, 2024 · 3 comments

Comments

@jeantuffier
Copy link

Hi!

I'm trying to use the example from https://google.github.io/horologist/compose-layout/ but I haven't figure out in which dependency rotaryWithScroll is located. I tried horlogist.composables, horlogist.layout and horlogist.materials but it doesn't seem to be there. Could you add a section in the documentation on where to find it?

Thanks

@yschimke
Copy link
Collaborator

Ooops, sorry, that needs to be updated. Wear Compose added rotaryScrollable which should be used instead.

@Composable
fun ScrollScreenLazyColumn(scrollState: LazyListState) {
    val focusRequester = rememberActiveFocusRequester()

    LazyColumn(
        modifier = Modifier.rotaryScrollable(
            behavior = behavior(scrollableState = scrollState),
            focusRequester = focusRequester,
        ),
        state = scrollState,
    ) {
        items(3) { i ->
            val modifier = Modifier.fillParentMaxHeight(0.5f)
            ExampleCard(modifier = modifier, i = i)
        }
    }
}

@yschimke
Copy link
Collaborator

I'll update the docs before closing this.

@yschimke
Copy link
Collaborator

Maybe a better sample for Column

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:wear/compose/integration-tests/demos/src/main/java/androidx/wear/compose/integration/demos/ScrollAwayDemos.kt;l=137?q=rotaryScrollable%20Column

        Column(
            modifier =
                Modifier.verticalScroll(scrollState)
                    .rotaryScrollable(
                        RotaryScrollableDefaults.behavior(
                            scrollableState = scrollState,
                            flingBehavior = ScrollableDefaults.flingBehavior()
                        ),
                        focusRequester = focusRequester
                    )
        ) {
            val modifier = Modifier.height(LocalConfiguration.current.screenHeightDp.dp / 2)
            repeat(10) { i -> ExampleCard(modifier, i) }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants