Skip to content

TabBarItem - remove deprecated prop #1554

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 1 commit into from
Sep 13, 2021
Merged
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
3 changes: 1 addition & 2 deletions generatedTypes/src/components/tabBar/TabBarItem.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ export interface TabBarItemProps {
*/
labelStyle?: StyleProp<TextStyle>;
/**
* Badge component props to display next the item label
* Badge component's props to display next the item label
*/
badge?: BadgeProps;
badgeProps?: BadgeProps;
/**
* Pass to render a leading element
Expand Down
19 changes: 6 additions & 13 deletions src/components/tabBar/TabBarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ViewStyle,
TextStyle
} from 'react-native';
import {LogService} from '../../services';
import {Constants} from '../../helpers';
import {Colors, Typography, Spacings} from '../../style';
import {asBaseComponent} from '../../commons/new';
Expand All @@ -20,6 +19,7 @@ import Text from '../text';
import Image from '../image';
import Badge, {BadgeProps} from '../badge';


const INDICATOR_HEIGHT = 2;
const INDICATOR_BG_COLOR = Colors.primary;
const HORIZONTAL_PADDING = Constants.isTablet ? Spacings.s7 : Spacings.s5;
Expand All @@ -46,9 +46,8 @@ export interface TabBarItemProps {
*/
labelStyle?: StyleProp<TextStyle>;
/**
* Badge component props to display next the item label
* Badge component's props to display next the item label
*/
badge?: BadgeProps; //TODO: remove after deprecation
badgeProps?: BadgeProps;
/**
* Pass to render a leading element
Expand Down Expand Up @@ -131,10 +130,6 @@ class TabBarItem extends PureComponent<TabBarItemProps, State> {
indicatorOpacity: props.selected ? new Animated.Value(1) : new Animated.Value(0),
selected: props.selected
};

if (!_.isEmpty(props.badge)) {
LogService.deprecationWarn({component: 'TabBarItem', oldProp: 'badge', newProp: 'badgeProps'});
}
}

componentDidUpdate(prevProps: TabBarItemProps) {
Expand Down Expand Up @@ -193,7 +188,6 @@ class TabBarItem extends PureComponent<TabBarItemProps, State> {
label,
labelStyle,
badgeProps,
badge,
leadingAccessory,
trailingAccessory,
uppercase,
Expand All @@ -212,8 +206,7 @@ class TabBarItem extends PureComponent<TabBarItemProps, State> {
const iconTint = iconColor || this.getColorFromStyle(labelStyle) || this.getColorFromStyle(styles.label);
const iconSelectedTint =
iconSelectedColor || this.getColorFromStyle(selectedLabelStyle) || this.getColorFromStyle(styles.selectedLabel);
const badgeFinalProps = badgeProps || badge;
const badgeSize = _.get(badgeFinalProps, 'size', 16);
const badgeSize = _.get(badgeProps, 'size', 16);

return (
<TouchableOpacity
Expand Down Expand Up @@ -247,12 +240,12 @@ class TabBarItem extends PureComponent<TabBarItemProps, State> {
</Text>
)}
{children}
{!_.isNil(badgeFinalProps) && (
{!_.isNil(badgeProps) && (
<Badge
backgroundColor={Colors.red30}
{...badgeFinalProps}
{...badgeProps}
size={badgeSize}
containerStyle={[styles.badge, badgeFinalProps.containerStyle]}
containerStyle={[styles.badge, badgeProps.containerStyle]}
/>
)}
{trailingAccessory}
Expand Down