Skip to content

Instantly share code, notes, and snippets.

@vovkasm
Created December 16, 2018 18:27
Show Gist options
  • Save vovkasm/581acd1da1b2426f103d72ff147e807e to your computer and use it in GitHub Desktop.
Save vovkasm/581acd1da1b2426f103d72ff147e807e to your computer and use it in GitHub Desktop.
Defer content of screen until screen will be shown.
const s = StyleSheet.create({
content: {
flex: 1,
},
screen: {
backgroundColor: theme.bgColor2,
},
})
@observer
export class MainScreen extends React.Component<IProps> {
@observable
private toolBarHeight: number = 0
render() {
return (
<Screen style={s.screen}>
<NavigationHeaderBase
border
centered
leftElement={this.renderAvatar()}
rightElement={<View />}
title={this.props.headerTitle}
/>
<View style={s.content}>{this.toolBarHeight > 0 ? this.props.children : null}</View>
<ToolBar activeItem={this.props.tabActive} onLayout={this.onToolBarLayout} />
</Screen>
)
}
private onToolBarLayout = (layout: LayoutRectangle) => {
if (layout.height !== this.toolBarHeight) {
this.toolBarHeight = layout.height
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment