Skip to content

Commit 6982500

Browse files
committed
chore(bottomsheet): refactor
1 parent 1a0f5b1 commit 6982500

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/bottomsheet/bottomsheet.android.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
154154
const color = owner.backgroundColor;
155155
const contentViewId = getId('design_bottom_sheet');
156156
const view = fragment.getDialog().findViewById(contentViewId);
157-
const transparent = bottomSheetOptions.options && bottomSheetOptions.options.transparent;
158-
if (transparent === true) {
157+
const transparent = bottomSheetOptions.options?.transparent === true;
158+
if (transparent) {
159159
// we need delay it just a bit or it wont work
160160
setTimeout(() => {
161161
view.setBackground(null);
@@ -164,15 +164,15 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
164164

165165
const behavior = com.google.android.material.bottomsheet.BottomSheetBehavior.from(view);
166166
// prevent hiding the bottom sheet by
167-
const dismissOnDraggingDownSheet = !bottomSheetOptions.options || bottomSheetOptions.options.dismissOnDraggingDownSheet !== false;
167+
const dismissOnDraggingDownSheet = bottomSheetOptions.options?.dismissOnDraggingDownSheet !== false;
168168
behavior.setHideable(dismissOnDraggingDownSheet);
169169
if (!dismissOnDraggingDownSheet) {
170170
// directly expand the bottom sheet after start
171171
behavior.setState(com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED);
172172
// set to maximum possible value to prevent dragging the sheet between peek and expanded height
173173
behavior.setPeekHeight(java.lang.Integer.MAX_VALUE);
174174
}
175-
const skipCollapsedState = !bottomSheetOptions.options || bottomSheetOptions.options.skipCollapsedState === true;
175+
const skipCollapsedState = bottomSheetOptions.options?.skipCollapsedState === true;
176176
if (skipCollapsedState) {
177177
// directly expand the bottom sheet after start
178178
behavior.setState(com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED);

0 commit comments

Comments
 (0)