Skip to content
Merged
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
5 changes: 3 additions & 2 deletions apps/nativescript-demo-ng/src/app/modal/modal.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<GridLayout backgroundColor="blue" padding="20" width="100%" height="100%">
<Label [nativeDialogClose]="'thanks for clicking modal ' + id" text="in modal" color="white" fontSize="20"></Label>
<GridLayout backgroundColor="blue" columns="*,*" padding="20" width="100%" height="100%">
<Button col="0" [nativeDialogClose]="'thanks for clicking modal ' + id" text="Close modal" fontSize="20"></Button>
<Button col="1" (tap)="openNewModal()" text="Open new modal" fontSize="20"></Button>
</GridLayout>
15 changes: 11 additions & 4 deletions apps/nativescript-demo-ng/src/app/modal/modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { Component, Inject, Optional } from '@angular/core';
import { NativeDialogRef } from '@nativescript/angular';
import { Component, Inject, OnDestroy, OnInit, Optional, ViewContainerRef } from '@angular/core';
import { ModalDialogService, NativeDialogRef, NativeDialogService } from '@nativescript/angular';

@Component({
selector: 'ns-modal',
templateUrl: `./modal.component.html`,
})
export class ModalComponent {
export class ModalComponent implements OnInit, OnDestroy {
id = Math.floor(Math.random() * 1000);

constructor(@Optional() ref: NativeDialogRef<ModalComponent>) {}
constructor(@Optional() private ref: NativeDialogRef<ModalComponent>, private nativeDialog: NativeDialogService, private modalDialog: ModalDialogService, private vcRef: ViewContainerRef) {}

openNewModal() {
this.nativeDialog.open(ModalComponent);
// this.modalDialog.showModal(ModalComponent, {
// viewContainerRef: this.vcRef
// });
}
ngOnInit() {
console.log('modal init');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/lib/legacy/directives/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class ModalDialogService {
ɵmarkDirty(componentRef.instance);
componentViewRef = new NgViewRef(componentRef);
if (componentViewRef !== componentRef.location.nativeElement) {
componentRef.location.nativeElement._ngDialogRoot = componentViewRef;
componentRef.location.nativeElement._ngDialogRoot = componentViewRef.firstNativeLikeView;
}
// if we don't detach the view from its parent, ios gets mad
componentViewRef.detachNativeLikeView();
Expand Down
3 changes: 0 additions & 3 deletions packages/angular/src/lib/views/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export function getFirstNativeLikeView(view: View, extractFromNSParent = false)
}
return getFirstNativeLikeView(view.getChildAt(0));
}
if (isContentView(view)) {
return getFirstNativeLikeView(view.content);
}

if (extractFromNSParent) {
// const node = view.parentNode;
Expand Down