react-native-smooth-swipe-list
A swipe-able ListView component modeled after the list view in the iOS Mail app.
Example
Running example
git clone git@github.com:ProvataHealth/react-native-smooth-swipe-list.git
cd react-native-smooth-swipe-list
cd Example
npm install
react-native run-ios
Installation
npm install --save react-native-smooth-swipe-list
Usage
A SwipeList
builds a ListView.DataSource
from its props.rowData
. The DataSource is primarily the views provided by rowData
wrapped by a SwipeRow
...
import SwipeList from 'react-native-smooth-swipe-list';
const ListParent = React.createClass({
propTypes: {
...
},
componentDidMount() {
this.rowData = this.props.todos.map(this.constructRowData);
},
componentWillReceiveProps(nextProps) {
...
},
constructRowData(todo) {
return {
id: todo.id,
rowView: this.getRowView(todo),
leftSubView: this.getMarkCompleteButton(),
rightSubView: this.getArchiveButton(),
style: styles.row
};
},
getRowView() {
...
},
getMarkCompleteButton() {
...
},
getArchiveButton() {
...
}
render() {
return <SwipeList rowData={this.rowData} />;
}
});
##API
###SwipeList Component
####Props
- ListView props...
rowData
- Object with the follow properties:
id
(required) - Used to identify the rowDatarowView
(required) - View to use as the row face[left/right]SubView
- View to show when swiping left or right[left/right]leftSubViewOptions
- Options to customize left and right subviews
fullWidth
- Will the view span the full width of the row (default false)closeOnClick
- Whether the row should close on a click if not followed by a valid gesture (default true)
style
- Style to apply to the row root viewprops
- Any additional props you want to be set on the SwipeRow
gestureTensionParams
- Provide to tweak the tension of gestures
threshold
- The point at which tension will begin to be applied (default subViewWidth)stretch
- How far past length the gesture can go (default 1)resistanceStrength
The resistance of the gesture past length (between 0-1, default 0.5)
scrollEnabled
Whether to allow scrolling the ListVIew (default: true)onScrollStateChange
- Hook for responding to scroll enabled (true) or disabled (false)swipeRowProps
- Props to be set on all SwipeRow
'srowStyle
- Style to apply to all rows root viewsstyle
- Style applied to the ListView
###Methods
tryCloseOpenRow()
- Close any open row
To be implemented:
openRow(rowKey)
- Opens row- *
scrollToRow(rowKey, skipAnimation)
- Scrolls to row. Optionally skip animating calloutRow(rowKey)
- Performs a shake animation on row
###SwipeRow Component
See React Native PanResponder for information about gesture events.
####Props
id
- id of the rows datastyle
- Style to apply to the row containerrowViewStyle
- Style to apply the the inner row viewgestureTensionParams
- Provide to tweak the tension of gestures
threshold
- The point at which tension will begin to be applied (default subViewWidth)stretch
- How far past length the gesture can go (default 1)resistanceStrength
The resistance of the gesture past length (between 0-1, default 0.5)
swipeEnabled
- Where the row should respond to gesturesonGestureStart
- Called on initial gesture, before 'onSwipeStart'onSwipeStart
- Called when a gesture startsonSwipeUpdate
- Called each update of the gesture after start and before endonSwipeEnd
- Called when the gesture endsonOpen
- Called when the row opensonClose
- Called when the row closesonCapture
- Called when a gesture capture happens[left/right]SubView
- View to be rendered for left / right gestures[left/right]SubViewOptions
- Option for configuring left and right sub views
fullWidth
- Will the view span the full width of the row (default false)closeOnClick
- Whether the row should close on a click if not followed by a valid gesture (default true)
startOpen
- Whether the row should start openblockChildEventsWhenOpen
- If true will capture gesture events before they reach the rowView (default: true)closeOnPropUpdate
- Whether to close the row if new props come in (default true)animateRemoveSpeed
- Speed (ms) at which to animate the row when it is removed (default: 150ms)
###Methods
close(skipAnimation)
- Close row. Optionally skip animatingopen(side, skipAnimation)
- Open row on side
. Optionally skip animating
Feature Checklist