While using the view-based system, we can harmonize a color using the below code.
MaterialColors.harmonizeWithPrimary(context, colorToHarmonize)
In a project that is fully migrated to Jetpack Compose and all the color values are stored in the Color.kt file, how do you apply harmonization to color at runtime?
You can use the method
And harmonize your custom color with the primaryColor from the dynamic color scheme
If you want to go the extra step you can provide the harmonized value(s) through CompositionLocalProvider to provide it down the composition, to match the way dynamic colors are provided by MaterialTheme.colorScheme.
I explored the issue a little more in this project: https://github.com/acolombo25/harmonized-colors-compose