Skip to content

Commit

Permalink
Add goals tab
Browse files Browse the repository at this point in the history
  • Loading branch information
kasnder committed Mar 2, 2020
1 parent fcf55b0 commit 1ffc0a4
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ 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: '', loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule) },
{
path: 'tip/:id',
loadChildren: () => import('./view-tip/view-tip.module').then(m => m.ViewTipPageModule)
Expand Down
17 changes: 17 additions & 0 deletions src/app/goals/goals.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { GoalsPage } from './goals.page';

@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
RouterModule.forChild([{ path: '', component: GoalsPage }])
],
declarations: [GoalsPage]
})
export class GoalsPageModule {}
17 changes: 17 additions & 0 deletions src/app/goals/goals.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Digital Habits: Goals
</ion-title>
</ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">Digital Habits: Goals</ion-title>
</ion-toolbar>
</ion-header>

<p>Nothing added yet. Choose some goals from the 'tips' tab.</p>
</ion-content>
3 changes: 3 additions & 0 deletions src/app/goals/goals.page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ion-content ion-toolbar {
--background: translucent;
}
24 changes: 24 additions & 0 deletions src/app/goals/goals.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';

import { GoalsPage } from './goals.page';

describe('GoalsPage', () => {
let component: GoalsPage;
let fixture: ComponentFixture<GoalsPage>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [GoalsPage],
imports: [IonicModule.forRoot()]
}).compileComponents();

fixture = TestBed.createComponent(GoalsPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));

it('should create', () => {
expect(component).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions src/app/goals/goals.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-tab2',
templateUrl: 'goals.page.html',
styleUrls: ['goals.page.scss']
})
export class GoalsPage {

constructor() {}

}
48 changes: 48 additions & 0 deletions src/app/tabs/tabs-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { TabsPage } from './tabs.page';

const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'tips',
children: [
{
path: '',
loadChildren: () =>
import('../tips/tips.module').then(m => m.TipsPageModule)
}
]
},
{
path: 'goals',
children: [
{
path: '',
loadChildren: () =>
import('../goals/goals.module').then(m => m.GoalsPageModule)
}
]
},
{
path: '',
redirectTo: '/tabs/goals',
pathMatch: 'full'
}
]
},
{
path: '',
redirectTo: '/tabs/goals',
pathMatch: 'full'
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TabsPageRoutingModule {}
19 changes: 19 additions & 0 deletions src/app/tabs/tabs.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IonicModule } from '@ionic/angular';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

import { TabsPageRoutingModule } from './tabs-routing.module';

import { TabsPage } from './tabs.page';

@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
TabsPageRoutingModule
],
declarations: [TabsPage]
})
export class TabsPageModule {}
15 changes: 15 additions & 0 deletions src/app/tabs/tabs.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<ion-tabs>

<ion-tab-bar slot="bottom">
<ion-tab-button tab="goals">
<ion-icon name="locate"></ion-icon>
<ion-label>Goals</ion-label>
</ion-tab-button>

<ion-tab-button tab="tips">
<ion-icon name="information"></ion-icon>
<ion-label>Tips</ion-label>
</ion-tab-button>
</ion-tab-bar>

</ion-tabs>
1 change: 1 addition & 0 deletions src/app/tabs/tabs.page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

26 changes: 26 additions & 0 deletions src/app/tabs/tabs.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TabsPage } from './tabs.page';

describe('TabsPage', () => {
let component: TabsPage;
let fixture: ComponentFixture<TabsPage>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [TabsPage],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TabsPage);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions src/app/tabs/tabs.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-tabs',
templateUrl: 'tabs.page.html',
styleUrls: ['tabs.page.scss']
})
export class TabsPage {

constructor() {}

}
8 changes: 4 additions & 4 deletions src/app/home/home.module.ts → src/app/tips/tips.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

import { HomePage } from './home.page';
import { TipsPage } from './tips.page';
import { TipComponentModule } from '../tip/tip.module';

@NgModule({
Expand All @@ -16,10 +16,10 @@ import { TipComponentModule } from '../tip/tip.module';
RouterModule.forChild([
{
path: '',
component: HomePage
component: TipsPage
}
])
],
declarations: [HomePage]
declarations: [TipsPage]
})
export class HomePageModule {}
export class TipsPageModule {}
4 changes: 2 additions & 2 deletions src/app/home/home.page.html → src/app/tips/tips.page.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>
Digital Habits
Digital Habits: Tips
</ion-title>
</ion-toolbar>
</ion-header>
Expand All @@ -14,7 +14,7 @@
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">
Digital Habits
Digital Habits: Tips
</ion-title>
</ion-toolbar>
</ion-header>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { TipComponentModule } from '../tip/tip.module';

import { HomePage } from './home.page';
import { TipsPage } from './tips.page';

describe('HomePage', () => {
let component: HomePage;
let fixture: ComponentFixture<HomePage>;
describe('TipsPage', () => {
let component: TipsPage;
let fixture: ComponentFixture<TipsPage>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomePage ],
declarations: [ TipsPage ],
imports: [IonicModule.forRoot(), TipComponentModule, RouterModule.forRoot([])]
}).compileComponents();

fixture = TestBed.createComponent(HomePage);
fixture = TestBed.createComponent(TipsPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
Expand Down
6 changes: 3 additions & 3 deletions src/app/home/home.page.ts → src/app/tips/tips.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { DataService, Tip } from '../services/data.service';

@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
templateUrl: 'tips.page.html',
styleUrls: ['tips.page.scss'],
})
export class HomePage {
export class TipsPage {
constructor(private data: DataService) {}

refresh(ev) {
Expand Down

0 comments on commit 1ffc0a4

Please sign in to comment.