Skip to content

Commit d5fc3e3

Browse files
authored
Use interpolateColors instead of interpolateColor (#1437)
1 parent da754ec commit d5fc3e3

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/components/tabController/TabBarItem.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
import React, {PureComponent, ReactElement} from 'react';
33
import {StyleSheet, /* processColor, */ TextStyle, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
44
import _ from 'lodash';
5-
import Reanimated, {processColor} from 'react-native-reanimated';
5+
import Reanimated, {interpolateColors, processColor} from 'react-native-reanimated';
66
import {State} from 'react-native-gesture-handler';
77
import {interpolateColor} from 'react-native-redash';
88
import {Colors, Typography, Spacings} from '../../style';
99
import Badge, {BadgeProps, BADGE_SIZES} from '../../components/badge';
1010
import {TouchableOpacity} from '../../incubator';
1111

12+
// Unlike const interpolate = interpolateNode || _interpolate;
13+
// interpolateColors has a different API (outputColorRange instead of outputRange)
14+
1215
const {cond, eq, call, block, and} = Reanimated;
1316

1417
const DEFAULT_LABEL_COLOR = Colors.black;
@@ -212,10 +215,18 @@ export default class TabBarItem extends PureComponent<Props> {
212215
const activeColor = !ignore ? selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR : inactiveColor;
213216

214217
// Animated color
215-
const color = interpolateColor(currentPage, {
216-
inputRange: [index - 1, index, index + 1],
217-
outputRange: [inactiveColor, activeColor, inactiveColor]
218-
});
218+
let color;
219+
if (interpolateColors) {
220+
color = interpolateColors(currentPage, {
221+
inputRange: [index - 1, index, index + 1],
222+
outputColorRange: [inactiveColor, activeColor, inactiveColor]
223+
});
224+
} else {
225+
color = interpolateColor(currentPage, {
226+
inputRange: [index - 1, index, index + 1],
227+
outputRange: [inactiveColor, activeColor, inactiveColor]
228+
});
229+
}
219230

220231
return [
221232
labelStyle,

0 commit comments

Comments
 (0)