Closed tgyuuAn closed 2 months ago
1 이전 채팅의 텍스트 사이즈를 저장해둠
2. 새로운 채팅이 들어왔을 때, 현재 사이즈와 다를경우, 마지막 아이템의 인덱스로 스크롤 함.
val listState = rememberLazyListState()
var previousChatSize by remember { mutableStateOf(1) }
val coroutineScope = rememberCoroutineScope()
LaunchedEffect(chatLog) {
if (previousChatSize != chatLog.size) {
coroutineScope.launch {
listState.animateScrollToItem(chatLog.size - 1)
}
previousChatSize = chatLog.size
}
}
LazyColumn(
state = listState,
verticalArrangement = Arrangement.spacedBy(20.dp),
contentPadding = PaddingValues(horizontal = 25.dp),
modifier = Modifier
.fillMaxSize()
.padding(top = topBarHeight, bottom = textFieldHeight),
) {
작업 사항
Todo
기타사항
참고 자료