Skip to content

Commit b5030d8

Browse files
ADjenkovADjenkov
ADjenkov
authored and
ADjenkov
committed
feat: complete componets and navigation
1 parent 666c75c commit b5030d8

20 files changed

+266
-195
lines changed

Diff for: e2e/modal-navigation-ng/app/app.module.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ import { NativeScriptModule } from "nativescript-angular/nativescript.module";
33
import { AppRoutingModule } from "./app.routing";
44
import { AppComponent } from "./app.component";
55

6-
import { ItemService } from "./item/item.service";
7-
import { ItemsComponent } from "./item/items.component";
8-
import { ItemDetailComponent } from "./item/item-detail.component";
9-
106
import { HomeComponent } from "./home/home.component";
7+
import { SecondComponent } from "./second/second.component";
8+
import { ModalSecondComponent } from "./modal-second/modal-second.component";
119
import { ModalComponent } from "./modal/modal.component";
10+
import { NestedModalComponent } from "./modal-nested/modal-nested.component";
1211
import { ModalRouterComponent } from "./modal/modal-router/modal-router.component";
1312

14-
// Uncomment and add to NgModule imports if you need to use two-way binding
15-
// import { NativeScriptFormsModule } from "nativescript-angular/forms";
13+
import { enable as traceEnable, addCategories } from "tns-core-modules/trace";
14+
import { routerTraceCategory } from "nativescript-angular/trace";
1615

17-
// Uncomment and add to NgModule imports if you need to use the HTTP wrapper
18-
// import { NativeScriptHttpModule } from "nativescript-angular/http";
16+
// addCategories(routerTraceCategory);
17+
// traceEnable();
1918

