Conversation
They aren't affected by the brush directly, so we need to set the alpha.
| AnnotatedString.Range(SpanStyle(brush = DynamicSolidColor(color, alpha)), 0, length) | ||
| val fullStyle = AnnotatedString.Range( | ||
| item = if (useDynamicColor) { | ||
| SpanStyle(brush = DynamicSolidColor(color, alpha)) |
There was a problem hiding this comment.
i'm pretty confused here, why does it use dynamic color in one but..... also in the else block
There was a problem hiding this comment.
Yeah, so it's really annoying. The SpanStyle can either take in a color, or a brush. It also takes in an optional alpha.
If you pass a color (or a SolidColor brush), the the alpha you pass is multiplied into the color itself. But since Emojis ignore the color (since they can't be tinted) any alpha we pass is completely ignored. So we need to pass a ShaderBrush AND an alpha. Our DynamicSolidColor brush does accept an alpha but it too just multiplies the alpha into the color and thus has the same issue.
So we're forced to pass a shader brush and I chose to use DynamicSolidColor with an alpha of 1, then pass alpha separately which will set the paint alpha and thus affect emojis.
This does have the side effect of recomposing on alpha change but only for paragraphs with emojis so I think it's fine.
| val cp = Character.codePointAt(this, i) | ||
|
|
||
| // --- Quick accepts: common emoji blocks --- | ||
| val isEmoji = when (cp) { |
There was a problem hiding this comment.
theres seriously no easier 'is emoji'??
There was a problem hiding this comment.
Not really unfortunately because it's complicated. There is a regex you can use, but I figures this was faster since it's a best effort only.
They aren't affected by the brush directly, so we need to set the alpha.