-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApodComponent.js
97 lines (83 loc) · 1.87 KB
/
ApodComponent.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
92
93
94
95
96
97
'use strict';
var React = require('react-native');
var {
Image,
Text,
StyleSheet,
View,
TouchableOpacity,
LayoutAnimation,
StatusBarIOS,
} = React;
var animations = require('./animations');
var Apod = React.createClass({
getInitialState: function() {
return {
cover: true
};
},
touches: 0,
decrementTouches: function() {
this.touches--;
},
onPress: function() {
this.touches++;
setTimeout(this.decrementTouches, 250);
if (this.touches == 2) {
LayoutAnimation.configureNext(animations.easeInEaseOut);
this.setState({
cover: !this.state.cover,
});
}
},
imageCover: function() {
return (
<Image
source={{uri:this.props.item.imageUrl}}
style={[styles.apod, {resizeMode:Image.resizeMode.cover,}]}>
</Image>
);
},
imageContain: function() {
return (
<Image
source={{uri: this.props.item.imageUrl}}
style={[styles.apod, {resizeMode:Image.resizeMode.contain,}]}>
<View style={{flex:1}} />
<Text style={styles.apodDescription}>{this.props.item.title}</Text>
</Image>
);
},
render: function() {
var image;
if (this.state.cover) {
image = this.imageCover();
} else {
image = this.imageContain();
}
StatusBarIOS.setStyle(2, false);
if (this.state.cover) {
StatusBarIOS.setHidden(true, 1);
} else {
StatusBarIOS.setHidden(false, 1);
}
return (
<TouchableOpacity onPress={this.onPress} activeOpacity={1}>
<View style={{flex:1, backgroundColor:'#000000',}}>{image}</View>
</TouchableOpacity>
);
}
});
var styles = StyleSheet.create({
apod: {
flex: 1,
backgroundColor: 'rgba(0,0,0,0)',
},
apodDescription: {
textAlign: 'center',
bottom: 0,
color: '#FFFFFF',
paddingBottom: 5,
},
});
module.exports = Apod;