Skip to content

Commit e423ac0

Browse files
committed
✨ CardList organism
1 parent 5b00428 commit e423ac0

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from "react";
2+
import { Dimensions, FlatList, TouchableOpacity, View } from "react-native";
3+
import Animated, { SlideInLeft, SlideOutRight } from "react-native-reanimated";
4+
5+
import { Card, CardProps } from "../../molecules";
6+
7+
type DataProps = CardProps & { id: number };
8+
9+
interface Props {
10+
data: DataProps[];
11+
callback: (id: number) => void;
12+
}
13+
14+
const { width } = Dimensions.get("window");
15+
16+
export const CardList = ({ data, callback }: Props) => {
17+
return (
18+
<FlatList
19+
data={data}
20+
keyExtractor={({ image, title }) => `${image}${title}`}
21+
renderItem={({ item: { image, title, id }, index }) => (
22+
<Animated.View
23+
key={id}
24+
entering={SlideInLeft.delay(100 * index)}
25+
exiting={SlideOutRight.delay(200)}
26+
>
27+
<TouchableOpacity onPress={() => callback(id)}>
28+
<Card image={image} title={title} />
29+
</TouchableOpacity>
30+
</Animated.View>
31+
)}
32+
ItemSeparatorComponent={() => <View style={{ height: 20 }} />}
33+
contentContainerStyle={{ width, paddingVertical: 50 }}
34+
/>
35+
);
36+
};

src/atomic/organisms/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./CardList";

0 commit comments

Comments
 (0)