Coder Social home page Coder Social logo

osdnk / react-native-haptics Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 204 KB

Library for performing haptic feedback in React Native

Ruby 4.38% Java 37.90% Shell 1.94% JavaScript 8.37% Python 10.20% Objective-C 37.22%
react reactnative haptics feedback ux

react-native-haptics's Introduction

react-native-haptics

Library for performing haptic feedback in React Native

API

Library exports methods:

impact(type)

Use impact feedback to indicate that an impact has occurred. For example, you might trigger impact feedback when a user interface object collides with another object or snaps into place.

impact("heavy")

A collision between large, heavy user interface elements.

impact("medium") or impact() - default

A collision between moderately sized user interface elements.

impact("light")

A collision between small, light user interface elements.

notification(type)

Use notification feedback to communicate that a task or action has succeeded, failed, or produced a warning of some kind.

notification("error")

A notification feedback type, indicating that a task has failed.

notification("success") or notification() - default

A notification feedback type, indicating that a task has completed successfully.

notification("warining")

A notification feedback type, indicating that a task has produced a warning.

selection()

Use selection feedback to communicate movement through a series of discrete values.

Usage

import RNHaptics from 'react-native-haptics';
const { notification, impact, selection } = RNHaptics;

notification("error")

Getting started

$ yarn add react-native-haptics

Mostly automatic installation

$ react-native link react-native-haptics

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-haptics and add RNHaptics.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNHaptics.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)

Android

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.osdnk.haptics.RNHapticsPackage; to the imports at the top of the file
  • Add new RNHapticsPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-haptics'
    project(':react-native-haptics').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-haptics/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-haptics')
    

Development

In order to develop simply modify files by opening the Example app via Android Studio or Xcode. Generally, it means that modifications refer to node_modules files. If you wish for your changes to be placed in the main folder in order to commit them use:

./copyFromNodeModules.sh

If you wish to copy files to node_modules without installing dependencies you're to use:

./putIntoNodeModules.sh

react-native-haptics's People

Contributors

osdnk avatar

Stargazers

 avatar

Watchers

 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.