text = speed,
color = Colors.primary,
style = LocalTextStyle.current.copy(fontSize = 108.sp),
fontStyle = FontStyle.Italic,
fontWeight = FontWeight.ExtraBold
But as per @yschimke’s comment it would be great to know how to best make use of Theming to support this cleanly? (I like Yuri's suggestion of
) ? Any thoughts?
10 months ago
The reason I argued for this is to continue the pattern of separating the style from the content. We don't have dark mode to worry about, so state changes are less important, but it's still worth adopting a pattern that makes it easy to change styles in a single place. Maybe put up a PR for discussion?
Just saw your comment @yschimke - I had thought local composition looked like overkill... but now I will try it
10 months ago
It's very lightweight to implement, a handful of lines of code that you win back by removing parameters passed down through the composables, and it basically magically works including if you ever change the style at runtime via a State field.
CompositionLocals works well for small deviations. If you want to add other semantics besides what MaterialTheme gives you, there’s flexibility in extending or outright replacing Material systems. We updated our guides recently so do check them out: https://developer.android.com/jetpack/compose/themes/custom