From 5d1213f1ab41755254da3c25540aec3403ae0d98 Mon Sep 17 00:00:00 2001 From: miniyoung Date: Sun, 21 Aug 2022 22:12:01 +0900 Subject: [PATCH] feat. AdvancedFlatList --- animatedRN/App.tsx | 16 +++ .../src/AdvancedFlatList/AdvancedFlatList.tsx | 114 ++++++++++++++++++ animatedRN/src/AdvancedFlatList/index.ts | 3 + animatedRN/src/Main/Main.tsx | 43 +++++++ animatedRN/src/Main/index.ts | 3 + 5 files changed, 179 insertions(+) create mode 100644 animatedRN/src/AdvancedFlatList/AdvancedFlatList.tsx create mode 100644 animatedRN/src/AdvancedFlatList/index.ts create mode 100644 animatedRN/src/Main/Main.tsx create mode 100644 animatedRN/src/Main/index.ts diff --git a/animatedRN/App.tsx b/animatedRN/App.tsx index d31f730..db17dde 100644 --- a/animatedRN/App.tsx +++ b/animatedRN/App.tsx @@ -4,11 +4,20 @@ import { createStackNavigator } from "@react-navigation/stack"; import { StyleSheet, Text, View } from "react-native"; import Accordion from "./src/Accordion"; import LoopingAnimation from "./src/LoopingAnimation"; +import Main from "./src/Main"; +import AdvancedFlatList from "./src/AdvancedFlatList"; const Stack = createStackNavigator(); const AppNavigator = () => ( + ( title: "LoopingAnimation", }} /> + ); diff --git a/animatedRN/src/AdvancedFlatList/AdvancedFlatList.tsx b/animatedRN/src/AdvancedFlatList/AdvancedFlatList.tsx new file mode 100644 index 0000000..27d8eae --- /dev/null +++ b/animatedRN/src/AdvancedFlatList/AdvancedFlatList.tsx @@ -0,0 +1,114 @@ +import * as React from "react"; +import { Animated, Dimensions, Image, FlatList, Text, View, StyleSheet } from "react-native"; +import { StatusBar } from "expo-status-bar"; + +const { width, height } = Dimensions.get("screen"); +const ITEM_WIDTH = width * 0.76; +const ITEM_HEIGHT = ITEM_WIDTH * 1.47; + +const images = [ + "https://images.unsplash.com/photo-1551316679-9c6ae9dec224?w=800&q=80", + "https://images.unsplash.com/photo-1562569633-622303bafef5?w=800&q=80", + "https://images.unsplash.com/photo-1503656142023-618e7d1f435a?w=800&q=80", + "https://images.unsplash.com/photo-1555096462-c1c5eb4e4d64?w=800&q=80", + "https://images.unsplash.com/photo-1517957754642-2870518e16f8?w=800&q=80", + "https://images.unsplash.com/photo-1546484959-f9a381d1330d?w=800&q=80", + "https://images.unsplash.com/photo-1548761208-b7896a6ff225?w=800&q=80", + "https://images.unsplash.com/photo-1511208687438-2c5a5abb810c?w=800&q=80", + "https://images.unsplash.com/photo-1548614606-52b4451f994b?w=800&q=80", + "https://images.unsplash.com/photo-1548600916-dc8492f8e845?w=800&q=80", +]; +const data = images.map((image, index) => ({ + key: String(index), + photo: image, + avatar_url: `https://randomuser.me/api/portraits/women/${Math.floor(Math.random() * 40)}.jpg`, +})); + +export default function AdvancedFlatList() { + const scrollX = React.useRef(new Animated.Value(0)).current; + + return ( + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: "#fff", + alignItems: "center", + justifyContent: "center", + }, +}); diff --git a/animatedRN/src/AdvancedFlatList/index.ts b/animatedRN/src/AdvancedFlatList/index.ts new file mode 100644 index 0000000..21abd0b --- /dev/null +++ b/animatedRN/src/AdvancedFlatList/index.ts @@ -0,0 +1,3 @@ +import AdvancedFlatList from "./AdvancedFlatList"; + +export default AdvancedFlatList; diff --git a/animatedRN/src/Main/Main.tsx b/animatedRN/src/Main/Main.tsx new file mode 100644 index 0000000..072cdb6 --- /dev/null +++ b/animatedRN/src/Main/Main.tsx @@ -0,0 +1,43 @@ +import React from "react"; +import { View, Text, StyleSheet, Pressable, ScrollView } from "react-native"; + +const Main = ({ navigation }: any) => { + return ( + + + navigation.navigate("Accordion")} style={styles.buttonContainer}> + Accordion + + navigation.navigate("LoopingAnimation")} style={styles.buttonContainer}> + LoopingAnimation + + navigation.navigate("AdvancedFlatList")} style={styles.buttonContainer}> + AdvancedFlatList + + + + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: "center", + alignItems: "center", + }, + buttonContainer: { + width: 300, + height: 40, + marginBottom: 20, + justifyContent: "center", + alignItems: "center", + backgroundColor: "gray", + borderRadius: 10, + }, + text: { + fontSize: 18, + color: "white", + }, +}); + +export default Main; diff --git a/animatedRN/src/Main/index.ts b/animatedRN/src/Main/index.ts new file mode 100644 index 0000000..274b9d2 --- /dev/null +++ b/animatedRN/src/Main/index.ts @@ -0,0 +1,3 @@ +import Main from "./Main"; + +export default Main;