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

yschimke

11/04/2021, 2:23 PM
Material (pre-compose) seems to have a well supported notion of custom typography - https://material.io/blog/android-material-theme-type Does this concept exist in compose Material (wear or mobile)? OR you should just follow the same approach with your own CompositionLocalProvider? Or generally people hardcode fonts inline and just use MaterialTheme for it's effect on Material widgets like Cards or Buttons?
a

Alex Vanyo

11/04/2021, 5:39 PM
Yes! https://developer.android.com/jetpack/compose/themes/material is the starting point for how theming works, and the customization also hooks into the Material widgets in an intelligent way
y

yschimke

11/04/2021, 9:20 PM
I should have been clearer. I meant styles other than the named ones like "header1", "body2" etc. Are these possible like in xml themes. Say "score", "subtitles" etc.
a

Alex Vanyo

11/04/2021, 9:50 PM
Also yes, although it ends up looking a bit different than XML If its more than a one-off style (such as giving it a name), you can override the
MaterialTheme
at any point in your Compose hierarchy, and then all children within that will use the modified theme. So rather than having a large amount of slightly different `MaterialTheme`s floating around where any of them could be used, there’s always a single
MaterialTheme
at any given point in the hierarchy. This also allows for some powerful things, like animated derivative theme’s like
Jetcaster
does: https://github.com/android/compose-samples/blob/main/Jetcaster/app/src/main/java/com/example/jetcaster/util/DynamicTheming.kt
y

yschimke

11/05/2021, 6:58 AM
OK, that's a good point. I guess it may be best to reuse the existing typeface labels, shapes and colors, and have different themes in different parts of the app. NewsfeedTheme, MarketplaceTheme, and so on. Thanks!