|
@@ -2,6 +2,7 @@ import { Component, ViewChild } from '@angular/core';
|
|
import { Nav, Platform } from 'ionic-angular';
|
|
import { Nav, Platform } from 'ionic-angular';
|
|
import { StatusBar } from '@ionic-native/status-bar';
|
|
import { StatusBar } from '@ionic-native/status-bar';
|
|
import { SplashScreen } from '@ionic-native/splash-screen';
|
|
import { SplashScreen } from '@ionic-native/splash-screen';
|
|
|
|
+import { Storage } from '@ionic/storage';
|
|
|
|
|
|
import { AuthProvider } from '../providers/auth/auth';
|
|
import { AuthProvider } from '../providers/auth/auth';
|
|
|
|
|
|
@@ -9,6 +10,8 @@ import { HomePage } from '../pages/home/home';
|
|
import { SearchPage } from '../pages/search/search';
|
|
import { SearchPage } from '../pages/search/search';
|
|
import { SettingsPage } from '../pages/settings/settings';
|
|
import { SettingsPage } from '../pages/settings/settings';
|
|
import { LoginPage } from '../pages/login/login';
|
|
import { LoginPage } from '../pages/login/login';
|
|
|
|
+import { ProfilePage } from '../pages/profile/profile';
|
|
|
|
+import { TwitterApiProvider } from '../providers/twitter-api/twitter-api';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
templateUrl: 'app.html'
|
|
templateUrl: 'app.html'
|
|
@@ -17,14 +20,16 @@ export class MyApp {
|
|
@ViewChild(Nav) nav: Nav;
|
|
@ViewChild(Nav) nav: Nav;
|
|
|
|
|
|
rootPage: any;
|
|
rootPage: any;
|
|
-
|
|
|
|
pages: Array<{ title: string, icon: string, component: any }>;
|
|
pages: Array<{ title: string, icon: string, component: any }>;
|
|
|
|
+ user: any;
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
platform: Platform,
|
|
platform: Platform,
|
|
statusBar: StatusBar,
|
|
statusBar: StatusBar,
|
|
splashScreen: SplashScreen,
|
|
splashScreen: SplashScreen,
|
|
- private authProvider: AuthProvider
|
|
|
|
|
|
+ private authProvider: AuthProvider,
|
|
|
|
+ private twitter: TwitterApiProvider,
|
|
|
|
+ private storage: Storage
|
|
) {
|
|
) {
|
|
platform.ready().then(() => {
|
|
platform.ready().then(() => {
|
|
// Okay, so the platform is ready and our plugins are available.
|
|
// Okay, so the platform is ready and our plugins are available.
|
|
@@ -35,6 +40,13 @@ export class MyApp {
|
|
splashScreen.hide();
|
|
splashScreen.hide();
|
|
authProvider.isLoggedIn().then(isLoggedIn => {
|
|
authProvider.isLoggedIn().then(isLoggedIn => {
|
|
this.rootPage = isLoggedIn ? HomePage : LoginPage;
|
|
this.rootPage = isLoggedIn ? HomePage : LoginPage;
|
|
|
|
+ storage.get("userId")
|
|
|
|
+ .then(userId => {
|
|
|
|
+ twitter.fetchUser(userId)
|
|
|
|
+ .then(res => {
|
|
|
|
+ this.user = res;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
})
|
|
})
|
|
});
|
|
});
|
|
|
|
|
|
@@ -45,14 +57,17 @@ export class MyApp {
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ showProfile(userId) {
|
|
|
|
+ this.nav.push(ProfilePage, { userId });
|
|
|
|
+ }
|
|
|
|
+
|
|
openPage(page) {
|
|
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);
|
|
this.nav.setRoot(page.component);
|
|
}
|
|
}
|
|
|
|
|
|
logout() {
|
|
logout() {
|
|
this.authProvider.logout();
|
|
this.authProvider.logout();
|
|
|
|
+ this.nav.setRoot(LoginPage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|