y

    yschimke

    10 months ago
    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?
    Alex Vanyo

    Alex Vanyo

    10 months ago
    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

    10 months ago
    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.
    Alex Vanyo

    Alex Vanyo

    10 months ago
    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 MaterialThemes 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

    10 months ago
    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!