Skip to content

Commit d0b273c

Browse files
authored
Merge pull request #400 from vallemar/master
feat(BottomSheet): (Android only) allows to interact with the screen behind the sheet
2 parents 599b319 + c42e12a commit d0b273c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/bottomsheet/bottomsheet-common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface BottomSheetOptions {
4343
peekHeight?: number; // optional parameter to set the collapsed sheet height. To work on iOS you need to set trackingScrollView.
4444
ignoreKeyboardHeight?: boolean; //(iOS only) A Boolean value that controls whether the height of the keyboard should affect the bottom sheet's frame when the keyboard shows on the screen. (Default: true)
4545
onChangeState?: onChangeStateBottomSheet; // One works to be called on the scroll of the sheet. Parameters: state (CLOSED, DRAGGING, DRAGGING, COLLAPSED) and slideOffset is the new offset of this bottom sheet within [-1,1] range. Offset increases as this bottom sheet is moving upward. From 0 to 1 the sheet is between collapsed and expanded states and from -1 to 0 it is between hidden and collapsed states.
46+
canTouchBehind?: boolean //(Android only) allows to interact with the screen behind the sheet. For it to work properly need dismissOnBackgroundTap set to true
4647
}
4748

4849
export abstract class ViewWithBottomSheetBase extends View {

src/bottomsheet/bottomsheet.android.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
196196
owner.callLoaded();
197197
}
198198

199+
if(bottomSheetOptions.options.canTouchBehind){
200+
const coordinator = view.getParent();
201+
coordinator.findViewById(getId("touch_outside")).setOnTouchListener(new android.view.View.OnTouchListener({
202+
onTouch: function (view, event) {
203+
fragment.getActivity().dispatchTouchEvent(event);
204+
return false;
205+
}
206+
}));
207+
}
208+
199209
bottomSheetOptions.shownCallback();
200210
},
201211

0 commit comments

Comments
 (0)