Canvas(modifier = Modifier.size(91.dp), onDraw = {
drawCircle(color = MaterialTheme.colorScheme.primary)
})
Compiler gives an error : @Composable invocations can only happen from the context of a @Composable function and underline colorScheme. Also, I cannot apply my palette to AndroidView, like PieChart. I provided the color scheme through CompositionLocalProvider, like this
CompositionLocalProvider(
LocalColors provides colors,
LocalTextStyles provides textStyles
) {...}
Example:
AndroidView(factory = { context ->
PieChart(context).apply {
layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
this.description.isEnabled = false
this.isDrawHoleEnabled = false
this.holeRadius = 60f
this.transparentCircleRadius = 0f
this.legend.isEnabled = false
this.setHoleColor(LocalColors.current.OnBackground.toArgb()) //here is an error
}
},
with the same result. My color scheme depends from dark or lite system colors. How should I fix this?