Fix tab icon height on horizontal / ipad

This commit is contained in:
Brent Vatne
2018-03-12 11:10:00 -07:00
parent 1d573bc246
commit 315e43701b
2 changed files with 15 additions and 3 deletions

View File

@@ -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',

View File

@@ -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 (