wear-ossamsung-galaxy-watch-4compose-wear

how to implement positionindicator for bezel (Galaxy watch 4 Classic) wear os 3.0 (jetpack compose)?


They know how to implement the scroll by bezel (Galaxy watch 4 Classic) in wear os 3.0 with jetpack compose

In the documentation it mentions the use of ScalingLazyListState or ScrollState but so far the scroll with the rotating bezel of my device has not been recognized.

if anyone has information or an example it would help me a lot.

enter image description here enter image description here


Solution

  • In Wear Compose Alpha 15, it is now supported.

        val focusRequester = remember { FocusRequester() }
    
        ScalingLazyColumn(
            modifier = modifier
                .fillMaxSize()
                .onRotaryScrollEvent {
                    coroutineScope.launch {
                        scrollState.scrollBy(it.verticalScrollPixels)
                    }
                    true
                }
                .focusRequester(focusRequester)
                .focusable(),
            state = scrollState,
    

    and then either when the screen is shown, or possible driven by paging (if using HorizontalPager) call requestFocus()

        LaunchedEffect(Unit) {
            focusRequester.requestFocus()
        }