-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Header not showing #16
Comments
It seems like you should include the header in renderTabBar?
|
Hi @alexpchin no, the header shouldn't be included in the tab bar. Did you forget to add the styles? Assuming you are copying from the quick start example in the readme. const styles = StyleSheet.create({
header: {
height: HEADER_HEIGHT,
backgroundColor: '#2196f3',
justifyContent: 'center',
alignItems: 'center',
elevation: 4,
},
headerText: {
color: 'white',
fontSize: 24,
},
content: {
height: 1500,
},
}); |
Hi @PedroBern I do appreciate that this issue seems like I haven't followed the installation instructions... I promise I'm not simple ;) I am adding to an existing react-native application. Firstly, to get up and running I had to install I will investigate further and perhaps create a demo to share on CodeSandbox or something. Question - If the content of one of the tabs is shorter than the other, are the tabs meant to stick at the top? Thanks, |
FYI, a small update. The issue is when you omit the return (
<CollapsibleTabView
// headerHeight={HEADER_HEIGHT} // optional, will be computed.
navigationState={{ index, routes }}
onIndexChange={handleIndexChange}
renderHeader={renderHeader}
renderScene={renderScene}
/>
); Thanks! |
That's weird, it does not happen here. I've just commented out, I get the same behavior as before.
Do you mean the tab or the screen of the tab? If you have a tab screen smaller than the window, you can see small content example.
Perfect, if can do that I appreciate :) |
Thank you for the heads up on the small content example. So far my steps:
Interestingly, the header works fine if the value is: headerHeight={1} The line in {headerHeight > 0 && renderHeader()} If the default {renderHeader()} This will display the header, but it seems like the scrollY then stops working. Please let me know if you follow the same steps and you do not replicate what I am seeing on UPDATE When logging out the header, it seemed like the header was initially {!!headerHeight && renderHeader()} Seems to resolve. Looking into why it's initially UPDATE2 Could this be because in item: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
padding: 10,
minHeight: 48,
}, TabBar height in this package is 49, which would give -1 (48-49) ? |
It will be handled inside the package in the next release with #17. EDIT: shipped in Regardings the header height, I will check it today and come back here. |
The Add this to your fork, in the const getHeaderHeight = React.useCallback(
(event: LayoutChangeEvent) => {
const value = event.nativeEvent.layout.height - tabBarHeight;
// 250 is the header height from the example. It will log the real tabBarHeight, around 49.xx
console.log(event.nativeEvent.layout.height - 250)
.... |
@PedroBern Thanks for replying so quickly. If I do pass in the console.log(event.nativeEvent.layout.height - 250) This logs out Have you managed to replicate my initial problem, where not providing a |
I get Check out #18, at any moment the preview will be ready. Or see the code and try to implement by yourself to see if works. I don't have access to iOS simulator right now, so I couldn't tell. EDIT: see the no upfront height example EDIT: I will wait your response to merge and release it. |
Hi @PedroBern Thanks! I've just fetched #18 and the problem still occurs. I will look at a possible solution now. |
@alexpchin thanks, please if you solve share it here or open a PR :) |
Hello @PedroBern From what I can tell, I think this is working: const getHeaderHeight = React.useCallback(
(event: LayoutChangeEvent) => {
const value = event.nativeEvent.layout.height - tabBarHeight;
if (Math.round(value * 10) / 10 !== Math.round(headerHeight * 10) / 10) {
onHeaderHeightChange?.();
setHeaderHeight(Math.max(value, 0));
setTranslateY(
scrollY.interpolate({
inputRange: [0, Math.max(value, 0)],
outputRange: [0, -value],
extrapolateRight: 'clamp',
})
);
}
},
[headerHeight, onHeaderHeightChange, scrollY, tabBarHeight]
); Accompanied by: {renderHeader()} |
Of course! Already pushed to #18 |
Solved in |
👍🏻 Kudos on the library by the way. Nice work! |
Thanks :) please let me know if you find more problems |
I've just tried to implement the basic example but the header isn't displaying? I'm on:
Using:
Any ideas?
The text was updated successfully, but these errors were encountered: