Skip to content

Commit c5f8eb2

Browse files
authored
Override forceInset on DrawerItems. (react-navigation#2872)
Fixes second part of issue react-navigation#2854. `itemsContainerForceInset` takes the same object as `forceInset` on SafeAreaView. It overrides the SafeAreaView container in DrawerItems.
1 parent 313ec7a commit c5f8eb2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

docs/api/navigators/DrawerNavigator.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ const styles = StyleSheet.create({
145145
- `inactiveTintColor` - label and icon color of the inactive label
146146
- `inactiveBackgroundColor` - background color of the inactive label
147147
- `onItemPress(route)` - function to be invoked when an item is pressed
148+
- `itemsContainerForceInset` - override default forceInset on the SafeAreaView that wraps the items container component
148149
- `itemsContainerStyle` - style object for the content section
149150
- `itemStyle` - style object for the single item, which can contain an Icon and/or a Label
150151
- `labelStyle` - style object to overwrite `Text` style inside content section, when your label is a string

src/views/Drawer/DrawerNavigatorItems.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = {
2626
getLabel: (scene: DrawerScene) => ?(React.Node | string),
2727
renderIcon: (scene: DrawerScene) => ?React.Node,
2828
onItemPress: (info: DrawerItem) => void,
29+
itemsContainerForceInset?: Object,
2930
itemsContainerStyle?: ViewStyleProp,
3031
itemStyle?: ViewStyleProp,
3132
labelStyle?: TextStyleProp,
@@ -46,12 +47,13 @@ const DrawerNavigatorItems = ({
4647
getLabel,
4748
renderIcon,
4849
onItemPress,
50+
itemsContainerForceInset = { horizontal: 'never', top: 'always' },
4951
itemsContainerStyle,
5052
itemStyle,
5153
labelStyle,
5254
iconContainerStyle,
5355
}: Props) => (
54-
<SafeAreaView forceInset={{ horizontal: 'never', top: 'always' }}>
56+
<SafeAreaView forceInset={itemsContainerForceInset}>
5557
<View style={[styles.container, itemsContainerStyle]}>
5658
{items.map((route: NavigationRoute, index: number) => {
5759
const focused = activeItemKey === route.key;

0 commit comments

Comments
 (0)