mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-11 22:33:32 +08:00
Use Header.HEIGHT instead of measuring to avoid flicker (#3940)
This commit is contained in:
@@ -77,7 +77,6 @@ exports[`StackNavigator applies correct values when headerRight is present 1`] =
|
||||
</View>
|
||||
<View
|
||||
collapsable={undefined}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"transform": Array [
|
||||
@@ -278,7 +277,6 @@ exports[`StackNavigator renders successfully 1`] = `
|
||||
</View>
|
||||
<View
|
||||
collapsable={undefined}
|
||||
onLayout={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"transform": Array [
|
||||
|
||||
@@ -47,12 +47,6 @@ class Header extends React.PureComponent {
|
||||
widths: {},
|
||||
};
|
||||
|
||||
_handleOnLayout = e => {
|
||||
if (typeof this.props.onLayout === 'function') {
|
||||
this.props.onLayout(e.nativeEvent.layout);
|
||||
}
|
||||
};
|
||||
|
||||
_getHeaderTitleString(scene) {
|
||||
const options = scene.descriptor.options;
|
||||
if (typeof options.headerTitle === 'string') {
|
||||
@@ -494,10 +488,7 @@ class Header extends React.PureComponent {
|
||||
const forceInset = headerForceInset || { top: 'always', bottom: 'never' };
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
style={this.props.layoutInterpolator(this.props)}
|
||||
onLayout={this._handleOnLayout}
|
||||
>
|
||||
<Animated.View style={this.props.layoutInterpolator(this.props)}>
|
||||
<SafeAreaView forceInset={forceInset} style={containerStyles}>
|
||||
<View style={StyleSheet.absoluteFill}>
|
||||
{options.headerBackground}
|
||||
|
||||
@@ -94,11 +94,7 @@ class StackViewLayout extends React.Component {
|
||||
}
|
||||
|
||||
// Handle the case where the header option is a function, and provide the default
|
||||
const renderHeader =
|
||||
header ||
|
||||
(props => (
|
||||
<Header onLayout={layout => (this._headerLayout = layout)} {...props} />
|
||||
));
|
||||
const renderHeader = header || (props => <Header {...props} />);
|
||||
|
||||
const {
|
||||
headerLeftInterpolator,
|
||||
@@ -453,8 +449,8 @@ class StackViewLayout extends React.Component {
|
||||
const hasHeader = options.header !== null;
|
||||
const headerMode = this._getHeaderMode();
|
||||
let marginTop = 0;
|
||||
if (!hasHeader && headerMode === 'float' && this._headerLayout) {
|
||||
marginTop = -this._headerLayout.height;
|
||||
if (!hasHeader && headerMode === 'float') {
|
||||
marginTop = -Header.HEIGHT;
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user