From 99677c27b11abb137d2f5625cc7ecf76382c9d3b Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Wed, 27 May 2015 16:57:48 -0500 Subject: [PATCH] Hacker news --- ionic/components/app/test/hn/main.html | 9 +++++ .../components/app/test/hn/pages/single.html | 10 +++--- ionic/components/app/test/hn/pages/single.js | 25 +++++++++---- ionic/components/app/test/hn/pages/top.html | 4 ++- ionic/components/app/test/hn/pages/top.js | 35 ++++++++++++++++--- ionic/components/item/item.js | 6 +++- ionic/components/list/list.scss | 1 + 7 files changed, 71 insertions(+), 19 deletions(-) diff --git a/ionic/components/app/test/hn/main.html b/ionic/components/app/test/hn/main.html index 834979452d..fd665625f7 100644 --- a/ionic/components/app/test/hn/main.html +++ b/ionic/components/app/test/hn/main.html @@ -1,2 +1,11 @@ + + diff --git a/ionic/components/app/test/hn/pages/single.html b/ionic/components/app/test/hn/pages/single.html index 3dee0a0855..bdc8b28be6 100644 --- a/ionic/components/app/test/hn/pages/single.html +++ b/ionic/components/app/test/hn/pages/single.html @@ -1,5 +1,5 @@ - - -

SINGLE

-
-
+{{post.title}} + + + diff --git a/ionic/components/app/test/hn/pages/single.js b/ionic/components/app/test/hn/pages/single.js index a35793695f..c86e172d65 100644 --- a/ionic/components/app/test/hn/pages/single.js +++ b/ionic/components/app/test/hn/pages/single.js @@ -1,15 +1,26 @@ -import {For, Ancestor, Descendent, Parent, NgElement, Component, View, bootstrap} from 'angular2/angular2'; -import {Content, Nav, NavPane, List, Item} from 'ionic/ionic'; +import {NgFor, bootstrap} from 'angular2/angular2'; -import {HackerNews} from 'hn' +import {Ancestor} from 'angular2/src/core/annotations_impl/visibility'; + +import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations'; +import {View} from 'angular2/src/core/annotations_impl/view'; + +import {NavController, NavParams, HeaderTemplate, Toolbar, Content, Nav, NavPane, List, Item} from 'ionic/ionic'; + +import {HackerNews} from '../hn' @Component({ selector: 'top-stories' }) @View({ - templateUrl: 'pages/top.html', - directives: [Content, For, List, Item] + templateUrl: 'pages/single.html', + directives: [HeaderTemplate, Toolbar, Content, NgFor, List, Item] }) export class HNSinglePost { - constructor(@Parent() viewport: Nav) {//, @Ancestor() app: HNApp) { - console.log('SINGLE'); + constructor( + nav: NavController, + params: NavParams + ) { + this.nav = nav; + this.post = params; + console.log('SINGLE', params); } } diff --git a/ionic/components/app/test/hn/pages/top.html b/ionic/components/app/test/hn/pages/top.html index 1d9fd499e0..853f548594 100644 --- a/ionic/components/app/test/hn/pages/top.html +++ b/ionic/components/app/test/hn/pages/top.html @@ -2,6 +2,8 @@ - {{story.title}} + + {{story.title}} + diff --git a/ionic/components/app/test/hn/pages/top.js b/ionic/components/app/test/hn/pages/top.js index a24030c545..54971bf05e 100644 --- a/ionic/components/app/test/hn/pages/top.js +++ b/ionic/components/app/test/hn/pages/top.js @@ -7,21 +7,39 @@ import {View} from 'angular2/src/core/annotations_impl/view'; import {NavController, HeaderTemplate, Toolbar, Content, List, Item} from 'ionic/ionic'; -import {HackerNews} from '../hn' +import {HackerNews} from '../hn'; +import {HNSinglePost} from './single'; console.log('Angular directives', NgFor, Content, List, Item); +@Component({ + selector: 'story' +}) +@View({ + template: '
' +}) +export class Story { + constructor() { + + } +} + @Component({ selector: 'top-stories' }) @View({ templateUrl: 'pages/top.html', - directives: [HeaderTemplate, Toolbar, Content, NgFor, List, Item] + directives: [HeaderTemplate, Toolbar, Content, NgFor, List, Story, Item] }) export class HNTopStories { - constructor() { + constructor( + nav: NavController + ) { + this.nav = nav; - this.stories = [{ + this.stories = [ + /* + { by: "FatalLogic", descendants: 77, id: 9444675, @@ -32,7 +50,8 @@ export class HNTopStories { title: "Under Pressure", type: "story", url: "http://minusbat.livejournal.com/180556.html" - }]; + }*/ + ]; var APIUrl = 'https://hacker-news.firebaseio.com/v0'; @@ -57,6 +76,12 @@ export class HNTopStories { //doStuffEnd } + openStory(story) { + console.log('Opening story', story); + + this.nav.push(HNSinglePost, story); + } + /* HackerNews.getTopStories((val) => { new Promise((resolve, reject) => { diff --git a/ionic/components/item/item.js b/ionic/components/item/item.js index 3a04430618..db5d32c789 100644 --- a/ionic/components/item/item.js +++ b/ionic/components/item/item.js @@ -18,20 +18,24 @@ import { }) @View({ template: ` +
- +
+ `, directives: [ ItemPrimarySwipeButtons, diff --git a/ionic/components/list/list.scss b/ionic/components/list/list.scss index 02548f33c7..b2c1e49653 100644 --- a/ionic/components/list/list.scss +++ b/ionic/components/list/list.scss @@ -28,6 +28,7 @@ $list-margin-bottom: 10px !default; list-style-type: none; &.list-inset { + margin-top: 0; margin-left: -$content-padding; margin-right: -$content-padding; }