Skip to content

Commit 278c405

Browse files
committed
fix: support dark mode in bottom sheets
1 parent fd00548 commit 278c405

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/bottomsheet/bottomsheet-common.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ export abstract class ViewWithBottomSheetBase extends View {
4545
eventName: shownInBottomSheetEvent,
4646
object: this,
4747
context: this._bottomSheetContext,
48-
closeCallback: this._closeBottomSheetCallback
48+
closeCallback: this._closeBottomSheetCallback,
4949
};
5050

5151
this.notify(args);
5252
}
5353
public _bottomSheetClosed(): void {
54+
const _rootModalViews = this._getRootModalViews();
55+
const modalIndex = _rootModalViews.indexOf(this);
56+
_rootModalViews.splice(modalIndex);
5457
this._tearDownUI();
5558
// if a frame _removeFromFrameStack will be called from _tearDownUI
5659
// if (this instanceof Frame) {
@@ -63,6 +66,7 @@ export abstract class ViewWithBottomSheetBase extends View {
6366
}
6467
protected abstract _showNativeBottomSheet(parent: View, options: BottomSheetOptions);
6568
protected _commonShowNativeBottomSheet(parent: View, options: BottomSheetOptions) {
69+
this._getRootModalViews().push(this);
6670
options.context = options.context || {};
6771
this._bottomSheetContext = options.context;
6872
this._onDismissBottomSheetCallback = (...originalArgs) => {
@@ -84,6 +88,7 @@ export abstract class ViewWithBottomSheetBase extends View {
8488
if (!this._closeBottomSheetCallback) {
8589
return;
8690
}
91+
8792
// const callback = this._closeBottomSheetCallback;
8893
this._closeBottomSheetCallback = null;
8994
if (this._bottomSheetContext) {
@@ -103,7 +108,7 @@ export abstract class ViewWithBottomSheetBase extends View {
103108
eventName: showingInBottomSheetEvent,
104109
object: this,
105110
context: this._bottomSheetContext,
106-
closeCallback: this._closeBottomSheetCallback
111+
closeCallback: this._closeBottomSheetCallback,
107112
};
108113
this.notify(args);
109114
}
@@ -123,12 +128,15 @@ export abstract class ViewWithBottomSheetBase extends View {
123128
if (arguments.length === 0) {
124129
throw new Error('showModal without parameters is deprecated. Please call showModal on a view instance instead.');
125130
} else {
126-
const view = options.view instanceof View ? (options.view as ViewWithBottomSheetBase) : Builder.createViewFromEntry({
127-
moduleName: options.view as string
128-
}) as ViewWithBottomSheetBase;
131+
const view =
132+
options.view instanceof View
133+
? (options.view as ViewWithBottomSheetBase)
134+
: (Builder.createViewFromEntry({
135+
moduleName: options.view as string,
136+
}) as ViewWithBottomSheetBase);
129137
view.cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS);
130138
const modalRootViewCssClasses = CSSUtils.getSystemCssClasses();
131-
modalRootViewCssClasses.forEach(c => view.cssClasses.add(c));
139+
modalRootViewCssClasses.forEach((c) => view.cssClasses.add(c));
132140

133141
view._showNativeBottomSheet(this, options);
134142
return view;

0 commit comments

Comments
 (0)