react-native-swipeout icon indicating copy to clipboard operation
react-native-swipeout copied to clipboard

After a cell open, how to automatically shut down another cell

Open Yohann-Chen opened this issue 8 years ago • 5 comments

image 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 avatar Jun 23 '17 03:06 Yohann-Chen

@Yohann-Chen Please check the example

https://github.com/dancormier/react-native-swipeout/blob/master/example/SwipeoutExample.js

silentcloud avatar Jun 23 '17 14:06 silentcloud

@silentcloud Thanks,I try to solved the problem. have fun:)

Yohann-Chen avatar Jun 24 '17 03:06 Yohann-Chen

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}>
          //
         //

Yohann-Chen avatar Jun 24 '17 13:06 Yohann-Chen

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

sanguineman91 avatar Dec 22 '18 07:12 sanguineman91

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))}>

oleshkevych avatar Jun 07 '19 13:06 oleshkevych