Skip to content

Commit f7dde96

Browse files
committed
Use processColor for animating colors in TabController TabBarItem (#1321)
* Use processColor for animating colors in TabController TabBarItem * Fix processColor in TabController item * lock version of reanimated * move reanimated to devDeps
1 parent 96a5f0e commit f7dde96

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/components/tabController/TabBarItem.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, {PureComponent} from 'react';
33
import {StyleSheet, /* processColor, */ TextStyle, LayoutChangeEvent, StyleProp, ViewStyle} from 'react-native';
44
import _ from 'lodash';
5-
import Reanimated from 'react-native-reanimated';
5+
import Reanimated, {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';
@@ -228,12 +228,18 @@ export default class TabBarItem extends PureComponent<Props> {
228228
getIconStyle() {
229229
const {index, currentPage, iconColor, selectedIconColor, labelColor, selectedLabelColor, ignore} = this.props;
230230

231-
const activeColor = selectedIconColor || selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR;
232-
const inactiveColor = iconColor || labelColor || DEFAULT_LABEL_COLOR;
231+
let activeColor = selectedIconColor || selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR;
232+
let inactiveColor = iconColor || labelColor || DEFAULT_LABEL_COLOR;
233+
234+
// TODO: Don't condition this once migrating completely to reanimated v2
235+
if (processColor) {
236+
// @ts-ignore
237+
activeColor = processColor(activeColor);
238+
// @ts-ignore
239+
inactiveColor = processColor(inactiveColor);
240+
}
233241

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

0 commit comments

Comments
 (0)