react-native-image-layouts
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-native-image-layouts

Simple component to render images in any layouts with RN Flatlist.

Installation

npm install react-native-image-layouts

or 

yarn add react-native-image-layouts

Usage

import ImageLayouts from "react-native-image-layouts";

const layoutPattern = [1, 3, 2, 2, 1];

const images = [/* list of uris */];

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  image: {
    width: '100%',
    height: 150,
  },
});

// ...
export default function App() {
  function renderItem(uri: string, _index: number) {
    return <Image source={{ uri: uri }} style={styles.image} />;
  }

  return (
    <SafeAreaView style={styles.container}>
      <ImageLayouts
        data={images}
        numberOfColumns={2}
        patterns={layoutPattern}
        renderItem={renderItem}
        dividerPadding={2}
      />
    </SafeAreaView>
  );
}

Screenshot:

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Package Sidebar

Install

npm i react-native-image-layouts

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

38.9 kB

Total Files

15

Last publish

Collaborators

  • tudatn