Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/containers/FadingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ const FadingView = forwardRef<Animated.View, FadingViewProps>(
children,
style,
opacity,
animatedProps = {},
// Remove animatedProps from rest to avoid passing stale/spread values
animatedProps: _externalAnimatedProps,
opacityThresholdToEnablePointerEvents = 1,
...rest
},
ref
) => {
const _animatedProps = useAnimatedProps(() => {
const animatedProps = useAnimatedProps(() => {
const _pointerEvents: AnimatedViewPointerEvents =
opacity.value >= opacityThresholdToEnablePointerEvents ? 'auto' : 'none';
return { pointerEvents: _pointerEvents };
Expand All @@ -62,7 +63,7 @@ const FadingView = forwardRef<Animated.View, FadingViewProps>(
<Animated.View
ref={ref}
style={[styles.container, style, fadeStyle]}
animatedProps={{ ..._animatedProps, ...animatedProps }}
animatedProps={animatedProps}
{...rest}
>
{children}
Expand Down
10 changes: 4 additions & 6 deletions src/components/containers/ScrollView.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import React, { useImperativeHandle } from 'react';
import { View, StyleSheet, ScrollView } from 'react-native';
import { View, StyleSheet } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import Animated, { useAnimatedRef } from 'react-native-reanimated';

import FadingView from './FadingView';
import { useScrollContainerLogic } from './useScrollContainerLogic';
import type { SharedScrollContainerProps } from './types';

const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);

type AnimatedScrollViewProps = React.ComponentProps<typeof AnimatedScrollView> & {
type AnimatedScrollViewProps = React.ComponentProps<typeof Animated.ScrollView> & {
children?: React.ReactNode;
};

Expand Down Expand Up @@ -91,7 +89,7 @@ const ScrollViewWithHeadersInputComp = (
]}
>
{!absoluteHeader && HeaderComponent({ showNavBar, scrollY })}
<AnimatedScrollView
<Animated.ScrollView
ref={scrollRef}
scrollEventThrottle={16}
overScrollMode="auto"
Expand Down Expand Up @@ -152,7 +150,7 @@ const ScrollViewWithHeadersInputComp = (
{LargeHeaderSubtitleComponent && LargeHeaderSubtitleComponent({ showNavBar, scrollY })}

{children}
</AnimatedScrollView>
</Animated.ScrollView>

{absoluteHeader && (
<View style={styles.absoluteHeader} onLayout={onAbsoluteHeaderLayout}>
Expand Down
27 changes: 16 additions & 11 deletions src/components/headers/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useMemo } from 'react';
import { useWindowDimensions } from 'react-native';
import { StyleSheet, View } from 'react-native';
import { StyleSheet } from 'react-native';
import Animated from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { FadingView } from '../containers';
import { HeaderBottomBorder } from '../line';
Expand Down Expand Up @@ -41,10 +42,12 @@ const Header: React.FC<HeaderProps> = ({
const noHeaderLeftRight = !headerLeft && !headerRight;

return (
<View>
<Animated.View>
{SurfaceComponent && SurfaceComponent({ showNavBar })}

<View style={[styles.container, !ignoreTopSafeArea && { paddingTop: top }, headerStyle]}>
<Animated.View
style={[styles.container, !ignoreTopSafeArea && { paddingTop: top }, headerStyle]}
>
{headerLeftFadesIn ? (
<FadingView
opacity={showNavBar}
Expand All @@ -58,7 +61,7 @@ const Header: React.FC<HeaderProps> = ({
{headerLeft}
</FadingView>
) : (
<View
<Animated.View
style={[
styles.leftContainer,
noHeaderLeftRight && styles.noFlex,
Expand All @@ -67,7 +70,7 @@ const Header: React.FC<HeaderProps> = ({
]}
>
{headerLeft}
</View>
</Animated.View>
)}

{headerCenter &&
Expand All @@ -79,9 +82,11 @@ const Header: React.FC<HeaderProps> = ({
{headerCenter}
</FadingView>
) : (
<View style={[styles.centerContainer, { width: centerWidth }, headerCenterStyle]}>
<Animated.View
style={[styles.centerContainer, { width: centerWidth }, headerCenterStyle]}
>
{headerCenter}
</View>
</Animated.View>
))}

{headerRightFadesIn ? (
Expand All @@ -97,7 +102,7 @@ const Header: React.FC<HeaderProps> = ({
{headerRight}
</FadingView>
) : (
<View
<Animated.View
style={[
styles.rightContainer,
noHeaderLeftRight && styles.noFlex,
Expand All @@ -106,9 +111,9 @@ const Header: React.FC<HeaderProps> = ({
]}
>
{headerRight}
</View>
</Animated.View>
)}
</View>
</Animated.View>

{!noBottomBorder && (
<HeaderBottomBorder
Expand All @@ -118,7 +123,7 @@ const Header: React.FC<HeaderProps> = ({
borderWidth={borderWidth}
/>
)}
</View>
</Animated.View>
);
};

Expand Down
5 changes: 3 additions & 2 deletions src/components/headers/LargeHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { StyleSheet } from 'react-native';
import Animated from 'react-native-reanimated';
import type { LargeHeaderProps } from './types';

const LH_VERTICAL_PADDING = 6;
Expand All @@ -13,7 +14,7 @@ const LH_HORIZONTAL_PADDING = 12;
const LargeHeader: React.FC<React.PropsWithChildren<LargeHeaderProps>> = ({
headerStyle,
children,
}) => <View style={[styles.headerContainer, headerStyle]}>{children}</View>;
}) => <Animated.View style={[styles.headerContainer, headerStyle]}>{children}</Animated.View>;

export default LargeHeader;

Expand Down