mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 12:55:21 +08:00
Fix tab icon height on horizontal / ipad
This commit is contained in:
@@ -100,6 +100,7 @@ class TabBarBottom extends React.PureComponent {
|
|||||||
if (showIcon === false) {
|
if (showIcon === false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TabBarIcon
|
<TabBarIcon
|
||||||
position={position}
|
position={position}
|
||||||
@@ -108,7 +109,11 @@ class TabBarBottom extends React.PureComponent {
|
|||||||
inactiveTintColor={inactiveTintColor}
|
inactiveTintColor={inactiveTintColor}
|
||||||
renderIcon={renderIcon}
|
renderIcon={renderIcon}
|
||||||
scene={scene}
|
scene={scene}
|
||||||
style={showLabel && this._shouldUseHorizontalTabs() ? {} : styles.icon}
|
style={
|
||||||
|
showLabel && this._shouldUseHorizontalTabs()
|
||||||
|
? styles.horizontalIcon
|
||||||
|
: styles.icon
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -286,6 +291,9 @@ class TabBarBottom extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_HEIGHT = 49;
|
||||||
|
const COMPACT_HEIGHT = 29;
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
tabBar: {
|
tabBar: {
|
||||||
backgroundColor: '#F7F7F7', // Default background color in iOS 10
|
backgroundColor: '#F7F7F7', // Default background color in iOS 10
|
||||||
@@ -294,10 +302,10 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
},
|
},
|
||||||
tabBarCompact: {
|
tabBarCompact: {
|
||||||
height: 29,
|
height: COMPACT_HEIGHT,
|
||||||
},
|
},
|
||||||
tabBarRegular: {
|
tabBarRegular: {
|
||||||
height: 49,
|
height: DEFAULT_HEIGHT,
|
||||||
},
|
},
|
||||||
tab: {
|
tab: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -314,6 +322,9 @@ const styles = StyleSheet.create({
|
|||||||
icon: {
|
icon: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
},
|
},
|
||||||
|
horizontalIcon: {
|
||||||
|
height: Platform.isPad ? DEFAULT_HEIGHT : COMPACT_HEIGHT,
|
||||||
|
},
|
||||||
label: {
|
label: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class TabBarIcon extends React.PureComponent {
|
|||||||
inputRange,
|
inputRange,
|
||||||
outputRange: inputRange.map(i => (i === index ? 0 : 1)),
|
outputRange: inputRange.map(i => (i === index ? 0 : 1)),
|
||||||
});
|
});
|
||||||
|
|
||||||
// We render the icon twice at the same position on top of each other:
|
// We render the icon twice at the same position on top of each other:
|
||||||
// active and inactive one, so we can fade between them.
|
// active and inactive one, so we can fade between them.
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user