Skip to content

Commit e0363db

Browse files
committed
Add new sample with lots of items
1 parent 838c3ba commit e0363db

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

fixture/react-native/src/ExamplesScreen.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ export const ExamplesScreen = () => {
9191
title: "Showcase App",
9292
destination: "ShowcaseApp",
9393
},
94+
{
95+
title: "Lot of Items",
96+
destination: "LotOfItems",
97+
},
9498
];
9599
return (
96100
<>

fixture/react-native/src/NavigationTree.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import MovieList from "./MovieList";
2828
import Carousel from "./Carousel";
2929
import { LayoutOptions } from "./LayoutOptions";
3030
import ShowcaseApp from "./ShowcaseApp";
31+
import LotOfItems from "./lot-of-items/LotOfItems";
3132

3233
const Stack = createStackNavigator<RootStackParamList>();
3334

@@ -98,6 +99,11 @@ const NavigationTree = () => {
9899
component={ShowcaseApp}
99100
options={{ title: "Showcase App" }}
100101
/>
102+
<Stack.Screen
103+
name="LotOfItems"
104+
component={LotOfItems}
105+
options={{ title: "Lot of Items" }}
106+
/>
101107
</Stack.Group>
102108
<Stack.Screen name="Masonry" component={Masonry} />
103109
<Stack.Screen name="ComplexMasonry" component={ComplexMasonry} />

fixture/react-native/src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ export type RootStackParamList = {
3232
Carousel: undefined;
3333
LayoutOptions: undefined;
3434
ShowcaseApp: undefined;
35+
LotOfItems: undefined;
3536
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { View, StyleSheet } from "react-native";
2+
import { FlashList } from "@shopify/flash-list";
3+
import React from "react";
4+
5+
import LotOfItemsHorizontalList from "./LotOfItemsHorizontalList";
6+
7+
interface Item {
8+
id: number;
9+
title: string;
10+
}
11+
12+
const DATA = [...Array(100).keys()].map((i) => {
13+
return { id: i, title: `Bloc ${i}` };
14+
});
15+
16+
function ItemList({ item }: { item: Item }) {
17+
return (
18+
<View>
19+
<LotOfItemsHorizontalList />
20+
</View>
21+
);
22+
}
23+
24+
const renderItem = ({ item }: { item: Item }) => {
25+
return <ItemList item={item} />;
26+
};
27+
28+
export default function Reminders() {
29+
return (
30+
<FlashList data={DATA} renderItem={renderItem} style={styles.container} />
31+
);
32+
}
33+
34+
const styles = StyleSheet.create({
35+
container: {
36+
backgroundColor: "#ecf0f1",
37+
},
38+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { View, Text, Pressable, StyleSheet } from "react-native";
2+
import { FlashList } from "@shopify/flash-list";
3+
import React from "react";
4+
5+
interface Item {
6+
id: number;
7+
title: string;
8+
}
9+
10+
const DATA = [...Array(30).keys()].map((i) => {
11+
return { id: i, title: `Item ${i}` };
12+
});
13+
14+
function Item({ item }: { item: Item }) {
15+
return (
16+
<Pressable>
17+
{({ pressed }) => (
18+
<View style={styles.item}>
19+
<Text>{item.title}</Text>
20+
{pressed ? <Text>pressed</Text> : null}
21+
</View>
22+
)}
23+
</Pressable>
24+
);
25+
}
26+
27+
const renderItem = ({ item }: { item: Item }) => {
28+
return <Item item={item} />;
29+
};
30+
31+
export default function LotOfItemsHorizontalList() {
32+
return <FlashList data={DATA} horizontal renderItem={renderItem} />;
33+
}
34+
35+
const styles = StyleSheet.create({
36+
item: {
37+
width: 50,
38+
},
39+
});

0 commit comments

Comments
 (0)