-
-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(modal-navigation): add reset root view mechanism (#1389)
- Loading branch information
Showing
16 changed files
with
269 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<StackLayout> | ||
<Label text="Home" horizontalAlignment="center"></Label> | ||
<Button text="Show Modal Without Frame" (tap)="onModalNoFrame()"></Button> | ||
<Button text="Show Modal Page With Frame" (tap)="onModalFrame()"></Button> | ||
<Button text="Reset Frame Root View" (tap)="onFrameRootViewReset()"></Button> | ||
<Button text="Reset Tab Root View" (tap)="onTabRootViewReset()"></Button> | ||
<Button text="Reset Layout Root View" (tap)="onLayoutRootViewReset()"></Button> | ||
<Button text="Show Dialog" (tap)="onShowDialog()"></Button> | ||
</StackLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Component, ViewContainerRef } from "@angular/core"; | ||
import { Router, NavigationEnd } from "@angular/router"; | ||
import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy"; | ||
import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs"; | ||
import { ModalComponent } from "./modal/modal.component"; | ||
import { ModalViewComponent } from "./modal-shared/modal-view.component"; | ||
import { ModalRouterComponent } from "./modal/modal-router/modal-router.component"; | ||
import { confirm } from "ui/dialogs"; | ||
|
||
import { AppModule } from "./app.module"; | ||
|
||
import { ViewContainerRefService } from "./shared/ViewContainerRefService"; | ||
|
||
@Component({ | ||
selector: "ns-layout", | ||
templateUrl: "layout.component.html", | ||
}) | ||
|
||
export class LayoutComponent { | ||
constructor( | ||
private modal: ModalDialogService, | ||
private router: Router, | ||
private location: NSLocationStrategy, | ||
private vcRef: ViewContainerRef, | ||
private _viewContainerRefService: ViewContainerRefService) { | ||
router.events.subscribe(e => { | ||
if (e instanceof NavigationEnd) { | ||
console.log("[ROUTER]: " + e.toString()); | ||
console.log(location.toString()); | ||
} | ||
}); | ||
|
||
this._viewContainerRefService.root = this.vcRef; | ||
} | ||
|
||
onModalNoFrame() { | ||
const options: ModalDialogOptions = { | ||
context: { | ||
navigationVisibility: false | ||
}, | ||
fullscreen: true, | ||
viewContainerRef: this.vcRef | ||
}; | ||
|
||
this.modal.showModal(ModalComponent, options).then((res: string) => { | ||
console.log("moda-no-frame closed"); | ||
}); | ||
} | ||
|
||
onModalFrame() { | ||
const options: ModalDialogOptions = { | ||
context: { | ||
navigationVisibility: true, | ||
modalRoute: "modal" | ||
}, | ||
fullscreen: true, | ||
viewContainerRef: this.vcRef | ||
}; | ||
|
||
this.modal.showModal(ModalRouterComponent, options).then((res: string) => { | ||
console.log("moda-frame closed"); | ||
}); | ||
} | ||
|
||
onFrameRootViewReset() { | ||
AppModule.root = "page-router"; | ||
AppModule.platformRef._livesync(); | ||
} | ||
|
||
onTabRootViewReset() { | ||
AppModule.root = "tab"; | ||
AppModule.platformRef._livesync(); | ||
} | ||
|
||
onLayoutRootViewReset() { | ||
AppModule.root = "layout"; | ||
AppModule.platformRef._livesync(); | ||
} | ||
|
||
onShowDialog() { | ||
let options = { | ||
title: "Dialog", | ||
message: "Message", | ||
okButtonText: "Yes", | ||
cancelButtonText: "No" | ||
} | ||
|
||
confirm(options).then((result: boolean) => { | ||
console.log(result); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
// this import should be first in order to load some required settings (like globals and reflect-metadata) | ||
import { platformNativeScript } from "nativescript-angular/platform-static"; | ||
|
||
import { AppModule } from "./app.module"; | ||
import { NativeScriptPlatformRef } from "nativescript-angular"; | ||
// "./app.module.ngfactory" is a dynamically generated module when compiled with AoT. | ||
import { AppModuleNgFactory } from "./app.module.ngfactory"; | ||
|
||
platformNativeScript().bootstrapModuleFactory(AppModuleNgFactory); | ||
AppModule.platformRef = <NativeScriptPlatformRef>platformNativeScript(); | ||
AppModule.platformRef.bootstrapModuleFactory(AppModuleNgFactory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.