Skip to content
This repository has been archived by the owner on Feb 15, 2019. It is now read-only.

Accept 2 new props for DrawerItems (disabled, handlesDrawerToggle) #220

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.exponent
lib/
.idea
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ const styles = StyleSheet.create({
});
```

See [ExNavigationDrawerLayout](https://github.com/exponentjs/ex-navigation/blob/master/src/drawer/ExNavigationDrawerLayout.js)
to discover which props you can pass to `DrawerNavigationItem`.

### Integrate with your existing Redux store

Expand Down
21 changes: 14 additions & 7 deletions src/drawer/ExNavigationDrawerLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ export default class ExNavigationDrawerLayout extends React.Component {
}

return this.props.items.map((item, index) => {
let { renderIcon, renderTitle, renderRight } = item;
let { renderIcon, renderTitle, renderRight, disabled } = item;
let isSelected = this.props.selectedItem === item.id;
const icon = renderIcon && renderIcon(isSelected);
const title = renderTitle && renderTitle(isSelected);
const rightElement = renderRight && renderRight(isSelected);
const icon = renderIcon && renderIcon(isSelected, disabled);
const title = renderTitle && renderTitle(isSelected, disabled);
const rightElement = renderRight && renderRight(isSelected, disabled);

if (item.showsTouches !== false) {
if (item.showsTouches !== false && !disabled) {
return (
<TouchableNativeFeedbackSafe
key={index}
Expand All @@ -108,6 +108,7 @@ export default class ExNavigationDrawerLayout extends React.Component {
return (
<TouchableWithoutFeedback
key={index}
disabled={disabled}
onPress={() => { this._handlePress(item); }}
onLongPress={() => { this._handleLongPress(item); }}>
<View style={[styles.buttonContainer, isSelected ? item.selectedStyle : item.style]}>
Expand All @@ -132,7 +133,10 @@ export default class ExNavigationDrawerLayout extends React.Component {
//
_handlePress = (item: any) => {
item.onPress();
this._component.closeDrawer();

if (!item.handlesDrawerToggle) {
this._component.closeDrawer();
}
}

_handleLongPress = (item: any) => {
Expand All @@ -141,7 +145,10 @@ export default class ExNavigationDrawerLayout extends React.Component {
}

item.onLongPress();
this._component.closeDrawer();

if (!item.handlesDrawerToggle) {
this._component.closeDrawer();
}
}
}

Expand Down