Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/tabController/PageCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Reanimated, {
} from 'react-native-reanimated';
import {Constants} from '../../commons/new';

const FIX_RTL = Constants.isRTL && Constants.isAndroid;
const FIX_RTL = Constants.isRTL;

/**
* @description: TabController's Page Carousel
Expand Down
3 changes: 1 addition & 2 deletions src/components/tabController/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {FaderProps} from '../fader';
import useScrollToItem from './useScrollToItem';
import {useDidUpdate} from 'hooks';

const FIX_RTL = Constants.isRTL && Constants.isAndroid;
const DEFAULT_HEIGHT = 48;

const DEFAULT_LABEL_STYLE = {
Expand Down Expand Up @@ -187,7 +186,7 @@ const TabBar = (props: Props) => {
// @ts-expect-error TODO: typing bug
scrollViewRef: tabBar,
itemsCount,
selectedIndex: FIX_RTL ? itemsCount - currentPage.value - 1 : currentPage.value,
selectedIndex: currentPage.value,
containerWidth,
offsetType: centerSelected ? useScrollToItem.offsetType.CENTER : useScrollToItem.offsetType.DYNAMIC
});
Expand Down
10 changes: 7 additions & 3 deletions src/components/tabController/useScrollToItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {useState, useCallback, useEffect, useRef, RefObject} from 'react';
import {LayoutChangeEvent} from 'react-native';
import {useSharedValue} from 'react-native-reanimated';
import {useScrollTo, ScrollToSupportedViews, ScrollToResultProps} from 'hooks';
import {Constants} from '../../commons/new';

const FIX_RTL = Constants.isRTL && Constants.isIOS;

export enum OffsetType {
CENTER = 'CENTER',
Expand Down Expand Up @@ -177,12 +180,13 @@ const useScrollToItem = <T extends ScrollToSupportedViews>(props: ScrollToItemPr

const focusIndex = useCallback((index: number, animated = true) => {
if (index >= 0 && offsets.CENTER.length > index) {
const rtlIndex = FIX_RTL ? itemsCount - index - 1 : index;
if (offsetType !== OffsetType.DYNAMIC) {
scrollTo(offsets[offsetType][index], animated);
scrollTo(offsets[offsetType][rtlIndex], animated);
} else {
const movingLeft = index < currentIndex.current;
currentIndex.current = index;
scrollTo(movingLeft ? offsets[OffsetType.RIGHT][index] : offsets[OffsetType.LEFT][index], animated);
currentIndex.current = rtlIndex;
scrollTo(movingLeft ? offsets[OffsetType.RIGHT][rtlIndex] : offsets[OffsetType.LEFT][rtlIndex], animated);
}
}
},
Expand Down