timeline : fix jumpToBottom for not live timeline.
This commit is contained in:
parent
7780bd7e11
commit
75977347e7
1 changed files with 11 additions and 0 deletions
|
|
@ -30,9 +30,11 @@ import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.rememberUpdatedState
|
import androidx.compose.runtime.rememberUpdatedState
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.rotate
|
import androidx.compose.ui.draw.rotate
|
||||||
|
|
@ -206,6 +208,7 @@ private fun BoxScope.TimelineScrollHelper(
|
||||||
lazyListState.firstVisibleItemIndex < 3 && isLive
|
lazyListState.firstVisibleItemIndex < 3 && isLive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var jumpToLiveHandled by remember { mutableStateOf(true) }
|
||||||
|
|
||||||
fun scrollToBottom() {
|
fun scrollToBottom() {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
|
|
@ -221,10 +224,18 @@ private fun BoxScope.TimelineScrollHelper(
|
||||||
if (isLive) {
|
if (isLive) {
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
} else {
|
} else {
|
||||||
|
jumpToLiveHandled = false
|
||||||
onJumpToLive()
|
onJumpToLive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(jumpToLiveHandled, isLive) {
|
||||||
|
if (!jumpToLiveHandled && isLive) {
|
||||||
|
lazyListState.scrollToItem(0)
|
||||||
|
jumpToLiveHandled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val latestOnFocusEventRender by rememberUpdatedState(onFocusEventRender)
|
val latestOnFocusEventRender by rememberUpdatedState(onFocusEventRender)
|
||||||
LaunchedEffect(focusRequestState) {
|
LaunchedEffect(focusRequestState) {
|
||||||
if (focusRequestState is FocusRequestState.Success && focusRequestState.isIndexed) {
|
if (focusRequestState is FocusRequestState.Success && focusRequestState.isIndexed) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue