ivano
02/17/2023, 2:42 PM@Composable invocations can only happen from the context of a @Composable functiononClick()Canvasephemient
02/17/2023, 2:44 PMvide
02/17/2023, 2:45 PMephemient
02/17/2023, 2:45 PMivano
02/17/2023, 2:45 PMivano
02/17/2023, 2:45 PMivano
02/17/2023, 2:52 PMivano
02/17/2023, 2:53 PMivano
02/17/2023, 2:53 PMCanvas(modifier = modifier) {
    val spacePerHour = (size.width - spacing) / infos.size
    (0 until infos.size - 1 step 2).forEach { i ->
        val info = infos[i]
        val hour = info.date.hour
        drawContext.canvas.nativeCanvas.apply {
            drawText(
                hour.toString(),
                spacing + i * spacePerHour,
                size.height - 5,
                textPaint
            )
        }
    }
}CLOVIS
02/17/2023, 2:53 PMivano
02/17/2023, 2:54 PM@Composable invocationsCanvas(modifier = modifier) {
        val spacePerHour = (size.width - spacing) / infos.size
        (0 until infos.size - 1 step 2).forEach { i ->
            val info = infos[i]
            val hour = info.date.hour
            drawContext.canvas.nativeCanvas.apply {
                BuildXAxis(this, hour, spacing, i, spacePerHour, this, textPaint)
            }
        }
    }
@Composable
private fun BuildXAxis(
    canvas: NativeCanvas,
    hour: Int,
    spacing: Float,
    i: Int,
    spacePerHour: Float,
    drawScope: DrawScope,
    textPaint: Paint
) {
    canvas.drawText(
        hour.toString(),
        spacing + i * spacePerHour,
        drawScope.size.height - 5,
        textPaint
    )
}ivano
02/17/2023, 2:54 PMBuildXAxisephemient
02/17/2023, 2:55 PM@Composableivano
02/17/2023, 2:57 PMivano
02/17/2023, 2:58 PM