Skip to content

Commit

Permalink
Use processColor for animating colors in TabController TabBarItem (#1321
Browse files Browse the repository at this point in the history
)

* Use processColor for animating colors in TabController TabBarItem

* Fix processColor in TabController item

* lock version of reanimated

* move reanimated to devDeps
  • Loading branch information
ethanshar committed May 24, 2021
1 parent 96a5f0e commit f7dde96
Showing 1 changed file with 11 additions and 5 deletions.
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

0 comments on commit f7dde96

Please sign in to comment.