2019
@NgModule({
2120
bootstrap: [
@@ -25,17 +24,15 @@ import { ModalRouterComponent } from "./modal/modal-router/modal-router.componen
2524
NativeScriptModule,
2625
AppRoutingModule
2726
],
28-
entryComponents: [ModalComponent],
27+
entryComponents: [ModalRouterComponent, NestedModalComponent, ModalComponent],
2928
declarations: [
3029
AppComponent,
31-
ItemsComponent,
32-
ItemDetailComponent,
3330
HomeComponent,
31+
SecondComponent,
3432
ModalComponent,
35-
ModalRouterComponent
36-
],
37-
providers: [
38-
ItemService
33+
NestedModalComponent,
34+
ModalRouterComponent,
35+
ModalSecondComponent
3936
],
4037
schemas: [
4138
NO_ERRORS_SCHEMA

Diff for: e2e/modal-navigation-ng/app/app.routing.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,31 @@ import { NativeScriptRouterModule } from "nativescript-angular/router";
33
import { Routes, ChildrenOutletContexts } from "@angular/router";
44

55
import { HomeComponent } from "./home/home.component";
6+
import { SecondComponent } from "./second/second.component";
7+
import { ModalSecondComponent } from "./modal-second/modal-second.component";
68
import { ModalComponent } from "./modal/modal.component";
9+
import { NestedModalComponent } from "./modal-nested/modal-nested.component";
710
import { ModalRouterComponent } from "./modal/modal-router/modal-router.component";
811

912
const routes: Routes = [
1013
{ path: "", redirectTo: "/home", pathMatch: "full" },
1114
{
12-
path: "home", component: HomeComponent, children: [{
13-
path: "modal", component: ModalRouterComponent, children: [
14-
{ path: "", component: ModalComponent }
15-
]
16-
}]
15+
path: "home", component: HomeComponent, children: [
16+
{
17+
path: "modal", component: ModalComponent, children: [
18+
{ path: "nested-frame-modal", component: NestedModalComponent }]
19+
},
20+
{ path: "modal-second", component: ModalSecondComponent }
21+
]
22+
},
23+
{
24+
path: "second", component: SecondComponent, children: [
25+
{
26+
path: "modal", component: ModalComponent, children: [
27+
{ path: "nested-frame-modal", component: NestedModalComponent }]
28+
},
29+
{ path: "modal-second", component: ModalSecondComponent }
30+
]
1731
}
1832
];
1933

Diff for: e2e/modal-navigation-ng/app/home/home.component.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
</ActionBar>
44

55
<StackLayout>
6+
<Button text="Show Modal Without Frame" (tap)="onModalNoFrame()"></Button>
67
<Button text="Show Modal Page With Frame" (tap)="onModalFrame()"></Button>
7-
<Button text="Show Modal Page" (tap)="onModalPage"></Button>
8-
<Button text="Show Modal Layout" (tap)="onModalLayout"></Button>
9-
<Button text="Show Modal TabView" (tap)="onModalTabView"></Button>
10-
<Button text="Navigate To Second Page" (tap)="onNavigate"></Button>
11-
<Button text="Reset Frame Root View" (tap)="onFrameRootViewReset"></Button>
8+
<Button text="Navigate To Second Page" (tap)="onNavigateSecond()"></Button>
9+
<Button text="Reset Frame Root View" (tap)="onFrameRootViewReset()"></Button>
1210
<Button text="Reset Tab Root View" (tap)="onTabRootViewReset"></Button>
1311
<Button text="Reset Layout Root View" (tap)="onLayoutRootViewReset"></Button>
1412
</StackLayout>

Diff for: e2e/modal-navigation-ng/app/home/home.component.ts

+29-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { View } from "tns-core-modules/ui/core/view";
66
import { ModalRouterComponent } from "../modal/modal-router/modal-router.component";
77
import { PageRouterOutlet } from "nativescript-angular/router/page-router-outlet";
88
import { RouterExtensions } from "nativescript-angular/router";
9+
import { ModalComponent } from "../modal/modal.component";
910

1011
@Component({
1112
moduleId: module.id,
@@ -15,15 +16,40 @@ import { RouterExtensions } from "nativescript-angular/router";
1516
export class HomeComponent {
1617
constructor(private modal: ModalDialogService, private vcRef: ViewContainerRef, private routerExtension: RouterExtensions) { }
1718

18-
public onModalFrame(args: EventData) {
19+
onModalNoFrame(args: EventData) {
1920
const options: ModalDialogOptions = {
20-
// context: null,
21+
context: {
22+
navigationVisibility: false
23+
},
24+
fullscreen: true,
25+
viewContainerRef: this.vcRef
26+
};
27+
28+
this.modal.showModal(ModalComponent, options).then((res: string) => {
29+
console.log("moda-no-frame closed");
30+
});
31+
}
32+
33+
onModalFrame(args: EventData) {
34+
const options: ModalDialogOptions = {
35+
context: {
36+
navigationVisibility: true,
37+
modalRoute: "modal"
38+
},
2139
fullscreen: true,
2240
viewContainerRef: this.vcRef
2341
};
2442

2543
this.modal.showModal(ModalRouterComponent, options).then((res: string) => {
26-
console.log("MODAL SHOWN");
44+
console.log("moda-frame closed");
2745
});
2846
}
47+
48+
onNavigateSecond(args: EventData) {
49+
this.routerExtension.navigate(["second"]);
50+
}
51+
52+
onFrameRootViewReset(args: EventData) {
53+
54+
}
2955
}

Diff for: e2e/modal-navigation-ng/app/item/item-detail.component.html

-8
This file was deleted.

Diff for: e2e/modal-navigation-ng/app/item/item-detail.component.ts

-27
This file was deleted.

Diff for: e2e/modal-navigation-ng/app/item/item.service.ts

-39
This file was deleted.

Diff for: e2e/modal-navigation-ng/app/item/item.ts

-5
This file was deleted.

Diff for: e2e/modal-navigation-ng/app/item/items.component.html

-33
This file was deleted.

Diff for: e2e/modal-navigation-ng/app/item/items.component.ts

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
<ActionBar *ngIf="navigationVisibility === 'visible'">
3+
<Label class="action-bar-title" text="Modal Nested"></Label>
4+
</ActionBar>
5+
6+
<GridLayout #rootLayout rows="auto" (showingModally)="onShowingModally($event)" backgroundColor="lightBlue">
7+
<Button text="Close Modal Nested" (tap)="close(rootLayout)"></Button>
8+
</GridLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component } from "@angular/core";
2+
import { View, ShownModallyData } from "ui/core/view"
3+
import { ModalDialogParams } from "nativescript-angular/directives/dialogs";
4+
5+
@Component({
6+
moduleId: module.id,
7+
selector: "modal-nested-page",
8+
templateUrl: "./modal-nested.component.html"
9+
})
10+
export class NestedModalComponent {
11+
public navigationVisibility: string = "collapse";
12+
13+
constructor(private params: ModalDialogParams) {
14+
15+
console.log("ModalNestedContent.constructor: " + JSON.stringify(params));
16+
this.navigationVisibility = params.context.navigationVisibility ? "visible" : "collapse";
17+
}
18+
19+
close(layoutRoot: View) {
20+
layoutRoot.closeModal();
21+
}
22+
23+
onShowingModally(args: ShownModallyData) {
24+
console.log("modal-page showingModally");
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
<ActionBar class="action-bar">
3+
<Label class="action-bar-title" text="Modal Second"></Label>
4+
</ActionBar>
5+
6+
<GridLayout #rootLayout rows="auto, auto" (loaded)="onLoaded($event)">
7+
<Button text="Go Back" (tap)="goBack()"></Button>
8+
<Button row="1" text="Close Modal Nested" (tap)="close(rootLayout)"></Button>
9+
</GridLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Component } from "@angular/core";
2+
import { View, EventData } from "ui/core/view"
3+
import { RouterExtensions } from "nativescript-angular/router";
4+
5+
@Component({
6+
moduleId: module.id,
7+
selector: "modal-second-page",
8+
templateUrl: "./modal-second.component.html"
9+
})
10+
export class ModalSecondComponent {
11+
constructor(private routerExtension: RouterExtensions) { }
12+
13+
onLoaded(args: EventData) {
14+
console.log("modal-second loaded");
15+
}
16+
17+
goBack(args: EventData) {
18+
this.routerExtension.back();
19+
}
20+
21+
close(layoutRoot: View) {
22+
layoutRoot.closeModal();
23+
}
24+
}

0 commit comments

Comments
 (0)