|
2 | 2 | import React, {PureComponent, ReactElement} from 'react';
|
3 | 3 | import {StyleSheet, /* processColor, */ TextStyle, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
|
4 | 4 | import _ from 'lodash';
|
5 |
| -import Reanimated, {processColor} from 'react-native-reanimated'; |
| 5 | +import Reanimated, {interpolateColors, processColor} from 'react-native-reanimated'; |
6 | 6 | import {State} from 'react-native-gesture-handler';
|
7 | 7 | import {interpolateColor} from 'react-native-redash';
|
8 | 8 | import {Colors, Typography, Spacings} from '../../style';
|
9 | 9 | import Badge, {BadgeProps, BADGE_SIZES} from '../../components/badge';
|
10 | 10 | import {TouchableOpacity} from '../../incubator';
|
11 | 11 |
|
| 12 | +// Unlike const interpolate = interpolateNode || _interpolate; |
| 13 | +// interpolateColors has a different API (outputColorRange instead of outputRange) |
| 14 | + |
12 | 15 | const {cond, eq, call, block, and} = Reanimated;
|
13 | 16 |
|
14 | 17 | const DEFAULT_LABEL_COLOR = Colors.black;
|
@@ -212,10 +215,18 @@ export default class TabBarItem extends PureComponent<Props> {
|
212 | 215 | const activeColor = !ignore ? selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR : inactiveColor;
|
213 | 216 |
|
214 | 217 | // 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 | + } |
219 | 230 |
|
220 | 231 | return [
|
221 | 232 | labelStyle,
|
|
0 commit comments