import { HIDE_OLD_BUSES_KEY , HIDE_TRAJECTORY_KEY } from '../../const' ; import { PreferencesManager } from '../../managers/preferences' ; import { AppVersion } from 'ionic-native' ; import { Component } from '@angular/core' ; import { Analytics } from '../../core/analytics' ; import strings from '../../strings' ; class @ Component ( { templateUrl : 'template.html' , } ) export class SettingsPage { public version : string = '' ; public hideTrajectory : boolean ; public hideOldBuses : boolean ; public get Text ( ) : any { return strings ; } public constructor ( private preferences ) { Analytics . trackView ( 'SettingsPage' ) ; } return { void } public ionViewDidLoad ( ) { AppVersion . getVersionNumber ( ) . then ( version => this . version = version ) ; this . preferences . getKey < boolean > ( HIDE_TRAJECTORY_KEY ) . then ( value => this . hideTrajectory = ! ! value ) ; this . preferences . getKey < boolean > ( HIDE_OLD_BUSES_KEY ) . then ( value => this . hideOldBuses = ! ! value ) ; } return { void } public onHideTrajectoryChange ( ) { Analytics . trackEvent ( 'trajectory switch' , 'toggle' , `${ this . hideTrajectory }` ) ; this . preferences . setKey ( HIDE_TRAJECTORY_KEY , this . hideTrajectory ) . then ( ( ) => console . log ( 'Toggled trajectory state.' ) ) ; } return { void } public onHideOldBusesChange ( ) { Analytics . trackEvent ( 'old buses switch' , 'toggle' , `${ this . hideOldBuses }` ) ; this . preferences . setKey ( HIDE_OLD_BUSES_KEY , this . hideOldBuses ) . then ( ( ) => console . log ( 'Toggled old buses display state.' ) ) ; } }