1
0
Fork 0

Fixes #2030: Quick action sheet collapses on scroll

master
Sawyer Blatz 2019-04-25 11:30:08 -07:00 committed by Emily Kager
parent 191786c671
commit 9e9b6f98f9
1 changed files with 15 additions and 0 deletions

View File

@ -142,6 +142,20 @@ class QuickActionSheetBehavior(
context: Context,
attrs: AttributeSet
) : BottomSheetBehavior<NestedScrollView>(context, attrs) {
override fun onNestedPreScroll(
coordinatorLayout: CoordinatorLayout,
child: NestedScrollView,
target: View,
dx: Int,
dy: Int,
consumed: IntArray,
type: Int
) {
if (dy < 0) { state = STATE_COLLAPSED }
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type)
}
override fun layoutDependsOn(parent: CoordinatorLayout, child: NestedScrollView, dependency: View): Boolean {
if (dependency is BrowserToolbar) {
return true
@ -164,6 +178,7 @@ class QuickActionSheetBehavior(
}
private fun repositionQuickActionSheet(quickActionSheetContainer: NestedScrollView, toolbar: BrowserToolbar) {
if (toolbar.translationY == toolbar.height.toFloat()) { state = STATE_HIDDEN }
quickActionSheetContainer.translationY = (toolbar.translationY + toolbar.height * -1.0).toFloat()
}
}