-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDeckScreen.js
91 lines (82 loc) · 2.33 KB
/
DeckScreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React, { Component } from 'react';
import { View, Text, Dimensions, Platform } from 'react-native';
import { connect } from 'react-redux';
import { MapView } from 'expo';
import { Card, Button, Icon } from 'react-native-elements';
import Swipe from '../components/Swipe';
import * as actions from '../actions';
const SCREEN_HEIGHT = Dimensions.get('window').height;
class DeckScreen extends Component {
static navigationOptions = {
tabBarLabel: 'Jobs',
tabBarIcon: ({ tintColor }) => {
return <Icon name='description' size={30} color={tintColor} />;
}
}
renderCard(job) {
const initialRegion = {
longitude: job.longitude,
latitude: job.latitude,
longitudeDelta: 0.045,
latitudeDelta: 0.02
};
return (
<Card title={job.jobtitle} titleStyle={{ height: SCREEN_HEIGHT * 0.07 }}>
<View style={{ height: SCREEN_HEIGHT / 4 }}>
<MapView
scrollEnabled={false}
style={{ flex: 1 }}
cacheEnabled={Platform.os === 'android'}
initialRegion={initialRegion}
/>
</View>
<View style={styles.detailWrapper}>
<Text>{job.company}</Text>
<Text>{job.formattedRelativeTime}</Text>
</View>
<View style={{ height: SCREEN_HEIGHT / 4 }}>
<Text>
{job.snippet.replace(/<b>/g, '').replace(/<\/b>/g, '')}
</Text>
</View>
</Card>
);
}
renderNoMoreJobs() {
return (
<Card title="No More Jobs">
<Button
title="Back To Map"
large
icon={{ name: 'my-location' }}
backgroundColor="#03A9F4"
onPress={() => this.props.navigation.navigate('map')}
/>
</Card>
);
}
render() {
return (
<View style={{ marginTop: 10 }}>
<Swipe
data={this.props.jobs}
renderCard={this.renderCard.bind(this)}
renderNoMoreCards={this.renderNoMoreJobs.bind(this)}
onSwipeRight={job => this.props.likeJob(job)}
keyProp='jobkey'
/>
</View>
);
}
}
const styles = {
detailWrapper: {
flexDirection: 'row',
justifyContent: 'space-around',
marginBottom: 10
}
};
function mapStateToProps({ jobs }) {
return { jobs: jobs.results || [] };
}
export default connect(mapStateToProps, actions)(DeckScreen);