File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import ScrollOnHeader from './ScrollOnHeader'
2929import ScrollableTabs from './ScrollableTabs'
3030import Snap from './Snap'
3131import StartOnSpecificTab from './StartOnSpecificTab'
32+ import StretchableHeader from './StretchableHeader'
3233import UndefinedHeaderHeight from './UndefinedHeaderHeight'
3334import { ExampleComponentType } from './types'
3435
@@ -49,6 +50,7 @@ const EXAMPLE_COMPONENTS: ExampleComponentType[] = [
4950 DynamicTabs ,
5051 MinHeaderHeight ,
5152 AnimatedHeader ,
53+ StretchableHeader ,
5254 AndroidSharedPullToRefresh ,
5355 HeaderOverscrollExample ,
5456]
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { StyleSheet , ImageBackground } from 'react-native'
3+ import { useHeaderMeasurements } from 'react-native-collapsible-tab-view'
4+ import Animated , { useAnimatedStyle } from 'react-native-reanimated'
5+
6+ import ExampleComponent from './Shared/ExampleComponent'
7+ import { ExampleComponentType } from './types'
8+
9+ const title = 'Stretchable Header'
10+
11+ export const Header = ( ) => {
12+ const { top } = useHeaderMeasurements ( )
13+
14+ const backgroundStyle = useAnimatedStyle ( ( ) => {
15+ return {
16+ transform : [
17+ {
18+ translateY : Math . min ( 0 , - top . value / 2 ) ,
19+ } ,
20+ {
21+ scale : Math . max ( 1 , ( 250 + top . value ) / 250 ) ,
22+ } ,
23+ ] ,
24+ }
25+ } )
26+
27+ return (
28+ < Animated . View style = { [ styles . root ] } pointerEvents = "none" >
29+ < Animated . View style = { [ styles . background , backgroundStyle ] } >
30+ < ImageBackground
31+ style = { styles . image }
32+ source = { require ( '../assets/album-art-2.jpg' ) }
33+ />
34+ </ Animated . View >
35+ </ Animated . View >
36+ )
37+ }
38+
39+ const Example : ExampleComponentType = ( ) => {
40+ return (
41+ < ExampleComponent renderHeader = { ( ) => < Header /> } allowHeaderOverscroll />
42+ )
43+ }
44+
45+ const styles = StyleSheet . create ( {
46+ root : {
47+ justifyContent : 'center' ,
48+ alignItems : 'center' ,
49+ height : 250 ,
50+ } ,
51+ background : {
52+ position : 'absolute' ,
53+ width : '100%' ,
54+ height : '100%' ,
55+ } ,
56+ image : {
57+ width : '100%' ,
58+ height : '100%' ,
59+ } ,
60+ } )
61+
62+ Example . title = title
63+
64+ export default Example
You can’t perform that action at this time.
0 commit comments