Message scroller
A transcript that follows new messages, keeps its place when older ones load, and offers a jump to the latest with the unread count.
Transcript
let messages = &state.messages;
MessageScroller::new(&mut state.scroller)
.max_height(360.0)
.bottom_fade(true)
.row_gap(12.0)
.show_rows(ui, messages.len(), |ui, index| {
if index == 0 {
ui.add(Marker::new("Today").variant(MarkerVariant::Separator));
}
let mine = index % 3 == 2;
let bubble = Bubble::new().text(messages[index].as_str());
ui.add(if mine {
bubble.alignment(MessageAlignment::End)
} else {
bubble.variant(BubbleVariant::Secondary)
});
});
The story above is gallery/src/stories/message_scroller.rs, running in your browser. Every snippet on this page is cut from it.