Created
January 24, 2018 02:25
-
-
Save ryanvade/70c268e0361d9a082a6e2b576985b678 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- app.html --> | |
<ion-menu [content]="content"> | |
<ion-header> | |
<ion-toolbar> | |
<ion-title>Menu</ion-title> | |
</ion-toolbar> | |
</ion-header> | |
<ion-content> | |
<ion-list> | |
<button menuClose ion-item *ngFor="let p of pages" *ngIf="checkForJudging(p)" (click)="openPage(p)"> | |
{{p.title}} | |
</button> | |
</ion-list> | |
</ion-content> | |
</ion-menu> | |
<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus --> | |
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav> | |
// app.component.ts | |
import { Component, ViewChild } from '@angular/core'; | |
import { Nav, Platform } from 'ionic-angular'; | |
import { StatusBar } from '@ionic-native/status-bar'; | |
import { SplashScreen } from '@ionic-native/splash-screen'; | |
import { SettingsProvider } from '../providers/settings/settings'; | |
import { HomePage } from '../pages/home/home'; | |
import { ListPage } from '../pages/list/list'; | |
import { MatchesPage } from '../pages/matches/matches'; | |
import { SettingsPage } from '../pages/settings/settings'; | |
import { SignInPage } from '../pages/signInGUI/signIn'; | |
@Component({ | |
templateUrl: 'app.html' | |
}) | |
export class MyApp { | |
@ViewChild(Nav) nav: Nav; | |
rootPage: any = HomePage; | |
pages: Array<{ title: string, component: any }>; | |
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, public settings: SettingsProvider) { | |
this.initializeApp(); | |
// used for an example of ngFor and navigation | |
this.pages = [ | |
{ title: 'Home', component: HomePage }, | |
{ title: 'List', component: ListPage }, | |
{ title: 'Matches', component: MatchesPage }, | |
{ title: 'Settings', component: SettingsPage }, | |
{ title: 'Sign In', component: SignInPage } | |
]; | |
} | |
initializeApp() { | |
this.platform.ready().then(() => { | |
// App Startup | |
this.settings.getFirstTimeUse().then(val => { | |
if (val != 'TRUE') { | |
this.firstTimeUse(); | |
} | |
this.statusBar.styleDefault(); | |
this.splashScreen.hide(); | |
}); | |
}); | |
} | |
openPage(page) { | |
// Reset the content nav to have just this page | |
// we wouldn't want the back button to show in this scenario | |
this.nav.setRoot(page.component); | |
} | |
checkForJudging(page) { | |
if(page.title != 'judging') { | |
return true; | |
} | |
if(this.judgingAuthenticated()) { | |
return true; | |
} | |
return false; | |
} | |
judgingAuthenticated() { | |
// some logic to check for authentication... | |
} | |
firstTimeUse() { | |
console.log('First Time Use'); | |
this.settings.setDefaults(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment