# compose-wear

Zoltan Demant

07/14/2022, 9:15 AM
Im considering creating a custom Text composable that I can reuse across phone/wear variants of my app. Im mostly worried about
provided through
, which I wouldnt have any access to. At the same time, I have my own design system (which leans on material); components with text all make use of my custom Text composable as well (and provide the appropiate style). The material/material-wear text composables look very similar to me, is there anything else I should keep in mind before doing this?
I also just noticed that
might be troublesome as well, I often rely on it being applied from parent composables (e.g. Surface).


07/14/2022, 10:15 AM
LocalContentColor is a good example, there is a wear specific one, so I guess you need to pick up either, or keep them in sync?
My 2c, I guess I'd be tempted to derive the wear MaterialTheme from the mobile one, and still use wear composables, like Text, on Wear. Mainly because I think once you have other composables like Chip, Button, you need those in sync with the Text also.

Zoltan Demant

07/14/2022, 10:45 AM
Thanks for the feedback! Ive actually discovered that I have plenty of other composables that Id like to reuse as well, Id hate to copy them just to access LocalContentColor for each platform. I think the theme portion is easily solved by having my own set of classes, either providing the material values (ContentAlpha.disabled, etc); or providing them to MaterialTheme (creating Colors from my custom Palette/Colors class). I was already doing this for my phone app to some degree, extending it to wear was actually super simple. It almost seems easier to create my own LocalContentColor, but the rabbit hole probably goes way deeper than I think - Id need to create my own Surface then, and thats used in a bunch of other places (TopBar/BottomBar is probably the most worrying). Eventually Ill just recreate the entire material library, lol. Another aspect would be somehow providing LocalContentColor from material, to both platforms; but I dont think its possible to base one CompositionLocal off of another? There are ways around it of course, but I dont think I like any of them. For your 2c about keeping text in sync with chips, buttons, etc; Ill always use my own button composable and internally use my own text composable - this would hold true for all components, so I think thats easily solvable as long as the correct contentColor (and style to some degree) is somehow passed in without me having to do it manually everywhere.
Obviously, all of this would be solved if both MaterialTheme relied on the same set of LocalContentColor/Style as well, but thats just me dreaming out loud 😇