This repository has been archived by the owner on Sep 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 651
Closing Swipeouts
mashwinprdxn edited this page Jun 28, 2018
·
3 revisions
In this example, rows
is sample data source.
getInitialState: function() {
// datasource rerendered when change is made (used to set Swipeout to active)
var ds = new ListView.DataSource({rowHasChanged: (row1, row2) => true})
return {
dataSource: ds.cloneWithRows(rows)
}
}
_updateDataSource: function(data) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(data)
})
},
// set active swipeout item
_handleSwipeout: function(sectionID, rowID) {
for (var i = 0; i < rows.length; i++) {
if (i != rowID) rows[i].active = false
else rows[i].active = true
}
this._updateDataSource(rows)
},
_renderRow: function (rowData: string, sectionID: number, rowID: number) {
return <Swipeout
rowID={rowID}
close={!rowData.active}
onOpen={(sectionID, rowID) => this._handleSwipeout(sectionID, rowID)}...>
...
</Swipeout>
}
render: function() {
return (
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderRow}.../>
)
}