Sam
12/22/2020, 10:47 PMrememberLazyListState with LazyColumn for a chat interface? JetChat in compose-samples still uses ScrollableColumn so it doesn’’t help much, especially in these areas:
• How do we smooth scroll to show a new incoming message? Since we only have relative-based smoothScrollBy instead of smoothScrollTo(0f) (on reverseLayout = true), it’s hard to get to the right spot and snapToIndex(0) is unnatural
• How do we get measurements of the specific message component sizes to make the right relative scrolling calculation? I’ve seen chatScrollState.layoutInfo.visibleItemsInfo but i’m not sure how to get updates when layoutInfo changes, sticking it inside LaunchedEffect doesn’t fire
• How do we know when we are getting to the end of the LazyColumn so that we can fetch older messages and add them to the list?
• In the case where new messages are coming in or old messages are being added, how do we maintain existing scroll position without the whole list jumping around?Sam
12/22/2020, 10:54 PMDominaezzz
12/22/2020, 10:54 PMDominaezzz
12/22/2020, 10:55 PMonActive { onDispose {} } on the oldest (or whatever you feel is right) item in the LazyColumn to trigger the fetch.Dominaezzz
12/22/2020, 10:56 PMsnapshotFlow { .... } to capture the changes.Dominaezzz
12/22/2020, 10:58 PMsmoothScrollBy until you're at the bottom of the list aha.Dominaezzz
12/22/2020, 10:59 PMSam
12/22/2020, 10:59 PMonActive to detect when to fetchSam
12/22/2020, 11:01 PMsnapToIndex or smoothScrollBy ?Dominaezzz
12/22/2020, 11:05 PMreverseLayout = true new messages tend to just show up without me having to scroll. Although if there's a tiny bit of scroll, it doesn't show up. Haven't gotten to that yet.Sam
12/22/2020, 11:05 PMDominaezzz
12/22/2020, 11:06 PMSam
12/22/2020, 11:51 PMDominaezzz
12/22/2020, 11:59 PMDominaezzz
12/22/2020, 11:59 PMSam
12/23/2020, 12:11 AMAndrey Kulikov
12/23/2020, 12:06 PMsmoothScrollToItem is still in progress, so not yet ready. we also don’t yet have a solid support for item animations, you can implement something on your own with tools like AnimatedVisibility, but not everything