Skip to content
Closed
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
4 changes: 2 additions & 2 deletions packages/rn-tester/js/examples/Animated/ColorStylesExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as React from 'react';
import {useState} from 'react';
import {Animated, StyleSheet, Text, View} from 'react-native';

function AnimatedView({useNativeDriver}: {useNativeDriver: boolean}) {
component AnimatedView(useNativeDriver: boolean) {
const animations = [];

const animatedViewStyle = {
Expand Down Expand Up @@ -123,7 +123,7 @@ function AnimatedView({useNativeDriver}: {useNativeDriver: boolean}) {
);
}

function AnimatedColorStyleExample(): React.Node {
component AnimatedColorStyleExample() {
const [useNativeDriver, setUseNativeDriver] = useState(false);

return (
Expand Down
4 changes: 2 additions & 2 deletions packages/rn-tester/js/examples/Animated/CombineExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default ({
render: () => <CombineExample />,
}: RNTesterModuleExample);

const CombineExample = () => {
component CombineExample() {
const [aValue, setAValue] = useState('0.4');
const [bValue, setBValue] = useState('0.5');
const a = new Animated.Value(parseFloat(aValue));
Expand Down Expand Up @@ -69,7 +69,7 @@ const CombineExample = () => {
<RNTesterButton onPress={() => setAnimation(mod)}>Modulo</RNTesterButton>
</View>
);
};
}

const styles = StyleSheet.create({
content: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const styles = StyleSheet.create({
},
});

function CompositeAnimationsWithEasingExample(): React.Node {
component CompositeAnimationsWithEasingExample() {
const anims = [1, 2, 3].map(() => new Animated.Value(0));
const theme = useContext(RNTesterThemeContext);

Expand Down
13 changes: 4 additions & 9 deletions packages/rn-tester/js/examples/Animated/ComposingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
useWindowDimensions,
} from 'react-native';

type Props = Readonly<{}>;
const boxSize = 12;
const padding = 8;
const leftToRightTimingConfig = (useNativeDriver: boolean) => ({
Expand Down Expand Up @@ -128,20 +127,15 @@ const items = [
},
];

function ComposingExampleItem({
title,
description,
compositeAnimation,
useNativeDriver,
}: {
component ComposingExampleItem(
title: string,
description: string,
compositeAnimation: (
values: Animated.Value[],
useNativeDriver: boolean,
) => CompositeAnimation,
useNativeDriver: boolean,
}): React.Node {
) {
const {width: windowWidth} = useWindowDimensions();

// Figure out how far along the x axis we should translate the box by taking into
Expand All @@ -150,6 +144,7 @@ function ComposingExampleItem({
const boxIndexes = useMemo(() => [0, 1, 2, 3, 4], []);
const xTranslations = useRef(boxIndexes.map(() => new Animated.Value(0)));
const animation = useRef(
// $FlowFixMe[react-rule-unsafe-ref]
compositeAnimation(xTranslations.current, useNativeDriver),
);
const theme = useContext(RNTesterThemeContext);
Expand Down Expand Up @@ -206,7 +201,7 @@ function ComposingExampleItem({
);
}

function ComposingExample(props: Props): React.Node {
component ComposingExample() {
const [useNativeDriver, setUseNativeDriver] = useState(false);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as React from 'react';
import {useContext} from 'react';
import {Text} from 'react-native';

function AnimatedContinuousInteractionsExample(): React.Node {
component AnimatedContinuousInteractionsExample() {
const theme = useContext(RNTesterThemeContext);
return (
<Text style={{color: theme.SecondaryLabelColor}}>
Expand Down
12 changes: 2 additions & 10 deletions packages/rn-tester/js/examples/Animated/EasingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import {
useAnimatedValue,
} from 'react-native';

type Props = Readonly<{}>;

type EasingListItem = {
title: string,
easing: (value: number) => number,
Expand Down Expand Up @@ -81,13 +79,7 @@ const easingSections = [
},
];

function EasingItem({
item,
useNativeDriver,
}: {
item: EasingListItem,
useNativeDriver: boolean,
}): React.Node {
component EasingItem(item: EasingListItem, useNativeDriver: boolean) {
const opacityAndScale = useAnimatedValue(1);
const animation = useRef(
Animated.timing(opacityAndScale, {
Expand Down Expand Up @@ -129,7 +121,7 @@ function EasingItem({
);
}

function EasingExample(props: Props): React.Node {
component EasingExample() {
const [useNativeDriver, setUseNativeDriver] = useState(false);

return (
Expand Down
10 changes: 2 additions & 8 deletions packages/rn-tester/js/examples/Animated/FadeInViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ const styles = StyleSheet.create({
},
});

function FadeInView({
useNativeDriver,
children,
}: {
useNativeDriver: boolean,
children: React.Node,
}) {
component FadeInView(useNativeDriver: boolean, children: React.Node) {
//opacity 0
const [fadeAnim] = useState(() => new Animated.Value(0));
useEffect(() => {
Expand Down Expand Up @@ -64,7 +58,7 @@ function FadeInView({
);
}

function FadeInExample(): React.Node {
component FadeInExample() {
const [show, setShow] = useState(true);
const [useNativeDriver, setUseNativeDriver] = useState(false);
return (
Expand Down
10 changes: 2 additions & 8 deletions packages/rn-tester/js/examples/Animated/LoopingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ export default ({
render: () => <LoopingExample />,
}: RNTesterModuleExample);

function LoopingView({
useNativeDriver,
running,
}: {
useNativeDriver: boolean,
running: boolean,
}) {
component LoopingView(useNativeDriver: boolean, running: boolean) {
const opacity = useMemo(() => new Animated.Value(1), []);
const scale = useMemo(() => new Animated.Value(1), []);

Expand Down Expand Up @@ -64,7 +58,7 @@ function LoopingView({
);
}

function LoopingExample(props: {}): React.Node {
component LoopingExample() {
const [running, setRunning] = useState(false);
const [useNativeDriver, setUseNativeDriver] = useState(false);

Expand Down
6 changes: 2 additions & 4 deletions packages/rn-tester/js/examples/Animated/MovingBoxExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ const styles = StyleSheet.create({
},
});

type Props = Readonly<{}>;

function MovingBoxView({useNativeDriver}: {useNativeDriver: boolean}) {
component MovingBoxView(useNativeDriver: boolean) {
const x = useAnimatedValue(0);
const [update, setUpdate] = useState(0);
const [boxVisible, setBoxVisible] = useState(true);
Expand Down Expand Up @@ -107,7 +105,7 @@ function MovingBoxView({useNativeDriver}: {useNativeDriver: boolean}) {
);
}

function MovingBoxExample(props: Props): React.Node {
component MovingBoxExample() {
const [useNativeDriver, setUseNativeDriver] = useState(false);

return (
Expand Down
20 changes: 10 additions & 10 deletions packages/rn-tester/js/examples/Animated/PanGestureExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
View,
} from 'react-native';

function TextBox({children}: Readonly<{children: React.Node}>): React.Node {
component TextBox(children: React.Node) {
// Prevent touch from being hijacked by Text
return (
<View pointerEvents="none">
Expand All @@ -31,15 +31,13 @@ function TextBox({children}: Readonly<{children: React.Node}>): React.Node {
);
}

function AnimatedEventExample({
containerPageXY,
useNativeDriver,
}: Readonly<{
component AnimatedEventExample(
containerPageXY: Readonly<{x: number, y: number}>,
useNativeDriver: boolean,
}>): React.Node {
) {
const boxRef = useRef<?React.ElementRef<typeof Animated.View>>();

// $FlowFixMe[react-rule-unsafe-ref]
const pointerPageXY = useRef(
new Animated.ValueXY(
{
Expand All @@ -50,6 +48,7 @@ function AnimatedEventExample({
),
).current;

// $FlowFixMe[react-rule-unsafe-ref]
const dragStartOffsetXY = useRef(
new Animated.ValueXY({x: 0, y: 0}, {useNativeDriver}),
).current;
Expand Down Expand Up @@ -126,13 +125,14 @@ function AnimatedEventExample({
);
}

function PanResponderExample({
useNativeDriver,
}: Readonly<{useNativeDriver: boolean}>): React.Node {
component PanResponderExample(useNativeDriver: boolean) {
// $FlowFixMe[react-rule-unsafe-ref]
const finalOffsetXY = useRef(
new Animated.ValueXY({x: 0, y: 0}, {useNativeDriver}),
).current;
// $FlowFixMe[react-rule-unsafe-ref]
const dragStartOffsetXY = useRef({x: 0, y: 0}).current;
// $FlowFixMe[react-rule-unsafe-ref]
const panResponder = useRef(
PanResponder.create({
onMoveShouldSetPanResponder: (pressEvent, gestureState) => {
Expand Down Expand Up @@ -177,7 +177,7 @@ function PanResponderExample({
);
}

function PanGestureExample(): React.Node {
component PanGestureExample() {
const [busy, setBusy] = useState(false);
const [useNativeDriver, setUseNativeDriver] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {Animated, Button, Text, View, useAnimatedValue} from 'react-native';

const componentList: number[] = Array.from({length: 100}, (_, i) => i + 1);

function PressableWithNativeDriver() {
component PressableWithNativeDriver() {
const currScroll = useAnimatedValue(0);
const [count, setCount] = useState(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const styles = StyleSheet.create({
},
});

function RotatingImagesView({useNativeDriver}: {useNativeDriver: boolean}) {
component RotatingImagesView(useNativeDriver: boolean) {
const anim = new Animated.Value(0);
const rotatingAnimation = Animated.spring(anim, {
// Returns to the start
Expand Down Expand Up @@ -84,7 +84,7 @@ function RotatingImagesView({useNativeDriver}: {useNativeDriver: boolean}) {
);
}

function RotatingImagesExample(): React.Node {
component RotatingImagesExample() {
const [useNativeDriver, setUseNativeDriver] = useState(false);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const styles = StyleSheet.create({
},
});

function TransformBounceView({useNativeDriver}: {useNativeDriver: boolean}) {
component TransformBounceView(useNativeDriver: boolean) {
const anim = new Animated.Value(0);
const bounceAnimation = Animated.spring(anim, {
// Returns to the start
Expand Down Expand Up @@ -91,7 +91,7 @@ function TransformBounceView({useNativeDriver}: {useNativeDriver: boolean}) {
);
}

function TransformBounceExample(): React.Node {
component TransformBounceExample() {
const [useNativeDriver, setUseNativeDriver] = useState(false);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ const transformProperties = {
translateY: {outputRange: [0, 100], selected: false},
};

function AnimatedView({
properties,
useNativeDriver,
}: {
properties: Array<string>,
useNativeDriver: boolean,
}) {
component AnimatedView(properties: Array<string>, useNativeDriver: boolean) {
const animatedValue = new Animated.Value(0);
const transformStyles = properties.map(property => ({
[property]: animatedValue.interpolate({
Expand Down Expand Up @@ -78,7 +72,7 @@ function AnimatedView({
);
}

function AnimatedTransformStyleExample(): React.Node {
component AnimatedTransformStyleExample() {
const [properties, setProperties] = useState(transformProperties);
const [useNativeDriver, setUseNativeDriver] = useState(false);
const onToggle = (property: string) =>
Expand Down
Loading