@legendapp/list 2.0.0-next.2 → 2.0.0-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/animated.d.mts → animated.d.mts} +10 -3
- package/{dist/animated.d.ts → animated.d.ts} +10 -3
- package/{dist/animated.js → animated.js} +2 -2
- package/{dist/animated.mjs → animated.mjs} +2 -2
- package/{dist/index.d.mts → index.d.mts} +86 -167
- package/{dist/index.d.ts → index.d.ts} +86 -167
- package/{dist/index.js → index.js} +1594 -1098
- package/{dist/index.mjs → index.mjs} +1596 -1100
- package/keyboard-controller.d.mts +148 -0
- package/keyboard-controller.d.ts +148 -0
- package/{dist/keyboard-controller.js → keyboard-controller.js} +4 -4
- package/{dist/keyboard-controller.mjs → keyboard-controller.mjs} +4 -4
- package/package.json +34 -88
- package/{dist/reanimated.d.mts → reanimated.d.mts} +2 -2
- package/{dist/reanimated.d.ts → reanimated.d.ts} +2 -2
- package/reanimated.js +60 -0
- package/reanimated.mjs +53 -0
- package/.claude/settings.local.json +0 -8
- package/.cursor/rules/changelog.mdc +0 -60
- package/.github/FUNDING.yml +0 -15
- package/.gitignore +0 -5
- package/.prettierrc.json +0 -5
- package/.vscode/settings.json +0 -14
- package/CLAUDE.md +0 -126
- package/biome.json +0 -46
- package/bun.lock +0 -1289
- package/bunfig.toml +0 -2
- package/dist/CHANGELOG.md +0 -119
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -139
- package/dist/keyboard-controller.d.mts +0 -261
- package/dist/keyboard-controller.d.ts +0 -261
- package/dist/package.json +0 -35
- package/dist/reanimated.js +0 -58
- package/dist/reanimated.mjs +0 -51
- package/example/README.md +0 -40
- package/example/api/data/genres.json +0 -23
- package/example/api/data/playlist/10402-10749.json +0 -1
- package/example/api/data/playlist/10402-10770.json +0 -1
- package/example/api/data/playlist/10402-37.json +0 -1
- package/example/api/data/playlist/10749-10752.json +0 -1
- package/example/api/data/playlist/10749-10770.json +0 -1
- package/example/api/data/playlist/10749-37.json +0 -1
- package/example/api/data/playlist/10749-878.json +0 -1
- package/example/api/data/playlist/10751-10402.json +0 -1
- package/example/api/data/playlist/10751-10752.json +0 -1
- package/example/api/data/playlist/10751-37.json +0 -1
- package/example/api/data/playlist/10751-53.json +0 -1
- package/example/api/data/playlist/10751-878.json +0 -1
- package/example/api/data/playlist/10751-9648.json +0 -1
- package/example/api/data/playlist/10752-37.json +0 -1
- package/example/api/data/playlist/12-10402.json +0 -1
- package/example/api/data/playlist/12-10749.json +0 -1
- package/example/api/data/playlist/12-18.json +0 -1
- package/example/api/data/playlist/12-27.json +0 -1
- package/example/api/data/playlist/12-35.json +0 -1
- package/example/api/data/playlist/14-36.json +0 -1
- package/example/api/data/playlist/14-878.json +0 -1
- package/example/api/data/playlist/16-10751.json +0 -1
- package/example/api/data/playlist/16-10770.json +0 -1
- package/example/api/data/playlist/16-35.json +0 -1
- package/example/api/data/playlist/16-36.json +0 -1
- package/example/api/data/playlist/16-53.json +0 -1
- package/example/api/data/playlist/18-10751.json +0 -1
- package/example/api/data/playlist/18-10752.json +0 -1
- package/example/api/data/playlist/18-37.json +0 -1
- package/example/api/data/playlist/18-53.json +0 -1
- package/example/api/data/playlist/18-878.json +0 -1
- package/example/api/data/playlist/27-10749.json +0 -1
- package/example/api/data/playlist/27-10770.json +0 -1
- package/example/api/data/playlist/28-10749.json +0 -1
- package/example/api/data/playlist/28-10751.json +0 -1
- package/example/api/data/playlist/28-10770.json +0 -1
- package/example/api/data/playlist/28-16.json +0 -1
- package/example/api/data/playlist/28-18.json +0 -1
- package/example/api/data/playlist/28-36.json +0 -1
- package/example/api/data/playlist/28-37.json +0 -1
- package/example/api/data/playlist/28-53.json +0 -1
- package/example/api/data/playlist/28-80.json +0 -1
- package/example/api/data/playlist/28-99.json +0 -1
- package/example/api/data/playlist/35-10749.json +0 -1
- package/example/api/data/playlist/35-10751.json +0 -1
- package/example/api/data/playlist/35-10752.json +0 -1
- package/example/api/data/playlist/35-27.json +0 -1
- package/example/api/data/playlist/35-36.json +0 -1
- package/example/api/data/playlist/35-53.json +0 -1
- package/example/api/data/playlist/35-80.json +0 -1
- package/example/api/data/playlist/36-37.json +0 -1
- package/example/api/data/playlist/36-878.json +0 -1
- package/example/api/data/playlist/36-9648.json +0 -1
- package/example/api/data/playlist/53-10752.json +0 -1
- package/example/api/data/playlist/80-10770.json +0 -1
- package/example/api/data/playlist/80-14.json +0 -1
- package/example/api/data/playlist/80-18.json +0 -1
- package/example/api/data/playlist/80-37.json +0 -1
- package/example/api/data/playlist/878-37.json +0 -1
- package/example/api/data/playlist/9648-10770.json +0 -1
- package/example/api/data/playlist/9648-37.json +0 -1
- package/example/api/data/playlist/9648-53.json +0 -1
- package/example/api/data/playlist/9648-878.json +0 -1
- package/example/api/data/playlist/99-10749.json +0 -1
- package/example/api/data/playlist/99-14.json +0 -1
- package/example/api/data/playlist/99-18.json +0 -1
- package/example/api/data/playlist/99-27.json +0 -1
- package/example/api/data/playlist/99-53.json +0 -1
- package/example/api/data/playlist/99-9648.json +0 -1
- package/example/api/data/playlist/index.ts +0 -73
- package/example/api/data/rows.json +0 -1
- package/example/api/index.ts +0 -36
- package/example/app/(tabs)/_layout.tsx +0 -60
- package/example/app/(tabs)/cards.tsx +0 -81
- package/example/app/(tabs)/index.tsx +0 -205
- package/example/app/(tabs)/moviesL.tsx +0 -7
- package/example/app/(tabs)/moviesLR.tsx +0 -7
- package/example/app/+not-found.tsx +0 -32
- package/example/app/_layout.tsx +0 -34
- package/example/app/accurate-scrollto/index.tsx +0 -125
- package/example/app/accurate-scrollto-2/index.tsx +0 -52
- package/example/app/accurate-scrollto-huge/index.tsx +0 -128
- package/example/app/add-to-end/index.tsx +0 -82
- package/example/app/ai-chat/index.tsx +0 -236
- package/example/app/bidirectional-infinite-list/index.tsx +0 -133
- package/example/app/cards-columns/index.tsx +0 -37
- package/example/app/cards-flashlist/index.tsx +0 -122
- package/example/app/cards-flatlist/index.tsx +0 -94
- package/example/app/cards-no-recycle/index.tsx +0 -110
- package/example/app/cards-renderItem.tsx +0 -354
- package/example/app/chat-example/index.tsx +0 -167
- package/example/app/chat-infinite/index.tsx +0 -239
- package/example/app/chat-keyboard/index.tsx +0 -248
- package/example/app/chat-resize-outer/index.tsx +0 -247
- package/example/app/columns/index.tsx +0 -78
- package/example/app/countries/index.tsx +0 -182
- package/example/app/countries-flashlist/index.tsx +0 -163
- package/example/app/countries-reorder/index.tsx +0 -187
- package/example/app/extra-data/index.tsx +0 -86
- package/example/app/filter-elements/filter-data-provider.tsx +0 -55
- package/example/app/filter-elements/index.tsx +0 -118
- package/example/app/initial-scroll-index/index.tsx +0 -106
- package/example/app/initial-scroll-index/renderFixedItem.tsx +0 -215
- package/example/app/initial-scroll-index-free-height/index.tsx +0 -70
- package/example/app/initial-scroll-index-keyed/index.tsx +0 -62
- package/example/app/lazy-list/index.tsx +0 -123
- package/example/app/movies-flashlist/index.tsx +0 -7
- package/example/app/mutable-cells/index.tsx +0 -104
- package/example/app/video-feed/index.tsx +0 -119
- package/example/app.config.js +0 -22
- package/example/app.json +0 -45
- package/example/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/example/assets/images/adaptive-icon.png +0 -0
- package/example/assets/images/favicon.png +0 -0
- package/example/assets/images/icon.png +0 -0
- package/example/assets/images/partial-react-logo.png +0 -0
- package/example/assets/images/react-logo.png +0 -0
- package/example/assets/images/react-logo@2x.png +0 -0
- package/example/assets/images/react-logo@3x.png +0 -0
- package/example/assets/images/splash-icon.png +0 -0
- package/example/autoscroll.sh +0 -101
- package/example/bun.lock +0 -2266
- package/example/bunfig.toml +0 -2
- package/example/components/Breathe.tsx +0 -54
- package/example/components/Circle.tsx +0 -69
- package/example/components/Collapsible.tsx +0 -44
- package/example/components/ExternalLink.tsx +0 -24
- package/example/components/HapticTab.tsx +0 -18
- package/example/components/HelloWave.tsx +0 -37
- package/example/components/Movies.tsx +0 -179
- package/example/components/ParallaxScrollView.tsx +0 -81
- package/example/components/ThemedText.tsx +0 -60
- package/example/components/ThemedView.tsx +0 -14
- package/example/components/__tests__/ThemedText-test.tsx +0 -10
- package/example/components/__tests__/__snapshots__/ThemedText-test.tsx.snap +0 -24
- package/example/components/ui/IconSymbol.ios.tsx +0 -32
- package/example/components/ui/IconSymbol.tsx +0 -43
- package/example/components/ui/TabBarBackground.ios.tsx +0 -22
- package/example/components/ui/TabBarBackground.tsx +0 -6
- package/example/constants/Colors.ts +0 -26
- package/example/constants/constants.ts +0 -5
- package/example/constants/useScrollTest.ts +0 -19
- package/example/hooks/useColorScheme.ts +0 -1
- package/example/hooks/useColorScheme.web.ts +0 -8
- package/example/hooks/useThemeColor.ts +0 -22
- package/example/ios/.xcode.env +0 -11
- package/example/ios/Podfile +0 -64
- package/example/ios/Podfile.lock +0 -2767
- package/example/ios/Podfile.properties.json +0 -5
- package/example/ios/listtest/AppDelegate.swift +0 -70
- package/example/ios/listtest/Images.xcassets/AppIcon.appiconset/App-Icon-1024x1024@1x.png +0 -0
- package/example/ios/listtest/Images.xcassets/AppIcon.appiconset/Contents.json +0 -14
- package/example/ios/listtest/Images.xcassets/Contents.json +0 -6
- package/example/ios/listtest/Images.xcassets/SplashScreenBackground.colorset/Contents.json +0 -20
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/Contents.json +0 -23
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/image.png +0 -0
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/image@2x.png +0 -0
- package/example/ios/listtest/Images.xcassets/SplashScreenLogo.imageset/image@3x.png +0 -0
- package/example/ios/listtest/Info.plist +0 -85
- package/example/ios/listtest/PrivacyInfo.xcprivacy +0 -48
- package/example/ios/listtest/SplashScreen.storyboard +0 -42
- package/example/ios/listtest/Supporting/Expo.plist +0 -12
- package/example/ios/listtest/listtest-Bridging-Header.h +0 -3
- package/example/ios/listtest/listtest.entitlements +0 -5
- package/example/ios/listtest.xcodeproj/project.pbxproj +0 -547
- package/example/ios/listtest.xcodeproj/xcshareddata/xcschemes/listtest.xcscheme +0 -88
- package/example/ios/listtest.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/metro.config.js +0 -16
- package/example/package.json +0 -73
- package/example/scripts/reset-project.js +0 -84
- package/example/tsconfig.json +0 -26
- package/posttsup.ts +0 -24
- package/src/Container.tsx +0 -176
- package/src/Containers.tsx +0 -85
- package/src/ContextContainer.ts +0 -145
- package/src/DebugView.tsx +0 -83
- package/src/LazyLegendList.tsx +0 -41
- package/src/LeanView.tsx +0 -18
- package/src/LegendList.tsx +0 -558
- package/src/ListComponent.tsx +0 -191
- package/src/ScrollAdjust.tsx +0 -24
- package/src/ScrollAdjustHandler.ts +0 -26
- package/src/Separator.tsx +0 -14
- package/src/animated.tsx +0 -6
- package/src/calculateItemsInView.ts +0 -363
- package/src/calculateOffsetForIndex.ts +0 -23
- package/src/calculateOffsetWithOffsetPosition.ts +0 -26
- package/src/checkAllSizesKnown.ts +0 -17
- package/src/checkAtBottom.ts +0 -36
- package/src/checkAtTop.ts +0 -27
- package/src/checkThreshold.ts +0 -30
- package/src/constants.ts +0 -11
- package/src/createColumnWrapperStyle.ts +0 -16
- package/src/doInitialAllocateContainers.ts +0 -40
- package/src/doMaintainScrollAtEnd.ts +0 -34
- package/src/findAvailableContainers.ts +0 -98
- package/src/finishScrollTo.ts +0 -8
- package/src/getId.ts +0 -21
- package/src/getItemSize.ts +0 -52
- package/src/getRenderedItem.ts +0 -34
- package/src/getScrollVelocity.ts +0 -47
- package/src/handleLayout.ts +0 -70
- package/src/helpers.ts +0 -39
- package/src/index.ts +0 -11
- package/src/keyboard-controller.tsx +0 -63
- package/src/onScroll.ts +0 -66
- package/src/prepareMVCP.ts +0 -50
- package/src/reanimated.tsx +0 -63
- package/src/requestAdjust.ts +0 -41
- package/src/scrollTo.ts +0 -40
- package/src/scrollToIndex.ts +0 -34
- package/src/setDidLayout.ts +0 -25
- package/src/setPaddingTop.ts +0 -28
- package/src/state.tsx +0 -304
- package/src/types.ts +0 -610
- package/src/updateAlignItemsPaddingTop.ts +0 -18
- package/src/updateAllPositions.ts +0 -130
- package/src/updateItemSize.ts +0 -203
- package/src/updateTotalSize.ts +0 -44
- package/src/useAnimatedValue.ts +0 -6
- package/src/useCombinedRef.ts +0 -22
- package/src/useInit.ts +0 -17
- package/src/useSyncLayout.tsx +0 -68
- package/src/useValue$.ts +0 -53
- package/src/viewability.ts +0 -279
- package/tsconfig.json +0 -59
- package/tsup.config.ts +0 -21
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { MaterialIcons } from "@expo/vector-icons";
|
|
2
|
-
import Swipeable from "react-native-gesture-handler/ReanimatedSwipeable";
|
|
3
|
-
|
|
4
|
-
import { Image, Platform, Pressable, StyleSheet, Text, UIManager, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
import { loremSentences, randomNames } from "@/app/cards-renderItem";
|
|
7
|
-
import { RectButton } from "react-native-gesture-handler";
|
|
8
|
-
|
|
9
|
-
export interface Item {
|
|
10
|
-
id: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Generate random metadata
|
|
14
|
-
const randomAvatars = Array.from({ length: 20 }, (_, i) => `https://i.pravatar.cc/150?img=${i + 1}`);
|
|
15
|
-
|
|
16
|
-
interface ItemCardProps {
|
|
17
|
-
item: Item;
|
|
18
|
-
index: number;
|
|
19
|
-
height: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (Platform.OS === "android") {
|
|
23
|
-
if (UIManager.setLayoutAnimationEnabledExperimental) {
|
|
24
|
-
UIManager.setLayoutAnimationEnabledExperimental(true);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const renderRightActions = () => {
|
|
29
|
-
return (
|
|
30
|
-
<RectButton
|
|
31
|
-
style={{
|
|
32
|
-
width: 80,
|
|
33
|
-
height: "100%",
|
|
34
|
-
backgroundColor: "#4CAF50",
|
|
35
|
-
justifyContent: "center",
|
|
36
|
-
alignItems: "center",
|
|
37
|
-
borderTopRightRadius: 12,
|
|
38
|
-
borderBottomRightRadius: 12,
|
|
39
|
-
shadowColor: "#000",
|
|
40
|
-
shadowOffset: { width: 2, height: 0 },
|
|
41
|
-
shadowOpacity: 0.1,
|
|
42
|
-
shadowRadius: 4,
|
|
43
|
-
}}
|
|
44
|
-
onPress={() => {
|
|
45
|
-
console.log("Marked as complete");
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<MaterialIcons name="check-circle" size={24} color="white" />
|
|
49
|
-
<Text
|
|
50
|
-
style={{
|
|
51
|
-
color: "white",
|
|
52
|
-
fontSize: 12,
|
|
53
|
-
marginTop: 4,
|
|
54
|
-
fontWeight: "600",
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
Complete
|
|
58
|
-
</Text>
|
|
59
|
-
</RectButton>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const ItemCard = ({ item, height }: ItemCardProps) => {
|
|
64
|
-
const indexForData = item.id.includes("new") ? 100 + +item.id.replace("new", "") : +item.id;
|
|
65
|
-
|
|
66
|
-
// Generate 1-5 random sentences
|
|
67
|
-
const numSentences = 5;
|
|
68
|
-
// const indexForData =
|
|
69
|
-
// item.id === "0" ? 0 : item.id === "1" ? 1 : item.id === "new0" ? 2 : 3;
|
|
70
|
-
// const numSentences =
|
|
71
|
-
// item.id === "0" ? 1 : item.id === "1" ? 2 : item.id === "new0" ? 4 : 8;
|
|
72
|
-
const randomText = Array.from({ length: numSentences }, (_, i) => loremSentences[i]).join(" ");
|
|
73
|
-
|
|
74
|
-
// Use randomIndex to deterministically select random data
|
|
75
|
-
const avatarUrl = randomAvatars[indexForData % randomAvatars.length];
|
|
76
|
-
const authorName = randomNames[indexForData % randomNames.length];
|
|
77
|
-
const timestamp = `${Math.max(1, indexForData % 24)}h ago`;
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<View style={[styles.itemOuterContainer, { height }]}>
|
|
81
|
-
<Swipeable
|
|
82
|
-
renderRightActions={renderRightActions}
|
|
83
|
-
overshootRight={true}
|
|
84
|
-
containerStyle={{ backgroundColor: "#4CAF50", borderRadius: 12 }}
|
|
85
|
-
>
|
|
86
|
-
<Pressable
|
|
87
|
-
onPress={() => {
|
|
88
|
-
// LinearTransition.easing(Easing.ease);
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
<View
|
|
92
|
-
style={[
|
|
93
|
-
styles.itemContainer,
|
|
94
|
-
{
|
|
95
|
-
// padding: 16,
|
|
96
|
-
backgroundColor: "#ffffff",
|
|
97
|
-
borderRadius: 12,
|
|
98
|
-
shadowColor: "#000",
|
|
99
|
-
shadowOffset: { width: 0, height: 2 },
|
|
100
|
-
shadowOpacity: 0.1,
|
|
101
|
-
shadowRadius: 4,
|
|
102
|
-
// marginVertical: 8,
|
|
103
|
-
overflow: "hidden",
|
|
104
|
-
},
|
|
105
|
-
]}
|
|
106
|
-
>
|
|
107
|
-
<View style={styles.headerContainer}>
|
|
108
|
-
<Image source={{ uri: avatarUrl }} style={styles.avatar} />
|
|
109
|
-
<View style={styles.headerText}>
|
|
110
|
-
<Text style={styles.authorName}>
|
|
111
|
-
{authorName} {item.id}
|
|
112
|
-
</Text>
|
|
113
|
-
<Text style={styles.timestamp}>{timestamp}</Text>
|
|
114
|
-
</View>
|
|
115
|
-
</View>
|
|
116
|
-
|
|
117
|
-
<Text style={styles.itemTitle}>Item #{item.id}</Text>
|
|
118
|
-
<Text
|
|
119
|
-
style={styles.itemBody}
|
|
120
|
-
// numberOfLines={isExpanded ? undefined : 10}
|
|
121
|
-
>
|
|
122
|
-
{randomText}
|
|
123
|
-
</Text>
|
|
124
|
-
<View style={styles.itemFooter}>
|
|
125
|
-
<Text style={styles.footerText}>❤️ 42</Text>
|
|
126
|
-
<Text style={styles.footerText}>💬 12</Text>
|
|
127
|
-
<Text style={styles.footerText}>🔄 8</Text>
|
|
128
|
-
</View>
|
|
129
|
-
</View>
|
|
130
|
-
</Pressable>
|
|
131
|
-
</Swipeable>
|
|
132
|
-
</View>
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const renderItem = ({ item, index, height }: ItemCardProps) => (
|
|
137
|
-
<ItemCard item={item} index={index} height={height} />
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const styles = StyleSheet.create({
|
|
141
|
-
itemOuterContainer: {
|
|
142
|
-
paddingVertical: 8,
|
|
143
|
-
paddingHorizontal: 8,
|
|
144
|
-
// marginTop: 16,
|
|
145
|
-
// maxWidth: 360,
|
|
146
|
-
},
|
|
147
|
-
itemContainer: {
|
|
148
|
-
padding: 16,
|
|
149
|
-
// borderBottomWidth: 1,
|
|
150
|
-
// borderBottomColor: "#ccc",
|
|
151
|
-
},
|
|
152
|
-
titleContainer: {
|
|
153
|
-
flexDirection: "row",
|
|
154
|
-
alignItems: "center",
|
|
155
|
-
gap: 8,
|
|
156
|
-
},
|
|
157
|
-
stepContainer: {
|
|
158
|
-
gap: 8,
|
|
159
|
-
marginBottom: 8,
|
|
160
|
-
},
|
|
161
|
-
listContainer: {
|
|
162
|
-
paddingHorizontal: 16,
|
|
163
|
-
},
|
|
164
|
-
itemTitle: {
|
|
165
|
-
fontSize: 18,
|
|
166
|
-
fontWeight: "bold",
|
|
167
|
-
marginBottom: 8,
|
|
168
|
-
color: "#1a1a1a",
|
|
169
|
-
},
|
|
170
|
-
itemBody: {
|
|
171
|
-
fontSize: 14,
|
|
172
|
-
color: "#666666",
|
|
173
|
-
lineHeight: 20,
|
|
174
|
-
// flex: 1,
|
|
175
|
-
},
|
|
176
|
-
itemFooter: {
|
|
177
|
-
flexDirection: "row",
|
|
178
|
-
justifyContent: "flex-start",
|
|
179
|
-
gap: 16,
|
|
180
|
-
marginTop: 12,
|
|
181
|
-
paddingTop: 12,
|
|
182
|
-
borderTopWidth: 1,
|
|
183
|
-
borderTopColor: "#f0f0f0",
|
|
184
|
-
},
|
|
185
|
-
footerText: {
|
|
186
|
-
fontSize: 14,
|
|
187
|
-
color: "#888888",
|
|
188
|
-
},
|
|
189
|
-
headerContainer: {
|
|
190
|
-
flexDirection: "row",
|
|
191
|
-
alignItems: "center",
|
|
192
|
-
marginBottom: 12,
|
|
193
|
-
},
|
|
194
|
-
avatar: {
|
|
195
|
-
width: 40,
|
|
196
|
-
height: 40,
|
|
197
|
-
borderRadius: 20,
|
|
198
|
-
marginRight: 12,
|
|
199
|
-
},
|
|
200
|
-
headerText: {
|
|
201
|
-
flex: 1,
|
|
202
|
-
},
|
|
203
|
-
authorName: {
|
|
204
|
-
fontSize: 16,
|
|
205
|
-
fontWeight: "600",
|
|
206
|
-
color: "#1a1a1a",
|
|
207
|
-
},
|
|
208
|
-
timestamp: {
|
|
209
|
-
fontSize: 12,
|
|
210
|
-
color: "#888888",
|
|
211
|
-
marginTop: 2,
|
|
212
|
-
},
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
export default renderItem;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { type Item, renderItem } from "@/app/cards-renderItem";
|
|
2
|
-
import { DRAW_DISTANCE, ESTIMATED_ITEM_LENGTH } from "@/constants/constants";
|
|
3
|
-
import { LegendList, type LegendListRef } from "@legendapp/list";
|
|
4
|
-
import { useRef, useState } from "react";
|
|
5
|
-
import { StyleSheet, View } from "react-native";
|
|
6
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
7
|
-
|
|
8
|
-
//** Purpose of this component is to show that LegendList with initialScrollIndex can correctly scroll to the begginning
|
|
9
|
-
// and the end of the list even if element height is unknown and calculated dynamically */
|
|
10
|
-
export default function IntialScrollIndexFreeHeight() {
|
|
11
|
-
const listRef = useRef<LegendListRef>(null);
|
|
12
|
-
|
|
13
|
-
const [data, setData] = useState<Item[]>(
|
|
14
|
-
() =>
|
|
15
|
-
Array.from({ length: 100 }, (_, i) => ({
|
|
16
|
-
id: i.toString(),
|
|
17
|
-
})) as any[],
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const { top, bottom } = useSafeAreaInsets();
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<View style={[StyleSheet.absoluteFill, styles.outerContainer]} key="legendlist">
|
|
24
|
-
<LegendList
|
|
25
|
-
ref={listRef}
|
|
26
|
-
initialScrollIndex={50}
|
|
27
|
-
style={[StyleSheet.absoluteFill, styles.scrollContainer]}
|
|
28
|
-
contentContainerStyle={styles.listContainer}
|
|
29
|
-
data={data}
|
|
30
|
-
renderItem={renderItem}
|
|
31
|
-
keyExtractor={(item) => `id${item.id}`}
|
|
32
|
-
estimatedItemSize={ESTIMATED_ITEM_LENGTH}
|
|
33
|
-
drawDistance={DRAW_DISTANCE}
|
|
34
|
-
maintainVisibleContentPosition
|
|
35
|
-
recycleItems={true}
|
|
36
|
-
//ListHeaderComponent={<View style={{ height: top }} />}
|
|
37
|
-
ListFooterComponent={<View style={{ height: bottom }} />}
|
|
38
|
-
numColumns={1}
|
|
39
|
-
/>
|
|
40
|
-
</View>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const styles = StyleSheet.create({
|
|
45
|
-
listHeader: {
|
|
46
|
-
alignSelf: "center",
|
|
47
|
-
height: 100,
|
|
48
|
-
width: 100,
|
|
49
|
-
backgroundColor: "#456AAA",
|
|
50
|
-
borderRadius: 12,
|
|
51
|
-
marginHorizontal: 8,
|
|
52
|
-
marginVertical: 8,
|
|
53
|
-
},
|
|
54
|
-
listEmpty: {
|
|
55
|
-
flex: 1,
|
|
56
|
-
justifyContent: "center",
|
|
57
|
-
alignItems: "center",
|
|
58
|
-
backgroundColor: "#6789AB",
|
|
59
|
-
paddingVertical: 16,
|
|
60
|
-
},
|
|
61
|
-
outerContainer: {
|
|
62
|
-
backgroundColor: "#456",
|
|
63
|
-
},
|
|
64
|
-
scrollContainer: {},
|
|
65
|
-
listContainer: {
|
|
66
|
-
width: "100%",
|
|
67
|
-
maxWidth: "100%",
|
|
68
|
-
marginHorizontal: "auto",
|
|
69
|
-
},
|
|
70
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { LegendList } from "@legendapp/list";
|
|
2
|
-
import { useCallback, useState } from "react";
|
|
3
|
-
import { Button, StyleSheet, Text, View } from "react-native";
|
|
4
|
-
|
|
5
|
-
// Dummy data: 50 items
|
|
6
|
-
const DATA = Array.from({ length: 70 }, (_, i) => ({ label: `Item ${i}`, height: ((i * 7919) % 100) + 10 }));
|
|
7
|
-
|
|
8
|
-
export default function App() {
|
|
9
|
-
const [scrollToIdx, setScrollToIdx] = useState(0);
|
|
10
|
-
|
|
11
|
-
console.log("keyed");
|
|
12
|
-
|
|
13
|
-
const renderItem = useCallback(
|
|
14
|
-
({ item }) => (
|
|
15
|
-
<View style={[styles.item, { height: item.height }]}>
|
|
16
|
-
<Text>{item.label}</Text>
|
|
17
|
-
</View>
|
|
18
|
-
),
|
|
19
|
-
[],
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<View style={styles.container}>
|
|
24
|
-
<View style={styles.buttons}>
|
|
25
|
-
<Button title="Scroll to 10" onPress={() => setScrollToIdx(10)} />
|
|
26
|
-
<Button title="Scroll to 20" onPress={() => setScrollToIdx(20)} />
|
|
27
|
-
<Button title="Scroll to 30" onPress={() => setScrollToIdx(30)} />
|
|
28
|
-
<Button title="Scroll to 40" onPress={() => setScrollToIdx(40)} />
|
|
29
|
-
</View>
|
|
30
|
-
|
|
31
|
-
<View key={scrollToIdx} style={styles.list}>
|
|
32
|
-
<LegendList
|
|
33
|
-
data={DATA}
|
|
34
|
-
renderItem={renderItem}
|
|
35
|
-
keyExtractor={(item) => item.label}
|
|
36
|
-
estimatedItemSize={60}
|
|
37
|
-
style={styles.list}
|
|
38
|
-
initialScrollIndex={scrollToIdx}
|
|
39
|
-
maintainVisibleContentPosition
|
|
40
|
-
/>
|
|
41
|
-
</View>
|
|
42
|
-
</View>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const styles = StyleSheet.create({
|
|
47
|
-
container: { flex: 1 },
|
|
48
|
-
buttons: {
|
|
49
|
-
flexDirection: "row",
|
|
50
|
-
justifyContent: "space-around",
|
|
51
|
-
marginBottom: 10,
|
|
52
|
-
},
|
|
53
|
-
list: { flex: 1 },
|
|
54
|
-
item: {
|
|
55
|
-
justifyContent: "center",
|
|
56
|
-
alignItems: "center",
|
|
57
|
-
backgroundColor: "#fafafa",
|
|
58
|
-
marginVertical: 4,
|
|
59
|
-
marginHorizontal: 16,
|
|
60
|
-
borderRadius: 8,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { LazyLegendList, type LegendListRef } from "@legendapp/list";
|
|
2
|
-
import { type TCountryCode, countries, getEmojiFlag } from "countries-list";
|
|
3
|
-
import { useRef, useState } from "react";
|
|
4
|
-
import { Pressable, StatusBar, StyleSheet, Text, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
type Country = {
|
|
7
|
-
id: string;
|
|
8
|
-
name: string;
|
|
9
|
-
flag: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const DATA: Country[] = Object.entries(countries)
|
|
13
|
-
.map(([code, country]) => ({
|
|
14
|
-
id: code,
|
|
15
|
-
name: country.name,
|
|
16
|
-
flag: getEmojiFlag(code as TCountryCode),
|
|
17
|
-
}))
|
|
18
|
-
.sort((a, b) => a.name.localeCompare(b.name));
|
|
19
|
-
|
|
20
|
-
export default function LazyList() {
|
|
21
|
-
const listRef = useRef<LegendListRef>(null);
|
|
22
|
-
const [selectedId, setSelectedId] = useState<string>();
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<View style={styles.container}>
|
|
26
|
-
<LazyLegendList ref={listRef} maintainVisibleContentPosition recycleItems>
|
|
27
|
-
<View style={styles.heading}>
|
|
28
|
-
<Text style={styles.headingText}>Countries lazy scrollview</Text>
|
|
29
|
-
</View>
|
|
30
|
-
{DATA.map((country) => (
|
|
31
|
-
<Pressable
|
|
32
|
-
key={country.id}
|
|
33
|
-
onPress={() => setSelectedId(country.id)}
|
|
34
|
-
style={({ pressed }) => [
|
|
35
|
-
styles.item,
|
|
36
|
-
selectedId === country.id && styles.selectedItem,
|
|
37
|
-
pressed && styles.pressedItem,
|
|
38
|
-
]}
|
|
39
|
-
>
|
|
40
|
-
<View style={styles.flagContainer}>
|
|
41
|
-
<Text style={styles.flag}>{country.flag}</Text>
|
|
42
|
-
</View>
|
|
43
|
-
<View style={styles.contentContainer}>
|
|
44
|
-
<Text style={[styles.title, selectedId === country.id && styles.selectedText]}>
|
|
45
|
-
{country.name}
|
|
46
|
-
<Text style={styles.countryCode}> ({country.id})</Text>
|
|
47
|
-
</Text>
|
|
48
|
-
</View>
|
|
49
|
-
</Pressable>
|
|
50
|
-
))}
|
|
51
|
-
</LazyLegendList>
|
|
52
|
-
</View>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const styles = StyleSheet.create({
|
|
57
|
-
container: {
|
|
58
|
-
flex: 1,
|
|
59
|
-
marginTop: StatusBar.currentHeight || 0,
|
|
60
|
-
backgroundColor: "#f5f5f5",
|
|
61
|
-
},
|
|
62
|
-
heading: {
|
|
63
|
-
paddingVertical: 8,
|
|
64
|
-
paddingHorizontal: 16,
|
|
65
|
-
},
|
|
66
|
-
headingText: {
|
|
67
|
-
fontWeight: "bold",
|
|
68
|
-
},
|
|
69
|
-
item: {
|
|
70
|
-
paddingHorizontal: 16,
|
|
71
|
-
paddingVertical: 6,
|
|
72
|
-
flexDirection: "row",
|
|
73
|
-
alignItems: "center",
|
|
74
|
-
backgroundColor: "#fff",
|
|
75
|
-
borderRadius: 12,
|
|
76
|
-
// shadowColor: "#000",
|
|
77
|
-
// shadowOffset: {
|
|
78
|
-
// width: 0,
|
|
79
|
-
// height: 2,
|
|
80
|
-
// },
|
|
81
|
-
// shadowOpacity: 0.1,
|
|
82
|
-
// shadowRadius: 3,
|
|
83
|
-
// elevation: 3,
|
|
84
|
-
},
|
|
85
|
-
selectedItem: {
|
|
86
|
-
// backgroundColor: "#e3f2fd",
|
|
87
|
-
// borderColor: "#1976d2",
|
|
88
|
-
// borderWidth: 1,
|
|
89
|
-
},
|
|
90
|
-
pressedItem: {
|
|
91
|
-
// backgroundColor: "#f0f0f0",
|
|
92
|
-
},
|
|
93
|
-
flagContainer: {
|
|
94
|
-
marginRight: 16,
|
|
95
|
-
width: 40,
|
|
96
|
-
height: 40,
|
|
97
|
-
borderRadius: 20,
|
|
98
|
-
backgroundColor: "#f8f9fa",
|
|
99
|
-
alignItems: "center",
|
|
100
|
-
justifyContent: "center",
|
|
101
|
-
},
|
|
102
|
-
flag: {
|
|
103
|
-
fontSize: 28,
|
|
104
|
-
},
|
|
105
|
-
contentContainer: {
|
|
106
|
-
flex: 1,
|
|
107
|
-
justifyContent: "center",
|
|
108
|
-
},
|
|
109
|
-
title: {
|
|
110
|
-
fontSize: 16,
|
|
111
|
-
color: "#333",
|
|
112
|
-
fontWeight: "500",
|
|
113
|
-
},
|
|
114
|
-
selectedText: {
|
|
115
|
-
color: "#1976d2",
|
|
116
|
-
fontWeight: "600",
|
|
117
|
-
},
|
|
118
|
-
countryCode: {
|
|
119
|
-
fontSize: 14,
|
|
120
|
-
color: "#666",
|
|
121
|
-
fontWeight: "400",
|
|
122
|
-
},
|
|
123
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { LegendList, type LegendListRenderItemProps } from "@legendapp/list";
|
|
2
|
-
import type React from "react";
|
|
3
|
-
import { createContext, useCallback, useContext, useState } from "react";
|
|
4
|
-
import { Button, StyleSheet, Text, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
const fakeData = Array.from({ length: 100 }, (_, index) => ({
|
|
7
|
-
id: index,
|
|
8
|
-
title: `Item ${index + 1}`,
|
|
9
|
-
score: 0,
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
type Item = (typeof fakeData)[number];
|
|
13
|
-
|
|
14
|
-
const DataContext = createContext({
|
|
15
|
-
data: fakeData,
|
|
16
|
-
increment: (id: number) => {},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const DataProvider = ({ initialData, children }: { initialData: Item[]; children: React.ReactNode }) => {
|
|
20
|
-
const [data, setData] = useState(initialData);
|
|
21
|
-
|
|
22
|
-
const increment = useCallback((id: number) => {
|
|
23
|
-
setData((prevData) => {
|
|
24
|
-
return prevData.map((item) => {
|
|
25
|
-
if (item.id === id) {
|
|
26
|
-
return { ...item, score: item.score + 1 };
|
|
27
|
-
}
|
|
28
|
-
return item;
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
return <DataContext.Provider value={{ data, increment }}>{children}</DataContext.Provider>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const useData = () => useContext(DataContext);
|
|
37
|
-
|
|
38
|
-
const Item = ({ item }: { item: Item }) => {
|
|
39
|
-
const { increment } = useData();
|
|
40
|
-
return (
|
|
41
|
-
<View
|
|
42
|
-
style={{
|
|
43
|
-
height: 100,
|
|
44
|
-
backgroundColor: "#fefefe",
|
|
45
|
-
justifyContent: "center",
|
|
46
|
-
paddingHorizontal: 24,
|
|
47
|
-
borderRadius: 16,
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
<Text style={{ fontSize: 24, fontWeight: "bold" }}>{`${item.title} - Score:${item.score}`}</Text>
|
|
51
|
-
<Button
|
|
52
|
-
title="Increment"
|
|
53
|
-
onPress={() => {
|
|
54
|
-
increment(item.id);
|
|
55
|
-
}}
|
|
56
|
-
/>
|
|
57
|
-
</View>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const ItemSeparatorComponent = () => <View style={{ height: 16 }} />;
|
|
62
|
-
|
|
63
|
-
export const List = () => {
|
|
64
|
-
const { data } = useData();
|
|
65
|
-
const renderItem = ({ item }: LegendListRenderItemProps<Item>) => <Item item={item} />;
|
|
66
|
-
return (
|
|
67
|
-
<View style={{ flex: 1, paddingHorizontal: 16, marginTop: 70 }}>
|
|
68
|
-
<LegendList
|
|
69
|
-
data={data}
|
|
70
|
-
estimatedItemSize={116}
|
|
71
|
-
ItemSeparatorComponent={ItemSeparatorComponent}
|
|
72
|
-
renderItem={renderItem}
|
|
73
|
-
keyExtractor={(item) => String(item.id)}
|
|
74
|
-
/>
|
|
75
|
-
</View>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default function HomeScreen() {
|
|
80
|
-
return (
|
|
81
|
-
<DataProvider initialData={fakeData}>
|
|
82
|
-
<List />
|
|
83
|
-
</DataProvider>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const styles = StyleSheet.create({
|
|
88
|
-
titleContainer: {
|
|
89
|
-
flexDirection: "row",
|
|
90
|
-
alignItems: "center",
|
|
91
|
-
gap: 8,
|
|
92
|
-
},
|
|
93
|
-
stepContainer: {
|
|
94
|
-
gap: 8,
|
|
95
|
-
marginBottom: 8,
|
|
96
|
-
},
|
|
97
|
-
reactLogo: {
|
|
98
|
-
height: 178,
|
|
99
|
-
width: 290,
|
|
100
|
-
bottom: 0,
|
|
101
|
-
left: 0,
|
|
102
|
-
position: "absolute",
|
|
103
|
-
},
|
|
104
|
-
});
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { LegendList } from "@legendapp/list";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { useEffect } from "react";
|
|
4
|
-
import { Dimensions, LogBox, StyleSheet, Text, View } from "react-native";
|
|
5
|
-
|
|
6
|
-
LogBox.ignoreLogs(["Open debugger"]);
|
|
7
|
-
|
|
8
|
-
const WINDOW_HEIGHT = Dimensions.get("window").height;
|
|
9
|
-
const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5", "#9B59B6", "#3498DB"];
|
|
10
|
-
|
|
11
|
-
const initialData = Array.from({ length: 8 }, (_, index) => ({
|
|
12
|
-
id: index.toString(),
|
|
13
|
-
color: colors[index % colors.length],
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
export default function VideoFeed() {
|
|
17
|
-
const [data, setData] = useState(initialData);
|
|
18
|
-
const [height, setHeight] = useState(0);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
setTimeout(() => {
|
|
22
|
-
setData(
|
|
23
|
-
Array.from({ length: 10 }, (_, index) => ({
|
|
24
|
-
id: index.toString(),
|
|
25
|
-
color: colors[index % colors.length],
|
|
26
|
-
})),
|
|
27
|
-
);
|
|
28
|
-
}, 1000);
|
|
29
|
-
}, []);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<View style={styles.container} onLayout={(e) => setHeight(e.nativeEvent.layout.height)}>
|
|
33
|
-
{!!height && (
|
|
34
|
-
<LegendList
|
|
35
|
-
data={data}
|
|
36
|
-
renderItem={Item}
|
|
37
|
-
keyExtractor={(item) => item.id}
|
|
38
|
-
decelerationRate="fast"
|
|
39
|
-
showsVerticalScrollIndicator={false}
|
|
40
|
-
estimatedItemSize={height}
|
|
41
|
-
pagingEnabled
|
|
42
|
-
drawDistance={1}
|
|
43
|
-
extraData={height}
|
|
44
|
-
onEndReached={() => {
|
|
45
|
-
setData([
|
|
46
|
-
...data,
|
|
47
|
-
...Array.from({ length: 10 }, (_, index) => ({
|
|
48
|
-
id: (data.length + index).toString(),
|
|
49
|
-
color: colors[index % colors.length],
|
|
50
|
-
})),
|
|
51
|
-
]);
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
)}
|
|
55
|
-
</View>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function Item({ item, extraData }: { item: { id: string; color: string }; extraData: number }) {
|
|
60
|
-
return (
|
|
61
|
-
<View style={[styles.rectangle, { height: extraData }]}>
|
|
62
|
-
<View style={[styles.rectangleInner, { backgroundColor: item.color }]} />
|
|
63
|
-
<Text style={styles.itemText}>Item {item.id}</Text>
|
|
64
|
-
</View>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const styles = StyleSheet.create({
|
|
69
|
-
container: {
|
|
70
|
-
flex: 1,
|
|
71
|
-
backgroundColor: "#fff",
|
|
72
|
-
},
|
|
73
|
-
rectangle: {
|
|
74
|
-
height: WINDOW_HEIGHT,
|
|
75
|
-
width: "100%",
|
|
76
|
-
position: "relative",
|
|
77
|
-
},
|
|
78
|
-
rectangleInner: {
|
|
79
|
-
height: "100%",
|
|
80
|
-
width: "100%",
|
|
81
|
-
},
|
|
82
|
-
itemText: {
|
|
83
|
-
position: "absolute",
|
|
84
|
-
bottom: 20,
|
|
85
|
-
left: 20,
|
|
86
|
-
color: "#fff",
|
|
87
|
-
fontSize: 18,
|
|
88
|
-
fontWeight: "bold",
|
|
89
|
-
},
|
|
90
|
-
redRectangle: {
|
|
91
|
-
aspectRatio: 1,
|
|
92
|
-
},
|
|
93
|
-
redRectangleInner: {
|
|
94
|
-
height: "100%",
|
|
95
|
-
width: "100%",
|
|
96
|
-
backgroundColor: "red",
|
|
97
|
-
borderRadius: 8,
|
|
98
|
-
},
|
|
99
|
-
columnWrapper: {
|
|
100
|
-
justifyContent: "space-between",
|
|
101
|
-
},
|
|
102
|
-
listHeader: {
|
|
103
|
-
alignSelf: "center",
|
|
104
|
-
height: 100,
|
|
105
|
-
width: 100,
|
|
106
|
-
backgroundColor: "#456AAA",
|
|
107
|
-
borderRadius: 12,
|
|
108
|
-
marginHorizontal: 8,
|
|
109
|
-
marginVertical: 8,
|
|
110
|
-
},
|
|
111
|
-
listEmpty: {
|
|
112
|
-
flex: 1,
|
|
113
|
-
justifyContent: "center",
|
|
114
|
-
alignItems: "center",
|
|
115
|
-
backgroundColor: "#6789AB",
|
|
116
|
-
paddingVertical: 16,
|
|
117
|
-
height: 100,
|
|
118
|
-
},
|
|
119
|
-
});
|