|
1 | 1 | 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'; |
3 | 3 | import Animated, {useSharedValue, type WithSpringConfig, Extrapolation, withSpring, useAnimatedStyle, interpolate} from 'react-native-reanimated'; |
4 | 4 |
|
5 | 5 | import {type Tab} from '../tab.type'; |
@@ -52,6 +52,7 @@ export const PrimaryTabs = <T extends string, Y extends IconProps>({ |
52 | 52 |
|
53 | 53 | const {primary, outlineVariant} = useTheme(); |
54 | 54 |
|
| 55 | + const tabWidth: DimensionValue = `${100 / tabs.length}%`; |
55 | 56 | const activeTabIndex = tabs.findIndex((tab) => tab.routeName === activeTab); |
56 | 57 |
|
57 | 58 | const calcStartIndicatorPosition = useCallback((totalTabsCount: number, targetTabIndex: number) => { |
@@ -129,7 +130,7 @@ export const PrimaryTabs = <T extends string, Y extends IconProps>({ |
129 | 130 | return ( |
130 | 131 | <View style={[styles.container, {borderBottomColor: outlineVariant}]} {...props}> |
131 | 132 | <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]}> |
133 | 134 | <Animated.View |
134 | 135 | style={[ |
135 | 136 | styles.indicator, |
|
0 commit comments