Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 10 additions & 11 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/react-native-fontawesome": "^0.3.0",
"@react-native-async-storage/async-storage": "^1.19.3",
"@react-native-community/slider": "^4.4.3",
"@react-native-masked-view/masked-view": "^0.3.0",
"@react-native-async-storage/async-storage": "^1.22.3",
"@react-native-community/slider": "^4.5.0",
"@react-native-masked-view/masked-view": "^0.3.1",
"@react-native-picker/picker": "^2.5.1",
"@react-navigation/elements": "^1.3.19",
"@react-navigation/native": "^6.1.8",
"@react-navigation/native-stack": "^6.9.14",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@react-navigation/stack": "^6.3.18",
"d3-shape": "^3.2.0",
"react-dom": "18.0.0",
"react-native-box2d": "^0.2.5",
"react-native-gesture-handler": "^2.13.2",
"react-native-pager-view": "^5.4.25",
"react-native-gesture-handler": "^2.16.0-rc.0",
"react-native-pager-view": "^6.2.3",
"react-native-reanimated": "link:../",
"react-native-safe-area-context": "^4.7.2",
"react-native-screens": "^3.27.0",
"react-native-svg": "^13.14.0",
"react-native-safe-area-context": "4.10.0-rc.0",
"react-native-screens": "git+https://github.com/software-mansion/react-native-screens.git#ddf267a4ce157dc60fa0bb94e8096c4d99f7e878",
"react-native-svg": "^15.2.0-rc.0",
"react-native-web": "~0.18.12"
Comment thread
tjzel marked this conversation as resolved.
},
"devDependencies": {
Expand Down
23 changes: 20 additions & 3 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import { EXAMPLES } from './examples';
import React from 'react';
import { useReducedMotion } from 'react-native-reanimated';

function isFabric(): boolean {
return !!(global as Record<string, unknown>)._IS_FABRIC;
}

type RootStackParamList = { [P in keyof typeof EXAMPLES]: undefined } & {
Home: undefined;
};
Expand Down Expand Up @@ -91,6 +95,7 @@ function HomeScreen({ navigation }: HomeScreenProps) {
icon={EXAMPLES[name].icon}
title={EXAMPLES[name].title}
onPress={() => navigation.navigate(name)}
missingOnFabric={EXAMPLES[name].missingOnFabric}
/>
)}
renderScrollComponent={(props) => <ScrollView {...props} />}
Expand All @@ -104,20 +109,28 @@ interface ItemProps {
icon?: string;
title: string;
onPress: () => void;
missingOnFabric?: boolean;
}

