react-native-swipeout
react-native-swipeout copied to clipboard
After a cell open, how to automatically shut down another cell
Like this, I opened the multiple cells
But I want to open a new cell later, last cell closed automatically
Looking forward to your reply
best wish
:)
@Yohann-Chen Please check the example
https://github.com/dancormier/react-native-swipeout/blob/master/example/SwipeoutExample.js
@silentcloud Thanks,I try to solved the problem. have fun:)
Sorry,I'm used FlatList,But according to the example, don't seem to close cell automatically Beacuse FlatList don't return sectionID,So I used article_id to my sectionID
These are code
render() {
var that = this;
var sectionID = Number(this.props.index)
var rowID = Number(this.props.model.article_id)
return(
<Swipeout
close={!(this.state.sectionID === sectionID && this.state.rowID === rowID)}
autoClose={true}
backgroundColor={'white'}
right={this.state.Rightbuttons}
navigate={this.props.navigate}
archive_id={this.props.archive_id}
rowID={rowID}
sectionID={sectionID}
onOpen={(sectionID,rowID) => this.setState({rowID:rowID,sectionID:sectionID})}
>
<TouchableOpacity activeOpacity={1} style={styles.contain} onPress={()=>this.jumpToStyoryView()}>
<View style={styles.leftView}>
//
//
Sorry,I'm used FlatList,But according to the example, don't seem to close cell automatically Beacuse FlatList don't return sectionID,So I used article_id to my sectionID
These are code
render() { var that = this; var sectionID = Number(this.props.index) var rowID = Number(this.props.model.article_id) return( <Swipeout close={!(this.state.sectionID === sectionID && this.state.rowID === rowID)} autoClose={true} backgroundColor={'white'} right={this.state.Rightbuttons} navigate={this.props.navigate} archive_id={this.props.archive_id} rowID={rowID} sectionID={sectionID} onOpen={(sectionID,rowID) => this.setState({rowID:rowID,sectionID:sectionID})} > <TouchableOpacity activeOpacity={1} style={styles.contain} onPress={()=>this.jumpToStyoryView()}> <View style={styles.leftView}> // //
I have the same proble, how to solve it
Instead of changing state it useful to keep the reference to the opened cell.
onSwipeOpen(ref) { // if something is already opened - close it and change the ref. if(this.swipedCardRef) this.swipedCardRef._close(); this.swipedCardRef = ref }
onSwipeClose(ref) { if (ref == this.swipedCardRef) { this.swipedCardRef = null; } }
<Swipeout ref={(component) => { this.swipedCardRef = component; }} right={swipeBtns} autoClose={isAutoClose} backgroundColor= 'transparent' disabled={isSwipeDisabled} onOpen={()=>(this.onSwipeOpen(swipedCardRef))} onClose={()=>(this.onSwipeClose(swipedCardRef))}>