Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
fix: use label color from styles if specified. closes #1175
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Jul 30, 2021
1 parent 90ff61f commit 5f6603f
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/TabBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ export default class TabBarItem<T extends Route> extends React.Component<
route,
position,
navigationState,
renderLabel: renderLabelPassed,
renderLabel: renderLabelCustom,
renderIcon,
renderBadge,
getLabelText,
getTestID,
getAccessibilityLabel,
getAccessible,
activeColor = DEFAULT_ACTIVE_COLOR,
inactiveColor = DEFAULT_INACTIVE_COLOR,
activeColor: activeColorCustom,
inactiveColor: inactiveColorCustom,
pressColor,
pressOpacity,
labelStyle,
Expand All @@ -107,6 +107,21 @@ export default class TabBarItem<T extends Route> extends React.Component<
const tabIndex = navigationState.routes.indexOf(route);
const isFocused = navigationState.index === tabIndex;

const labelColorFromStyle = StyleSheet.flatten(labelStyle || {}).color;

const activeColor =
activeColorCustom !== undefined
? activeColorCustom
: typeof labelColorFromStyle === 'string'
? labelColorFromStyle
: DEFAULT_ACTIVE_COLOR;
const inactiveColor =
inactiveColorCustom !== undefined
? inactiveColorCustom
: typeof labelColorFromStyle === 'string'
? labelColorFromStyle
: DEFAULT_INACTIVE_COLOR;

const activeOpacity = this.getActiveOpacity(
position,
navigationState.routes,
Expand Down Expand Up @@ -150,8 +165,8 @@ export default class TabBarItem<T extends Route> extends React.Component<
}

const renderLabel =
renderLabelPassed !== undefined
? renderLabelPassed
renderLabelCustom !== undefined
? renderLabelCustom
: ({ route, color }: { route: T; color: string }) => {
const labelText = getLabelText({ route });

Expand Down

0 comments on commit 5f6603f

Please sign in to comment.