Fixes several back button issues (#237)

* Disable header back button label as the feature is still wip

* Fix icon size
This commit is contained in:
Mike Grabowski 2017-02-08 19:08:06 +01:00 committed by Satyajit Sahoo
parent acc893d8e8
commit 8e8c4fb9a1
2 changed files with 29 additions and 12 deletions

View File

@ -119,16 +119,21 @@ class Header extends React.Component<void, HeaderProps, void> {
return null;
}
const tintColor = this._getHeaderTintColor(props.navigation);
const previousNavigation = addNavigationHelpers({
...props.navigation,
state: props.scenes[props.scene.index - 1].route,
});
const backButtonTitle = this._getHeaderTitle(previousNavigation);
// @todo(grabobu):
// We have implemented support for back button label (which works 100% fine),
// but when title is too long, it will overlap the <HeaderTitle />.
// We had to revert the PR implementing that because of Android issues,
// I will land it this week and re-enable that for next release.
//
// const previousNavigation = addNavigationHelpers({
// ...props.navigation,
// state: props.scenes[props.scene.index - 1].route,
// });
// const backButtonTitle = this._getHeaderTitle(previousNavigation);
return (
<HeaderBackButton
onPress={props.onNavigateBack}
tintColor={tintColor}
title={backButtonTitle}
/>
);
};

View File

@ -27,7 +27,11 @@ const HeaderBackButton = ({ onPress, title, tintColor }: Props) => (
>
<View style={styles.container}>
<Image
style={[styles.button, { tintColor }]}
style={[
styles.icon,
title && styles.iconWithTitle,
{ tintColor },
]}
source={require('./assets/back-icon.png')}
/>
{Platform.OS === 'ios' && title && (
@ -58,13 +62,16 @@ const styles = StyleSheet.create({
},
title: {
fontSize: 17,
paddingRight: 10,
},
button: Platform.OS === 'ios'
icon: Platform.OS === 'ios'
? {
height: 21,
width: 13,
margin: 10,
marginRight: 5,
height: 20,
width: 12,
marginLeft: 10,
marginRight: 22,
marginVertical: 12,
resizeMode: 'contain',
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
}
: {
@ -74,6 +81,11 @@ const styles = StyleSheet.create({
resizeMode: 'contain',
transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }],
},
iconWithTitle: Platform.OS === 'ios'
? {
marginRight: 5,
}
: {},
});
export default HeaderBackButton;