Skip to content

Use processColor for animating colors in TabController TabBarItem #1321

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 4 commits into from
May 24, 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
16 changes: 11 additions & 5 deletions src/components/tabController/TabBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, {PureComponent} from 'react';
import {StyleSheet, /* processColor, */ TextStyle, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
import _ from 'lodash';
import Reanimated from 'react-native-reanimated';
import Reanimated, {processColor} from 'react-native-reanimated';
import {State} from 'react-native-gesture-handler';
import {interpolateColor} from 'react-native-redash';
import {Colors, Typography, Spacings} from '../../style';
Expand Down Expand Up @@ -228,12 +228,18 @@ export default class TabBarItem extends PureComponent<Props> {
getIconStyle() {
const {index, currentPage, iconColor, selectedIconColor, labelColor, selectedLabelColor, ignore} = this.props;

const activeColor = selectedIconColor || selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR;
const inactiveColor = iconColor || labelColor || DEFAULT_LABEL_COLOR;
let activeColor = selectedIconColor || selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR;
let inactiveColor = iconColor || labelColor || DEFAULT_LABEL_COLOR;

// TODO: Don't condition this once migrating completely to reanimated v2
if (processColor) {
// @ts-ignore
activeColor = processColor(activeColor);
// @ts-ignore
inactiveColor = processColor(inactiveColor);
}

const tintColor = cond(eq(currentPage, index),
// TODO: using processColor here broke functionality,
// not using it seem to not be very performant
activeColor,
ignore ? activeColor : inactiveColor);

Expand Down