Skip to content

Use interpolateColors instead of interpolateColor #1437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/components/tabController/TabBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
import React, {PureComponent, ReactElement} from 'react';
import {StyleSheet, /* processColor, */ TextStyle, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
import _ from 'lodash';
import Reanimated, {processColor} from 'react-native-reanimated';
import Reanimated, {interpolateColors, processColor} from 'react-native-reanimated';
import {State} from 'react-native-gesture-handler';
import {interpolateColor} from 'react-native-redash';
import {Colors, Typography, Spacings} from '../../style';
import Badge, {BadgeProps, BADGE_SIZES} from '../../components/badge';
import {TouchableOpacity} from '../../incubator';

// Unlike const interpolate = interpolateNode || _interpolate;
// interpolateColors has a different API (outputColorRange instead of outputRange)

const {cond, eq, call, block, and} = Reanimated;

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

// Animated color
const color = interpolateColor(currentPage, {
inputRange: [index - 1, index, index + 1],
outputRange: [inactiveColor, activeColor, inactiveColor]
});
let color;
if (interpolateColors) {
color = interpolateColors(currentPage, {
inputRange: [index - 1, index, index + 1],
outputColorRange: [inactiveColor, activeColor, inactiveColor]
});
} else {
color = interpolateColor(currentPage, {
inputRange: [index - 1, index, index + 1],
outputRange: [inactiveColor, activeColor, inactiveColor]
});
}

return [
labelStyle,
Expand Down