diff options
| author | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-03-25 15:32:20 +0000 |
|---|---|---|
| committer | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-03-25 15:32:20 +0000 |
| commit | 7809ccbba56be8c5377f94cf2d287a0e1521fdc1 (patch) | |
| tree | 1c590049df5546f141eeb3bf58ad5ea9d1e0fbf6 /components/parallax-scroll-view.tsx | |
| parent | d071a19fdeb0fc369e356004118f59a7fe4fed91 (diff) | |
Initial commit: App Oficina base project
Diffstat (limited to 'components/parallax-scroll-view.tsx')
| -rw-r--r-- | components/parallax-scroll-view.tsx | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/components/parallax-scroll-view.tsx b/components/parallax-scroll-view.tsx deleted file mode 100644 index 6f674a7..0000000 --- a/components/parallax-scroll-view.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import type { PropsWithChildren, ReactElement } from 'react'; -import { StyleSheet } from 'react-native'; -import Animated, { - interpolate, - useAnimatedRef, - useAnimatedStyle, - useScrollOffset, -} from 'react-native-reanimated'; - -import { ThemedView } from '@/components/themed-view'; -import { useColorScheme } from '@/hooks/use-color-scheme'; -import { useThemeColor } from '@/hooks/use-theme-color'; - -const HEADER_HEIGHT = 250; - -type Props = PropsWithChildren<{ - headerImage: ReactElement; - headerBackgroundColor: { dark: string; light: string }; -}>; - -export default function ParallaxScrollView({ - children, - headerImage, - headerBackgroundColor, -}: Props) { - const backgroundColor = useThemeColor({}, 'background'); - const colorScheme = useColorScheme() ?? 'light'; - const scrollRef = useAnimatedRef<Animated.ScrollView>(); - const scrollOffset = useScrollOffset(scrollRef); - const headerAnimatedStyle = useAnimatedStyle(() => { - return { - transform: [ - { - translateY: interpolate( - scrollOffset.value, - [-HEADER_HEIGHT, 0, HEADER_HEIGHT], - [-HEADER_HEIGHT / 2, 0, HEADER_HEIGHT * 0.75] - ), - }, - { - scale: interpolate(scrollOffset.value, [-HEADER_HEIGHT, 0, HEADER_HEIGHT], [2, 1, 1]), - }, - ], - }; - }); - - return ( - <Animated.ScrollView - ref={scrollRef} - style={{ backgroundColor, flex: 1 }} - scrollEventThrottle={16}> - <Animated.View - style={[ - styles.header, - { backgroundColor: headerBackgroundColor[colorScheme] }, - headerAnimatedStyle, - ]}> - {headerImage} - </Animated.View> - <ThemedView style={styles.content}>{children}</ThemedView> - </Animated.ScrollView> - ); -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - }, - header: { - height: HEADER_HEIGHT, - overflow: 'hidden', - }, - content: { - flex: 1, - padding: 32, - gap: 16, - overflow: 'hidden', - }, -}); |