A tabview component with collapsible header. adapted with refreshable, scrollable and touchable header
npm install react-native-tab-view-header
#### Install
react-native-tab-view-header is built upon react-native-tab-view
```
npm install react-native-tab-view-header react-native-tab-view --save
or using yarn
``
yarn add react-native-tab-view-header react-native-tab-view

`js
import React, { useState } from "react";
import { Alert, Animated, TouchableOpacity, View, Text, FlatList, Dimensions } from "react-native";
import { getStatusBarHeight } from "react-native-iphone-x-helper";
import CollapsibleTabViewHeader from "react-native-tab-view-header";
const WINDOW_HEIGHT = Dimensions.get('window').height;
const App = () => {
const [currentSlideIndex, setCurrentSlideIndex] = useState(0);
const slideData = [{
key: 'first',
title: 'First',
Wrapper: Animated.FlatList,
WrapperProps: {
data: Array(20).fill(1),
renderItem: ({ item, index }) => (
{Index: ${index}}
),
keyExtractor: (_item, index) => index
}
}, {
key: 'second',
title: 'Second',
Wrapper: Animated.FlatList,
WrapperProps: {
data: Array(40).fill(1),
renderItem: ({ item, index }) => (
{Index: ${index}}
),
keyExtractor: (_item, index) => index
}
}]
const renderHeaderScroll = () => (
data={Array(40).fill(1)}
renderItem={({ item, index }) =>
{index + ''}
}
keyExtractor={(_, i) => i}
horizontal
/>
)
return (
tabIndex={currentSlideIndex} // if you want to control the current tab index
onIndexChange={i => {
console.log('onIndexChange: ', i);
setCurrentSlideIndex(i);
}}
renderTabBar={undefined} // only provide this if you want to render your custom tab bar
renderHeader={() =>
onPress={() => {
Alert.alert('Header Clicked');
}}>
{'Click Header'}
{renderHeaderScroll()}
}
enableRefresh={false} // enable refresh control
tabBarStickyPosition={getStatusBarHeight()} // position to stop the header and tab-bar
onTabBarStickyChange={sticky => null} // callback that triggers whenever the tab-bar stick/unstick
/>
)
}
export default App;
`
| Property | Type | Description |
| ----------------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| tabSlides | Array | Array containing data pertaining to each tab slide |Function
| onIndexChange | | Called whenever the current tab index changes |Function
| renderTabBar | | Function that renders your custom tab-bar component |Function
| renderHeader | | Function that renders your custom header component |number
| tabIndex | | The default visible slide index of the tab view |number
| headerHeight | | The height of the header (Optional but speedup tabview render when provide together with tabBarHeight) |Function
| onScrollY | | Listens to the scroll offset of the tabview |number
| tabBarStickyPosition | | The position in which the tab-bar should stop |Function
| onTabBarStickyChange | | Called whenever the tab-bar stick/unstick to it position |Function
| onHeaderHeightChanged | | Called whenever the header height changes |Function
| renderLabel | | Function that renders the tab-bar label instead of the entire tab-bar |Function
| mountingPlaceholder | | Function that renders a loading view while the tab-header is been calculated |
- Add refresh control feature
- Add support for ` ` and ` `` (Currently only support FlatList, SectionList)
- Add Header Collapse snap effect
- react-native-tab-view
- @junghsuan collapsible-tabview
##### Contribution
Pull requests and contributions are welcome