tad
06/11/2021, 8:23 PMIndicationInstance
, but ContentDrawScope
doesn't allow for that.tad
06/11/2021, 8:23 PMclass ClipPathIndication(
val indication: Indication,
val path: Path
) : Indication {
@Composable
override fun rememberUpdatedInstance(interactionSource: InteractionSource): IndicationInstance {
val innerInstance = indication.rememberUpdatedInstance(interactionSource)
return remember(interactionSource, this, innerInstance) {
Instance(innerInstance, path)
}
}
class Instance(
val innerInstance: IndicationInstance,
val path: Path
) : IndicationInstance {
override fun ContentDrawScope.drawIndication() {
drawContent()
clipPath(path) {
innerInstance.drawIndication() // Not allowed; we're in DrawScope now.
}
}
}
}
Nader Jawad
06/11/2021, 10:45 PMthis
reference like so:
override fun ContentDrawScope.drawIndication() {
drawContent()
clipPath(path) {
with (innerInstance) {
this@drawIndication.drawIndication()
}
}
}
tad
06/11/2021, 10:45 PMtad
06/11/2021, 10:47 PMNader Jawad
06/11/2021, 10:49 PMContentDrawScope
is a sub interface of DrawScope
so the instance that you are seeing in the clipPath
trailing lambda is the same instance. It's just that you need to get a ContentDrawScope
receiver scope to issue the drawIndication
call. Hence the need to distinguish between which this
reference