-
Notifications
You must be signed in to change notification settings - Fork 740
Expand file tree
/
Copy pathmulti-list-swipe.js
More file actions
104 lines (100 loc) · 2.57 KB
/
Copy pathmulti-list-swipe.js
File metadata and controls
104 lines (100 loc) · 2.57 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
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
98
99
100
101
102
103
104
import React, { Component } from "react";
import { Platform, ListView } from "react-native";
import {
Container,
Header,
Title,
Content,
Button,
Icon,
List,
ListItem,
Text,
Left,
Right,
Body
} from "native-base";
import styles from "./styles";
const datas = [
"Simon Mignolet",
"Nathaniel Clyne",
"Dejan Lovren",
"Mama Sakho",
"Alberto Moreno",
"Emre Can",
"Joe Allen",
"Phil Coutinho"
];
class MultiListSwipe extends Component {
constructor(props) {
super(props);
this.ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
this.state = {
basic: true,
listViewData: datas
};
}
deleteRow(secId, rowId, rowMap) {
rowMap[`${secId}${rowId}`].props.closeRow();
const newData = [...this.state.listViewData];
newData.splice(rowId, 1);
this.setState({ listViewData: newData });
}
render() {
return (
<Container style={styles.container}>
<Header>
<Left>
<Button transparent onPress={() => this.props.navigation.goBack()}>
<Icon name="arrow-back" />
</Button>
</Left>
<Body style={{ flex: Platform.OS === 'ios' ? 3 : 1 }} >
<Title>Multiple List Swipe</Title>
</Body>
<Right />
</Header>
<Content>
<List
dataSource={this.ds.cloneWithRows(this.state.listViewData)}
renderRow={data =>
<ListItem style={{ paddingLeft: 20 }}>
<Text>
{data}
</Text>
</ListItem>}
renderLeftHiddenRow={data =>
<Button
full
onPress={() => alert(data)}
style={{
backgroundColor: "#CCC",
flex: 1,
alignItems: "center",
justifyContent: "center"
}}
>
<Icon active name="information-circle" />
</Button>}
renderRightHiddenRow={(data, secId, rowId, rowMap) =>
<Button
full
danger
onPress={_ => this.deleteRow(secId, rowId, rowMap)}
style={{
flex: 1,
alignItems: "center",
justifyContent: "center"
}}
>
<Icon active name="trash" />
</Button>}
leftOpenValue={75}
rightOpenValue={-75}
/>
</Content>
</Container>
);
}
}
export default MultiListSwipe;