fix: fix drawer content padding in RTL

This commit is contained in:
Satyajit Sahoo
2021-05-14 09:06:00 +02:00
parent 2f282f1070
commit ea8ea20127
2 changed files with 14 additions and 5 deletions

View File

@@ -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,
]}

View File

@@ -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,
]}
>