How to achieve @ mentions like twitter and faceboo...
# compose
r
How to achieve @ mentions like twitter and facebook similar to https://github.com/linkedin/Spyglass using compose. Any suggestions or ideas?
One option is to use android view in compose. So i can use the same library view in compose as well
a
Really shouldn't be hard to implement tokenization manually, I think the JetChat sample has something for that
r
Ok. Will look into it. Gotta give it a try.
n
I did this. It was one of the most fun tasks I've worked on with Compose. I used a core text field and used VisualTransformation. I suggest looking at how that works and rendering everything bold first, then render portions of the text bold next. Additionally, it might be fun to code than visually confirm it works, we were actually able to develop faster by writing this feature in unit tests first. https://developer.android.com/reference/kotlin/androidx/compose/ui/text/input/VisualTransformation
r
Thanks i did exactly that. It was little difficult to actually figure out that i need to use transformation. Just one question - is it possible to delete the entire names that are spans on back press in soft keyboard rather than a character at a time.
Something to do with offsetmapping??
n
I don't remember how I did it but I did.
It is with the transformations again.
r
Hmm. Need to explore this.
n
Write unit tests to test the interface. In my base I was looking for {{userid-xxx}}. If it detected that the last } got deleted then I'd return the entire backing string before the first {
r
Jetchat does not have this feature.
In my case i have range start and end which is use to style replaced text on drop down selection. But when user deletes the range is out of bound. Eg. @abc is colored 4 chars. Range is from 0-3. So delete c my range is till 0-3. So basically beed to delete the span from span list of this happens. I think having some of delimeter to figure out start and end of span should help.
a
They usually have an internal representation that gets replaced
Like @<123456>
And then you map it to the ID of the user, snag their information, etf
Etc
r
hmm. got it
v
@Nick if possible can you please share the code for this?