Skip to content

Commit aa514a1

Browse files
authored
Merge pull request #204 from StoDevX/news-titles
add news article titles to News articles
2 parents a5f7e85 + e6ec51d commit aa514a1

File tree

4 files changed

+50
-15
lines changed

4 files changed

+50
-15
lines changed

views/news/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import tabs from './tabs'
1212

1313

1414
export default function NewsPage({navigator, route}: {navigator: typeof Navigator, route: Object}) {
15-
return <TabbedView style={styles.container} tabs={tabs} childProps={{navigator, route}} />
15+
return <TabbedView style={styles.container} tabs={tabs} navigator={navigator} route={route} />
1616
}
1717
NewsPage.propTypes = {
1818
navigator: React.PropTypes.instanceOf(Navigator).isRequired,

views/news/news-container.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313

1414
import delay from 'delay'
1515

16+
import Icon from 'react-native-vector-icons/Ionicons'
1617
import type {StoryType} from './types'
1718
import LoadingView from '../components/loading'
1819
import * as c from '../components/colors'
@@ -22,6 +23,7 @@ const entities = new Entities()
2223

2324
export default class NewsContainer extends React.Component {
2425
static propTypes = {
26+
name: PropTypes.string.isRequired,
2527
navigator: PropTypes.instanceOf(Navigator).isRequired,
2628
route: PropTypes.object.isRequired,
2729
url: PropTypes.string.isRequired,
@@ -72,9 +74,12 @@ export default class NewsContainer extends React.Component {
7274
let snippet = entities.decode(story.contentSnippet)
7375
return (
7476
<TouchableHighlight underlayColor={'#ebebeb'} onPress={() => this.onPressNews(title, story)}>
75-
<View style={styles.rowContainer}>
76-
<Text style={styles.itemTitle} numberOfLines={1}>{title}</Text>
77-
<Text style={styles.itemPreview} numberOfLines={2}>{snippet}</Text>
77+
<View style={[styles.row]}>
78+
<View style={[styles.rowContainer]}>
79+
<Text style={styles.itemTitle} numberOfLines={1}>{title}</Text>
80+
<Text style={styles.itemPreview} numberOfLines={2}>{snippet}</Text>
81+
</View>
82+
<Icon style={[styles.arrowIcon]} name='ios-arrow-forward' />
7883
</View>
7984
</TouchableHighlight>
8085
)
@@ -85,6 +90,7 @@ export default class NewsContainer extends React.Component {
8590
id: 'NewsItemView',
8691
index: this.props.route.index + 1,
8792
title: title,
93+
backButtonTitle: this.props.name,
8894
props: {story},
8995
})
9096
}
@@ -117,26 +123,35 @@ const styles = StyleSheet.create({
117123
paddingBottom: 50,
118124
backgroundColor: '#ffffff',
119125
},
120-
rowContainer: {
121-
marginLeft: 10,
126+
row: {
127+
flexDirection: 'row',
128+
alignItems: 'flex-start',
129+
borderBottomWidth: 1,
130+
borderBottomColor: '#ebebeb',
131+
marginLeft: 20,
122132
paddingRight: 10,
123133
paddingTop: 8,
124134
paddingBottom: 8,
125-
borderBottomWidth: 1,
126-
borderBottomColor: '#ebebeb',
135+
},
136+
arrowIcon: {
137+
color: c.iosText,
138+
fontSize: 20,
139+
marginRight: 6,
140+
marginLeft: 6,
141+
marginTop: 0,
142+
},
143+
rowContainer: {
144+
flexDirection: 'column',
145+
flex: 1,
127146
},
128147
itemTitle: {
129148
color: c.black,
130-
paddingLeft: 10,
131-
paddingRight: 10,
132149
paddingBottom: 3,
133150
fontSize: 16,
134151
textAlign: 'left',
135152
},
136153
itemPreview: {
137154
color: c.iosText,
138-
paddingLeft: 10,
139-
paddingRight: 10,
140155
fontSize: 13,
141156
textAlign: 'left',
142157
},

views/news/news-item.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import {WebView} from 'react-native'
44

55
import type {StoryType} from './types'
66

7-
export default function NewsItemView({story: {content}}: {story: StoryType}) {
8-
content = content + `
7+
export default function NewsItemView({story: {content, title}}: {source: string, story: StoryType}) {
8+
content = `
99
<style>
1010
body {
11-
font-family: -apple-system;
11+
font-family: -apple-system, Roboto, sans-serif;
1212
font-size: 16px;
1313
margin: 0;
1414
padding: 1em;
@@ -30,7 +30,24 @@ export default function NewsItemView({story: {content}}: {story: StoryType}) {
3030
color: black;
3131
text-decoration: none;
3232
}
33+
34+
.aao-header {
35+
border-bottom: solid 2px #eaeaea;
36+
margin: 0 0 1em;
37+
padding-bottom: 1em;
38+
font-weight: bold;
39+
text-align: center;
40+
}
41+
.aao-header h1 {
42+
line-height: 1.1em;
43+
font-size: 1.5em;
44+
margin-bottom: 0;
45+
}
3346
</style>
47+
<header class="aao-header">
48+
<h1>${title}</h1>
49+
</header>
50+
${content}
3451
`
3552
return (
3653
<WebView source={{html: content}} />

views/news/tabs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default [
1010
component: NewsContainer,
1111
props: {
1212
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=-1&q=https://wp.stolaf.edu/feed',
13+
name: 'St. Olaf',
1314
},
1415
},
1516
{
@@ -19,6 +20,7 @@ export default [
1920
component: NewsContainer,
2021
props: {
2122
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=-1&q=http://oleville.com/politicole/feed',
23+
name: 'PoliticOle',
2224
},
2325
},
2426
{
@@ -28,6 +30,7 @@ export default [
2830
component: NewsContainer,
2931
props: {
3032
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=-1&q=http://manitoumessenger.com/feed',
33+
name: 'Mess',
3134
},
3235
},
3336
]

0 commit comments

Comments
 (0)