Skip to content

Commit 571fe28

Browse files
committed
refactor
1 parent ce00152 commit 571fe28

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/bottomsheet/bottomsheet-common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export abstract class ViewWithBottomSheetBase extends View {
128128
if (options.onChangeState && typeof options.onChangeState === 'function') {
129129
this._onChangeStateBottomSheetCallback = (stateBottomSheet: StateBottomSheet, slideOffset: number) => {
130130
// only called if not already called by _closeBottomSheetCallback
131-
options.onChangeState(stateBottomSheet, slideOffset);
131+
options.onChangeState(stateBottomSheet, slideOffset ?? stateBottomSheet);
132132
};
133133
}
134134

src/bottomsheet/bottomsheet.ios.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ class MDCBottomSheetControllerDelegateImpl extends NSObject {
3232
const topPadding = window.safeAreaInsets.top;
3333
const bottomPadding = window.safeAreaInsets.bottom;
3434

35-
const isStateCollapsed = heightScreen - yOffset - bottomPadding === heightCollapsedSheet;
35+
const isCollapsed = heightScreen - yOffset - bottomPadding === heightCollapsedSheet;
3636
const isExpanded = yOffset === topPadding;
37-
if (!isStateCollapsed && !isExpanded) {
37+
if (!isCollapsed && !isExpanded) {
3838
//normalized = (value - min) / (max - min);
3939
let normalized = 0;
4040
if (yOffset + bottomPadding > heightScreen - heightCollapsedSheet) {
@@ -44,8 +44,7 @@ class MDCBottomSheetControllerDelegateImpl extends NSObject {
4444
}
4545
owner._onChangeStateBottomSheetCallback(StateBottomSheet.DRAGGING, normalized);
4646
} else {
47-
const state = isStateCollapsed ? StateBottomSheet.COLLAPSED : StateBottomSheet.EXPANDED;
48-
owner._onChangeStateBottomSheetCallback(state, state);
47+
owner._onChangeStateBottomSheetCallback(isCollapsed ? StateBottomSheet.COLLAPSED : StateBottomSheet.EXPANDED);
4948
}
5049
}
5150
}
@@ -65,20 +64,14 @@ class MDCBottomSheetControllerDelegateImpl extends NSObject {
6564
if (state === MDCSheetState.Closed) {
6665
if (owner) {
6766
owner._onDismissBottomSheetCallback && owner._onDismissBottomSheetCallback();
68-
if (owner._onChangeStateBottomSheetCallback) {
69-
owner._onChangeStateBottomSheetCallback(StateBottomSheet.CLOSED, StateBottomSheet.CLOSED);
70-
}
67+
owner._onChangeStateBottomSheetCallback && owner._onChangeStateBottomSheetCallback(StateBottomSheet.CLOSED);
7168
if (owner && owner.isLoaded) {
7269
owner.callUnloaded();
7370
}
7471
}
7572
} else {
7673
if (owner && owner._onChangeStateBottomSheetCallback) {
77-
if (state === MDCSheetState.Extended) {
78-
owner._onChangeStateBottomSheetCallback(StateBottomSheet.EXPANDED, StateBottomSheet.EXPANDED);
79-
} else {
80-
owner._onChangeStateBottomSheetCallback(StateBottomSheet.COLLAPSED, StateBottomSheet.COLLAPSED);
81-
}
74+
owner._onChangeStateBottomSheetCallback(state === MDCSheetState.Extended ? StateBottomSheet.EXPANDED : StateBottomSheet.EXPANDED)
8275
}
8376
}
8477
}

0 commit comments

Comments
 (0)