|
| 1 | +import React from "react"; |
| 2 | +import { StyleSheet, Text, View, Image } from "react-native"; |
| 3 | +import * as Animatable from "react-native-animatable"; |
| 4 | +import RNMasonryScroll from "react-native-masonry-scrollview"; |
| 5 | + |
| 6 | +const { createAnimatableComponent } = Animatable; |
| 7 | + |
| 8 | +const AnimatableView = createAnimatableComponent(View); |
| 9 | + |
| 10 | +const images = [ |
| 11 | + "https://images.unsplash.com/photo-1558981001-792f6c0d5068?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 12 | + "https://images.unsplash.com/photo-1580502734537-c6a7ee0bdb41?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 13 | + "https://images.unsplash.com/photo-1580500325788-5012abe74ebf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 14 | + "https://images.unsplash.com/photo-1580524764764-284c2a54b185?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 15 | + "https://images.unsplash.com/photo-1558981001-792f6c0d5068?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 16 | + "https://images.unsplash.com/photo-1580502734537-c6a7ee0bdb41?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 17 | + "https://images.unsplash.com/photo-1580500325788-5012abe74ebf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 18 | + "https://images.unsplash.com/photo-1580524764764-284c2a54b185?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 19 | + "https://images.unsplash.com/photo-1558981001-792f6c0d5068?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 20 | + "https://images.unsplash.com/photo-1580502734537-c6a7ee0bdb41?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 21 | + "https://images.unsplash.com/photo-1580500325788-5012abe74ebf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 22 | + "https://images.unsplash.com/photo-1580524764764-284c2a54b185?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 23 | + "https://images.unsplash.com/photo-1558981001-792f6c0d5068?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 24 | + "https://images.unsplash.com/photo-1580502734537-c6a7ee0bdb41?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 25 | + "https://images.unsplash.com/photo-1580500325788-5012abe74ebf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 26 | + "https://images.unsplash.com/photo-1580524764764-284c2a54b185?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 27 | + "https://images.unsplash.com/photo-1558981001-792f6c0d5068?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 28 | + "https://images.unsplash.com/photo-1580502734537-c6a7ee0bdb41?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 29 | + "https://images.unsplash.com/photo-1580500325788-5012abe74ebf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 30 | + "https://images.unsplash.com/photo-1580524764764-284c2a54b185?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 31 | + "https://images.unsplash.com/photo-1558981001-792f6c0d5068?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 32 | + "https://images.unsplash.com/photo-1580502734537-c6a7ee0bdb41?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 33 | + "https://images.unsplash.com/photo-1580500325788-5012abe74ebf?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60", |
| 34 | + "https://images.unsplash.com/photo-1580524764764-284c2a54b185?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=400&q=60" |
| 35 | +]; |
| 36 | + |
| 37 | +export default function App() { |
| 38 | + return ( |
| 39 | + <RNMasonryScroll |
| 40 | + columns={3} |
| 41 | + evenColumnStyle={{}} |
| 42 | + oddColumnStyle={{ marginTop: 60 }} |
| 43 | + > |
| 44 | + {images.map((image, imageIndex) => { |
| 45 | + return ( |
| 46 | + <AnimatableView |
| 47 | + animation="fadeInUp" |
| 48 | + delay={100 * imageIndex} |
| 49 | + style={{ |
| 50 | + height: 300, |
| 51 | + width: 300, |
| 52 | + margin: 10, |
| 53 | + borderRadius: 10, |
| 54 | + overflow: "hidden", |
| 55 | + backgroundColor: "silver" |
| 56 | + }} |
| 57 | + > |
| 58 | + <Image |
| 59 | + style={{ flex: 1 }} |
| 60 | + source={{ uri: image }} |
| 61 | + key={imageIndex} |
| 62 | + /> |
| 63 | + </AnimatableView> |
| 64 | + ); |
| 65 | + })} |
| 66 | + </RNMasonryScroll> |
| 67 | + ); |
| 68 | +} |
| 69 | + |
| 70 | +const styles = StyleSheet.create({ |
| 71 | + container: { |
| 72 | + flex: 1, |
| 73 | + backgroundColor: "#fff", |
| 74 | + alignItems: "center", |
| 75 | + justifyContent: "center" |
| 76 | + } |
| 77 | +}); |
0 commit comments