-
Notifications
You must be signed in to change notification settings - Fork 0
/
Row.js
58 lines (51 loc) · 1.27 KB
/
Row.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
import React, { Component } from 'react';
import {
View,
StyleSheet
} from 'react-native';
import glamorous from 'glamorous-native'
const Row = glamorous.view(
{
flexDirection: "row"
},
(props) => ({
justifyContent: props.centered ? "center" : "flex-start"
}),
(props, s) => {
const {top, right, bottom, left} = props
const isAbsolute = [top, right, bottom, left].filter(p => typeof p === "number").length > 0
return {
position: isAbsolute ? "absolute" : "relative",
top,
right,
bottom,
left,
}
}
)
const incrementThings = (state, props) => {
return {
top: state.top + 1,
height: state.height + 1
}
}
export default class Example extends Component {
constructor(props) {
this.state = {top: 0, height: 50}
}
componentWillMount(){
setTimeout(() => this.setState(incrementThings), 50)
}
render(){
return(
<Row centered top={this.state.top} style={[Styles.row, {backgroundColor: "green"}]} height={this.state.height} >
<Text>I'm sliding down</Text>
</Row>
)
}
}
const Styles = StyleSheet.create({
row: {
borderWidth: 3,
},
})