-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListCards.js
90 lines (82 loc) · 2.21 KB
/
ListCards.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
import React, { Component } from 'react';
import {
AppRegistry,
Animated,
StyleSheet,
Text,
View,
TouchableOpacity
} from 'react-native';
export default class ListCards extends Component {
constructor(props) {
super(props);
this.state={
...props,
showAnim:new Animated.Value(0)
};
this.showorhide=0;
}
_showorhideItems(){
if(typeof(this.state.name)=='undefined'||this.state.name==null){
return;
}
Animated.timing( // Uses easing functions
this.state.showAnim, // The value to drive
{
toValue: this.showorhide == 0 ? 1 : 0,
} // Configuration
).start();
this.showorhide=this.showorhide==0?1:0;
}
render(){
return(
<View>
<TouchableOpacity onPress={this._showorhideItems.bind(this)}>
<View style={styles.headerLine}>
<View style={styles.headerRows}><Text>{this.state.name}</Text></View>
</View>
</TouchableOpacity>
<Animated.View
style={{
opacity : this.state.showAnim,
height:this.state.showAnim.interpolate({
inputRange: [0, 1],
outputRange: [0, 110]
}),
overflow:'hidden'
}
}
>
<View style={styles.showitemContain}>
<View style={{height:50, justifyContent:'center', alignItems:'center',}}>
<Text>{this.state.title==null?'':this.state.title}</Text>
</View>
<View style={{height:50, justifyContent:'center', alignItems:'center',}}>
<Text>{this.state.fromwhere==null?'':this.state.fromwhere}</Text>
</View>
</View>
</Animated.View>
</View>
)
}
}
const styles=StyleSheet.create({
headerLine:{
height:50,
flexDirection:'row',
//borderWidth:1,
backgroundColor:'#ccc',
},
headerRows:{
flex:1,
justifyContent:'center',
alignItems:'center',
},
showitemContain:{
borderWidth:1,
borderColor:'red',
height:110,
justifyContent:'center',
alignItems:'center',
}
});