https://kotlinlang.org logo
#compose
Title
# compose
m

Melvin Biamont

03/09/2023, 7:40 PM
Hello 👋 My backend server returns me text with xml tags representing icons like this:
Copy code
val response = "Image <icon name='System/actionArrow' color='#FF0000'/> in the middle of the text"
Using
HtmlCompat
and
Spanned
, I’m converting this string into an
AnnotatedString
(with
appendInlineContent
). Then, in my
Text
, I pass the
inlineContent
map with something like
Copy code
mapOf(
   "System/Forward" to InlineTextContent(...),
   "System/Increase" to InlineTextContent(...),
   (...)
)
And it works, I have inlined icons in my text 🙌 . But I can’t tint the icons properly. As
inlineContent
is just a map ID -> InlineTextContent; I can’t pass the tint to the
InlineTextContent
or I should add the tint to the inlineContent ID like this (which is ridiculous):
Copy code
mapOf(
   (...)
   "System/Forward_#222222" to InlineTextContent(...),
   "System/Forward_#333333" to InlineTextContent(...),
   (...)
)
Any idea how I could pass more arguments to the
inlineContent
than just its ID? Couldn’t it be a function`(String) -> InlineTextContent?` instead of a map?
6 Views