Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

feat: pass current opacity to renderIcon prop in CrossFadeIcon #220

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export type BottomTabBarProps = BottomTabBarOptions & {
renderIcon: (props: {
route: NavigationRoute;
focused: boolean;
currentOpacity: number;
tintColor?: string;
horizontal?: boolean;
}) => React.ReactNode;
Expand Down Expand Up @@ -211,6 +212,7 @@ export type NavigationCommonTabOptions = {
| React.ReactNode
| ((props: {
focused: boolean;
currentOpacity?: number;
tintColor?: string;
horizontal?: boolean;
}) => React.ReactNode);
Expand Down
9 changes: 8 additions & 1 deletion src/utils/createTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ExtraProps<Config extends {}> = {
export type RenderIconProps = {
route: NavigationRoute;
focused: boolean;
currentOpacity?: number;
tintColor?: string;
horizontal?: boolean;
};
Expand Down Expand Up @@ -75,6 +76,7 @@ export default function createTabNavigator<
_renderIcon = ({
route,
focused,
currentOpacity,
tintColor,
horizontal = false,
}: RenderIconProps) => {
Expand All @@ -84,7 +86,12 @@ export default function createTabNavigator<

if (options.tabBarIcon) {
return typeof options.tabBarIcon === 'function'
? options.tabBarIcon({ focused, tintColor, horizontal })
? options.tabBarIcon({
focused,
tintColor,
currentOpacity,
horizontal,
})
: options.tabBarIcon;
}

Expand Down
3 changes: 3 additions & 0 deletions src/views/CrossFadeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Props = {
renderIcon: (props: {
route: NavigationRoute;
focused: boolean;
currentOpacity: number;
tintColor?: string;
horizontal?: boolean;
}) => React.ReactNode;
Expand Down Expand Up @@ -40,6 +41,7 @@ export default class TabBarIcon extends React.Component<Props> {
{renderIcon({
route,
focused: true,
currentOpacity: activeOpacity,
horizontal,
tintColor: activeTintColor,
})}
Expand All @@ -48,6 +50,7 @@ export default class TabBarIcon extends React.Component<Props> {
{renderIcon({
route,
focused: false,
currentOpacity: inactiveOpacity,
horizontal,
tintColor: inactiveTintColor,
})}
Expand Down