mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
fix: fix drawer content padding in RTL
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import { ScrollView, StyleSheet, ScrollViewProps } from 'react-native';
|
||||
import {
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
ScrollViewProps,
|
||||
I18nManager,
|
||||
} from 'react-native';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import DrawerPositionContext from '../utils/DrawerPositionContext';
|
||||
|
||||
@@ -16,14 +21,18 @@ export default function DrawerContentScrollView({
|
||||
const drawerPosition = React.useContext(DrawerPositionContext);
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
const isRight = I18nManager.isRTL
|
||||
? drawerPosition === 'left'
|
||||
: drawerPosition === 'right';
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
{...rest}
|
||||
contentContainerStyle={[
|
||||
{
|
||||
paddingTop: insets.top + 4,
|
||||
paddingLeft: drawerPosition === 'left' ? insets.left : 0,
|
||||
paddingRight: drawerPosition === 'right' ? insets.right : 0,
|
||||
paddingStart: !isRight ? insets.left : 0,
|
||||
paddingEnd: isRight ? insets.right : 0,
|
||||
},
|
||||
contentContainerStyle,
|
||||
]}
|
||||
|
||||
@@ -214,7 +214,7 @@ export default function Header(props: Props) {
|
||||
style={[
|
||||
styles.left,
|
||||
headerTitleAlign === 'center' && styles.expand,
|
||||
{ marginLeft: insets.left },
|
||||
{ marginStart: insets.left },
|
||||
leftContainerStyle,
|
||||
]}
|
||||
>
|
||||
@@ -236,7 +236,7 @@ export default function Header(props: Props) {
|
||||
style={[
|
||||
styles.right,
|
||||
styles.expand,
|
||||
{ marginRight: insets.right },
|
||||
{ marginEnd: insets.right },
|
||||
rightContainerStyle,
|
||||
]}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user