-
-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathApp.js
84 lines (73 loc) · 1.88 KB
/
App.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
import React, { Component, PropTypes } from 'react'
import { StyleSheet } from 'fela-tools'
import { Text, View } from 'react-native'
const rules = StyleSheet.create({
container: props => ({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
'@media (min-width: 200px)': {
backgroundColor: 'yellow'
},
'@media (orientation: landscape)': {
backgroundColor: 'red'
},
'@media (orientation: portrait)': {
backgroundColor: 'blue'
}
}),
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
},
ticker: props => ({ color: props.color })
})
class Ticker extends Component {
constructor() {
super()
this.state = { color: 'red' }
this.startTicker = this.startTicker.bind(this)
}
startTicker() {
this.setState({ color: this.state.color === 'red' ? 'blue' : 'red' })
setTimeout(this.startTicker, 500)
}
componentDidMount() {
this.startTicker()
}
render() {
const { renderer } = this.context
return (
<Text
style={renderer.renderRule(rules.ticker, { color: this.state.color })}
>
I am
{this.state.color}
</Text>
)
}
}
Ticker.contextTypes = { renderer: PropTypes.object }
const App = (_, { renderer }) => (
<View style={renderer.renderRule(rules.container, { bgColor: 'gray' })}>
<Text style={renderer.renderRule(rules.welcome)}>
Welcome to Fela Native!
</Text>
<Text style={renderer.renderRule(rules.instructions)}>
To get started, edit index.ios.js
</Text>
<Text style={renderer.renderRule(rules.instructions)}>
Double tap R on your keyboard to reload,
{'\n'} Shake or press menu button for dev menu
</Text>
<Ticker />
</View>
)
App.contextTypes = { renderer: PropTypes.object }
export default App