https://kotlinlang.org logo
#compose-wear
Title
# compose-wear
y

yschimke

03/07/2024, 8:48 AM
If you have felt the frustration with Play Store rejections for RSB, PositionIndicator, Clipping or Splashscreens, @Garan Jenkin and I updated the ComposeStarter sample to use the latest Horologist APIs. This is Horologist 0.5.23 which is based on Wear Compose 1.3 which is stable. https://github.com/android/wear-os-samples/blob/main/ComposeStarter/app/src/main/j[…]le/android/wearable/composestarter/presentation/MainActivity.kt
👍 4
starter.mp4
The hope is APIs like AppScaffold and ScreenScaffold will go into M3.
Walking through some key bits
Copy code
AppScaffold {
            SwipeDismissableNavHost(navController = navController, startDestination = "menu") {
                composable("menu") {
                    GreetingScreen("Android", onShowList = { navController.navigate("list") })
                }
                composable("list") {
                    ListScreen()
                }
            }
        }
This sets up an AppScaffold with a default TimeText you can override above the NavHost. Then uses regular wear compose navigation for each screen.
Copy code
@Composable
fun ListScreen() {
    val columnState = rememberResponsiveColumnState(...)

    ScreenScaffold(scrollState = columnState) {
        /*
         * The Horologist [ScalingLazyColumn] takes care of the horizontal and vertical
         * padding for the list, so there is no need to specify it, as in the [GreetingScreen]
         * composable.
         */
        ScalingLazyColumn(
            columnState = columnState,
            modifier = Modifier
                .fillMaxSize()
        ) {
            item {
                ResponsiveListHeader(contentPadding = firstItemPadding()) {
                    Text(text = "Header")
                }
            }
            item {
...
            }
        }
    }
}
This creates a safe ScalingLazyColumn state based on factors like the screen size. Then uses ScreenScaffold to make sure that the AppScaffold TimeText scrollAway uses this state.
It also adds a default PositionIndicator for the state.
The ScalingLazyColumn override handles RSB, focus, layout and the TimeText will be placed correctly to scroll away avoiding the content.
Horologist 0.6.x is on Wear Compose 1.4 alpha, and have a lot more API churn. But 0.5.x should be a safe choice and remove a lot of frustration.
b

bod

03/17/2024, 8:58 PM
Any idea why I get a white screen glitch when swiping to dismiss? Just checked out the project and ran it without touching any of the code:
(also here's the preview I'm seeing - to be fair, I'm on AS Canary)
y

yschimke

03/17/2024, 9:01 PM
Try zooming in to 1:1?
You can also view with other ways in the toolbar.
I can check tomorrow on the white flashing. The background Scrim defaults to Black. Not white. But not sure if it's something to do with the platform back support?
I don't get it on API 30 emulator, so I'm going to guess it's something messed up with the emulator API 33, system back support?
Feel free to raise a bug, or I'll ask tomorrow.
b

bod

03/17/2024, 9:35 PM
Try zooming in to 1:1?
That worked
And indeed I'm on a 33 emulator
For the white flashing, I can open an issue - did you mean on the
wear-os-samples
repo or somewhere else?
y

yschimke

03/17/2024, 9:37 PM
Either. More direct is androidx wear compose issues.
Click feedback button
👍 1
b

bod

03/17/2024, 9:44 PM
🙏🏻 1
y

yschimke

03/18/2024, 9:48 AM
cc @stevebower I can see there is code for this, but I don't understand if it's really meant to be happening, or why its white.
Copy code
private val FLASH_COLOR = Color.White
s

stevebower

03/19/2024, 10:59 AM
Thanks for raising the ticket - we will investigate.
👍 1