Skip to content

Commit bab0156

Browse files
authored
Merge pull request oblador#108 from oblador/touchable
Touchable as Prop
2 parents 960fd76 + f715db8 commit bab0156

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
File renamed without changes.

Accordion.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ export default class Accordion extends Component {
2222
PropTypes.number, // sets index of section to open
2323
]),
2424
underlayColor: PropTypes.string,
25+
touchableComponent: PropTypes.func,
26+
touchableProps: PropTypes.object,
2527
};
2628

2729
static defaultProps = {
2830
underlayColor: 'black',
31+
touchableComponent: TouchableHighlight,
2932
};
3033

3134
constructor(props) {
@@ -71,20 +74,23 @@ export default class Accordion extends Component {
7174
}
7275
});
7376

77+
const Touchable = this.props.touchableComponent;
78+
7479
return (
7580
<View {...viewProps}>
7681
{this.props.sections.map((section, key) =>
7782
<View key={key}>
78-
<TouchableHighlight
83+
<Touchable
7984
onPress={() => this._toggleSection(key)}
8085
underlayColor={this.props.underlayColor}
86+
{...this.props.touchableProps}
8187
>
8288
{this.props.renderHeader(
8389
section,
8490
key,
8591
this.state.activeSection === key
8692
)}
87-
</TouchableHighlight>
93+
</Touchable>
8894
<Collapsible
8995
collapsed={this.state.activeSection !== key}
9096
{...collapsibleProps}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import Accordion from 'react-native-collapsible/Accordion';
5252
|**`initiallyActiveSection`**|Set which index in the `sections` array is initially open. Defaults to none. |
5353
|**`activeSection`**|Control which index in the `sections` array is currently open. Defaults to none. If false, closes all sections.|
5454
|**`underlayColor`**|The color of the underlay that will show through when tapping on headers. Defaults to black. |
55+
|**`touchableComponent`**| The touchable component used in the Accordion. Defaults to `TouchableHighlight` |
56+
|**`touchableProps`**| Properties for the `touchableComponent` |
5557
|**`align`**|See `Collapsible`|
5658
|**`duration`**|See `Collapsible`|
5759
|**`easing`**|See `Collapsible`|

0 commit comments

Comments
 (0)