New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-rewards

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-rewards

This package lets you easily add microinteractions to your app and reward users with the rain of confettis or flying emoji in seconds.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

react-native-rewards

Library is strongly inspired by react-rewards created by The Develobear!

react-native-rewards demo

## Getting started

$ npm install react-native-rewards --save

$ yarn add react-native-root-view-background

Library is 100% javascript so, there is no need to do native linking

Usage

using props:

import RewardsComponent from 'react-native-rewards';
import React, { Component, createRef } from 'react';

class App extends Component {
  state={
    animationState: 'rest',
  }

  render() {
    const { animationState } = this.state;
    return (
      <RewardsComponent
        animationType="confetti"
        state={animationState}
        onRest={() => this.setState({ animationState: 'rest' })}
      >
        <TouchableOpacity
          onPress={() => this.setState({ animationState: 'reward' })}
          style={styles.buttonProps}
        >
          <Text style={styles.buttonText}>+</Text>
        </TouchableOpacity>
      </RewardsComponent>
    )
  }
}

using ref:

import RewardsComponent from 'react-native-rewards';
import React, { Component, createRef } from 'react';

class App extends Component {
  constructor(props) {
    super(props);
    this.rewardsComponent = createRef();
  }

  render() {
    return (
       <RewardsComponent
        ref={this.rewardsComponent}
        animationType="emoji"
      >
        <TouchableOpacity
          onPress={() => this.rewardsComponent.current.rewardMe()}
          style={styles.button}
        >
          <Image source={require('./assets/cup.png')}
           style={styles.icon}/>
        </TouchableOpacity>
      </RewardsComponent>
    )
  }
}

Props

nametypedescriptionrequireddefault
childrenReact Elementcontent to animate e.g. ButtonYES
initialSpeedNumber/Floatinitial speed of particesNO1
spreadNumber/FloatMultiplier of distance beetween particesNO1
deaccelerationNumber/FloatMultiplier how fast partices deaccelerate in firt phaseNO1
rotationXSpeedNumber/FloatRotation speed multiplier in X axisNO5
rotationZSpeedNumber/FloatRotation speed multiplier in Z axisNO5
particiesCountNumber/IntegerPartices count in reward animationNO20
colorsArrayColors used to generate confettiNOSome colors :)
emojiArrayEmojis used to generate confettiNO['👍','😊','🎉']
animationTypeStringType of animation confetti/emojiNOconfetti
stateStringState of animation, changing of this value triggers animationNOrest
onRestFunctionCallback when animation goes to rest stateNO

Methods

You can call this method by using refs of component

  • rewardMe - Triggers reward animation
  • punishMe - Triggers punish animation

Notes for local development

You need to have facebook watchman installed

  • cd example
  • yarn
  • yarn start
  • yarn run sync in another terminal window (doesn't matter where)

If you have any issues, you can clear your watches using watchman watch-del-all and try again.

Author

Feel free to ask me qustion on Twitter @JanRomaniak!

Keywords

android

FAQs

Package last updated on 24 Nov 2018

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