react-native-card-animated-modal

An animated modal from a card item in a list for React Native.

Showing:

Popularity

Downloads/wk

5

GitHub Stars

87

Maintenance

Last Commit

2yrs ago

Contributors

2

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

react-native-card-animated-modal

This component is inspired by the iOS App of the Day cards in App Store. It does not need any native code requirements so it can be used with non-ejected expo projects. The card-modal interaction uses the concept of shared elements.

Features

  • Pure Javascript code.
  • Customizable content rendering per item card.
  • Customizable list component.

Installation

Install the package using npm or yarn.

npm install --save react-native-card-animated-modal
or
yarn add react-native-card-animated-modal

Example Output

Example

Go to example folder and run it locally.

Basic Usage

import CardList from "react-native-card-animated-modal";
import { View, Text } from "react-native";

const now = new Date();
const CARDS = [
  {
    image: {
      uri:
        "http://www.gamespersecond.com/media/2011/07/battlefield-3-poster.jpg"
    },
    height: 300,
    renderItem: ({ item, index }) => (
      <View>
        <Text>Customizable Content</Text>
      </View>
    )
  }
];

const App = () => (
  <CardList
    listProps={{
      ListHeaderComponent: () => (
        <View style={{ padding: 16, paddingBottom: 0 }}>
          <Text
            style={{
              fontSize: 13,
              color: "rgba(0, 0, 0, 0.5)"
            }}
          >
            {now.toDateString()}
          </Text>
          <Text style={{ fontSize: 32, fontWeight: "bold" }}>Featured</Text>
        </View>
      )
    }}
    data={CARDS}
    renderItem={({ item, index }) => {
      /* Render card per item */
      if (item.renderItem) return item.renderItem({ item, index });

      /* Default card when not specified */
      return (
        <View>
          <Text>Default Content</Text>
        </View>
      );
    }}
    renderDetails={({ item, index }) => (
      /* You can also provide custom content per item */
      <View style={{ paddingVertical: 30, paddingHorizontal: 16 }}>
        <Text style={{ color: "rgba(0, 0, 0, 0.7)", fontSize: 18 }}>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
          eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
          minim veniam, quis nostrud exercitation ullamco laboris nisi ut
          aliquip ex ea commodo consequat. Duis aute irure dolor in
          reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
          pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
          culpa qui officia deserunt mollit anim id est laborum.
        </Text>
      </View>
    )}
  />
);

Data Structure Example

[
  {
    // image source for Image component
    image: {
      uri:
        "http://www.gamespersecond.com/media/2011/07/battlefield-3-poster.jpg"
    },
    // Height for the card
    height: 300,
    // Will be used when you want to render different contents per card.
    renderItem: ({ item, index }) => (
      <View>
        <Text>Customizable Content</Text>
      </View>
    )
  }
];

Props

PropRequiredDefaultDescription
dataoptional but should be provided[]Data of the cards to be provided to the list component.
renderItemoptional() => nullFunction that takes ({ item, index }) that will be used to render content of each card.
renderDetailsoptional() => nullFunction that takes ({ item, index }) that will be used to render details in the bottom of each card when expanded.
listPropsoptional{}Props that will be applied to the list component.
cardContainerStyleoptional{}Styling property that will be applied to the cards.
detailsContainerStyleoptional{}Styling property that will be applied to the details area of the expanded card.
listContainerStyleoptional{flexGrow: 1, backgroundColor: "rgb(250, 250, 250)"}Styling property that will be applied to the contentContainerStyle of list component
safeAreaStyleoptional{ flex: 1 }Styling property that will be applied to the container which is SafeAreaView
cardWidthoptionalDevice Width - 32The width of the cards.
ListComponentoptionalFlatListCustomizable list component. You can pass here a different component that you want to use for rendering the list.
headeroptionalnullHeader component that will be rendered at the top of the list
footeroptionalnullFooter component that will be rendered at the bottom of the list

License

MIT © AMAGI

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial