MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / _showNativeModalView

Function _showNativeModalView

packages/core/ui/core/view/view-common.ts:450–502  ·  view source on GitHub ↗
(parent: ViewCommon, options: ShowModalOptions)

Source from the content-addressed store, hash-verified

448 }
449
450 protected _showNativeModalView(parent: ViewCommon, options: ShowModalOptions) {
451 _rootModalViews.push(this);
452
453 this.cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS);
454 const modalRootViewCssClasses = CSSUtils.getSystemCssClasses();
455 modalRootViewCssClasses.forEach((c) => this.cssClasses.add(c));
456
457 parent._modal = this;
458 this.style.fontScaleInternal = getFontScale();
459 this._modalParent = parent;
460 this._modalContext = options.context;
461 this._closeModalCallback = (...originalArgs) => {
462 const cleanupModalViews = () => {
463 const modalIndex = _rootModalViews.indexOf(this);
464 if (modalIndex > -1) {
465 _rootModalViews.splice(modalIndex, 1);
466 }
467
468 this._modalParent = null;
469 this._modalContext = null;
470 this._closeModalCallback = null;
471 this._dialogClosed();
472 parent._modal = null;
473 };
474
475 const whenClosedCallback = () => {
476 const transitionState = SharedTransition.getState(this.transitionId);
477 if (transitionState?.interactiveBegan) {
478 SharedTransition.updateState(this.transitionId, {
479 interactiveBegan: false,
480 });
481 if (!transitionState?.interactiveCancelled) {
482 cleanupModalViews();
483 }
484 }
485
486 if (!transitionState?.interactiveCancelled) {
487 if (typeof options.closeCallback === 'function') {
488 options.closeCallback.apply(undefined, originalArgs);
489 }
490
491 this._tearDownUI(true);
492 }
493 };
494
495 const transitionState = SharedTransition.getState(this.transitionId);
496 if (!transitionState?.interactiveBegan) {
497 cleanupModalViews();
498 }
499
500 this._hideNativeModalView(parent, whenClosedCallback);
501 };
502 }
503
504 protected _hideNativeModalView(parent: ViewCommon, whenClosedCallback: () => void) {}
505

Callers

nothing calls this directly

Calls 7

getFontScaleFunction · 0.90
cleanupModalViewsFunction · 0.85
forEachMethod · 0.80
getStateMethod · 0.80
addMethod · 0.65
pushMethod · 0.45
_hideNativeModalViewMethod · 0.45

Tested by

no test coverage detected