Skip to content

feat(BottomSheet): (Android only) allows to interact with the screen behind the sheet #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/bottomsheet/bottomsheet-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface BottomSheetOptions {
peekHeight?: number; // optional parameter to set the collapsed sheet height. To work on iOS you need to set trackingScrollView.
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)
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.
canTouchBehind?: boolean //(Android only) allows to interact with the screen behind the sheet. For it to work properly need dismissOnBackgroundTap set to true
}

export abstract class ViewWithBottomSheetBase extends View {
Expand Down
10 changes: 10 additions & 0 deletions src/bottomsheet/bottomsheet.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,16 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
owner.callLoaded();
}

if(bottomSheetOptions.options.canTouchBehind){
const coordinator = view.getParent();
coordinator.findViewById(getId("touch_outside")).setOnTouchListener(new android.view.View.OnTouchListener({
onTouch: function (view, event) {
fragment.getActivity().dispatchTouchEvent(event);
return false;
}
}));
}

bottomSheetOptions.shownCallback();
},

Expand Down