Skip to content

Commit 468a8ca

Browse files
brunocasciospencercarli
authored andcommitted
Added iconContainerStyle prop to Drawer (react-navigation#2825)
* Added iconContainerStyle prop to Drawer * Updated DrawerNavigator docs * Improved code quality * Improved code with eslint
1 parent e650505 commit 468a8ca

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docs/api/navigators/DrawerNavigator.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,18 @@ const styles = StyleSheet.create({
148148
- `itemsContainerStyle` - style object for the content section
149149
- `itemStyle` - style object for the single item, which can contain an Icon and/or a Label
150150
- `labelStyle` - style object to overwrite `Text` style inside content section, when your label is a string
151+
- `iconContainerStyle` - style object to overwrite `View` icon container styles.
152+
151153
#### Example:
152154

153155
```js
154156
contentOptions: {
155157
activeTintColor: '#e91e63',
156158
itemsContainerStyle: {
157159
marginVertical: 0,
160+
},
161+
iconContainerStyle: {
162+
opacity: 1
158163
}
159164
}
160165
```

src/views/Drawer/DrawerNavigatorItems.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Props = {
2929
itemsContainerStyle?: ViewStyleProp,
3030
itemStyle?: ViewStyleProp,
3131
labelStyle?: TextStyleProp,
32+
iconContainerStyle?: ViewStyleProp,
3233
};
3334

3435
/**
@@ -48,6 +49,7 @@ const DrawerNavigatorItems = ({
4849
itemsContainerStyle,
4950
itemStyle,
5051
labelStyle,
52+
iconContainerStyle,
5153
}: Props) => (
5254
<View style={[styles.container, itemsContainerStyle]}>
5355
{items.map((route: NavigationRoute, index: number) => {
@@ -69,7 +71,13 @@ const DrawerNavigatorItems = ({
6971
>
7072
<View style={[styles.item, { backgroundColor }, itemStyle]}>
7173
{icon ? (
72-
<View style={[styles.icon, focused ? null : styles.inactiveIcon]}>
74+
<View
75+
style={[
76+
styles.icon,
77+
focused ? null : styles.inactiveIcon,
78+
iconContainerStyle,
79+
]}
80+
>
7381
{icon}
7482
</View>
7583
) : null}

0 commit comments

Comments
 (0)