@@ -64,9 +64,9 @@ export interface TabControllerBarProps {
64
64
*/
65
65
indicatorStyle ?: StyleProp < ViewStyle > ;
66
66
/**
67
- * Whether the indicator should be wide ( as the item)
67
+ * the indicator insets (default: Spacings.s4, set to 0 to make it wide as the item)
68
68
*/
69
- wideIndicator ?: boolean ;
69
+ indicatorInsets ?: number ;
70
70
/**
71
71
* custom label style
72
72
*/
@@ -145,7 +145,7 @@ const TabBar = (props: Props) => {
145
145
shadowStyle : propsShadowStyle ,
146
146
// minTabsForScroll,
147
147
indicatorStyle,
148
- wideIndicator ,
148
+ indicatorInsets = Spacings . s4 ,
149
149
labelStyle,
150
150
selectedLabelStyle,
151
151
labelColor,
@@ -163,7 +163,6 @@ const TabBar = (props: Props) => {
163
163
children : propsChildren
164
164
} = props ;
165
165
166
- const indicatorInset = wideIndicator ? 0 : Spacings . s4 ;
167
166
const context = useContext ( TabBarContext ) ;
168
167
// @ts -ignore // TODO: typescript
169
168
const { itemStates, items : contextItems , currentPage, targetPage, registerTabItems, selectedIndex} = context ;
@@ -322,7 +321,7 @@ const TabBar = (props: Props) => {
322
321
323
322
const selectedIndicator =
324
323
itemsWidths && itemsWidths . length > 0 ? (
325
- < Reanimated . View style = { [ styles . selectedIndicator , { marginHorizontal : indicatorInset } , indicatorStyle , _indicatorTransitionStyle ] } />
324
+ < Reanimated . View style = { [ styles . selectedIndicator , { marginHorizontal : indicatorInsets } , indicatorStyle , _indicatorTransitionStyle ] } />
326
325
) : undefined ;
327
326
328
327
const renderCodeBlock = _ . memoize ( ( ) => {
@@ -336,7 +335,7 @@ const TabBar = (props: Props) => {
336
335
nodes . push ( set ( _indicatorWidth ,
337
336
interpolate ( currentPage , {
338
337
inputRange : itemsWidths . map ( ( _v , i ) => i ) ,
339
- outputRange : itemsWidths . map ( v => v - 2 * indicatorInset )
338
+ outputRange : itemsWidths . map ( v => v - 2 * indicatorInsets )
340
339
} ) ) ) ;
341
340
342
341
nodes . push ( Reanimated . onChange ( targetPage , Reanimated . call ( [ targetPage ] , focusIndex as any ) ) ) ;
@@ -354,7 +353,7 @@ const TabBar = (props: Props) => {
354
353
} , [ shadowStyle , containerWidth , containerStyle ] ) ;
355
354
356
355
const indicatorContainerStyle = useMemo ( ( ) => {
357
- return [ styles . tabBar , { flex : spreadItems ? 1 : undefined } , ! _ . isUndefined ( height ) && { height} , { backgroundColor} ] ;
356
+ return [ styles . tabBar , spreadItems && styles . spreadItems , ! _ . isUndefined ( height ) && { height} , { backgroundColor} ] ;
358
357
} , [ height , backgroundColor ] ) ;
359
358
360
359
const scrollViewContainerStyle = useMemo ( ( ) => {
@@ -431,6 +430,9 @@ const styles = StyleSheet.create({
431
430
backgroundColor : Colors . white
432
431
}
433
432
} )
433
+ } ,
434
+ spreadItems : {
435
+ flex : 1
434
436
}
435
437
} ) ;
436
438
0 commit comments