From c7da1b6c2886707c0b0c6e79401874ef8de6aeb7 Mon Sep 17 00:00:00 2001 From: Daniel Freiling Date: Fri, 20 Apr 2018 17:06:25 +0200 Subject: [PATCH 1/3] fix(modal): missing animated & stretched params --- nativescript-angular/directives/dialogs.ts | 17 +++++++++++++++-- ng-sample/app/examples/modal/modal-test.ts | 8 ++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index 8907f44cb..da8225eb8 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -19,6 +19,8 @@ import { PageFactory, PAGE_FACTORY } from "../platform-providers"; export interface ModalDialogOptions { context?: any; fullscreen?: boolean; + animated?: boolean; + stretched?: boolean; viewContainerRef?: ViewContainerRef; moduleRef?: NgModuleRef; } @@ -35,6 +37,8 @@ interface ShowDialogOptions { context: any; doneCallback; fullscreen: boolean; + animated: boolean; + stretched: boolean; pageFactory: PageFactory; parentView: ViewBase; resolver: ComponentFactoryResolver; @@ -44,7 +48,7 @@ interface ShowDialogOptions { @Injectable() export class ModalDialogService { public showModal(type: Type, - { viewContainerRef, moduleRef, context, fullscreen }: ModalDialogOptions + { viewContainerRef, moduleRef, context, fullscreen, animated, stretched }: ModalDialogOptions ): Promise { if (!viewContainerRef) { throw new Error( @@ -71,6 +75,8 @@ export class ModalDialogService { context, doneCallback: resolve, fullscreen, + animated, + stretched, pageFactory, parentView, resolver, @@ -84,6 +90,8 @@ export class ModalDialogService { context, doneCallback, fullscreen, + animated, + stretched, pageFactory, parentView, resolver, @@ -118,7 +126,12 @@ export class ModalDialogService { } page.content = componentView; - parentView.showModal(page, context, closeCallback, fullscreen); + // parentView typed as ViewBase, but only View takes stretched param. + if (parentView instanceof View) { + parentView.showModal(page, context, closeCallback, fullscreen, animated, stretched); + } else { + parentView.showModal(page, context, closeCallback, fullscreen, animated); + } }); } } diff --git a/ng-sample/app/examples/modal/modal-test.ts b/ng-sample/app/examples/modal/modal-test.ts index 6851c333d..d70f969ce 100644 --- a/ng-sample/app/examples/modal/modal-test.ts +++ b/ng-sample/app/examples/modal/modal-test.ts @@ -9,6 +9,8 @@ import { ModalContent } from "./modal-content"; + + @@ -35,10 +37,12 @@ export class ModalTest { ModalContent ]; - public showModal(fullscreen: boolean) { + public showModal(fullscreen: boolean, animated = true, stretched = false) { const options: ModalDialogOptions = { context: { promptMsg: "This is the prompt message!" }, - fullscreen: fullscreen, + fullscreen, + animated, + stretched, viewContainerRef: this.vcRef }; From 935298867409c1b2bf7b8e7f5e726528427cb09a Mon Sep 17 00:00:00 2001 From: Daniel Freiling Date: Fri, 4 May 2018 11:32:30 +0200 Subject: [PATCH 2/3] refactor(modals): use ViewBase.showModal call with all params --- nativescript-angular/directives/dialogs.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index da8225eb8..e1739db33 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -126,12 +126,7 @@ export class ModalDialogService { } page.content = componentView; - // parentView typed as ViewBase, but only View takes stretched param. - if (parentView instanceof View) { - parentView.showModal(page, context, closeCallback, fullscreen, animated, stretched); - } else { - parentView.showModal(page, context, closeCallback, fullscreen, animated); - } + parentView.showModal(page, context, closeCallback, fullscreen, animated, stretched); }); } } From 982b2424b9078812825a51038a69c7106bc86dbc Mon Sep 17 00:00:00 2001 From: Daniel Freiling Date: Sat, 5 May 2018 00:34:02 +0200 Subject: [PATCH 3/3] refactor(modals): cast parentView to any for now showModal with all params has been merged, but awaiting new release of tns-core-modules --- nativescript-angular/directives/dialogs.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index e1739db33..0bff79c1f 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -126,7 +126,9 @@ export class ModalDialogService { } page.content = componentView; - parentView.showModal(page, context, closeCallback, fullscreen, animated, stretched); + // TODO: remove cast after https://github.com/NativeScript/NativeScript/pull/5734 + // is in a published version of tns-core-modules. + (parentView).showModal(page, context, closeCallback, fullscreen, animated, stretched); }); } }