Installations
npm install react-navigation-collapsible
Score
38.9
Supply Chain
52.9
Quality
68.4
Maintenance
50
Vulnerability
95.6
License
Releases
Unable to fetch releases
Developer
benevbright
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
Yes
Node Version
NPM Version
Statistics
1,164 Stars
268 Commits
93 Forks
13 Watching
6 Branches
16 Contributors
Updated on 23 Oct 2024
Languages
TypeScript (65.48%)
Java (14.45%)
Objective-C (10.47%)
JavaScript (4.35%)
Makefile (1.92%)
Ruby (1.7%)
Starlark (1.4%)
Shell (0.23%)
Total Downloads
Cumulative downloads
Total Downloads
482,680
Last day
80.6%
233
Compared to previous day
Last week
22.7%
950
Compared to previous week
Last month
-10.4%
4,376
Compared to previous month
Last year
-32.7%
52,486
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
4
react-navigation-collapsible
An extension of react-navigation that makes your header collapsible.
Try out the demo on Expo Snack
🏗 The Collapsible Tab-navigator is no longer supported due to the Android bug from react-native.
Usage
1-1. Default Header
1// Expo ONLY 2import { disableExpoTranslucentStatusBar } from 'react-navigation-collapsible'; 3 4/* Call this If you have disabled Expo's default translucent statusBar. */ 5disableExpoTranslucentStatusBar();
1import { Animated } from 'react-native'; 2import { useCollapsibleHeader } from 'react-navigation-collapsible'; 3 4const MyScreen = ({ navigation, route }) => { 5 const options = { 6 navigationOptions: { 7 headerStyle: { backgroundColor: 'green', height: 150 } /* Optional */, 8 headerBackground: <Image /> /* Optional */, 9 }, 10 config: { 11 collapsedColor: 'red' /* Optional */, 12 useNativeDriver: true /* Optional, default: true */, 13 elevation: 4 /* Optional */, 14 disableOpacity: true /* Optional, default: false */, 15 }, 16 }; 17 const { 18 onScroll /* Event handler */, 19 onScrollWithListener /* Event handler creator */, 20 containerPaddingTop /* number */, 21 scrollIndicatorInsetTop /* number */, 22 /* Animated.AnimatedValue contentOffset from scrolling */ 23 positionY /* 0.0 ~ length of scrollable component (contentOffset) 24 /* Animated.AnimatedInterpolation by scrolling */, 25 translateY /* 0.0 ~ -headerHeight */, 26 progress /* 0.0 ~ 1.0 */, 27 opacity /* 1.0 ~ 0.0 */, 28 } = useCollapsibleHeader(options); 29 30 /* in case you want to use your listener 31 const listener = ({nativeEvent}) => { 32 // I want to do something 33 }; 34 const onScroll = onScrollWithListener(listener); 35 */ 36 37 return ( 38 <Animated.FlatList 39 onScroll={onScroll} 40 contentContainerStyle={{ paddingTop: containerPaddingTop }} 41 scrollIndicatorInsets={{ top: scrollIndicatorInsetTop }} 42 /* rest of your stuff */ 43 /> 44 ); 45};
See /example/src/DefaultHeaderScreen.tsx
1-2. Sticky Header
See /example/src/StickyHeaderScreen.tsx
1-3. Background Header
See /example/src/BackgroundHeaderScreen.tsx
2. Sub Header (e.g Search Bar)
1import { Animated } from 'react-native'; 2import { 3 useCollapsibleSubHeader, 4 CollapsibleSubHeaderAnimator, 5} from 'react-navigation-collapsible'; 6 7const MySearchBar = () => ( 8 <View style={{ padding: 15, width: '100%', height: 60 }}> 9 <TextInput placeholder="search here" /> 10 </View> 11); 12 13const MyScreen = ({ navigation, route }) => { 14 const { 15 onScroll /* Event handler */, 16 containerPaddingTop /* number */, 17 scrollIndicatorInsetTop /* number */, 18 translateY, 19 } = useCollapsibleSubHeader(); 20 21 return ( 22 <> 23 <Animated.FlatList 24 onScroll={onScroll} 25 contentContainerStyle={{ paddingTop: containerPaddingTop }} 26 scrollIndicatorInsets={{ top: scrollIndicatorInsetTop }} 27 /* rest of your stuff */ 28 /> 29 {/* Wrap your component with `CollapsibleSubHeaderAnimator` */} 30 <CollapsibleSubHeaderAnimator translateY={translateY}> 31 <MySearchBar /> 32 </CollapsibleSubHeaderAnimator> 33 </> 34 ); 35};
See /example/src/SubHeaderScreen.tsx
3. Custom Header
1import { Animated } from 'react-native'; 2import { useCollapsibleHeader } from 'react-navigation-collapsible'; 3 4const MyScreen = ({ navigation, route }) => { 5 const options = { 6 navigationOptions: { 7 /* Add a custom header to 'useCollapsibleHeader' options the same way you would add it to the Stack.Screen options */ 8 header: ({ scene, previous, navigation }) => { 9 const { options } = scene.descriptor; 10 const title = 11 options.headerTitle !== undefined 12 ? options.headerTitle 13 : options.title !== undefined 14 ? options.title 15 : scene.route.name; 16 17 return ( 18 <MyHeader 19 title={title} 20 leftButton={ 21 previous ? ( 22 <MyBackButton onPress={navigation.goBack} /> 23 ) : ( 24 undefined 25 ) 26 } 27 style={options.headerStyle} 28 /> 29 ); 30 }, 31 }, 32 }; 33 const { 34 onScroll /* Event handler */, 35 containerPaddingTop /* number */, 36 scrollIndicatorInsetTop /* number */, 37 } = useCollapsibleHeader(options); 38 39 return ( 40 <Animated.FlatList 41 onScroll={onScroll} 42 contentContainerStyle={{ paddingTop: containerPaddingTop }} 43 scrollIndicatorInsets={{ top: scrollIndicatorInsetTop }} 44 /* rest of your stuff */ 45 /> 46 ); 47};
See /example/src/CustomHeaderScreen.tsx
react-navigation
recommends to use headerMode='screen'
when you use the custom header. [Set headerMode
to screen
]
Install
1# install module 2yarn add react-navigation-collapsible
Contribution
PR is welcome!
How to test changes with the example?
/example imports the library directly from the root folder, configured with babel-plugin-module-resolver.
So, just build the library with the watch
option and run the example.
1yarn tsc -w 2cd example && yarn ios
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
binaries present in source code
Details
- Warn: binary detected: example/android/gradle/wrapper/gradle-wrapper.jar:1
Reason
Found 4/29 approved changesets -- score normalized to 1
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/benevbright/react-navigation-collapsible/build.yml/main?enable=pin
- Info: 0 out of 1 GitHub-owned GitHubAction dependencies pinned
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Reason
41 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-c2jc-4fpr-4vhg
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-7gc6-qh9x-w6h8
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-mph8-6787-r8hw
- Warn: Project is vulnerable to: GHSA-7mhc-prgv-r3q4
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-4cpg-3vgw-4877
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-2j79-8pqc-r7x6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-gff7-g5r8-mg8m
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-5fg8-2547-mr8q
- Warn: Project is vulnerable to: GHSA-crh6-fp67-6883
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
Score
2.5
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More