diff --git a/CHANGELOG.md b/CHANGELOG.md index 4941b0824..311d21572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ + +## [7.0.3](https://github.com/NativeScript/nativescript-angular/compare/7.0.2...7.0.3) (2018-12-05) + + +### Bug Fixes + +* **router:** handle nested primary p-r-o ([#1645](https://github.com/NativeScript/nativescript-angular/issues/1645)) ([e632fc5](https://github.com/NativeScript/nativescript-angular/commit/e632fc5)) + + + + +## [7.0.2](https://github.com/NativeScript/nativescript-angular/compare/7.0.1...7.0.2) (2018-11-26) + + +### Bug Fixes + +* **page-router-outlet:** actionBarVisibility not applied ([#1621](https://github.com/NativeScript/nativescript-angular/issues/1621)) ([a6ff509](https://github.com/NativeScript/nativescript-angular/commit/a6ff509)) +* **router-extensions:** unable to go back with relativeTo param ([#1632](https://github.com/NativeScript/nativescript-angular/issues/1632)) ([63900dc](https://github.com/NativeScript/nativescript-angular/commit/63900dc)) + + + ## [7.0.1](https://github.com/NativeScript/nativescript-angular/compare/7.0.0...7.0.1) (2018-11-20) diff --git a/LICENSE b/LICENSE index 59dc28ed0..9d63a0a67 100755 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2015-2018 Telerik EAD + Copyright (c) 2015-2018 Progress Software Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/e2e/modal-navigation-ng/e2e/screens/screen.ts b/e2e/modal-navigation-ng/e2e/screens/screen.ts index d45ad05bc..107d34b41 100644 --- a/e2e/modal-navigation-ng/e2e/screens/screen.ts +++ b/e2e/modal-navigation-ng/e2e/screens/screen.ts @@ -44,7 +44,7 @@ export class Screen { } loadedHome = async () => { - const lblHome = await this._driver.findElementByAutomationText(home); + const lblHome = await this._driver.waitForElement(home); assert.isTrue(await lblHome.isDisplayed()); console.log(home + " loaded!"); } @@ -149,7 +149,7 @@ export class Screen { } loadedModalFrame = async () => { - const lblModal = await this._driver.findElementByAutomationText(modal, 1000); + const lblModal = await this._driver.waitForElement(modal, 5000); assert.isTrue(await lblModal.isDisplayed(), `${modal} is not displayed!`); console.log(modal + " loaded!"); } @@ -226,7 +226,7 @@ export class Screen { } loadedSecondPage = async () => { - const lblModalSecond = await this._driver.findElementByAutomationText(modalSecond); + const lblModalSecond = await this._driver.waitForElement(modalSecond, 5000); assert.isTrue(await lblModalSecond.isDisplayed()); console.log(modalSecond + " loaded!"); } @@ -259,7 +259,7 @@ export class Screen { } loadedNestedModalFrame = async () => { - const lblModalNested = await this._driver.findElementByAutomationText(modalNested); + const lblModalNested = await this._driver.waitForElement(modalNested, 5000); assert.isTrue(await lblModalNested.isDisplayed()); console.log(modalNested + " loaded!"); } diff --git a/e2e/nested-router-tab-view/app/about/about-nested.component.html b/e2e/nested-router-tab-view/app/about/about-nested.component.html new file mode 100644 index 000000000..0e39308c8 --- /dev/null +++ b/e2e/nested-router-tab-view/app/about/about-nested.component.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/e2e/nested-router-tab-view/app/about/about-nested.component.ts b/e2e/nested-router-tab-view/app/about/about-nested.component.ts new file mode 100644 index 000000000..ff1197b7e --- /dev/null +++ b/e2e/nested-router-tab-view/app/about/about-nested.component.ts @@ -0,0 +1,9 @@ +import { Component } from "@angular/core"; + +@Component({ + moduleId: module.id, + selector: "about-nested-page", + templateUrl: "./about-nested.component.html" +}) +export class AboutNestedComponent { +} diff --git a/e2e/nested-router-tab-view/app/about/about.component.html b/e2e/nested-router-tab-view/app/about/about.component.html index 92f893d2d..9f9ae3731 100644 --- a/e2e/nested-router-tab-view/app/about/about.component.html +++ b/e2e/nested-router-tab-view/app/about/about.component.html @@ -4,4 +4,7 @@ + + + \ No newline at end of file diff --git a/e2e/nested-router-tab-view/app/about/about.component.ts b/e2e/nested-router-tab-view/app/about/about.component.ts index 2d8eed10c..75eb5b55e 100644 --- a/e2e/nested-router-tab-view/app/about/about.component.ts +++ b/e2e/nested-router-tab-view/app/about/about.component.ts @@ -1,5 +1,4 @@ -import { Component, ViewContainerRef } from "@angular/core"; -import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs"; +import { Component } from "@angular/core"; import { RouterExtensions } from "nativescript-angular/router"; import { ActivatedRoute } from "@angular/router"; @@ -10,8 +9,6 @@ import { ActivatedRoute } from "@angular/router"; }) export class AboutComponent { constructor( - private modal: ModalDialogService, - private vcRef: ViewContainerRef, private activeRoute: ActivatedRoute, private routerExtension: RouterExtensions) { } diff --git a/e2e/nested-router-tab-view/app/app.component.html b/e2e/nested-router-tab-view/app/app.component.html index 5aeb4e2b0..1265aa9c8 100644 --- a/e2e/nested-router-tab-view/app/app.component.html +++ b/e2e/nested-router-tab-view/app/app.component.html @@ -1,13 +1 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/e2e/nested-router-tab-view/app/app.routing.ts b/e2e/nested-router-tab-view/app/app.routing.ts index e7b630902..276f26d91 100644 --- a/e2e/nested-router-tab-view/app/app.routing.ts +++ b/e2e/nested-router-tab-view/app/app.routing.ts @@ -10,6 +10,7 @@ import { LoginComponent } from "./login/login.component"; import { TabsComponent } from "./tabs/tabs.component"; import { HomeComponent } from "./home/home.component"; import { AboutComponent } from "./about/about.component"; +import { AboutNestedComponent } from "./about/about-nested.component"; import { ModalComponent } from "./modal/modal.component"; import { NestedModalComponent } from "./modal-nested/modal-nested.component"; @@ -56,7 +57,11 @@ const routes: Routes = [ { path: "team/:id", component: TeamDetailComponent, outlet: "teamTab" }, ] }, - { path: "about", component: AboutComponent } + { + path: "about", component: AboutComponent, children: [ + { path: "about-nested", component: AboutNestedComponent }, + ] + } ]; @NgModule({ diff --git a/e2e/nested-router-tab-view/app/home/home.component.html b/e2e/nested-router-tab-view/app/home/home.component.html index 6779e7468..bfd588cb0 100644 --- a/e2e/nested-router-tab-view/app/home/home.component.html +++ b/e2e/nested-router-tab-view/app/home/home.component.html @@ -28,7 +28,6 @@ - diff --git a/e2e/nested-router-tab-view/app/shared.module.ts b/e2e/nested-router-tab-view/app/shared.module.ts index 5f60aaaf3..be7d8a867 100644 --- a/e2e/nested-router-tab-view/app/shared.module.ts +++ b/e2e/nested-router-tab-view/app/shared.module.ts @@ -8,6 +8,7 @@ import { DataService } from "./data.service"; import { HomeComponent } from "./home/home.component"; import { AboutComponent } from "./about/about.component"; +import { AboutNestedComponent } from "./about/about-nested.component"; import { PlayerComponent } from "./player/players.component"; import { PlayerDetailComponent } from "./player/player-detail.component"; import { TeamsComponent } from "./team/teams.component"; @@ -21,6 +22,7 @@ import { TeamDetailComponent } from "./team/team-detail.component"; declarations: [ HomeComponent, AboutComponent, + AboutNestedComponent, PlayerComponent, PlayerDetailComponent, TeamsComponent, @@ -29,6 +31,7 @@ import { TeamDetailComponent } from "./team/team-detail.component"; exports: [ HomeComponent, AboutComponent, + AboutNestedComponent, PlayerComponent, PlayerDetailComponent, TeamsComponent, diff --git a/e2e/nested-router-tab-view/app/tabs/tabs.component.html b/e2e/nested-router-tab-view/app/tabs/tabs.component.html index 0542dbc71..4e1ddec84 100644 --- a/e2e/nested-router-tab-view/app/tabs/tabs.component.html +++ b/e2e/nested-router-tab-view/app/tabs/tabs.component.html @@ -3,7 +3,7 @@ - + diff --git a/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts b/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts index da759348c..af4d6e65e 100644 --- a/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts +++ b/e2e/nested-router-tab-view/e2e/home-tabs.e2e-spec.ts @@ -48,6 +48,7 @@ describe("home-tabs:", () => { await screen.loadedPlayersList(); await screen.navigateToAboutPage(); await screen.loadedAbout(); + await screen.loadedNestedAbout(); }); it("should go back to Tabs and then back to Home", async () => { diff --git a/e2e/nested-router-tab-view/e2e/screen.ts b/e2e/nested-router-tab-view/e2e/screen.ts index 53eefdd20..870fdf9bf 100644 --- a/e2e/nested-router-tab-view/e2e/screen.ts +++ b/e2e/nested-router-tab-view/e2e/screen.ts @@ -3,6 +3,7 @@ import { assert } from "chai"; const home = "Home Component"; const about = "About Component"; +const aboutNested = "Nested About Component"; const login = "Login Component"; const tabs = "Tabs Component"; @@ -70,7 +71,13 @@ export class Screen { loadedAbout= async () => { const lblAbout = await this._driver.findElementByAutomationText(about); assert.isTrue(await lblAbout.isDisplayed()); - console.log(home + " loaded!"); + console.log(about + " loaded!"); + } + + loadedNestedAbout= async () => { + const lblAboutNested = await this._driver.findElementByAutomationText(aboutNested); + assert.isTrue(await lblAboutNested.isDisplayed()); + console.log(aboutNested + " loaded!"); } loadedTabs = async () => { diff --git a/e2e/renderer/app/app-routing.module.ts b/e2e/renderer/app/app-routing.module.ts index 6e89eca70..61a49f6a5 100644 --- a/e2e/renderer/app/app-routing.module.ts +++ b/e2e/renderer/app/app-routing.module.ts @@ -1,5 +1,5 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; +import { NativeScriptRouterModule, NSEmptyOutletComponent } from "nativescript-angular/router"; import { ActionBarDynamicItemsComponent } from "./action-bar/action-bar-dynamic-items.component"; import { ActionBarExtensionComponent } from "./action-bar/action-bar-extension.component"; @@ -54,6 +54,16 @@ export const routes = [ component: NestedPageComponent }] }, + { + path: "action-bar-visibility-never-lazy", + component: ActionBarVisibilityNeverComponent, + children: [{ + path: "nested", + outlet: "nested", + component: NSEmptyOutletComponent, + loadChildren:"~/page-router-outlet/nested-lazy-page.module#NestedLazyPageModule" + }] + }, { path: "action-bar-dynamic", component: ActionBarDynamicItemsComponent, @@ -111,7 +121,6 @@ export const navigatableComponents = [ ActionBarVisibilityAlwaysComponent, ActionBarVisibilityNeverComponent, ActionBarVisibilityAutoComponent, - NestedPageComponent, TabItemBindingComponent, diff --git a/e2e/renderer/app/app.module.ts b/e2e/renderer/app/app.module.ts index 94a20f26e..1f170798e 100644 --- a/e2e/renderer/app/app.module.ts +++ b/e2e/renderer/app/app.module.ts @@ -11,6 +11,8 @@ import { ItemsService } from "./items.service"; import { rendererTraceCategory, viewUtilCategory, bootstrapCategory } from "nativescript-angular/trace"; import { addCategories, enable, categories } from "tns-core-modules/trace"; +import { SharedModule } from "./shared.module"; + addCategories(bootstrapCategory); addCategories(rendererTraceCategory); addCategories(viewUtilCategory); @@ -22,7 +24,7 @@ export class MyErrorHandler implements ErrorHandler { console.log("### ErrorHandler Error: " + error.toString()); console.log("### ErrorHandler Stack: " + error.stack); } -} +} @NgModule({ @@ -38,6 +40,7 @@ export class MyErrorHandler implements ErrorHandler { imports: [ NativeScriptModule, AppRoutingModule, + SharedModule ], schemas: [NO_ERRORS_SCHEMA], }) diff --git a/e2e/renderer/app/list.component.ts b/e2e/renderer/app/list.component.ts index 168370525..9996d5a79 100644 --- a/e2e/renderer/app/list.component.ts +++ b/e2e/renderer/app/list.component.ts @@ -9,6 +9,7 @@ import { Component } from "@angular/core"; + diff --git a/e2e/renderer/app/page-router-outlet/nested-lazy-page.module.ts b/e2e/renderer/app/page-router-outlet/nested-lazy-page.module.ts new file mode 100644 index 000000000..6a761a4ed --- /dev/null +++ b/e2e/renderer/app/page-router-outlet/nested-lazy-page.module.ts @@ -0,0 +1,20 @@ +import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; +import { NativeScriptRouterModule } from "nativescript-angular/router"; +import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { SharedModule } from "~/shared.module"; +import { NestedPageComponent } from "./nested-page.component"; + +@NgModule({ + imports: [ + SharedModule, + NativeScriptCommonModule, + NativeScriptRouterModule, + NativeScriptRouterModule.forChild([ + { path: "", component: NestedPageComponent } + ]) + ], + providers: [ + ], + schemas: [NO_ERRORS_SCHEMA] +}) +export class NestedLazyPageModule { } \ No newline at end of file diff --git a/e2e/renderer/app/shared.module.ts b/e2e/renderer/app/shared.module.ts new file mode 100644 index 000000000..b36208dc3 --- /dev/null +++ b/e2e/renderer/app/shared.module.ts @@ -0,0 +1,14 @@ +import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; +import { NativeScriptRouterModule } from "nativescript-angular/router"; +import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NestedPageComponent } from "./page-router-outlet/nested-page.component"; + +@NgModule({ + imports: [ + NativeScriptCommonModule, + NativeScriptRouterModule + ], + declarations:[NestedPageComponent], + schemas: [NO_ERRORS_SCHEMA] +}) +export class SharedModule { } \ No newline at end of file diff --git a/e2e/renderer/e2e/action-bar.e2e-spec.ts b/e2e/renderer/e2e/action-bar.e2e-spec.ts index f92fc8b97..011c17645 100644 --- a/e2e/renderer/e2e/action-bar.e2e-spec.ts +++ b/e2e/renderer/e2e/action-bar.e2e-spec.ts @@ -6,6 +6,7 @@ import { } from "nativescript-dev-appium"; import { isOnTheLeft } from "./helpers/location"; +import { assert } from "chai"; describe("Action Bar scenario", () => { let driver: AppiumDriver; @@ -132,16 +133,10 @@ describe("Action Bar scenario", () => { conditional = await driver.findElementByAutomationText("conditional"); }); - it("should detach conditional action item when its condition is false", done => { - (async () => { - await toggle(); - - try { - await driver.findElementByAutomationText("conditional"); - } catch (e) { - done(); - } - })(); + it("should detach conditional action item when its condition is false", async () => { + await toggle(); + const conditionalBtn = await driver.waitForElement("conditional", 1000); + assert.isUndefined(conditionalBtn, "Conditional button should not be visible!"); }); it("should reattach conditional action item at correct place", async () => { diff --git a/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts b/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts index 8746c5707..ad79f6116 100644 --- a/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts +++ b/e2e/renderer/e2e/page-router-outlet.e2e-spec.ts @@ -93,6 +93,52 @@ describe("page-router-outlet-scenario", () => { }); }); + describe("actionBarVisibility 'never' doesn't show action bars in lazy module page", async () => { + let imagePostFix = ""; + before(async () => { + driver = await createDriver(); + await driver.driver.resetApp(); + if (driver.isIOS && driver.nsCapabilities.device.name.toLowerCase().includes("x")) { + imagePostFix = "-lazy"; + } + }); + + afterEach(async function () { + if (this.currentTest.state === "failed") { + await driver.logTestArtifacts(this.currentTest.title); + } + }); + + it("should navigate to page", async () => { + const navigationButton = + await driver.findElementByAutomationText("ActionBarVisibility Never Lazy"); + await navigationButton.click(); + + await driver.findElementByAutomationText("ShowActionBar"); + }); + + it("should hide action bar by default", async () => { + const screenMatches = await driver.compareScreen(`actionBarVisibility-never-default${imagePostFix}`, 5); + assert(screenMatches); + }); + + it("should not show action bar when shown by page", async () => { + const showActionBarButton = await driver.findElementByAutomationText("ShowActionBar"); + showActionBarButton.click(); + + const screenMatches = await driver.compareScreen(`actionBarVisibility-never-shown${imagePostFix}`, 5); + assert(screenMatches); + }); + + it("should not do anything when hidden action bar by page", async () => { + const hideActionBarButton = await driver.findElementByAutomationText("HideActionBar"); + hideActionBarButton.click(); + + const screenMatches = await driver.compareScreen(`actionBarVisibility-never-hidden${imagePostFix}`, 5); + assert(screenMatches); + }); + }); + describe("actionBarVisibility 'auto' shows action bars based on page", async () => { before(async () => { driver = await createDriver(); diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-default-lazy_actual.png b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-default-lazy_actual.png new file mode 100644 index 000000000..ab50e264d Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-default-lazy_actual.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-hidden-lazy_actual.png b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-hidden-lazy_actual.png new file mode 100644 index 000000000..afe670a4f Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-hidden-lazy_actual.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-shown-lazy_actual.png b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-shown-lazy_actual.png new file mode 100644 index 000000000..afe670a4f Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 110/actionBarVisibility-never-shown-lazy_actual.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone 7 12/tab-view-binding-first-tab.png b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 12/tab-view-binding-first-tab.png new file mode 100644 index 000000000..a781c90f1 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone 7 12/tab-view-binding-first-tab.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-default-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-default-lazy.png new file mode 100644 index 000000000..9ebe2b597 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-default-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-hidden-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-hidden-lazy.png new file mode 100644 index 000000000..6ed7234b1 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-hidden-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-shown-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-shown-lazy.png new file mode 100644 index 000000000..6ed7234b1 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone X 110/actionBarVisibility-never-shown-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-default-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-default-lazy.png new file mode 100644 index 000000000..e6afdad26 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-default-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-hidden-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-hidden-lazy.png new file mode 100644 index 000000000..ac403f9f9 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-hidden-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-shown-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-shown-lazy.png new file mode 100644 index 000000000..ac403f9f9 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone XR 12/actionBarVisibility-never-shown-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-default.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-default.png index fc09b4860..bf236a332 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-default.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-default.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-hidden.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-hidden.png index d68c4ec93..36532a957 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-hidden.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-hidden.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-shown.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-shown.png index d68c4ec93..67a2d2515 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-shown.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-always-shown.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-default.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-default.png index e43126a22..2db5cadce 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-default.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-default.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-hidden.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-hidden.png index 4af0cf3d8..c31877f38 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-hidden.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-hidden.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-shown.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-shown.png index 2b50a8104..e547d9e3a 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-shown.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-auto-shown.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default-lazy.png new file mode 100644 index 000000000..54f0ffdd4 Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default.png index de5e9bd34..f22f58278 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-default.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden-lazy.png new file mode 100644 index 000000000..d3b34b6ab Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden.png index 653bf602c..e3059e1ed 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-hidden.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown-lazy.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown-lazy.png new file mode 100644 index 000000000..d3b34b6ab Binary files /dev/null and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown-lazy.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown.png index 653bf602c..11225f72b 100644 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown.png and b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/actionBarVisibility-never-shown.png differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-first-tab.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-first-tab.png deleted file mode 100644 index 090808fcd..000000000 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-first-tab.png and /dev/null differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-second-tab.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-second-tab.png deleted file mode 100644 index aac9eda44..000000000 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-second-tab.png and /dev/null differ diff --git a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-third-tab.png b/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-third-tab.png deleted file mode 100644 index 82796824e..000000000 Binary files a/e2e/renderer/e2e/resources/images/renderer/iPhone XS 12/tab-view-binding-third-tab.png and /dev/null differ diff --git a/e2e/renderer/package.json b/e2e/renderer/package.json index f003dd9ef..f9f52bfc4 100644 --- a/e2e/renderer/package.json +++ b/e2e/renderer/package.json @@ -24,9 +24,10 @@ }, "devDependencies": { "@angular/compiler-cli": "~7.0.0", - "@types/chai": "^4.0.2", - "@types/mocha": "^2.2.41", - "@types/node": "^7.0.5", + "@ngtools/webpack": "~7.0.0", + "@types/chai": "~4.1.3", + "@types/mocha": "~5.2.1", + "@types/node": "10.11.4", "babel-traverse": "6.25.0", "babel-types": "6.25.0", "babylon": "6.17.4", @@ -34,15 +35,14 @@ "chai-as-promised": "~7.1.1", "colors": "^1.1.2", "lazy": "1.0.11", - "mocha": "~3.5.0", - "mocha-junit-reporter": "^1.13.0", - "mocha-multi": "^0.11.0", + "mocha": "~5.1.0", + "mocha-junit-reporter": "~1.17.0", + "mocha-multi": "~1.0.0", "nativescript-dev-appium": "next", "nativescript-dev-typescript": "~0.7.1", "nativescript-dev-webpack": "next", "tslib": "^1.7.1", - "typescript": "~3.1.1", - "@ngtools/webpack": "~7.0.0" + "typescript": "~3.1.1" }, "scripts": { "e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json", diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index 787e05755..6f7ef22ed 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-angular", - "version": "7.0.1", + "version": "7.0.3", "description": "An Angular renderer that lets you build mobile apps with NativeScript.", "homepage": "https://www.nativescript.org/", "bugs": "https://github.com/NativeScript/nativescript-angular/issues", diff --git a/nativescript-angular/router/ns-empty-outlet.component.ts b/nativescript-angular/router/ns-empty-outlet.component.ts index eea9a74fd..502f6e4fc 100644 --- a/nativescript-angular/router/ns-empty-outlet.component.ts +++ b/nativescript-angular/router/ns-empty-outlet.component.ts @@ -1,5 +1,6 @@ -import { Component } from "@angular/core"; +import { Component, ViewChild } from "@angular/core"; import { Page } from "tns-core-modules/ui/page"; +import { PageRouterOutlet } from "./page-router-outlet"; @Component({ // tslint:disable-next-line:component-selector selector: "ns-empty-outlet", @@ -7,9 +8,16 @@ import { Page } from "tns-core-modules/ui/page"; template: "" }) export class NSEmptyOutletComponent { + @ViewChild(PageRouterOutlet) pageRouterOutlet: PageRouterOutlet; constructor(private page: Page) { if (this.page) { this.page.actionBarHidden = true; + + this.page.on("loaded", () => { + if (this.pageRouterOutlet && this.page.frame) { + this.pageRouterOutlet.setActionBarVisibility(this.page.frame.actionBarVisibility); + } + }); } } } diff --git a/nativescript-angular/router/ns-location-strategy.ts b/nativescript-angular/router/ns-location-strategy.ts index 3798731b1..fa6b1c488 100644 --- a/nativescript-angular/router/ns-location-strategy.ts +++ b/nativescript-angular/router/ns-location-strategy.ts @@ -25,6 +25,7 @@ export class Outlet { path: string; pathByOutlets: string; states: Array = []; + isNSEmptyOutlet: boolean; // Used in reuse-strategy by its children to determine if they should be detached too. shouldDetach: boolean = true; @@ -52,6 +53,24 @@ export class Outlet { const lastState = this.peekState(); return lastState && lastState.segmentGroup.toString() === stateUrl; } + + // Search for frame that can go back. + // Nested 'primary' outlets could result in Outlet with multiple navigatable frames. + getFrameToBack(): Frame { + let frame = this.frames[this.frames.length - 1]; + + if (!this.isNSEmptyOutlet) { + for (let index = this.frames.length - 1; index >= 0; index--) { + const currentFrame = this.frames[index]; + if (currentFrame.canGoBack()) { + frame = currentFrame; + break; + } + } + } + + return frame; + } } export interface NavigationOptions { @@ -250,7 +269,7 @@ export class NSLocationStrategy extends LocationStrategy { const topmostFrame = this.frameService.getFrame(); this.currentOutlet = this.getOutletByFrame(topmostFrame); } - this.currentOutlet.frames[this.currentOutlet.frames.length - 1].goBack(); + this.currentOutlet.getFrameToBack().goBack(); } else { // Nested navigation - just pop the state if (isLogEnabled()) { @@ -447,6 +466,12 @@ export class NSLocationStrategy extends LocationStrategy { if (currentOutlet.containsFrame(frame) && !isEqualToCurrent) { this.callPopState(null, true, currentOutlet); } + + if (!currentOutlet.isNSEmptyOutlet) { + currentOutlet.frames = currentOutlet.frames.filter(currentFrame => currentFrame !== frame); + return currentOutlet.frames.length; + } + return !currentOutlet.containsFrame(frame); }); } diff --git a/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts index 593a2c2af..65e353ceb 100644 --- a/nativescript-angular/router/page-router-outlet.ts +++ b/nativescript-angular/router/page-router-outlet.ts @@ -280,6 +280,7 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire return; } + this.outlet.isNSEmptyOutlet = this.isEmptyOutlet; this.locationStrategy.updateOutletFrame(this.outlet, this.frame); if (this.outlet && this.outlet.isPageNavigationBack) { @@ -422,7 +423,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire if (modalNavigation > 0) { // Modal with 'primary' p-r-o outlet = this.locationStrategy.findOutletByModal(modalNavigation); } else { + const pathByOutlets = this.locationStrategy.getPathByOutlets(topActivatedRoute); outlet = this.locationStrategy.findOutletByKey(outletKey); + outlet = outlet || this.locationStrategy.findOutletByOutletPath(pathByOutlets); } // Named lazy loaded outlet. diff --git a/nativescript-angular/router/router-extensions.ts b/nativescript-angular/router/router-extensions.ts index 0943f8acb..9f2379488 100644 --- a/nativescript-angular/router/router-extensions.ts +++ b/nativescript-angular/router/router-extensions.ts @@ -93,22 +93,24 @@ export class RouterExtensions { const outletsToBack: Array = []; const rootRoute: ActivatedRoute = this.router.routerState.root; let outlets = options.outlets; - let relativeRoute = options.relativeTo; + let relativeRoute = options.relativeTo || rootRoute; - if (!outlets && relativeRoute) { - outlets = [relativeRoute.outlet]; - relativeRoute = relativeRoute.parent || rootRoute; - } else if (!relativeRoute) { - relativeRoute = rootRoute; + const relativeRouteOutlet = this.findOutletByRoute(relativeRoute); + const isNSEmptyOutlet = relativeRouteOutlet && relativeRouteOutlet.isNSEmptyOutlet; + + // Lazy named outlet has added 'primary' inner NSEmptyOutlet child. + // Take parent route when `relativeTo` option points to the outer named outlet. + if (isNSEmptyOutlet && relativeRoute.outlet !== "primary") { + relativeRoute = relativeRoute.parent || relativeRoute; } - for (let index = 0; index < relativeRoute.children.length; index++) { - const currentRoute = relativeRoute.children[index]; + const routesToMatch = outlets ? relativeRoute.children : [relativeRoute]; + outlets = outlets || [relativeRoute.outlet]; + for (let index = 0; index < routesToMatch.length; index++) { + const currentRoute = routesToMatch[index]; if (outlets.some(currentOutlet => currentOutlet === currentRoute.outlet)) { - const currentRouteSnapshop = findTopActivatedRouteNodeForOutlet(currentRoute.snapshot); - const outletKey = this.locationStrategy.getRouteFullPath(currentRouteSnapshop); - let outlet = this.locationStrategy.findOutletByKey(outletKey); + const outlet = this.findOutletByRoute(currentRoute); if (outlet) { outletsToBack.push(outlet); @@ -118,4 +120,14 @@ export class RouterExtensions { return { outletsToBack: outletsToBack, outlets: outlets }; } + + private findOutletByRoute(currentRoute: ActivatedRoute): Outlet { + let outlet; + + const currentRouteSnapshop = findTopActivatedRouteNodeForOutlet(currentRoute.snapshot); + const outletKey = this.locationStrategy.getRouteFullPath(currentRouteSnapshop); + outlet = this.locationStrategy.findOutletByKey(outletKey); + + return outlet; + } }