Skip to content
This repository was archived by the owner on Sep 16, 2020. It is now read-only.

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

Open
Yohann-Chen opened this issue Jun 23, 2017 · 5 comments
Open

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

Yohann-Chen opened this issue Jun 23, 2017 · 5 comments

Comments

@Yohann-Chen
Copy link

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

@silentcloud
Copy link
Collaborator

@Yohann-Chen
Copy link
Author

Yohann-Chen commented Jun 24, 2017

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

@Yohann-Chen
Copy link
Author

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

@sanguineman91
Copy link

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

@oleshkevych
Copy link

oleshkevych commented Jun 7, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants