Починил повторное появление реквестов при прокрутке в чат-листе
This commit is contained in:
@@ -1802,8 +1802,6 @@ fun ChatsListScreen(
|
||||
remember(localDensity) { with(localDensity) { 56.dp.toPx() } }
|
||||
val requestsHideThresholdPx =
|
||||
remember(localDensity) { with(localDensity) { 16.dp.toPx() } }
|
||||
val topOffsetTolerancePx =
|
||||
remember(localDensity) { with(localDensity) { 3.dp.toPx() } }
|
||||
|
||||
AnimatedContent(
|
||||
targetState = showDownloadsScreen,
|
||||
@@ -2099,16 +2097,13 @@ fun ChatsListScreen(
|
||||
requestsCount,
|
||||
requestsRevealThresholdPx,
|
||||
requestsHideThresholdPx,
|
||||
topOffsetTolerancePx,
|
||||
hapticFeedback
|
||||
) {
|
||||
var accumulatedPullDown = 0f
|
||||
var hapticSent = false
|
||||
object : androidx.compose.ui.input.nestedscroll.NestedScrollConnection {
|
||||
fun isAtTop(): Boolean {
|
||||
return chatListState.firstVisibleItemIndex == 0 &&
|
||||
chatListState.firstVisibleItemScrollOffset <=
|
||||
topOffsetTolerancePx.roundToInt()
|
||||
return !chatListState.canScrollBackward
|
||||
}
|
||||
|
||||
override fun onPreScroll(
|
||||
@@ -2130,41 +2125,12 @@ fun ChatsListScreen(
|
||||
if (isRequestsVisible) {
|
||||
isRequestsVisible = false
|
||||
}
|
||||
}
|
||||
return androidx.compose.ui.geometry.Offset.Zero
|
||||
}
|
||||
|
||||
override fun onPostScroll(
|
||||
consumed: androidx.compose.ui.geometry.Offset,
|
||||
available: androidx.compose.ui.geometry.Offset,
|
||||
source: androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||
): androidx.compose.ui.geometry.Offset {
|
||||
if (source != androidx.compose.ui.input.nestedscroll.NestedScrollSource.Drag ||
|
||||
requestsCount <= 0
|
||||
) {
|
||||
accumulatedPullDown = 0f
|
||||
hapticSent = false
|
||||
return androidx.compose.ui.geometry.Offset.Zero
|
||||
}
|
||||
|
||||
if (isRequestsVisible) {
|
||||
accumulatedPullDown = 0f
|
||||
hapticSent = false
|
||||
return androidx.compose.ui.geometry.Offset.Zero
|
||||
}
|
||||
|
||||
val pullDownDelta =
|
||||
if (available.y > 0f && isAtTop())
|
||||
available.y
|
||||
else 0f
|
||||
|
||||
if (pullDownDelta > 0f) {
|
||||
} else if (available.y > 0f && !isRequestsVisible && isAtTop()) {
|
||||
// Pull down from top should always reopen requests.
|
||||
accumulatedPullDown =
|
||||
(accumulatedPullDown +
|
||||
pullDownDelta)
|
||||
(accumulatedPullDown + available.y)
|
||||
.coerceAtMost(
|
||||
requestsRevealThresholdPx *
|
||||
2f
|
||||
requestsRevealThresholdPx * 2f
|
||||
)
|
||||
if (accumulatedPullDown >= requestsRevealThresholdPx) {
|
||||
isRequestsVisible = true
|
||||
@@ -2176,7 +2142,7 @@ fun ChatsListScreen(
|
||||
hapticSent = true
|
||||
}
|
||||
}
|
||||
} else if (available.y < 0f || !isAtTop()) {
|
||||
} else if (available.y <= 0f || !isAtTop()) {
|
||||
accumulatedPullDown = 0f
|
||||
hapticSent = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user