mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-24 17:18:09 +00:00
Add custom style for DrawerItem (#2764)
* Add custom style of DrawerItem * Update itemStyle to DrawerNavigator doc * rename style to itemsContainerStyle [BREAKING CHANGE] * update * update * fix issue comma * update DrawerNavigator-test
This commit is contained in:
parent
4df002daab
commit
3a63950ec8
@ -145,15 +145,15 @@ const styles = StyleSheet.create({
|
||||
- `inactiveTintColor` - label and icon color of the inactive label
|
||||
- `inactiveBackgroundColor` - background color of the inactive label
|
||||
- `onItemPress(route)` - function to be invoked when an item is pressed
|
||||
- `style` - style object for the content section
|
||||
- `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
|
||||
|
||||
#### Example:
|
||||
|
||||
```js
|
||||
contentOptions: {
|
||||
activeTintColor: '#e91e63',
|
||||
style: {
|
||||
itemsContainerStyle: {
|
||||
marginVertical: 0,
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ exports[`DrawerNavigator renders successfully 1`] = `
|
||||
Object {
|
||||
"backgroundColor": "rgba(0, 0, 0, .04)",
|
||||
},
|
||||
undefined,
|
||||
]
|
||||
}
|
||||
>
|
||||
|
@ -26,7 +26,8 @@ type Props = {
|
||||
getLabel: (scene: DrawerScene) => ?(React.Element<*> | string),
|
||||
renderIcon: (scene: DrawerScene) => ?React.Element<*>,
|
||||
onItemPress: (info: DrawerItem) => void,
|
||||
style?: ViewStyleProp,
|
||||
itemsContainerStyle?: ViewStyleProp,
|
||||
itemStyle?: ViewStyleProp,
|
||||
labelStyle?: TextStyleProp,
|
||||
};
|
||||
|
||||
@ -44,10 +45,11 @@ const DrawerNavigatorItems = ({
|
||||
getLabel,
|
||||
renderIcon,
|
||||
onItemPress,
|
||||
style,
|
||||
itemsContainerStyle,
|
||||
itemStyle,
|
||||
labelStyle,
|
||||
}: Props) => (
|
||||
<View style={[styles.container, style]}>
|
||||
<View style={[styles.container, itemsContainerStyle]}>
|
||||
{items.map((route: NavigationRoute, index: number) => {
|
||||
const focused = activeItemKey === route.key;
|
||||
const color = focused ? activeTintColor : inactiveTintColor;
|
||||
@ -65,7 +67,7 @@ const DrawerNavigatorItems = ({
|
||||
}}
|
||||
delayPressIn={0}
|
||||
>
|
||||
<View style={[styles.item, { backgroundColor }]}>
|
||||
<View style={[styles.item, { backgroundColor }, itemStyle]}>
|
||||
{icon ? (
|
||||
<View style={[styles.icon, focused ? null : styles.inactiveIcon]}>
|
||||
{icon}
|
||||
|
Loading…
x
Reference in New Issue
Block a user