diff --git a/README.md b/README.md index d94050f..8093bb4 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ It also serves as a catalog for all react-native pacakges in the community. ## Packages * [react-native-heap-analytics](https://github.com/negativetwelve/react-native-heap-analytics) +* [react-native-shake-event](https://github.com/jadsonlourenco/react-native-shake-event) * [react-native-svg](https://github.com/react-native-community/react-native-svg) * [react-native-ux-cam](https://github.com/negativetwelve/react-native-ux-cam) * [react-native-video](https://github.com/react-native-community/react-native-video) diff --git a/android/app/build.gradle b/android/app/build.gradle index cd12be9..c8e64ab 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -137,6 +137,7 @@ android { } dependencies { + compile project(':react-native-shake-event') compile project(':react-native-svg') compile project(':react-native-video') compile project(':react-native-ux-cam') diff --git a/android/app/src/main/java/com/rnpackages/MainApplication.java b/android/app/src/main/java/com/rnpackages/MainApplication.java index 53c7f15..2fc2e4c 100644 --- a/android/app/src/main/java/com/rnpackages/MainApplication.java +++ b/android/app/src/main/java/com/rnpackages/MainApplication.java @@ -3,6 +3,7 @@ import android.app.Application; import com.facebook.react.ReactApplication; +import com.jadsonlourenco.RNShakeEvent.RNShakeEventPackage; import com.horcrux.svg.SvgPackage; import com.brentvatne.react.ReactVideoPackage; import com.rnuxcam.rnuxcam.UXCamPackage; @@ -26,6 +27,7 @@ public boolean getUseDeveloperSupport() { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new RNShakeEventPackage(), new SvgPackage(), new ReactVideoPackage(), new UXCamPackage() diff --git a/android/settings.gradle b/android/settings.gradle index de97110..7451e45 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'RNPackages' +include ':react-native-shake-event' +project(':react-native-shake-event').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-shake-event/android') include ':react-native-svg' project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android') include ':react-native-video' diff --git a/ios/RNPackages.xcodeproj/project.pbxproj b/ios/RNPackages.xcodeproj/project.pbxproj index a74d7b5..bf4fadb 100644 --- a/ios/RNPackages.xcodeproj/project.pbxproj +++ b/ios/RNPackages.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 1ED3D47199F24599A9125D38 /* libRNUXCam.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 659F784FC46344179C5B6774 /* libRNUXCam.a */; }; 442CFF7594324918A98A95CE /* libRCTVideo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C6FC00D33D8474A8E688CFE /* libRCTVideo.a */; }; AA3C83CBF3C4477BBF860411 /* libRNHeap.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 702B3FCBEC9440E0874F0ADC /* libRNHeap.a */; }; + D2F4A8B09CC64040AC39BD67 /* libRNShakeEvent.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F01EE52D5314AD0BB2E06D9 /* libRNShakeEvent.a */; }; 915FAC3A46E54800ADEE082B /* libRNSVG.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 57FC3505C8CA45A7B135F342 /* libRNSVG.a */; }; /* End PBXBuildFile section */ @@ -264,6 +265,8 @@ 7C6FC00D33D8474A8E688CFE /* libRCTVideo.a */ = {isa = PBXFileReference; name = "libRCTVideo.a"; path = "libRCTVideo.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; 1B63D7E53F1C43C1984724A9 /* RNHeap.xcodeproj */ = {isa = PBXFileReference; name = "RNHeap.xcodeproj"; path = "../node_modules/react-native-heap-analytics/ios/RNHeap.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 702B3FCBEC9440E0874F0ADC /* libRNHeap.a */ = {isa = PBXFileReference; name = "libRNHeap.a"; path = "libRNHeap.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; + CF23E95EE0114317B7199B62 /* RNShakeEvent.xcodeproj */ = {isa = PBXFileReference; name = "RNShakeEvent.xcodeproj"; path = "../node_modules/react-native-shake-event/ios/RNShakeEvent.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 4F01EE52D5314AD0BB2E06D9 /* libRNShakeEvent.a */ = {isa = PBXFileReference; name = "libRNShakeEvent.a"; path = "libRNShakeEvent.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; F6CD04D862284277B2A3C4FD /* RNSVG.xcodeproj */ = {isa = PBXFileReference; name = "RNSVG.xcodeproj"; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; 57FC3505C8CA45A7B135F342 /* libRNSVG.a */ = {isa = PBXFileReference; name = "libRNSVG.a"; path = "libRNSVG.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ @@ -295,6 +298,7 @@ 1ED3D47199F24599A9125D38 /* libRNUXCam.a in Frameworks */, 442CFF7594324918A98A95CE /* libRCTVideo.a in Frameworks */, AA3C83CBF3C4477BBF860411 /* libRNHeap.a in Frameworks */, + D2F4A8B09CC64040AC39BD67 /* libRNShakeEvent.a in Frameworks */, 915FAC3A46E54800ADEE082B /* libRNSVG.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -465,6 +469,7 @@ 4B184078C3454F4F808958E7 /* RNUXCam.xcodeproj */, 10D94D39E400418C9E39A435 /* RCTVideo.xcodeproj */, 1B63D7E53F1C43C1984724A9 /* RNHeap.xcodeproj */, + CF23E95EE0114317B7199B62 /* RNShakeEvent.xcodeproj */, F6CD04D862284277B2A3C4FD /* RNSVG.xcodeproj */, ); name = Libraries; @@ -1002,6 +1007,7 @@ "$(SRCROOT)/../node_modules/react-native-ux-cam/ios", "$(SRCROOT)/../node_modules/react-native-video/ios", "$(SRCROOT)/../node_modules/react-native-heap-analytics/ios", + "$(SRCROOT)/../node_modules/react-native-shake-event/ios", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", ); }; @@ -1032,6 +1038,7 @@ "$(SRCROOT)/../node_modules/react-native-ux-cam/ios", "$(SRCROOT)/../node_modules/react-native-video/ios", "$(SRCROOT)/../node_modules/react-native-heap-analytics/ios", + "$(SRCROOT)/../node_modules/react-native-shake-event/ios", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", ); }; @@ -1057,6 +1064,7 @@ "$(SRCROOT)/../node_modules/react-native-ux-cam/ios", "$(SRCROOT)/../node_modules/react-native-video/ios", "$(SRCROOT)/../node_modules/react-native-heap-analytics/ios", + "$(SRCROOT)/../node_modules/react-native-shake-event/ios", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", ); }; @@ -1081,6 +1089,7 @@ "$(SRCROOT)/../node_modules/react-native-ux-cam/ios", "$(SRCROOT)/../node_modules/react-native-video/ios", "$(SRCROOT)/../node_modules/react-native-heap-analytics/ios", + "$(SRCROOT)/../node_modules/react-native-shake-event/ios", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", ); }; @@ -1120,6 +1129,7 @@ "$(SRCROOT)/../node_modules/react-native-ux-cam/ios", "$(SRCROOT)/../node_modules/react-native-video/ios", "$(SRCROOT)/../node_modules/react-native-heap-analytics/ios", + "$(SRCROOT)/../node_modules/react-native-shake-event/ios", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", ); }; @@ -1159,6 +1169,7 @@ "$(SRCROOT)/../node_modules/react-native-ux-cam/ios", "$(SRCROOT)/../node_modules/react-native-video/ios", "$(SRCROOT)/../node_modules/react-native-heap-analytics/ios", + "$(SRCROOT)/../node_modules/react-native-shake-event/ios", "$(SRCROOT)/../node_modules/react-native-svg/ios/**", ); }; diff --git a/js/components/PackagesView.js b/js/components/PackagesView.js index 3be159b..e20fb4c 100644 --- a/js/components/PackagesView.js +++ b/js/components/PackagesView.js @@ -4,6 +4,7 @@ import {StyleSheet, View} from 'react-native'; // Packages import HeapAnalyticsExample from '../examples/HeapAnalyticsExample'; +import ShakeEventExample from '../examples/ShakeEventExample'; import SVGExample from '../examples/SVGExample'; import UXCamExample from '../examples/UXCamExample'; import VideoExample from '../examples/VideoExample'; @@ -19,6 +20,7 @@ const styles = StyleSheet.create({ export default () => ( + diff --git a/js/examples/ShakeEventExample.js b/js/examples/ShakeEventExample.js new file mode 100644 index 0000000..a867bfb --- /dev/null +++ b/js/examples/ShakeEventExample.js @@ -0,0 +1,20 @@ +// Libraries +import React from 'react'; +import ShakeEvent from 'react-native-shake-event'; + + +export default class ShakeEventExample extends React.Component { + componentWillMount() { + ShakeEvent.addEventListener('shake', () => { + console.log('Device shake!'); + }); + } + + componentWillUnmount() { + ShakeEvent.removeEventListener('shake'); + } + + render() { + return null; + } +} diff --git a/js/examples/__tests__/ShakeEventExample.spec.js b/js/examples/__tests__/ShakeEventExample.spec.js new file mode 100644 index 0000000..c363c77 --- /dev/null +++ b/js/examples/__tests__/ShakeEventExample.spec.js @@ -0,0 +1,14 @@ +// Libraries +import 'react-native'; +import React from 'react'; +import Renderer from 'react-test-renderer'; + +// Components +import ShakeEventExample from '../ShakeEventExample'; + + +it('renders correctly', () => { + const tree = Renderer.create( + + ); +}); diff --git a/package.json b/package.json index 8c5085e..7cc8f0c 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "react": "16.0.0-alpha.12", "react-native": "0.47.1", "react-native-heap-analytics": "^1.3.0", + "react-native-shake-event": "^4.0.1", "react-native-svg": "^5.4.1", "react-native-ux-cam": "^3.4.0", "react-native-video": "^1.2.0" diff --git a/yarn.lock b/yarn.lock index e7242ad..100ffe0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4616,6 +4616,12 @@ react-native-heap-analytics@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/react-native-heap-analytics/-/react-native-heap-analytics-1.3.0.tgz#4082980701b30010d6533940f963605d51f1de89" +react-native-shake-event@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/react-native-shake-event/-/react-native-shake-event-4.0.1.tgz#b167e844b711eff50d44d029537fbb228b2ac6b2" + dependencies: + invariant "^2.2.2" + react-native-svg@^5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/react-native-svg/-/react-native-svg-5.4.1.tgz#c46191c786adbe9d5007342b4279efd153db8839"