Aram Sheroyan
10/19/2021, 11:51 PM@Immutable
data class CustomTypography(
val title_s: TextStyle = TextStyle(fontSize = 32.sp, color = CustomTheme.colors.customPrymaryColor)
)
but it says that Composable invocations can only happen from the context of composable function
Casey Brooks
10/20/2021, 12:18 AMval title_s: TextStyle @Composable get() = ...
Albert Chang
10/20/2021, 12:22 AMLocalContentColor
, and material components like Surface
and Scaffold
will automatically set LocalContentColor
to the appropriate color in your theme.onBackground
or onSurface
colors of your theme.Aram Sheroyan
10/20/2021, 12:26 AMAlbert Chang
10/20/2021, 12:30 AMAram Sheroyan
10/20/2021, 12:42 AMAlbert Chang
10/20/2021, 2:24 AMTypography
objects. For the second approach, you can use extension functions like this:
val CustomTheme.title_s: TextStyle
@Composable get() = typography.title_s.copy(color = colors.primary)
However this will create an extra TextStyle
object for every Text
component. I would avoid that for such a common component.