59 lines
1.5 KiB
TypeScript
Raw Normal View History

/// <reference path="../../../typings/browser/ambient/jquery/index.d.ts" />
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Storage } from '@ionic/storage';
import { SavedPage, UserProfile } from '../../libs/UserProfile';
@Component({
selector: 'settings',
templateUrl: 'settings.html'
})
export class SettingsPage
{
textSize: number = 0;
userProfile: UserProfile;
constructor(public navCtrl: NavController, public local: Storage)
{
this.userProfile = new UserProfile(UserProfile.createDefaultUser());
// Check if there is a profile saved in local storage
this.local.get('profile').then(profile =>
{
let t = this.userProfile;
if (profile !== null)
t = JSON.parse(profile);
this.userProfile.update(t, local);
}).catch(error =>
{
console.log(error);
});
}
textSizeChanged()
{
this.userProfile.textSizeChanged();
this.save();
}
save()
{
this.userProfile.save(this.local);
}
reset()
{
this.userProfile.reset(this.local);
}
removePage(page: SavedPage)
{
let idx = this.userProfile.user.saved_pages.indexOf(page);
this.userProfile.user.saved_pages.splice(idx, 1);
// save the users settings.
this.userProfile.save(this.local);
}
}