Skip to content

Instantly share code, notes, and snippets.

@bogoslavskiy
Created July 8, 2018 21:12
Show Gist options
  • Save bogoslavskiy/fcb618ecd1f4e52beeeaeaff07231192 to your computer and use it in GitHub Desktop.
Save bogoslavskiy/fcb618ecd1f4e52beeeaeaff07231192 to your computer and use it in GitHub Desktop.
[...]
_renderHeader = (animation, canJumpToTab) => props => (
<SearchBar
animation={animation}
changeInputFocus={suggestionFocus =>
this.setState({suggestionFocus})
}
renderTabBar={() => (
<TabBar
onTabPress={({route}) => {
if(route.key != this.state.currentTab && canJumpToTab) {
animation.onTabPress(route);
}
}}
getLabelText={this._getLabelText}
indicatorStyle={styles.indicator}
style={styles.tabbar}
labelStyle={styles.label}
{...props}
/>
)}
/>
);
[...]
render() {
return (
<SearchBarProvider currentTab={this.state.currentTab}>
{(animation, { canJumpToTab }) =>
<View style={initialLayout}>
<TabView
style={styles.container}
navigationState={this.state}
renderScene={this._renderScene}
renderTabBar={this._renderHeader(animation, canJumpToTab)}
onIndexChange={this._handleIndexChange}
initialLayout={initialLayout}
swipeEnabled={false} // TODO ...
canJumpToTab={() => canJumpToTab}
useNativeDriver
/>
{this._renderSuggestion(animation)}
</View>
}
</SearchBarProvider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment