diff --git a/example/src/App.tsx b/example/src/App.tsx index ca9c0eef..1448666b 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -29,6 +29,7 @@ import ScrollOnHeader from './ScrollOnHeader' import ScrollableTabs from './ScrollableTabs' import Snap from './Snap' import StartOnSpecificTab from './StartOnSpecificTab' +import StretchableHeader from './StretchableHeader' import UndefinedHeaderHeight from './UndefinedHeaderHeight' import { ExampleComponentType } from './types' @@ -49,6 +50,7 @@ const EXAMPLE_COMPONENTS: ExampleComponentType[] = [ DynamicTabs, MinHeaderHeight, AnimatedHeader, + StretchableHeader, AndroidSharedPullToRefresh, HeaderOverscrollExample, ] diff --git a/example/src/StretchableHeader.tsx b/example/src/StretchableHeader.tsx new file mode 100644 index 00000000..b59aa1e7 --- /dev/null +++ b/example/src/StretchableHeader.tsx @@ -0,0 +1,65 @@ +import React from 'react' +import { StyleSheet, ImageBackground } from 'react-native' +import { useHeaderMeasurements } from 'react-native-collapsible-tab-view' +import Animated, { useAnimatedStyle } from 'react-native-reanimated' + +import ExampleComponent from './Shared/ExampleComponent' +import { ExampleComponentType } from './types' + +const title = 'Stretchable Header' +const HEADER_HEIGHT = 250 + +export const Header = () => { + const { top } = useHeaderMeasurements() + + const backgroundStyle = useAnimatedStyle(() => { + return { + transform: [ + { + translateY: Math.min(0, -top.value / 2), + }, + { + scale: Math.max(1, (HEADER_HEIGHT + top.value) / HEADER_HEIGHT), + }, + ], + } + }) + + return ( + + + + + + ) +} + +const Example: ExampleComponentType = () => { + return ( +
} allowHeaderOverscroll /> + ) +} + +const styles = StyleSheet.create({ + root: { + justifyContent: 'center', + alignItems: 'center', + height: HEADER_HEIGHT, + }, + background: { + position: 'absolute', + width: '100%', + height: '100%', + }, + image: { + width: '100%', + height: '100%', + }, +}) + +Example.title = title + +export default Example