forked from vikrantsingh123/TextRecognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.js
59 lines (59 loc) · 1.72 KB
/
delete.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
import React, { Component } from 'react';
import { ListView } from 'react-native';
import { Container, Header, Content, Button, Icon, List, ListItem, Text } from 'native-base';
const datas = [
'Simon Mignolet',
'Nathaniel Clyne',
'Dejan Lovren',
'Mama Sakho',
'Alberto Moreno',
'Emre Can',
'Joe Allen',
'Phil Coutinho',
];
export default class SwipeableListExample 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() {
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
return (
<Container>
<Header />
<Content>
<List
leftOpenValue={75}
rightOpenValue={-75}
dataSource={this.ds.cloneWithRows(this.state.listViewData)}
renderRow={data => (
<ListItem>
<Text> {data} </Text>
</ListItem>
)}
renderLeftHiddenRow={data => (
<Button full onPress={() => alert(data)}>
<Icon active name="information-circle" />
</Button>
)}
renderRightHiddenRow={(data, secId, rowId, rowMap) => (
<Button full danger onPress={_ => this.deleteRow(secId, rowId, rowMap)}>
<Icon active name="trash" />
</Button>
)}
/>
</Content>
</Container>
);
}
}