Skip to content
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

ionic: update to rc1 and fix tabs router and selected tab #428

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions generators/app/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ module.exports = [
type: 'confirm',
name: 'lazy',
message: 'Do you want lazy loading?',
default: false,
when: props => props.ui !== 'ionic'
default: false
},
{
type: 'confirm',
Expand Down
13 changes: 10 additions & 3 deletions generators/app/templates/_angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
<% } -%>
<% if (props.ui === 'ionic') { -%>
{
"glob": "**/*",
"input": "node_modules/@ionic/angular/dist/ionic/svg",
"output": "svg"
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
},
<% } -%>
"src/assets"
Expand Down Expand Up @@ -104,6 +104,13 @@
<% } -%>
<% if (props.pwa) { -%>
"src/manifest.json",
<% } -%>
<% if (props.ui === 'ionic') { -%>
{
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
},
<% } -%>
"src/assets"
]
Expand Down
24 changes: 12 additions & 12 deletions generators/app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
"generate": "ng generate"
},
"dependencies": {
"@angular/animations": "^7.0.0",
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.0",
"@angular/core": "^7.0.0",
"@angular/forms": "^7.0.0",
"@angular/http": "^7.0.0",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",
"@angular/animations": "^7.1.4",
"@angular/common": "^7.1.4",
"@angular/compiler": "^7.1.4",
"@angular/core": "^7.1.4",
"@angular/forms": "^7.1.4",
"@angular/http": "^7.1.4",
"@angular/platform-browser": "^7.1.4",
"@angular/platform-browser-dynamic": "^7.1.4",
"@angular/router": "^7.1.4",
"@ngx-translate/core": "^10.0.1",
<% if (props.target.includes('cordova')) { -%>
"@ionic-native/core": "5.0.0-beta.21",
Expand All @@ -78,10 +78,10 @@
"cordova-plugin-whitelist": "^1.3.3",
<% } -%>
<% if (props.pwa) { -%>
"@angular/service-worker": "^7.0.0",
"@angular/service-worker": "^7.1.4",
<% } -%>
<% if (props.ui === 'ionic') { -%>
"@ionic/angular": "4.0.0-beta.16",
"@ionic/angular": "4.0.0-rc.1",
<% } else if (props.ui === 'bootstrap') { -%>
"@ng-bootstrap/ng-bootstrap": "^3.3.0",
"bootstrap": "^4.1.1",
Expand Down Expand Up @@ -111,7 +111,7 @@
"@angular/cli": "~7.0.2",
"@angular/compiler-cli": "^7.0.0",
"@angular/language-service": "^7.0.0",
"@angular-devkit/build-angular": "^0.10.2",
"@angular-devkit/build-angular": "^0.12.1",
"@biesbjerg/ngx-translate-extract": "^2.3.4",
"@ngx-rocket/scripts": "^3.0.0",
"@types/jasmine": "^2.8.7",
Expand Down
12 changes: 1 addition & 11 deletions generators/app/templates/src/app/_app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ import { AppComponent } from './app.component';
describe('AppComponent', () => {
<% if (props.target.includes('cordova')) { -%>

let statusBarSpy: any, splashScreenSpy: any, platformReadySpy: any;
<% if (props.ui === 'ionic') { -%>
let platformSpy: any;
<% } -%>
let statusBarSpy: any, splashScreenSpy: any;

<% } -%>
beforeEach(async(() => {
<% if (props.target.includes('cordova')) { -%>
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
platformReadySpy = Promise.resolve();
<% if (props.ui === 'ionic') { -%>
platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy });
<% } -%>

<% } -%>
TestBed.configureTestingModule({
Expand All @@ -59,9 +52,6 @@ describe('AppComponent', () => {
providers: [
{ provide: StatusBar, useValue: statusBarSpy },
{ provide: SplashScreen, useValue: splashScreenSpy },
<% if (props.ui === 'ionic') { -%>
{ provide: Platform, useValue: platformSpy },
<% } -%>
]
<% } else { -%>
providers: []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<ion-tabs #navTabs useRouter="true">
<ion-router-outlet></ion-router-outlet>
<ion-tab-bar slot="bottom" [selectedTab]="selectedTabName$ | async">
<ion-tab-button *ngFor="let t of tabs; index as tabIndex" [tab]="t.name" show="true" [href]="t.route">
<ion-icon [name]="t.icon"></ion-icon>
<ion-label>{{ t.title | translate }}</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
<ion-router-outlet></ion-router-outlet>
<ion-tab-bar slot="bottom" [selectedTab]="selectedTabName$ | async">
<ion-tab-button *ngFor="let t of tabs; index as tabIndex" show="true" [tab]="t.name" routerDirection="top" [routerLink]="'/'+t.route">
<ion-icon [name]="t.icon"></ion-icon>
<ion-label>{{ t.title | translate }}</ion-label>
</ion-tab-button>
</ion-tab-bar>
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,16 @@ import { filter, map } from 'rxjs/operators';
import { of } from 'rxjs/observable/of';
import { merge } from 'rxjs/observable/merge';

import { SettingsComponent } from '@app/settings/settings.component';
import { AboutComponent } from '@app/about/about.component';
import { HomeComponent } from '@app/home/home.component';

@Component({
selector: 'app-shell',
templateUrl: './shell.component.html',
styleUrls: ['./shell.component.scss']
})
export class ShellComponent {
tabs = [
{ component: HomeComponent, name: 'home', route: 'home', title: 'Home', icon: 'home' },
{ component: AboutComponent, name: 'about', route: 'about', title: 'About', icon: 'logo-angular' },
{ component: SettingsComponent, name: 'settings', route: 'settings', title: 'Settings', icon: 'cog' }
{ name: 'home', route: 'home', title: 'Home', icon: 'home' },
{ name: 'about', route: 'about', title: 'About', icon: 'logo-angular' },
{ name: 'settings', route: 'settings', title: 'Settings', icon: 'cog' }
];
selectedTabName$: Observable<string>;
constructor(private router: Router, private activatedRoute: ActivatedRoute) {
Expand All @@ -35,12 +31,6 @@ export class ShellComponent {
}
if (route && route.component === ShellComponent && route.firstChild) {
route = route.firstChild;
// Fixed the bug#19420 : route.component is undefined if module is lazy
// See: https://github.com/angular/angular/issues/19420
while (route.firstChild) {
sinedied marked this conversation as resolved.
Show resolved Hide resolved
route = route.firstChild;
}
// Fixed #19420 end
return this.tabs.find(tabElement => tabElement.route === route.routeConfig.path).name;
}
}
Expand Down