From 85f7155651fe7f48429381a4365a4f42a81bca95 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 10 Jun 2017 10:26:18 -0700 Subject: [PATCH] simple post details page --- package.json | 2 +- src/app/app.component.ts | 2 ++ src/app/app.module.ts | 7 +++-- src/pages/post-details/post-details.html | 26 +++++++++++++++++++ src/pages/post-details/post-details.module.ts | 16 ++++++++++++ src/pages/post-details/post-details.scss | 3 +++ src/pages/post-details/post-details.ts | 23 ++++++++++++++++ src/pages/stream/stream.html | 17 +++++++++--- src/pages/stream/stream.ts | 7 ++++- 9 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 src/pages/post-details/post-details.html create mode 100644 src/pages/post-details/post-details.module.ts create mode 100644 src/pages/post-details/post-details.scss create mode 100644 src/pages/post-details/post-details.ts diff --git a/package.json b/package.json index 35037b4..de50adf 100644 --- a/package.json +++ b/package.json @@ -65,4 +65,4 @@ "windows" ] } -} +} \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 0b26f20..b85b8a4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -42,6 +42,8 @@ export class MyApp { } }).catch(err => { console.log('ERROR: ' + err); + pnut.token = 'DOLORSITAmET6E6uaqT70D8R8o-yAG2eqa48wBihEqYhWKN3WQzlIzBd4V18vI-OCjKWCwGUQDPlNO2sS9DgkyYMM0SbJAirYH'; + this.nav.setRoot(StreamPage, {stream: 'global'}); }); this.platform.ready().then(() => { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ba112a3..f8fb543 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,6 +7,7 @@ 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 { PostDetailsPage } from '../pages/post-details/post-details'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; @@ -18,7 +19,8 @@ import { IonicStorageModule } from '@ionic/storage'; HomePage, ListPage, LoginPage, - StreamPage + StreamPage, + PostDetailsPage ], imports: [ BrowserModule, @@ -31,7 +33,8 @@ import { IonicStorageModule } from '@ionic/storage'; HomePage, ListPage, LoginPage, - StreamPage + StreamPage, + PostDetailsPage ], providers: [ StatusBar, diff --git a/src/pages/post-details/post-details.html b/src/pages/post-details/post-details.html new file mode 100644 index 0000000..7ebc1a0 --- /dev/null +++ b/src/pages/post-details/post-details.html @@ -0,0 +1,26 @@ + + + + + postDetails + + + + + + + + + + Post {{ postData.id }} + +

{{ postData.user.username }}

+

{{ postData.content.text }}

+
+
+
diff --git a/src/pages/post-details/post-details.module.ts b/src/pages/post-details/post-details.module.ts new file mode 100644 index 0000000..32e2af6 --- /dev/null +++ b/src/pages/post-details/post-details.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { PostDetailsPage } from './post-details'; + +@NgModule({ + declarations: [ + PostDetailsPage, + ], + imports: [ + IonicPageModule.forChild(PostDetailsPage), + ], + exports: [ + PostDetailsPage + ] +}) +export class PostDetailsPageModule {} diff --git a/src/pages/post-details/post-details.scss b/src/pages/post-details/post-details.scss new file mode 100644 index 0000000..5a2326b --- /dev/null +++ b/src/pages/post-details/post-details.scss @@ -0,0 +1,3 @@ +page-post-details { + +} diff --git a/src/pages/post-details/post-details.ts b/src/pages/post-details/post-details.ts new file mode 100644 index 0000000..f8ec320 --- /dev/null +++ b/src/pages/post-details/post-details.ts @@ -0,0 +1,23 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from 'ionic-angular'; + +/** + * Generated class for the PostDetailsPage page. + * + * See http://ionicframework.com/docs/components/#navigation for more info + * on Ionic pages and navigation. + */ +@IonicPage() +@Component({ + selector: 'page-post-details', + templateUrl: 'post-details.html', +}) +export class PostDetailsPage { + + postData: Object; + + constructor(public navCtrl: NavController, public navParams: NavParams) { + this.postData = navParams.data.post; + } + +} diff --git a/src/pages/stream/stream.html b/src/pages/stream/stream.html index 1002ea9..ce062a0 100644 --- a/src/pages/stream/stream.html +++ b/src/pages/stream/stream.html @@ -10,7 +10,7 @@ - {{title}} + {{ title }} @@ -19,12 +19,21 @@ - + - + -

{{ post.user.username }}

+

{{ post.user.username }}

{{ post.is_deleted ? '{post deleted}' : post.content.text }}

+
+
+
+ + + +
+
+
diff --git a/src/pages/stream/stream.ts b/src/pages/stream/stream.ts index 7feb046..a9d8ce6 100644 --- a/src/pages/stream/stream.ts +++ b/src/pages/stream/stream.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; +import { PostDetailsPage } from '../post-details/post-details'; import * as pnut from 'pnut-butter'; @@ -35,7 +36,7 @@ export class StreamPage { fetchGlobal() { console.log('-- fetching global stream --'); - pnut.global().then(res => { + pnut.global({include_raw: 1, count: 50}).then(res => { // console.log(res); this.posts = res.data; // console.log(this.posts); @@ -53,4 +54,8 @@ export class StreamPage { }); } + showPostDetails(postData) { + this.navCtrl.push(PostDetailsPage, {post: postData}); + } + }