Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: set modal dialog root view parent #10443

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
Loading
from
Open
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
2 changes: 2 additions & 0 deletions 2 packages/core/ui/core/view/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ function initializeDialogFragment() {
const owner = this.owner;
this.activity = new WeakRef(this.getActivity());
owner._setupAsRootView(this.getActivity());
owner.parent = Application.getRootView();
owner._isAddedToNativeVisualTree = true;

// we need to set the window SoftInputMode here.
Expand Down Expand Up @@ -296,6 +297,7 @@ function initializeDialogFragment() {

owner._isAddedToNativeVisualTree = false;
owner._tearDownUI(true);
owner.parent = null;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions 8 packages/core/ui/core/view/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CoreTypes } from '../../../core-types';
import type { ModalTransition } from '../../transition/modal-transition';
import { SharedTransition } from '../../transition/shared-transition';
import { NativeScriptUIView } from '../../utils';
import { Application } from '../../../application';

export * from './view-common';
// helpers (these are okay re-exported here)
Expand Down Expand Up @@ -500,17 +501,20 @@ export class View extends ViewCommon implements ViewDefinition {
this._setupAsRootView({});

super._showNativeModalView(<ViewCommon>parentWithController, options);
let controller = this.viewController;
let controller: IOSHelper.UILayoutViewController = this.viewController;
if (!controller) {
const nativeView = this.ios || this.nativeViewProtected;
controller = <UIViewController>IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(this));
controller = <IOSHelper.UILayoutViewController>IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(this));
controller.modal = true;

if (nativeView instanceof UIView) {
controller.view.addSubview(nativeView);
}

this.viewController = controller;
}
// we set the parent to root to access all css root variables
this.parent = Application.getRootView();

if (options.transition) {
controller.modalPresentationStyle = UIModalPresentationStyle.Custom;
Expand Down
1 change: 1 addition & 0 deletions 1 packages/core/ui/core/view/view-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
}

this._tearDownUI(true);
this.parent = null;
}
};

Expand Down
3 changes: 2 additions & 1 deletion 3 packages/core/ui/core/view/view-helper/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export namespace IOSHelper {
export function getFrameFromPosition(position: { left; top; right; bottom }, insets?: { left; top; right; bottom }): any; /* CGRect */
export function shrinkToSafeArea(view: View, frame: any /* CGRect */): any; /* CGRect */
export function expandBeyondSafeArea(view: View, frame: any /* CGRect */): any; /* CGRect */
export class UILayoutViewController {
export class UILayoutViewController extends UIViewController {
public static initWithOwner(owner: WeakRef<View>): UILayoutViewController;
modal?: boolean;
}
export class UIAdaptivePresentationControllerDelegateImp {
public static initWithOwnerAndCallback(owner: WeakRef<View>, whenClosedCallback: Function): UIAdaptivePresentationControllerDelegateImp;
Expand Down
7 changes: 5 additions & 2 deletions 7 packages/core/ui/core/view/view-helper/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const AndroidHelper = 0;
@NativeClass
class UILayoutViewController extends UIViewController {
public owner: WeakRef<View>;
// used to know if we are a modal controller
// in this case the owner has a parent (rootView) but we still need to load/unload it
public modal;

public static initWithOwner(owner: WeakRef<View>): UILayoutViewController {
const controller = <UILayoutViewController>UILayoutViewController.new();
Expand Down Expand Up @@ -99,15 +102,15 @@ class UILayoutViewController extends UIViewController {

IOSHelper.updateAutoAdjustScrollInsets(this, owner);

if (!owner.isLoaded && !owner.parent) {
if (!owner.isLoaded && (!owner.parent || this.modal)) {
owner.callLoaded();
}
}

public viewDidDisappear(animated: boolean): void {
super.viewDidDisappear(animated);
const owner = this.owner?.deref();
if (owner && owner.isLoaded && !owner.parent) {
if (owner && owner.isLoaded && (!owner.parent || this.modal)) {
owner.callUnloaded();
}
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.