-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.js
More file actions
63 lines (56 loc) · 2.2 KB
/
Item.js
File metadata and controls
63 lines (56 loc) · 2.2 KB
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
import React, { Component } from 'react'
import { View, Text, TouchableOpacity, LayoutAnimation,Animated } from 'react-native';
import styles from './styles';
import {observer} from 'mobx-react';
import TodoStore from './todoStore';
class Item extends Component {
constructor(props){
super(props);
this.state = {detail: false}
this.loadAnim = new Animated.Value(0);
}
componentDidMount() {
Animated.timing(this.loadAnim,{
toValue:1,
duration:800,
useNativeDriver:true,
delay:this.props.index*100
}).start();
}
_onPress() {
LayoutAnimation.spring();
this.setState({ detail: !this.state.detail });
}
render() {
let load = this.loadAnim.interpolate({
inputRange:[0,1],
outputRange:[50,0],
})
return (
<TouchableOpacity onPress={() => this._onPress()} style={{flexDirection:'row',alignItems:'center',justifyContent:'center'}}>
<View style={{position:'absolute',flexDirection:'row',alignItems:'center',justifyContent:'space-around',width:250,left:this.state.detail ? 0 : -250,}}>
<TouchableOpacity onPress={()=>{
TodoStore.updateCheck(this.props.index,true)
}} style={{marginLeft:10,width:30,height:30,borderRadius:15,backgroundColor:'green'}}/>
<TouchableOpacity onPress={() => {
TodoStore.updateCheck(this.props.index, false)
}} style={{marginLeft:10,width:30,height:30,borderRadius:15,backgroundColor:'red'}}/>
<TouchableOpacity onPress={() => {
TodoStore.removeData(this.props.index)
}} style={{marginLeft:10,width:30,height:30,borderRadius:15,backgroundColor:'#666'}}/>
</View>
<Animated.View
style={[styles.itemBox, { flex: 1, left: this.state.detail ? 250 : 0 },{transform:[{translateY:load}]}]} >
<Text style={[styles.itemTitle, this.props.check && styles.itemTitleTrue,]}>
{this.props.title}
</Text>
<View style={this.props.check ? styles.itemCheckTrue : styles.itemCheckFalse } shadowColor={'#000'} elevation={1} shadowOffset={{width:0,height:0}} />
</Animated.View>
</TouchableOpacity>
)
}
}
Item.defaulProps = {
check:false,
}
export default Item;