fix chat report dialog adjusting to wrong height
This commit is contained in:
+17
-10
@@ -292,6 +292,17 @@ class BottomSheetView(
|
|||||||
|
|
||||||
val oldRatio = behavior.halfExpandedRatio
|
val oldRatio = behavior.halfExpandedRatio
|
||||||
val newRatio = getHalfExpandedRatio(contentHeight)
|
val newRatio = getHalfExpandedRatio(contentHeight)
|
||||||
|
|
||||||
|
val targetHeight = this.getTargetHeight()
|
||||||
|
val availableHeight = screenHeight - getStatusBarHeight() - getNavigationBarHeight()
|
||||||
|
val shouldBeExpanded = targetHeight >= availableHeight
|
||||||
|
|
||||||
|
// Don't update during user gestures — defer until the gesture completes.
|
||||||
|
if (currentState == BottomSheetBehavior.STATE_DRAGGING) {
|
||||||
|
pendingLayoutUpdate = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
behavior.halfExpandedRatio = newRatio
|
behavior.halfExpandedRatio = newRatio
|
||||||
|
|
||||||
if (preventExpansion) {
|
if (preventExpansion) {
|
||||||
@@ -299,16 +310,12 @@ class BottomSheetView(
|
|||||||
it.requestLayout()
|
it.requestLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
val targetHeight = this.getTargetHeight()
|
// During settling (programmatic animation from our own state change),
|
||||||
val availableHeight = screenHeight - getStatusBarHeight() - getNavigationBarHeight()
|
// redirect the animation to the new position if the ratio changed.
|
||||||
val shouldBeExpanded = targetHeight >= availableHeight
|
if (currentState == BottomSheetBehavior.STATE_SETTLING) {
|
||||||
|
if (oldRatio != newRatio) {
|
||||||
// Don't force state changes during user gestures — the ratio and maxHeight
|
behavior.state = BottomSheetBehavior.STATE_HALF_EXPANDED
|
||||||
// are already updated above, so when the gesture settles the sheet will land
|
}
|
||||||
// at the correct position. Forcing a state change mid-drag interrupts
|
|
||||||
// dismiss swipes and causes visual glitches.
|
|
||||||
if (currentState == BottomSheetBehavior.STATE_DRAGGING || currentState == BottomSheetBehavior.STATE_SETTLING) {
|
|
||||||
pendingLayoutUpdate = true
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user