-
Notifications
You must be signed in to change notification settings - Fork 592
/
Copy pathreact-native-reanimated+3.16.7.patch
135 lines (129 loc) · 7.88 KB
/
react-native-reanimated+3.16.7.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
diff --git a/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts b/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts
index a427011..9244d1b 100644
--- a/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts
+++ b/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts
@@ -1,7 +1,7 @@
import React from 'react';
-import type { FlatListProps } from 'react-native';
+import type { FlatListProps, StyleProp, ViewStyle } from 'react-native';
import { FlatList } from 'react-native';
-import type { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
+import type { AnimatedStyle, ILayoutAnimationBuilder } from '../commonTypes';
import type { AnimatedProps } from '../helperTypes';
declare const AnimatedFlatList: React.ComponentClass<import("../helperTypes").AnimateProps<FlatListProps<unknown>>, any>;
interface ReanimatedFlatListPropsWithLayout<T> extends AnimatedProps<FlatListProps<T>> {
@@ -18,6 +18,14 @@ interface ReanimatedFlatListPropsWithLayout<T> extends AnimatedProps<FlatListPro
skipEnteringExitingAnimations?: boolean;
/** Property `CellRendererComponent` is not supported in `Animated.FlatList`. */
CellRendererComponent?: never;
+ /**
+ * Either animated view styles or a function that receives the item to be
+ * rendered and its index and returns animated view styles.
+ */
+ CellRendererComponentStyle?: StyleProp<AnimatedStyle<StyleProp<ViewStyle>>> | (({ item, index, }: {
+ item: T;
+ index: number;
+ }) => StyleProp<AnimatedStyle<StyleProp<ViewStyle>>>) | undefined;
}
export type FlatListPropsWithLayout<T> = ReanimatedFlatListPropsWithLayout<T>;
interface AnimatedFlatListComplement<T> extends FlatList<T> {
diff --git a/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts.map b/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts.map
index afc2283..0c3ac1f 100644
--- a/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts.map
+++ b/node_modules/react-native-reanimated/lib/typescript/component/FlatList.d.ts.map
@@ -1 +1 @@
-{"version":3,"file":"FlatList.d.ts","sourceRoot":"","sources":["../../../src/component/FlatList.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,OAAO,KAAK,EACV,aAAa,EAId,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAGjG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,QAAA,MAAM,gBAAgB,0FAAoC,CAAC;AA4B3D,UAAU,iCAAiC,CAAC,CAAC,CAC3C,SAAQ,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACvC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,uBAAuB,CAAC;IAC9C;;;OAGG;IACH,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,KAAK,CAAC;CAC/B;AAED,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,iCAAiC,CAAC,CAAC,CAAC,CAAC;AAI9E,UAAU,0BAA0B,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACzD,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;CACxB;A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B,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IACzD,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;CACxB;AA2DD,eAAO,MAAM,kBAAkB;;MAQ1B,MAAM,YAAY,CAAC;AAExB,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,gBAAgB,GACzD,0BAA0B,CAAC,CAAC,CAAC,CAAC"}
\ No newline at end of file
diff --git a/node_modules/react-native-reanimated/src/component/FlatList.tsx b/node_modules/react-native-reanimated/src/component/FlatList.tsx
index c886b0d..67b5ca5 100644
--- a/node_modules/react-native-reanimated/src/component/FlatList.tsx
+++ b/node_modules/react-native-reanimated/src/component/FlatList.tsx
@@ -16,7 +16,9 @@ import type { AnimatedProps } from '../helperTypes';
const AnimatedFlatList = createAnimatedComponent(FlatList);
-interface CellRendererComponentProps {
+interface CellRendererComponentProps<ItemT = any> {
+ index: number;
+ item: ItemT;
onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
children: React.ReactNode;
style?: StyleProp<AnimatedStyle<ViewStyle>>;
@@ -25,6 +27,9 @@ interface CellRendererComponentProps {
const createCellRendererComponent = (
itemLayoutAnimationRef?: React.MutableRefObject<
ILayoutAnimationBuilder | undefined
+ >,
+ cellRendererComponentStyleRef?: React.MutableRefObject<
+ ReanimatedFlatListPropsWithLayout<any>['CellRendererComponentStyle']
>
) => {
const CellRendererComponent = (props: CellRendererComponentProps) => {
@@ -33,7 +38,15 @@ const createCellRendererComponent = (
// TODO TYPESCRIPT This is temporary cast is to get rid of .d.ts file.
layout={itemLayoutAnimationRef?.current as any}
onLayout={props.onLayout}
- style={props.style}>
+ style={[
+ props.style,
+ typeof cellRendererComponentStyleRef?.current === 'function'
+ ? cellRendererComponentStyleRef?.current({
+ index: props.index,
+ item: props.item,
+ })
+ : cellRendererComponentStyleRef?.current,
+ ]}>
{props.children}
</AnimatedView>
);
@@ -57,6 +70,20 @@ interface ReanimatedFlatListPropsWithLayout<T>
skipEnteringExitingAnimations?: boolean;
/** Property `CellRendererComponent` is not supported in `Animated.FlatList`. */
CellRendererComponent?: never;
+ /**
+ * Either animated view styles or a function that receives the item to be
+ * rendered and its index and returns animated view styles.
+ */
+ CellRendererComponentStyle:
+ | StyleProp<AnimatedStyle<StyleProp<ViewStyle>>>
+ | (({
+ item,
+ index,
+ }: {
+ item: T;
+ index: number;
+ }) => StyleProp<AnimatedStyle<StyleProp<ViewStyle>>>)
+ | undefined;
}
export type FlatListPropsWithLayout<T> = ReanimatedFlatListPropsWithLayout<T>;
@@ -73,8 +100,12 @@ const FlatListForwardRefRender = function <Item = any>(
props: ReanimatedFlatListPropsWithLayout<Item>,
ref: React.ForwardedRef<FlatList>
) {
- const { itemLayoutAnimation, skipEnteringExitingAnimations, ...restProps } =
- props;
+ const {
+ itemLayoutAnimation,
+ skipEnteringExitingAnimations,
+ CellRendererComponentStyle,
+ ...restProps
+ } = props;
// Set default scrollEventThrottle, because user expects
// to have continuous scroll events and
@@ -88,9 +119,16 @@ const FlatListForwardRefRender = function <Item = any>(
const itemLayoutAnimationRef = useRef(itemLayoutAnimation);
itemLayoutAnimationRef.current = itemLayoutAnimation;
+ const cellRendererComponentStyleRef = useRef(CellRendererComponentStyle);
+ cellRendererComponentStyleRef.current = CellRendererComponentStyle;
+
const CellRendererComponent = React.useMemo(
- () => createCellRendererComponent(itemLayoutAnimationRef),
- [itemLayoutAnimationRef]
+ () =>
+ createCellRendererComponent(
+ itemLayoutAnimationRef,
+ cellRendererComponentStyleRef
+ ),
+ [itemLayoutAnimationRef, CellRendererComponentStyle]
);
const animatedFlatList = (