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

Set style for active/expanded?

Open andreaslindahl opened this issue 10 years ago • 8 comments

Is is possible to set different styles on the header, depending on whether the accordion is expanded or not?

Also, it is possible to only allow one accordion to be expanded at a time?

andreaslindahl avatar Oct 07 '15 13:10 andreaslindahl

Would love to know how to do this as well

abritez avatar Jul 23 '16 04:07 abritez

It would really help me as well if we could have a props returning if the accordion is opened or closed.

tsyirvo avatar Jul 24 '16 16:07 tsyirvo

I'll submit a PR shortly to have a prop for the opened and closed header ;)

tsyirvo avatar Jul 24 '16 16:07 tsyirvo

@tsyirvo Did you ever get around to submitting a PR for this? Could use this feature as well.

digitaldavenyc avatar Aug 31 '16 19:08 digitaldavenyc

Could there be a way to access the is_visible variable to determine being opened or closed?

digitaldavenyc avatar Aug 31 '16 19:08 digitaldavenyc

@digitaldavenyc I didn't submit my PR yet :/ In the meantime, you can change {this.props.header} on line 106 by this.state.is_visible ? this.props.headerOpened : this.props.headerClosed. It will allow you to have two props for the header, one when closed and one when open ;)

tsyirvo avatar Sep 05 '16 08:09 tsyirvo

@tsyirvo I'm not sure what you mean by that method? Can u elaborate on the implementation.

btw. sorry for super delayed response

digitaldavenyc avatar May 29 '17 18:05 digitaldavenyc

Change line 106 to {this.props.header({ isOpen: this.state.is_visible })}

and then you can use your component like

<Accordion
  header={({isOpen}) => <View><Text>{isOpen}</Text></View>}
  content={<View><Text>Hello World!</Text></View>}
/>

ercpereda avatar Sep 22 '17 21:09 ercpereda