[fenix] Fixes https://github.com/mozilla-mobile/fenix/issues/2030: Quick action sheet collapses on scroll

pull/600/head
Sawyer Blatz 6 years ago committed by Emily Kager
parent 5ee04c708c
commit 21d96cd06e

@ -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()
}
}

Loading…
Cancel
Save