Skip to content

Commit f3ba77c

Browse files
committed
fix: fix and remove recyclerlistview component
1 parent b32f436 commit f3ba77c

File tree

16 files changed

+1511
-3978
lines changed

16 files changed

+1511
-3978
lines changed

packages/react-native-calendar-kit/src/service/CalendarList/HorizontalVirtualizedList.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useMemo } from 'react';
2-
import { View } from 'react-native';
2+
import { View } from './View';
33

44
interface HorizontalVirtualizedListProps {
55
count: number;
@@ -42,8 +42,7 @@ export const HorizontalVirtualizedList = React.memo(
4242
left: relativePosition,
4343
width: itemSize,
4444
height: '100%',
45-
}}
46-
>
45+
}}>
4746
{renderItem({ item: i, index: i })}
4847
</View>
4948
);
@@ -61,7 +60,6 @@ export const HorizontalVirtualizedList = React.memo(
6160
itemSize,
6261
]);
6362

64-
// Calculate container transform to handle large offsets
6563
const firstVisiblePosition =
6664
visibleRange.start > 0 ? getItemPosition(visibleRange.start) : 0;
6765

@@ -71,10 +69,8 @@ export const HorizontalVirtualizedList = React.memo(
7169
position: 'relative',
7270
width: totalSize,
7371
height: '100%',
74-
// Use transform to handle large offsets instead of large absolute positions
7572
transform: [{ translateX: firstVisiblePosition }],
76-
}}
77-
>
73+
}}>
7874
{renderItems}
7975
</View>
8076
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import { Platform, View as RNView, type ViewProps } from 'react-native';
3+
4+
const RCTView = React.forwardRef<RNView, ViewProps>((props, ref) => {
5+
return React.createElement('RCTView', { ...props, ref });
6+
});
7+
8+
RCTView.displayName = 'RCTView';
9+
10+
export const View =
11+
Platform.OS === 'android' || Platform.OS === 'ios' ? RCTView : RNView;

packages/react-native-calendar-kit/src/service/CalendarList/index.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ import {
1313
type NativeSyntheticEvent,
1414
} from 'react-native';
1515

16-
import { HorizontalVirtualizedList } from './HorizontalVirtualizedList';
1716
import { ScrollView } from 'react-native-gesture-handler';
1817
import Animated, {
1918
AnimatedRef,
19+
runOnJS,
20+
useAnimatedReaction,
2021
useAnimatedRef,
2122
useScrollViewOffset,
22-
useAnimatedReaction,
23-
runOnJS,
23+
useSharedValue,
2424
} from 'react-native-reanimated';
25+
import { HorizontalVirtualizedList } from './HorizontalVirtualizedList';
2526

2627
const AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
2728

@@ -97,12 +98,10 @@ export const CalendarList = React.forwardRef<
9798
) => {
9899
const scrollViewRef = useRef<ScrollView>(null);
99100
const [viewportWidth, setViewportWidth] = useState(0);
100-
const [scrollOffset, setScrollOffset] = useState(0);
101+
const [scrollOffset, setScrollOffset] = useState(initialOffset ?? 0);
101102
const isLoaded = useRef(false);
102103

103-
const totalSize = useMemo(() => {
104-
return count * itemSize;
105-
}, [count, itemSize]);
104+
const totalSize = count * itemSize;
106105

107106
const visibleRange = useMemo(() => {
108107
if (viewportWidth === 0 || count === 0) {
@@ -125,7 +124,8 @@ export const CalendarList = React.forwardRef<
125124
);
126125

127126
const animScrollRef = useAnimatedRef<Animated.ScrollView>();
128-
const scrollOffsetAnim = useScrollViewOffset(animScrollRef);
127+
const internalOffset = useSharedValue(initialOffset ?? 0);
128+
const scrollOffsetAnim = useScrollViewOffset(animScrollRef, internalOffset);
129129

130130
const handleColumnChanged = useCallback(
131131
(offset: number) => {
@@ -257,6 +257,7 @@ export const CalendarList = React.forwardRef<
257257
contentContainerStyle={[contentContainerStyle, { width: totalSize }]}
258258
onScroll={onScroll}
259259
onLayout={handleLayout}
260+
contentOffset={{ x: initialOffset ?? 0, y: 0 }}
260261
scrollEventThrottle={scrollEventThrottle}
261262
scrollEnabled={scrollEnabled}
262263
showsHorizontalScrollIndicator={false}

packages/react-native-calendar-kit/src/service/recyclerlistview/README.MD

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/react-native-calendar-kit/src/service/recyclerlistview/core/LayoutManager.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

packages/react-native-calendar-kit/src/service/recyclerlistview/core/LayoutProvider.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)