Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-notification-stack-card

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-notification-stack-card

A React Native stack list for notification card

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

npm license

React Native Notification Stack Card

A React Native stack list for notification card

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

proptype/valid valuesdefaultdescription
visibleItemsnumber3Number of visible items
stackTypestring'below'above / below
dataany[]Array data of notification item
itemWidthnumber100Note: You also need configure width on your renderItem
itemHeightnumber100Note: You also need configure height on your renderItem
spacingnumber10Spacing of your item
closeButtonViewReactElementnullView of close button
renderItem(item: any) => ()nullRendering your item. Destructure activeIndex from item and customize based on it.
onItemPress(index: number: item: any) => ()nullCallback when your item press
onEmpty() => ()nullCallback when you already close all your item

Function

functiondescription
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.

Keywords

FAQs

Package last updated on 31 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc