Skip to content

Commit

Permalink
fix: adjust bottom tabs sidebar for rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jun 26, 2024
1 parent 06209b9 commit 480ab04
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
22 changes: 19 additions & 3 deletions packages/bottom-tabs/src/views/BottomTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
type ParamListBase,
type TabNavigationState,
useLinkBuilder,
useLocale,
useTheme,
} from '@react-navigation/native';
import Color from 'color';
Expand Down Expand Up @@ -143,6 +144,7 @@ export function BottomTabBar({
style,
}: Props) {
const { colors } = useTheme();
const { direction } = useLocale();
const { buildHref } = useLinkBuilder();

const focusedRoute = state.routes[state.index];
Expand Down Expand Up @@ -274,6 +276,23 @@ export function BottomTabBar({
: tabBarPosition === 'right'
? styles.end
: styles.bottom,
(
Platform.OS === 'web'
? tabBarPosition === 'right'
: (direction === 'rtl' && tabBarPosition === 'left') ||
(direction !== 'rtl' && tabBarPosition === 'right')
)
? { borderLeftWidth: StyleSheet.hairlineWidth }
: (
Platform.OS === 'web'
? tabBarPosition === 'left'
: (direction === 'rtl' && tabBarPosition === 'right') ||
(direction !== 'rtl' && tabBarPosition === 'left')
)
? { borderRightWidth: StyleSheet.hairlineWidth }
: tabBarPosition === 'top'
? { borderBottomWidth: StyleSheet.hairlineWidth }
: { borderTopWidth: StyleSheet.hairlineWidth },
{
backgroundColor:
tabBarBackgroundElement != null ? 'transparent' : colors.card,
Expand Down Expand Up @@ -428,19 +447,16 @@ const styles = StyleSheet.create({
top: 0,
bottom: 0,
start: 0,
borderEndWidth: StyleSheet.hairlineWidth,
},
end: {
top: 0,
bottom: 0,
end: 0,
borderStartWidth: StyleSheet.hairlineWidth,
},
bottom: {
start: 0,
end: 0,
bottom: 0,
borderTopWidth: StyleSheet.hairlineWidth,
elevation: 8,
},
bottomContent: {
Expand Down
23 changes: 10 additions & 13 deletions packages/bottom-tabs/src/views/BottomTabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type ParamListBase,
StackActions,
type TabNavigationState,
useLocale,
} from '@react-navigation/native';
import * as React from 'react';
import { Animated, Platform, StyleSheet } from 'react-native';
Expand Down Expand Up @@ -81,6 +82,8 @@ export function BottomTabView(props: Props) {

const focusedRouteKey = state.routes[state.index].key;

const { direction } = useLocale();

/**
* List of loaded tabs, tabs will be loaded when navigated to.
*/
Expand Down Expand Up @@ -213,13 +216,13 @@ export function BottomTabView(props: Props) {

return (
<SafeAreaProviderCompat
style={
tabBarPosition === 'left'
? styles.start
: tabBarPosition === 'right'
? styles.end
: null
}
style={{
flexDirection:
(tabBarPosition === 'left' && direction === 'ltr') ||
(tabBarPosition === 'right' && direction === 'rtl')
? 'row-reverse'
: 'row',
}}
>
{tabBarPosition === 'top' ? (
<BottomTabBarHeightCallbackContext.Provider value={setTabBarHeight}>
Expand Down Expand Up @@ -331,12 +334,6 @@ export function BottomTabView(props: Props) {
}

const styles = StyleSheet.create({
start: {
flexDirection: 'row-reverse',
},
end: {
flexDirection: 'row',
},
screens: {
flex: 1,
overflow: 'hidden',
Expand Down

0 comments on commit 480ab04

Please sign in to comment.