Giter Site home page Giter Site logo

delta94 / react-native-notification-stack-card Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iqbalansyor/react-native-notification-stack-card

0.0 0.0 0.0 1.54 MB

A React Native stack list for notification card

Home Page: https://www.npmjs.com/package/react-native-notification-stack-card

License: MIT License

JavaScript 41.80% Starlark 1.62% Java 16.73% Objective-C 11.92% Ruby 2.05% TypeScript 25.87%

react-native-notification-stack-card's Introduction

npm license

React Native Notification Stack Card

A React Native stack list for notification card

Inspired by FlexinStudio

Preview

notif-cardsfd3015b508480d7b.gif

Installation

npm install react-native-notification-stack-card --save

Usage

Import StackCardList component:

import StackCardList from 'react-native-notification-stack-card';

Usage:

  <StackCardList
      data={data}
      visibleItems={VISIBLE_ITEMS}
      itemWidth={ITEM_WIDTH}
      itemHeight={ITEM_HEIGHT}
      closeButtonView={<Icon name={'close'} color={'#ffffff'} size={20} />}
      stackType={'above'}
      spacing={SPACING}
      onEmpty={this.onEmpty}
      onItemPress={this.onItemPress}
      renderItem={this.renderItem}
    />
  )

Customize your notification view based on index and activeIndex:

  const renderItem = (item: any) => {
    const {index, activeIndex} = item;
    const isActiveIndex = index === activeIndex;
    const isSecondIndex = (index === index) === activeIndex + 1;
    const isThirdIndex = index === activeIndex + 2;
    const isAfterClicked = index < activeIndex;
    const backgroundColor = isActiveIndex
      ? 'transparent'
      : isSecondIndex
      ? '#95A9F7'
      : isThirdIndex
      ? '#BDC9F9'
      : isAfterClicked
      ? '#BDC9F9'
      : '#95A9F7';

    return <YourContentView backgroundColor={backgroundColor} />;
  };

closeButtonView

To create close button there are 2 option:

  1. You can use closeButtonView props. The position is absolute (left: 20, top: 20). Pass your x icon or anything your view.

  1. Create you own close button. And use next() when it pressed.

Configuration

Props

prop type/valid values default description
visibleItems number 3 Number of visible items
stackType string 'below' above / below
data any [] Array data of notification item
itemWidth number 100 Note: You also need configure width on your renderItem
itemHeight number 100 Note: You also need configure height on your renderItem
spacing number 10 Spacing of your item
closeButtonView ReactElement null View of close button
renderItem (item: any) => () null Rendering your item. Destructure activeIndex from item and customize based on it.
onItemPress (index: number: item: any) => () null Callback when your item press
onEmpty () => () null Callback when you already close all your item

Function

function description
next() To close your active notif and next to the notif behind

Demo Application

This repository contains a demo React Native application with a customizable example of the StackCardList component in use.

To use the demo application:

  1. Clone this repository: https://github.com/iqbalansyor/react-native-notification-stack-card.git
  2. Navigate to the demo application: cd path/to/this/repository/react-native-notification-stack-card/Example
  3. Install demo application dependencies: npm install
  4. For ios, run cd ios && pod install && cd ..
  5. Run npm run start || react-native run-android || react-native run-ios

Contact me

Contributing

Feel free to try it out. Please submit a pull request with any features/fixes for the project.

License

This project is licensed under the MIT License - see the MIT Open Source Initiative for details.

react-native-notification-stack-card's People

Contributors

iqbalansyor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.