can i have access in a lazycolumn to the previous ...
# compose-desktop
z
can i have access in a lazycolumn to the previous element? i have a chat app, and now if the same person sends multiple messages i want the chat bubbles to be closer together and not every single bubble needs to include the name. since its the same person. i can do this on android. how do i do something like that on compose desktop in a lazycolumn?
k
“I can do this on Android” -> presumably by looking at the contact info and timestamps? What is the Android-specific code that can’t be ported to the desktop part of your codebase?
r
I'd consider doing this when populating the "item { }"s. e.g.
Copy code
messages.forEachIndex { idx, msg ->
  val prevMsg = messages[idx]
  item {
    ChatBubble(
       name = if (prevMsg.sender == msg.sender) "" else msg.sender,
       text = msg.text,
    )
  }
}
There's nothing special about LazyColumn here, the approach would be the same if this was a regular old column.
z
thanks i will try that