Skip to content

Commit ae4d6cc

Browse files
committed
fix: allow dialogs and bottomsheet views to access ns-root css variables
1 parent 2d8613c commit ae4d6cc

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/bottomsheet/bottomsheet.android.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
146146
savedInstanceState: android.os.Bundle
147147
): android.view.View {
148148
owner._setupAsRootView(fragment.getActivity());
149+
owner.parent = Application.getRootView();
149150
owner._isAddedToNativeVisualTree = true;
150151
return owner.nativeViewProtected;
151152
},
@@ -237,6 +238,7 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
237238
}
238239
owner._isAddedToNativeVisualTree = false;
239240
owner._tearDownUI(true);
241+
owner.parent = null;
240242
}
241243
}
242244
});

src/bottomsheet/bottomsheet.ios.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
361361
return;
362362
}
363363
this._setupAsRootView({});
364+
this.parent = Application.getRootView();
364365

365366
this._commonShowNativeBottomSheet(parentWithController, options);
366367
let controller: IMDLayoutViewController = this.viewController;
@@ -454,7 +455,10 @@ export class ViewWithBottomSheet extends ViewWithBottomSheetBase {
454455
if (this.isLoaded) {
455456
this.callUnloaded();
456457
}
457-
458+
this._isAddedToNativeVisualTree = false;
459+
this._tearDownUI(true);
460+
this.parent = null;
461+
458462
this._onDismissBottomSheetCallback && this._onDismissBottomSheetCallback();
459463
// it is very important to clear the viewController as N does not do it
460464
// and the destroy of the view from svelte could trigger a layout pass on the viewController

src/dialogs/dialogs.android.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function createAlertDialogBuilder(options?: DialogOptions & MDCAlertControlerOpt
7272

7373
(builder as any)._currentModalCustomView = view;
7474
view._setupAsRootView(activity);
75+
view.parent = Application.getRootView();
7576
view._isAddedToNativeVisualTree = true;
7677
view.callLoaded();
7778

@@ -176,7 +177,7 @@ function prepareAndCreateAlertDialog(
176177
Utils.android.dismissSoftInput(options.view.nativeView);
177178
} else {
178179
const activity = (Application.android.foregroundActivity || Application.android.startActivity) as globalAndroid.app.Activity;
179-
const context = ad.getApplicationContext() as android.content.Context;
180+
const context = ad.getApplicationContext();
180181
const view = activity != null ? activity.getCurrentFocus() : null;
181182
if (view) {
182183
const imm = context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as android.view.inputmethod.InputMethodManager;
@@ -198,11 +199,12 @@ function prepareAndCreateAlertDialog(
198199
new DialogInterface.OnDismissListener({
199200
onDismiss() {
200201
// ensure callback is called after destroying the custom view
201-
onDone(false, undefined, ()=>{
202+
onDone(false, undefined, () => {
202203
if ((builder as any)._currentModalCustomView) {
203204
const view = (builder as any)._currentModalCustomView;
204205
view.callUnloaded();
205206
view._tearDownUI(true);
207+
view.parent = null;
206208
view._isAddedToNativeVisualTree = false;
207209
(builder as any)._currentModalCustomView = null;
208210
}

src/dialogs/dialogs.ios.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class UIViewAutoSizeUIViewAutoSize extends UIView {
5555
function createUIViewAutoSizeUIViewAutoSize(view: View) {
5656
const self = UIViewAutoSizeUIViewAutoSize.new() as UIViewAutoSizeUIViewAutoSize;
5757
view._setupAsRootView({});
58+
view.parent = Application.getRootView();
5859
view._isAddedToNativeVisualTree = true;
5960
view.callLoaded();
6061
self._view = view;
@@ -104,6 +105,7 @@ class MDCAlertControllerImpl extends MDCAlertController {
104105
const view = this.accessoryView._view;
105106
view.callUnloaded();
106107
view._tearDownUI(true);
108+
view.parent = null;
107109
view._isAddedToNativeVisualTree = false;
108110
this.accessoryView._view = null;
109111
}
@@ -174,8 +176,8 @@ function createAlertController(options: DialogOptions & MDCAlertControlerOptions
174176
options.view instanceof View
175177
? options.view
176178
: Builder.createViewFromEntry({
177-
moduleName: options.view as string
178-
});
179+
moduleName: options.view as string
180+
});
179181

180182
view.cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS);
181183
const modalRootViewCssClasses = CSSUtils.getSystemCssClasses();
@@ -277,8 +279,8 @@ export function confirm(arg: any): Promise<boolean> {
277279
};
278280
const options = !isDialogOptions(arg)
279281
? Object.assign(defaultOptions, {
280-
message: arg + ''
281-
})
282+
message: arg + ''
283+
})
282284
: Object.assign(defaultOptions, arg);
283285
const alertController = createAlertController(options, resolve);
284286

@@ -540,7 +542,7 @@ function showUIAlertController(alertController: MDCAlertController, options: Dia
540542
if (alertController.popoverPresentationController) {
541543
alertController.popoverPresentationController.sourceView = viewController.view;
542544
alertController.popoverPresentationController.sourceRect = CGRectMake(viewController.view.bounds.size.width / 2.0, viewController.view.bounds.size.height / 2.0, 1.0, 1.0);
543-
alertController.popoverPresentationController.permittedArrowDirections = 0;
545+
alertController.popoverPresentationController.permittedArrowDirections = 0 as any;
544546
}
545547
viewController.presentViewControllerAnimatedCompletion(alertController, true, null);
546548
}

0 commit comments

Comments
 (0)