I've seen that, but it looks like it's just extending material theme/colors.
f
fmasa
02/03/2021, 4:36 PM
You can roll your own ambient (if you need different themes) or define static values somewhere - MaterialTheme object + MaterialTheme composable is good example.
So something like this (very barebones) example should do the job:
Copy code
@Immutable
data class AppColors(
val colorOne: Color,
val colorTwo: Color,
)
fun defaultColors() = AppColors(Color.RED, Color.BLACK)
val AmbientAppColors = staticAmbientOf { defaultColors() }
object AppTheme {
val colors: AppColors
@Composable
@ComposableContract(readonly = true)
get() = AmbientAppColors.current
}
// Then in your code
Text("Foo", color = AppTheme.colors.colorOne)
// Overriding theme (where darkColors returns instance of AppColors
Provides (AmbientAppColors provides darkColors()) {
// UI using dark theme
}