reformatted stream

This commit is contained in:
Morgan McMillian 2017-06-10 11:53:36 -07:00
parent 85f7155651
commit ac0974d41c
4 changed files with 126 additions and 77 deletions

View file

@ -36,6 +36,7 @@
"ionic-angular": "3.3.0", "ionic-angular": "3.3.0",
"ionic-plugin-keyboard": "^2.2.1", "ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0", "ionicons": "3.0.0",
"moment": "^2.18.1",
"ng2-cordova-oauth": "0.0.8", "ng2-cordova-oauth": "0.0.8",
"pnut-butter": "^0.8.1", "pnut-butter": "^0.8.1",
"rxjs": "5.1.1", "rxjs": "5.1.1",

View file

@ -12,6 +12,7 @@ import { PostDetailsPage } from '../pages/post-details/post-details';
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 { IonicStorageModule } from '@ionic/storage'; import { IonicStorageModule } from '@ionic/storage';
import { TimeagoPipe } from '../pipes/timeago/timeago';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -20,7 +21,8 @@ import { IonicStorageModule } from '@ionic/storage';
ListPage, ListPage,
LoginPage, LoginPage,
StreamPage, StreamPage,
PostDetailsPage PostDetailsPage,
TimeagoPipe
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View file

@ -19,22 +19,46 @@
<ion-content> <ion-content>
<ion-list> <ion-list>
<ion-item *ngFor="let post of posts" (click)="showPostDetails(post)" text-wrap> <ion-card *ngFor="let post of posts">
<ion-item>
<ion-avatar item-start> <ion-avatar item-start>
<img src="{{ post.user.content.avatar_image.link }}"> <img src="{{ post.user.content.avatar_image.link }}">
</ion-avatar> </ion-avatar>
<h1>{{ post.user.username }}</h1> <h2>{{ post.user.name }}</h2>
<p>@{{ post.user.username }}</p>
<ion-note item-end>{{ post.created_at | timeago }}</ion-note>
</ion-item>
<ion-card-content>
<p>{{ post.is_deleted ? '{post deleted}' : post.content.text }}</p> <p>{{ post.is_deleted ? '{post deleted}' : post.content.text }}</p>
</ion-card-content>
<div *ngIf="post.raw"> <div *ngIf="post.raw">
<div *ngFor="let r of post.raw"> <div *ngFor="let r of post.raw">
<div *ngIf="r.type == 'io.pnut.core.oembed'"> <div *ngIf="r.type == 'io.pnut.core.oembed'">
<ion-thumbnail>
<img src="{{ r.value.url }}"> <img src="{{ r.value.url }}">
</ion-thumbnail>
</div> </div>
</div> </div>
</div> </div>
</ion-item> <ion-row>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="star"></ion-icon>
<div *ngIf="post.counts.bookmarks > 0">{{ post.counts.bookmarks }}</div>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="repeat"></ion-icon>
<div *ngIf="post.counts.reposts > 0">{{ post.counts.reposts }}</div>
</button>
</ion-col>
<ion-col>
<button ion-button icon-left clear small block>
<ion-icon name="text"></ion-icon>
<div *ngIf="post.counts.replies > 0">{{ post.counts.replies }}</div>
</button>
</ion-col>
</ion-row>
</ion-card>
</ion-list> </ion-list>
</ion-content> </ion-content>

View file

@ -0,0 +1,22 @@
import { Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';
/**
* Generated class for the TimeagoPipe pipe.
*
* See https://angular.io/docs/ts/latest/guide/pipes.html for more info on
* Angular Pipes.
*/
@Pipe({
name: 'timeago',
})
export class TimeagoPipe implements PipeTransform {
now: any;
/**
* Takes a value and makes it lowercase.
*/
transform(value: string, ...args) {
this.now = moment(value).fromNow(true);
return this.now;
}
}