mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-25 01:28:16 +00:00
Add showIcon
to tabBarOptions
so that icons can be hidden on iOS (#291)
This commit is contained in:
parent
a7002f2151
commit
546fc657d5
@ -42,6 +42,7 @@ type Props = {
|
|||||||
showLabel: boolean;
|
showLabel: boolean;
|
||||||
style: any;
|
style: any;
|
||||||
labelStyle?: any;
|
labelStyle?: any;
|
||||||
|
showIcon: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class TabBarBottom extends PureComponent<DefaultProps, Props, void> {
|
export default class TabBarBottom extends PureComponent<DefaultProps, Props, void> {
|
||||||
@ -53,6 +54,7 @@ export default class TabBarBottom extends PureComponent<DefaultProps, Props, voi
|
|||||||
inactiveTintColor: '#929292', // Default inactive tint color in iOS 10
|
inactiveTintColor: '#929292', // Default inactive tint color in iOS 10
|
||||||
inactiveBackgroundColor: 'transparent',
|
inactiveBackgroundColor: 'transparent',
|
||||||
showLabel: true,
|
showLabel: true,
|
||||||
|
showIcon: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
props: Props;
|
props: Props;
|
||||||
@ -98,7 +100,11 @@ export default class TabBarBottom extends PureComponent<DefaultProps, Props, voi
|
|||||||
activeTintColor,
|
activeTintColor,
|
||||||
inactiveTintColor,
|
inactiveTintColor,
|
||||||
renderIcon,
|
renderIcon,
|
||||||
|
showIcon,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
if (showIcon === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<TabBarIcon
|
<TabBarIcon
|
||||||
position={position}
|
position={position}
|
||||||
@ -136,9 +142,10 @@ export default class TabBarBottom extends PureComponent<DefaultProps, Props, voi
|
|||||||
inputRange,
|
inputRange,
|
||||||
outputRange,
|
outputRange,
|
||||||
});
|
});
|
||||||
|
const justifyContent = this.props.showIcon ? 'flex-end' : 'center';
|
||||||
return (
|
return (
|
||||||
<TouchableWithoutFeedback key={route.key} onPress={() => jumpToIndex(index)}>
|
<TouchableWithoutFeedback key={route.key} onPress={() => jumpToIndex(index)}>
|
||||||
<Animated.View style={[styles.tab, { backgroundColor }]}>
|
<Animated.View style={[styles.tab, { backgroundColor, justifyContent }]}>
|
||||||
{this._renderIcon(scene)}
|
{this._renderIcon(scene)}
|
||||||
{this._renderLabel(scene)}
|
{this._renderLabel(scene)}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user