Initial commit
This commit is contained in:
26
src/app/app-routing.module.ts
Normal file
26
src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
redirectTo: 'home',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
{
|
||||
path: 'home',
|
||||
loadChildren: () => import('./home/home.module').then(m => m.HomePageModule)
|
||||
},
|
||||
{
|
||||
path: 'list',
|
||||
loadChildren: () => import('./list/list.module').then(m => m.ListPageModule)
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
|
||||
],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
24
src/app/app.component.html
Normal file
24
src/app/app.component.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<ion-app>
|
||||
<ion-split-pane contentId="main-content">
|
||||
<ion-menu contentId="main-content" type="overlay">
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Menu</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-menu-toggle auto-hide="false" *ngFor="let p of appPages">
|
||||
<ion-item [routerDirection]="'root'" [routerLink]="[p.url]">
|
||||
<ion-icon slot="start" [name]="p.icon"></ion-icon>
|
||||
<ion-label>
|
||||
{{p.title}}
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-menu-toggle>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
</ion-menu>
|
||||
<ion-router-outlet id="main-content"></ion-router-outlet>
|
||||
</ion-split-pane>
|
||||
</ion-app>
|
||||
0
src/app/app.component.scss
Normal file
0
src/app/app.component.scss
Normal file
67
src/app/app.component.spec.ts
Normal file
67
src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
||||
import { StatusBar } from '@ionic-native/status-bar/ngx';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
|
||||
let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy;
|
||||
|
||||
beforeEach(async(() => {
|
||||
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
|
||||
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
|
||||
platformReadySpy = Promise.resolve();
|
||||
platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy });
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
providers: [
|
||||
{ provide: StatusBar, useValue: statusBarSpy },
|
||||
{ provide: SplashScreen, useValue: splashScreenSpy },
|
||||
{ provide: Platform, useValue: platformSpy },
|
||||
],
|
||||
imports: [ RouterTestingModule.withRoutes([])],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
it('should create the app', async () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should initialize the app', async () => {
|
||||
TestBed.createComponent(AppComponent);
|
||||
expect(platformSpy.ready).toHaveBeenCalled();
|
||||
await platformReadySpy;
|
||||
expect(statusBarSpy.styleDefault).toHaveBeenCalled();
|
||||
expect(splashScreenSpy.hide).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should have menu labels', async () => {
|
||||
const fixture = await TestBed.createComponent(AppComponent);
|
||||
await fixture.detectChanges();
|
||||
const app = fixture.nativeElement;
|
||||
const menuItems = app.querySelectorAll('ion-label');
|
||||
expect(menuItems.length).toEqual(2);
|
||||
expect(menuItems[0].textContent).toContain('Home');
|
||||
expect(menuItems[1].textContent).toContain('List');
|
||||
});
|
||||
|
||||
it('should have urls', async () => {
|
||||
const fixture = await TestBed.createComponent(AppComponent);
|
||||
await fixture.detectChanges();
|
||||
const app = fixture.nativeElement;
|
||||
const menuItems = app.querySelectorAll('ion-item');
|
||||
expect(menuItems.length).toEqual(2);
|
||||
expect(menuItems[0].getAttribute('ng-reflect-router-link')).toEqual('/home');
|
||||
expect(menuItems[1].getAttribute('ng-reflect-router-link')).toEqual('/list');
|
||||
});
|
||||
|
||||
});
|
||||
40
src/app/app.component.ts
Normal file
40
src/app/app.component.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
||||
import { StatusBar } from '@ionic-native/status-bar/ngx';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: 'app.component.html',
|
||||
styleUrls: ['app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
public appPages = [
|
||||
{
|
||||
title: 'Home',
|
||||
url: '/home',
|
||||
icon: 'home'
|
||||
},
|
||||
{
|
||||
title: 'List',
|
||||
url: '/list',
|
||||
icon: 'list'
|
||||
}
|
||||
];
|
||||
|
||||
constructor(
|
||||
private platform: Platform,
|
||||
private splashScreen: SplashScreen,
|
||||
private statusBar: StatusBar
|
||||
) {
|
||||
this.initializeApp();
|
||||
}
|
||||
|
||||
initializeApp() {
|
||||
this.platform.ready().then(() => {
|
||||
this.statusBar.styleDefault();
|
||||
this.splashScreen.hide();
|
||||
});
|
||||
}
|
||||
}
|
||||
27
src/app/app.module.ts
Normal file
27
src/app/app.module.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { RouteReuseStrategy } from '@angular/router';
|
||||
|
||||
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
|
||||
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
|
||||
import { StatusBar } from '@ionic-native/status-bar/ngx';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent],
|
||||
entryComponents: [],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(),
|
||||
AppRoutingModule
|
||||
],
|
||||
providers: [
|
||||
StatusBar,
|
||||
SplashScreen,
|
||||
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule {}
|
||||
23
src/app/home/home.module.ts
Normal file
23
src/app/home/home.module.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { HomePage } from './home.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: HomePage
|
||||
}
|
||||
])
|
||||
],
|
||||
declarations: [HomePage]
|
||||
})
|
||||
export class HomePageModule {}
|
||||
48
src/app/home/home.page.html
Normal file
48
src/app/home/home.page.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-menu-button></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-title>
|
||||
Home
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-card class="welcome-card">
|
||||
<img src="/assets/shapes.svg" alt=""/>
|
||||
<ion-card-header>
|
||||
<ion-card-subtitle>Get Started</ion-card-subtitle>
|
||||
<ion-card-title>Welcome to Ionic</ion-card-title>
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<p>
|
||||
Now that your app has been created, you'll want to start building out features
|
||||
and components. Check out some of the resources below for next steps.
|
||||
</p>
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
|
||||
<ion-list lines="none">
|
||||
<ion-list-header>
|
||||
<ion-label>Resources</ion-label>
|
||||
</ion-list-header>
|
||||
<ion-item href="https://ionicframework.com/docs/">
|
||||
<ion-icon slot="start" color="medium" name="book"></ion-icon>
|
||||
<ion-label>Ionic Documentation</ion-label>
|
||||
</ion-item>
|
||||
<ion-item href="https://ionicframework.com/docs/building/scaffolding">
|
||||
<ion-icon slot="start" color="medium" name="build"></ion-icon>
|
||||
<ion-label>Scaffold Out Your App</ion-label>
|
||||
</ion-item>
|
||||
<ion-item href="https://ionicframework.com/docs/layout/structure">
|
||||
<ion-icon slot="start" color="medium" name="grid"></ion-icon>
|
||||
<ion-label>Change Your App Layout</ion-label>
|
||||
</ion-item>
|
||||
<ion-item href="https://ionicframework.com/docs/theming/basics">
|
||||
<ion-icon slot="start" color="medium" name="color-fill"></ion-icon>
|
||||
<ion-label>Theme Your App</ion-label>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
4
src/app/home/home.page.scss
Normal file
4
src/app/home/home.page.scss
Normal file
@@ -0,0 +1,4 @@
|
||||
.welcome-card img {
|
||||
max-height: 35vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
24
src/app/home/home.page.spec.ts
Normal file
24
src/app/home/home.page.spec.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
|
||||
import { HomePage } from './home.page';
|
||||
|
||||
describe('HomePage', () => {
|
||||
let component: HomePage;
|
||||
let fixture: ComponentFixture<HomePage>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [HomePage],
|
||||
imports: [IonicModule.forRoot()]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HomePage);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
12
src/app/home/home.page.ts
Normal file
12
src/app/home/home.page.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
templateUrl: 'home.page.html',
|
||||
styleUrls: ['home.page.scss'],
|
||||
})
|
||||
export class HomePage {
|
||||
|
||||
constructor() {}
|
||||
|
||||
}
|
||||
23
src/app/list/list.module.ts
Normal file
23
src/app/list/list.module.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { ListPage } from './list.page';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
IonicModule,
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: '',
|
||||
component: ListPage
|
||||
}
|
||||
])
|
||||
],
|
||||
declarations: [ListPage]
|
||||
})
|
||||
export class ListPageModule {}
|
||||
27
src/app/list/list.page.html
Normal file
27
src/app/list/list.page.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-buttons slot="start">
|
||||
<ion-menu-button></ion-menu-button>
|
||||
</ion-buttons>
|
||||
<ion-title>
|
||||
List
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<ion-list>
|
||||
<ion-item *ngFor="let item of items">
|
||||
<ion-icon [name]="item.icon" slot="start"></ion-icon>
|
||||
{{item.title}}
|
||||
<div class="item-note" slot="end">
|
||||
{{item.note}}
|
||||
</div>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
<!--
|
||||
<div *ngIf="selectedItem" padding>
|
||||
You navigated here from <b>{{selectedItem.title }}</b>
|
||||
</div>
|
||||
-->
|
||||
</ion-content>
|
||||
1
src/app/list/list.page.scss
Normal file
1
src/app/list/list.page.scss
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
32
src/app/list/list.page.spec.ts
Normal file
32
src/app/list/list.page.spec.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
|
||||
import { ListPage } from './list.page';
|
||||
|
||||
describe('ListPage', () => {
|
||||
let component: ListPage;
|
||||
let fixture: ComponentFixture<ListPage>;
|
||||
let listPage: HTMLElement;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ListPage ],
|
||||
imports: [IonicModule.forRoot()]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ListPage);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should have a list of 10 elements', () => {
|
||||
listPage = fixture.nativeElement;
|
||||
const items = listPage.querySelectorAll('ion-item');
|
||||
expect(items.length).toEqual(10);
|
||||
});
|
||||
|
||||
});
|
||||
39
src/app/list/list.page.ts
Normal file
39
src/app/list/list.page.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-list',
|
||||
templateUrl: 'list.page.html',
|
||||
styleUrls: ['list.page.scss']
|
||||
})
|
||||
export class ListPage implements OnInit {
|
||||
private selectedItem: any;
|
||||
private icons = [
|
||||
'flask',
|
||||
'wifi',
|
||||
'beer',
|
||||
'football',
|
||||
'basketball',
|
||||
'paper-plane',
|
||||
'american-football',
|
||||
'boat',
|
||||
'bluetooth',
|
||||
'build'
|
||||
];
|
||||
public items: Array<{ title: string; note: string; icon: string }> = [];
|
||||
constructor() {
|
||||
for (let i = 1; i < 11; i++) {
|
||||
this.items.push({
|
||||
title: 'Item ' + i,
|
||||
note: 'This is item #' + i,
|
||||
icon: this.icons[Math.floor(Math.random() * this.icons.length)]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
// add back when alpha.4 is out
|
||||
// navigate(item) {
|
||||
// this.router.navigate(['/list', JSON.stringify(item)]);
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user