function Item({ icon, title, onPress }: ItemProps) {
function Item({ icon, title, onPress, missingOnFabric }: ItemProps) {
const isDisabled = missingOnFabric && isFabric();
if (Platform.OS === 'macos') {
return (
<Pressable style={styles.button} onPress={onPress}>
<Pressable
style={[styles.button, isDisabled && styles.disabledButton]}
onPress={onPress}
disabled={isDisabled}>
{icon && <Text style={styles.title}>{icon + ' '}</Text>}
<Text style={styles.title}>{title}</Text>
</Pressable>
);
}

return (
<RectButton style={styles.button} onPress={onPress}>
<RectButton
style={[styles.button, isDisabled && styles.disabledButton]}
onPress={onPress}
enabled={!isDisabled}>
{icon && <Text style={styles.title}>{icon + ' '}</Text>}
<Text style={styles.title}>{title}</Text>
</RectButton>
Expand Down Expand Up @@ -261,6 +274,10 @@ const styles = StyleSheet.create({
alignItems: 'center',
backgroundColor: 'white',
},
disabledButton: {
backgroundColor: 'grey',
opacity: 0.5,
},
title: {
fontSize: 16,
color: 'black',
Expand Down
4 changes: 4 additions & 0 deletions app/src/examples/AboutExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export default function AboutExample() {
<Text style={styles.bold}>RN version:</Text>{' '}
{getReactNativeVersion()}
</Text>
<Text style={styles.text}>
<Text style={styles.bold}>Bridgeless enabled:</Text>{' '}
{(global as any)._IS_BRIDGELESS ? 'yes' : 'no'}
Comment thread
tjzel marked this conversation as resolved.
Outdated
Comment thread
tjzel marked this conversation as resolved.
Outdated
</Text>
</>
)}
</View>
Expand Down
4 changes: 2 additions & 2 deletions app/src/examples/CustomHandler/PagerExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Animated, {
useDerivedValue,
useSharedValue,
} from 'react-native-reanimated';
import PagerView, { PageScrollState } from 'react-native-pager-view';
import PagerView from 'react-native-pager-view';

import { AnimatedText } from './AnimatedText';
import { Pagination } from './Pagination';
Expand All @@ -27,7 +27,7 @@ const SLIDES = [

export default function PagerExample() {
const scrollPosition = useSharedValue(0);
const scrollState = useSharedValue<PageScrollState>('idle');
const scrollState = useSharedValue<'idle' | 'dragging' | 'settling'>('idle');
const currentPage = useSharedValue(0);
const stringifiedCurrentPage = useDerivedValue(() => {
return `${currentPage.value + 1}`;
Expand Down
11 changes: 5 additions & 6 deletions app/src/examples/CustomHandler/useAnimatedPagerHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NativeSyntheticEvent } from 'react-native';
import {
PageScrollStateChangedEvent,
PageScrollStateChangedNativeEvent,
PagerViewOnPageScrollEvent,
PagerViewOnPageSelectedEvent,
} from 'react-native-pager-view';
Expand Down Expand Up @@ -42,18 +41,18 @@ export function useAnimatedPagerScrollStateHandler<
>(
handlers: {
onPageScrollStateChanged: (
e: ReanimatedEvent<PageScrollStateChangedEvent>,
e: ReanimatedEvent<PageScrollStateChangedNativeEvent>,
context: TContext
) => void;
},
dependencies?: Array<unknown>
): (e: NativeSyntheticEvent<PageScrollStateChangedEvent>) => void {
): (e: PageScrollStateChangedNativeEvent) => void {
const { context, doDependenciesDiffer } = useHandler<
PageScrollStateChangedEvent,
PageScrollStateChangedNativeEvent,
TContext
>(handlers, dependencies);

return useEvent<NativeSyntheticEvent<PageScrollStateChangedEvent>>(
return useEvent<PageScrollStateChangedNativeEvent>(
(event) => {
'worklet';
const { onPageScrollStateChanged } = handlers;
Expand Down
48 changes: 20 additions & 28 deletions app/src/examples/LiquidSwipe/LiquidSwipe.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';
import { Dimensions, StyleSheet } from 'react-native';
import Animated, {
useSharedValue,
useAnimatedGestureHandler,
cancelAnimation,
interpolate,
Extrapolation,
withSpring,
} from 'react-native-reanimated';
import {
PanGestureHandler,
PanGestureHandlerGestureEvent,
Gesture,
GestureDetector,
GestureHandlerRootView,
} from 'react-native-gesture-handler';
import Weave from './Weave';
import { initialSideWidth, initialWaveCenter } from './WeaveHelpers';
Expand All @@ -34,26 +34,21 @@ export default function LiquidSwipe() {
const isBack = useSharedValue(false);
const centerY = useSharedValue(initialWaveCenter);
const progress = useSharedValue(0);
const ctxDragX = useSharedValue(0);
const ctxStartY = useSharedValue(0);
Comment thread
tjzel marked this conversation as resolved.
Outdated

const maxDist = width - initialSideWidth;

type AnimatedGHContext = {
dragX: number;
startY: number;
};
const handler = useAnimatedGestureHandler<
PanGestureHandlerGestureEvent,
AnimatedGHContext
>({
onStart: (event, ctx) => {
const gesture = Gesture.Pan()
.onStart((event) => {
// stop animating progress, this will also place "isBack" value in the
// final state (we update isBack in progress animation callback)
cancelAnimation(progress);
ctx.dragX = 0;
ctx.startY = isBack.value ? event.y : centerY.value;
},
onActive: (event, ctx) => {
centerY.value = ctx.startY + event.translationY;
ctxDragX.value = 0;
ctxStartY.value = isBack.value ? event.y : centerY.value;
})
.onChange((event) => {
centerY.value = ctxStartY.value + event.translationY;
if (isBack.value) {
progress.value = interpolate(
event.translationX,
Expand All @@ -69,29 +64,26 @@ export default function LiquidSwipe() {
Extrapolation.CLAMP
);
}
},
onEnd: () => {
})
.onEnd(() => {
const threshold = isBack.value ? 0.5 : 0.2;
const goBack = progress.value > threshold;
centerY.value = withSpring(initialWaveCenter);
progress.value = withSpring(goBack ? 1 : 0, {}, () => {
isBack.value = goBack;
});
},
});
});

return (
<View style={styles.container}>
<GestureHandlerRootView style={styles.container}>
<Content
backgroundColor="white"
source={assets[0]}
title1="Online"
title2="Gambling"
color="black"
/>
<PanGestureHandler
onGestureEvent={handler}
onHandlerStateChange={handler}>
<GestureDetector gesture={gesture}>
<Animated.View style={StyleSheet.absoluteFill}>
<Weave progress={progress} centerY={centerY} isBack={isBack}>
<Content
Expand All @@ -104,7 +96,7 @@ export default function LiquidSwipe() {
</Weave>
<Button y={centerY} progress={progress} />
</Animated.View>
</PanGestureHandler>
</View>
</GestureDetector>
</GestureHandlerRootView>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React from 'react';

const AnimatedScreenStackHeaderConfig = Animated.createAnimatedComponent(
Platform.OS === 'web'
? React.forwardRef(ScreenStackHeaderConfig)
? React.forwardRef(ScreenStackHeaderConfig as any)
Comment thread
tomekzaw marked this conversation as resolved.
: ScreenStackHeaderConfig
);
Animated.addWhitelistedNativeProps({ title: true });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { Button, View, StyleSheet } from 'react-native';
import type { ButtonProps } from 'react-native';
import { ParamListBase } from '@react-navigation/native';
import {
createNativeStackNavigator,
Expand All @@ -9,7 +10,11 @@ import Animated, { SlideInLeft, SlideOutLeft } from 'react-native-reanimated';

const photo = require('./assets/image.jpg');
const Stack = createNativeStackNavigator();
const AnimatedButton = Animated.createAnimatedComponent(Button);
const AnimatedButton = Animated.createAnimatedComponent(
React.forwardRef((props: ButtonProps, ref: React.ForwardedRef<Button>) => (
<Button {...props} ref={ref} />
))
);
Comment thread
tjzel marked this conversation as resolved.
Outdated

function Screen1({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
Expand Down
7 changes: 6 additions & 1 deletion app/src/examples/SharedElementTransitions/ManyTags.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { Button, View, Text, StyleSheet } from 'react-native';
import type { ButtonProps } from 'react-native';
import { ParamListBase } from '@react-navigation/native';
import {
createNativeStackNavigator,
Expand All @@ -9,7 +10,11 @@ import Animated from 'react-native-reanimated';

const photo = require('./assets/image.jpg');
const Stack = createNativeStackNavigator();
const AnimatedButton = Animated.createAnimatedComponent(Button);
const AnimatedButton = Animated.createAnimatedComponent(
React.forwardRef((props: ButtonProps, ref: React.ForwardedRef<Button>) => (
<Button {...props} ref={ref} />
))
);

function Screen1({ navigation }: NativeStackScreenProps<ParamListBase>) {
return (
Expand Down
Loading