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

Nat Strangerweather

07/12/2023, 5:24 PM
Hi there, is there any help for tiles beyond https://github.com/android/wear-os-samples/tree/main/WearTilesKotlin and https://github.com/joreilly/Confetti/blob/main/wearApp/src/main/java/dev/johnoreilly/confetti/wear/tile/CurrentSessionsTileService.kt? I have managed to get as far as showing a tile with a chip button that takes me to the app, and a latest news headline that updates in real time. Now I am stuck on the layout because I can't find anything on how to define textstyle and how to make a column fit max size etc. At the moment, everything is squashed in the middle and I only get the first 2 or 3 words of my headline. I would love a guide of some sort if there is one. I have looked at the docs, for instance https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.Column.Builder, but I can't really work out how to use it in practice; I tried to use
expand()
but when I use that everything disappears from the screen. 😅
Copy code
private fun mainTileLayout(
        context: Context,
        deviceParameters: DeviceParameters
    ) =
        PrimaryLayout.Builder(deviceParameters)
            .setContent(
                LayoutElementBuilders.Column.Builder()
                    .addContent(tileText())
                    .addContent(tileChip(context, deviceParameters))
                    .build()
            ).build()
Copy code
private fun tileText(): LayoutElementBuilders.Text {
        val dataStore = AppDataStore(context)
        val savedHeadline = runBlocking { dataStore.readTileHeadline.first() }
        return LayoutElementBuilders
            .Text.Builder()
            .setText(savedHeadline)
            .build()
    }
j

John Nichol

07/13/2023, 10:50 AM
@Nat Strangerweather given this is a compose specific channel there are not a lot of Tiles devs hanging out here - but let's see if we can help you - @Mohammad Saboorian do we have a tiles channel?
TIles fonts are deliberately fairly restrictive given that Tiles are rendered in the SysUI
m

Mohammad Saboorian

07/13/2023, 11:02 AM
We don't have a Tile specific channel. The issue about things disappearing is unfortunately due to how PrimaryLayout is designed (which doesn't allow using
expand()
). You can see another instance here https://issuetracker.google.com/284480137
n

Nat Strangerweather

07/13/2023, 11:21 AM
@John Nichol Ah yes, of course, I forgot it was Compose specific! I have been so used to asking my questions here that it did not even occur to me. Is Compose for Tiles entirely abandoned now? Thanks in any case for the link. @Mohammad Saboorian Thanks for the link. It seems there is a workaround, so I'll try that. This is what I am going for...
j

John Nichol

07/13/2023, 11:29 AM
For the moment you are using the right Tiles API. We decided not to push ahead with the androidx.glance tiles Alpha at the current time as there are lots of things we wanted to add to tiles that didn't really fit. We haven't given up on having a more Compose/Kotlin like tiles API in the future - but nothing concrete announced or committed at this time
7 Views