Skip to content

Commit a701866

Browse files
chore(nav): moved tab width to variabl
1 parent b6ae257 commit a701866

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/navigation/tabs/primary-tabs/PrimaryTabs.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {useCallback, useEffect, useState} from 'react';
2-
import {View, type ViewProps, type StyleProp, type ViewStyle, type TextStyle, type LayoutChangeEvent} from 'react-native';
2+
import {View, type ViewProps, type DimensionValue, type StyleProp, type ViewStyle, type TextStyle, type LayoutChangeEvent} from 'react-native';
33
import Animated, {useSharedValue, type WithSpringConfig, Extrapolation, withSpring, useAnimatedStyle, interpolate} from 'react-native-reanimated';
44

55
import {type Tab} from '../tab.type';
@@ -52,6 +52,7 @@ export const PrimaryTabs = <T extends string, Y extends IconProps>({
5252

5353
const {primary, outlineVariant} = useTheme();
5454

55+
const tabWidth: DimensionValue = `${100 / tabs.length}%`;
5556
const activeTabIndex = tabs.findIndex((tab) => tab.routeName === activeTab);
5657

5758
const calcStartIndicatorPosition = useCallback((totalTabsCount: number, targetTabIndex: number) => {
@@ -129,7 +130,7 @@ export const PrimaryTabs = <T extends string, Y extends IconProps>({
129130
return (
130131
<View style={[styles.container, {borderBottomColor: outlineVariant}]} {...props}>
131132
<View style={[styles.tabs, tabsContainerStyle]}>{tabs.map(renderTab)}</View>
132-
<Animated.View style={[styles.indicatorContainer, {width: `${100 / tabs.length}%`}, indicatorContainerAnimatedStyle]}>
133+
<Animated.View style={[styles.indicatorContainer, {width: tabWidth}, indicatorContainerAnimatedStyle]}>
133134
<Animated.View
134135
style={[
135136
styles.indicator,

0 commit comments

Comments
 (0)