Commit 17bba525 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Minimium swipable state for opening bottom sheets

BottomSheet triggers onSheetOpened event when the sheet offset
goes beyond the height of the minimum swipable state which
depends on |swipeToDissmissEnabled|. The method is mainly used for
the transition from open to closed state. When transitioning
from hidden to open, the minimum swipable state needs to take
|isPeekStateEnabled| since even dismissable sheet can have the
peek state when opening.

Bug: 1014730
Change-Id: I46f4f8edaf7693d9ae4b6fe00a23d635baaa4d4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1868211
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708121}
parent d65cb07e
......@@ -972,7 +972,15 @@ public class BottomSheet
}
// Do open/close computation based on the minimum allowed state by the sheet's content.
float minScrollableHeight = getSheetHeightForState(getMinSwipableSheetState());
// Note that when transitioning from hidden to peek, even dismissable sheets may want
// to have a peek state.
@SheetState
int minSwipableState = getMinSwipableSheetState();
if (isPeekStateEnabled() && !isSheetOpen() && mCurrentState != mTargetState) {
minSwipableState = SheetState.PEEK;
}
float minScrollableHeight = getSheetHeightForState(minSwipableState);
boolean isAtMinHeight = MathUtils.areFloatsEqual(getCurrentOffsetPx(), minScrollableHeight);
boolean heightLessThanPeek = getCurrentOffsetPx() < minScrollableHeight;
// Trigger the onSheetClosed event when the sheet is moving toward the hidden state if peek
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment