Skip to content

fix(modal): missing animated & stretched params #1293

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

Merged
merged 9 commits into from
May 22, 2018
14 changes: 12 additions & 2 deletions nativescript-angular/directives/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { PageFactory, PAGE_FACTORY } from "../platform-providers";
export interface ModalDialogOptions {
context?: any;
fullscreen?: boolean;
animated?: boolean;
stretched?: boolean;
viewContainerRef?: ViewContainerRef;
moduleRef?: NgModuleRef<any>;
}
Expand All @@ -36,6 +38,8 @@ interface ShowDialogOptions {
context: any;
doneCallback;
fullscreen: boolean;
animated: boolean;
stretched: boolean;
pageFactory: PageFactory;
parentView: ViewBase;
resolver: ComponentFactoryResolver;
Expand All @@ -48,7 +52,7 @@ export class ModalDialogService {
}

public showModal(type: Type<any>,
{ viewContainerRef, moduleRef, context, fullscreen }: ModalDialogOptions
{ viewContainerRef, moduleRef, context, fullscreen, animated, stretched }: ModalDialogOptions
): Promise<any> {
if (!viewContainerRef) {
throw new Error(
Expand Down Expand Up @@ -77,6 +81,8 @@ export class ModalDialogService {
context,
doneCallback: resolve,
fullscreen,
animated,
stretched,
pageFactory,
parentView,
resolver,
Expand All @@ -90,6 +96,8 @@ export class ModalDialogService {
context,
doneCallback,
fullscreen,
animated,
stretched,
pageFactory,
parentView,
resolver,
Expand Down Expand Up @@ -132,7 +140,9 @@ export class ModalDialogService {
(<any>componentView.parent).removeChild(componentView);
}

parentView.showModal(componentView, context, closeCallback, fullscreen);
// TODO: remove <any> cast after https://github.com/NativeScript/NativeScript/pull/5734
// is in a published version of tns-core-modules.
(<any>parentView).showModal(componentView, context, closeCallback, fullscreen, animated, stretched);
});
}
}
Expand Down
8 changes: 6 additions & 2 deletions ng-sample/app/examples/modal/modal-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ModalContent } from "./modal-content";
<GridLayout rows="*, auto">
<StackLayout verticalAlignment="top" margin="12">
<Button text="show component" (tap)="showModal(false)"></Button>
<Button text="show component no anim (ios)" (tap)="showModal(false, false)"></Button>
<Button text="show component stretched (android)" (tap)="showModal(false, false, true)"></Button>
<Button text="show component fullscreen" (tap)="showModal(true)"></Button>

<Button text="alert" (tap)="showAlert()"></Button>
Expand All @@ -33,10 +35,12 @@ export class ModalTest {

static exports = [];

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
};

Expand Down