Initial settings page, issue #31

This commit is contained in:
Morgan McMillian 2017-07-23 07:48:29 -07:00
parent 61024e18ca
commit 73f2a297ab
6 changed files with 108 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import { Device } from '@ionic-native/device';
import { LoginPage } from '../pages/login/login';
import { StreamPage } from '../pages/stream/stream';
import { SettingsPage } from '../pages/settings/settings';
import * as pnut from 'pnut-butter';
@ -30,6 +31,7 @@ export class MyApp {
{ title: 'Mentions', component: StreamPage, params: {stream: 'mentions'} },
{ title: 'Global', component: StreamPage, params: {stream: 'global'} },
{ title: 'Bookmarks', component: StreamPage, params: {stream: 'bookmarks'} },
{ title: 'Settings', component: SettingsPage, params: {}},
{ title: 'Logout', component: {}, params: {}},
];
@ -67,6 +69,8 @@ export class MyApp {
if (page.title === 'Logout') {
this.storage.remove('token');
this.nav.setRoot(LoginPage);
} else if (page.title === 'Settings') {
this.nav.push(page.component, page.params);
} else {
this.nav.setRoot(page.component, page.params);
}

View file

@ -6,6 +6,7 @@ import { MyApp } from './app.component';
import { LoginPage } from '../pages/login/login';
import { StreamPage, NewPostModal, PostMenu } from '../pages/stream/stream';
import { ThreadPage } from '../pages/thread/thread';
import { SettingsPage } from '../pages/settings/settings';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
@ -20,6 +21,7 @@ import { ParserPipe } from '../pipes/parser/parser';
LoginPage,
StreamPage,
ThreadPage,
SettingsPage,
TimeagoPipe,
NewPostModal,
PostMenu,
@ -36,6 +38,7 @@ import { ParserPipe } from '../pipes/parser/parser';
LoginPage,
StreamPage,
ThreadPage,
SettingsPage,
NewPostModal,
PostMenu
],

View file

@ -0,0 +1,36 @@
<!--
Generated template for the SettingsPage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>settings</ion-title>
</ion-navbar>
</ion-header>
<ion-content overflow-scroll=”true”>
<ion-list>
<ion-item>
<ion-label>
<h2>Unified Home</h2>
<p>Include mentions in home timeline</p>
</ion-label>
<ion-toggle [(ngModel)]="set_unified" (ionChange)="updateUnified()"></ion-toggle>
</ion-item>
<ion-item>
<ion-label>
<h2>Use CC on Reply All</h2>
<p>Additional mentions follow /</p>
</ion-label>
<ion-toggle [(ngModel)]="set_cc" (ionChange)="updateCc()"></ion-toggle>
</ion-item>
</ion-list>
</ion-content>

View file

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { SettingsPage } from './settings';
@NgModule({
declarations: [
SettingsPage,
],
imports: [
IonicPageModule.forChild(SettingsPage),
],
exports: [
SettingsPage
]
})
export class SettingsPageModule {}

View file

@ -0,0 +1,3 @@
page-settings {
}

View file

@ -0,0 +1,46 @@
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Storage } from '@ionic/storage';
/**
* Generated class for the SettingsPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-settings',
templateUrl: 'settings.html',
})
export class SettingsPage {
private set_unified: boolean;
private set_cc: boolean;
constructor(public navCtrl: NavController, private storage: Storage, public navParams: NavParams) {
}
ngAfterViewInit() {
this.storage.get('unified').then((val) => {
this.set_unified = val;
}).catch(err => {
console.log('ERROR: ' + err);
});
this.storage.get('cc').then((val) => {
this.set_cc = val;
}).catch(err => {
console.log('ERROR: ' + err);
});
}
updateUnified() {
this.storage.set('unified', this.set_unified);
}
updateCc() {
this.storage.set('cc', this.set_cc);
}
}