Added iconContainerStyle prop to Drawer (#2825)

* Added iconContainerStyle prop to Drawer

* Updated DrawerNavigator docs

* Improved code quality

* Improved code with eslint
This commit is contained in:
Bruno 2017-10-28 12:07:17 -03:00 committed by Spencer Carli
parent e6505054bd
commit 468a8ca9be
2 changed files with 14 additions and 1 deletions

View File

@ -148,6 +148,8 @@ const styles = StyleSheet.create({
- `itemsContainerStyle` - style object for the content section
- `itemStyle` - style object for the single item, which can contain an Icon and/or a Label
- `labelStyle` - style object to overwrite `Text` style inside content section, when your label is a string
- `iconContainerStyle` - style object to overwrite `View` icon container styles.
#### Example:
```js
@ -155,6 +157,9 @@ contentOptions: {
activeTintColor: '#e91e63',
itemsContainerStyle: {
marginVertical: 0,
},
iconContainerStyle: {
opacity: 1
}
}
```

View File

@ -29,6 +29,7 @@ type Props = {
itemsContainerStyle?: ViewStyleProp,
itemStyle?: ViewStyleProp,
labelStyle?: TextStyleProp,
iconContainerStyle?: ViewStyleProp,
};
/**
@ -48,6 +49,7 @@ const DrawerNavigatorItems = ({
itemsContainerStyle,
itemStyle,
labelStyle,
iconContainerStyle,
}: Props) => (
<View style={[styles.container, itemsContainerStyle]}>
{items.map((route: NavigationRoute, index: number) => {
@ -69,7 +71,13 @@ const DrawerNavigatorItems = ({
>
<View style={[styles.item, { backgroundColor }, itemStyle]}>
{icon ? (
<View style={[styles.icon, focused ? null : styles.inactiveIcon]}>
<View
style={[
styles.icon,
focused ? null : styles.inactiveIcon,
iconContainerStyle,
]}
>
{icon}
</View>
) : null}