diff --git a/README.md b/README.md index 9424630..49e93f4 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,10 @@ limitations under the License. * Install Node.js (https://nodejs.org) * Install the latest Ionic and Cordova tools - ```bash - npm install -g ionic cordova - ``` + +```bash +npm install -g ionic cordova +``` ## Platform build dependencies diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7966a6b..4bb6a8d 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -4,9 +4,11 @@ import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import { Storage } from '@ionic/storage'; -import { HomePage } from '../pages/home/home'; +// import { HomePage } from '../pages/home/home'; import { ListPage } from '../pages/list/list'; import { LoginPage } from '../pages/login/login'; +import { StreamPage } from '../pages/stream/stream'; + import * as pnut from 'pnut-butter'; @Component({ @@ -24,7 +26,7 @@ export class MyApp { // used for an example of ngFor and navigation this.pages = [ - { title: 'Home', component: HomePage }, + { title: 'Global Stream', component: StreamPage }, { title: 'List', component: ListPage }, ]; @@ -35,7 +37,7 @@ export class MyApp { this.storage.get('token').then((val) => { if (val.length > 1) { pnut.token = val; - this.nav.setRoot(HomePage); + this.nav.setRoot(StreamPage); } }).catch(err => { console.log('ERROR: ' + err); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6787d41..ba112a3 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -6,6 +6,7 @@ import { MyApp } from './app.component'; import { HomePage } from '../pages/home/home'; import { ListPage } from '../pages/list/list'; import { LoginPage } from '../pages/login/login'; +import { StreamPage } from '../pages/stream/stream'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; @@ -16,7 +17,8 @@ import { IonicStorageModule } from '@ionic/storage'; MyApp, HomePage, ListPage, - LoginPage + LoginPage, + StreamPage ], imports: [ BrowserModule, @@ -28,7 +30,8 @@ import { IonicStorageModule } from '@ionic/storage'; MyApp, HomePage, ListPage, - LoginPage + LoginPage, + StreamPage ], providers: [ StatusBar, diff --git a/src/pages/login/login.ts b/src/pages/login/login.ts index e6d942b..c23eed6 100644 --- a/src/pages/login/login.ts +++ b/src/pages/login/login.ts @@ -4,7 +4,7 @@ import { Storage } from '@ionic/storage'; import { HomePage } from '../home/home'; import { OauthCordova } from 'ng2-cordova-oauth/platform/cordova'; -import { OauthBrowser } from 'ng2-cordova-oauth/platform/browser'; +// import { OauthBrowser } from 'ng2-cordova-oauth/platform/browser'; import { PnutAuth } from '../../providers/pnut-oauth'; import * as pnut from 'pnut-butter'; @@ -22,7 +22,7 @@ import * as pnut from 'pnut-butter'; export class LoginPage { private oauth: OauthCordova = new OauthCordova(); - private oauthb: OauthBrowser = new OauthBrowser(); + // private oauthb: OauthBrowser = new OauthBrowser(); private pnutProvider: PnutAuth = new PnutAuth({ appScope: ['basic','stream','write_post'] }); @@ -32,8 +32,8 @@ export class LoginPage { } login() { - this.oauthb.logInVia(this.pnutProvider).then(success => { - // console.log('RESULT: ' + JSON.stringify(success)); + this.oauth.logInVia(this.pnutProvider).then(success => { + console.log('RESULT: ' + JSON.stringify(success)); this.storage.set('token', success['access_token']); pnut.token = success['access_token']; this.navCtrl.setRoot(HomePage); diff --git a/src/pages/stream/stream.html b/src/pages/stream/stream.html new file mode 100644 index 0000000..45904bc --- /dev/null +++ b/src/pages/stream/stream.html @@ -0,0 +1,28 @@ + + + + + stream + + + + + + + + + + + + +

{{post.user.username}}

+

{{post.content.text}}

+
+
+ +
diff --git a/src/pages/stream/stream.module.ts b/src/pages/stream/stream.module.ts new file mode 100644 index 0000000..a1b6be0 --- /dev/null +++ b/src/pages/stream/stream.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { StreamPage } from './stream'; + +@NgModule({ + declarations: [ + StreamPage, + ], + imports: [ + IonicPageModule.forChild(StreamPage), + ], + exports: [ + StreamPage + ] +}) +export class StreamPageModule {} diff --git a/src/pages/stream/stream.scss b/src/pages/stream/stream.scss new file mode 100644 index 0000000..e72322f --- /dev/null +++ b/src/pages/stream/stream.scss @@ -0,0 +1,11 @@ +page-stream { + .item-md ion-avatar img { + border-radius: 0; + } + .item-wp ion-avatar img { + border-radius: 0; + } + .item-ios ion-avatar img { + border-radius: 0; + } +} diff --git a/src/pages/stream/stream.ts b/src/pages/stream/stream.ts new file mode 100644 index 0000000..e250aca --- /dev/null +++ b/src/pages/stream/stream.ts @@ -0,0 +1,35 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from 'ionic-angular'; + +import * as pnut from 'pnut-butter'; + +/** + * Generated class for the StreamPage page. + * + * See http://ionicframework.com/docs/components/#navigation for more info + * on Ionic pages and navigation. + */ +@IonicPage() +@Component({ + selector: 'page-stream', + templateUrl: 'stream.html', +}) +export class StreamPage { + + posts: Array = [] + + constructor(public navCtrl: NavController, public navParams: NavParams) { + this.fetchGlobal(); + } + + fetchGlobal() { + console.log('-- fetching global stream --'); + pnut.global().then(res => { + // console.log(res); + this.posts = res.data; + }).catch(err => { + console.log(err); + }); + } + +}