Skip to content

Commit

Permalink
fix(demos/config) fix for config page not updating. ionic-team#9413
Browse files Browse the repository at this point in the history
  • Loading branch information
ncapito committed Nov 30, 2016
1 parent a796786 commit 59c4ef6
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions demos/src/config/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { Platform, NavController } from 'ionic-angular';
import { Config, Platform, NavController } from 'ionic-angular';

if (!window.localStorage) {
Object.defineProperty(window, 'localStorage', new (function () {
Expand Down Expand Up @@ -85,34 +85,11 @@ export class TabPage {
export class ApiDemoPage {
config: any;
initialConfig: any;

constructor(public platform: Platform, public navCtrl: NavController) {

if (window.localStorage.getItem('configDemo') !== null) {
this.config = JSON.parse(window.localStorage.getItem('configDemo'));
} else if (platform.is('ios')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'bottom'
};
} else if (platform.is('windows')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'top'
};
} else {
this.config = {
'backButtonIcon': 'md-arrow-back',
'iconMode': 'md',
'tabsPlacement': 'bottom'
};
}

this.initialConfig = JSON.parse(JSON.stringify(this.config));
constructor(_config: Config, public navCtrl: NavController) {
this.config = _config.settings();
}


load() {
window.localStorage.setItem('configDemo', JSON.stringify(this.config));
window.location.reload();
Expand All @@ -139,5 +116,34 @@ export class PushPage {
template: '<ion-nav [root]="root" #content></ion-nav>'
})
export class ApiDemoApp {
config: any;
root = TabPage;
constructor(public _config: Config, public platform: Platform) {

if (window.localStorage.getItem('configDemo') !== null) {
this.config = JSON.parse(window.localStorage.getItem('configDemo'));
} else if (platform.is('ios')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'bottom'
};
} else if (platform.is('windows')) {
this.config = {
'backButtonIcon': 'ios-arrow-back',
'iconMode': 'ios',
'tabsPlacement': 'top'
};
} else {
this.config = {
'backButtonIcon': 'md-arrow-back',
'iconMode': 'md',
'tabsPlacement': 'bottom'
};
}

this._config.set('tabsPlacement', this.config.tabsPlacement);
this._config.set('iconMode', this.config.iconMode);
this._config.set('backButtonIcon', this.config.backButtonIcon);
}
}

0 comments on commit 59c4ef6

Please sign in to comment.