diff --git a/examples/React/.babelrc b/examples/React/.babelrc new file mode 100644 index 00000000..a9ce1369 --- /dev/null +++ b/examples/React/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["react-native"] +} diff --git a/examples/React/.buckconfig b/examples/React/.buckconfig new file mode 100644 index 00000000..934256cb --- /dev/null +++ b/examples/React/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/examples/React/.flowconfig b/examples/React/.flowconfig new file mode 100644 index 00000000..7d608958 --- /dev/null +++ b/examples/React/.flowconfig @@ -0,0 +1,56 @@ +[ignore] +; We fork some components by platform +.*/*[.]android.js + +; Ignore "BUCK" generated dirs +/\.buckd/ + +; Ignore unexpected extra "@providesModule" +.*/node_modules/.*/node_modules/fbjs/.* + +; Ignore duplicate module providers +; For RN Apps installed via npm, "Libraries" folder is inside +; "node_modules/react-native" but in the source repo it is in the root +.*/Libraries/react-native/React.js + +; Ignore polyfills +.*/Libraries/polyfills/.* + +; Ignore metro +.*/node_modules/metro/.* + +[include] + +[libs] +node_modules/react-native/Libraries/react-native/react-native-interface.js +node_modules/react-native/flow/ +node_modules/react-native/flow-github/ + +[options] +emoji=true + +module.system=haste + +munge_underscores=true + +module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' + +module.file_ext=.js +module.file_ext=.jsx +module.file_ext=.json +module.file_ext=.native.js + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FlowFixMeProps +suppress_type=$FlowFixMeState + +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy +suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError + +unsafe.enable_getters_and_setters=true + +[version] +^0.61.0 diff --git a/examples/React/.gitignore b/examples/React/.gitignore new file mode 100644 index 00000000..0826423b --- /dev/null +++ b/examples/React/.gitignore @@ -0,0 +1,53 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots diff --git a/examples/React/.watchmanconfig b/examples/React/.watchmanconfig new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/examples/React/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/examples/React/App.js b/examples/React/App.js new file mode 100644 index 00000000..efa5f7e3 --- /dev/null +++ b/examples/React/App.js @@ -0,0 +1,101 @@ +/** + * Sample React Native App + * https://github.com/facebook/react-native + * @flow + */ + +import React, { Component } from 'react'; +import { + Platform, + StyleSheet, + Text, + View, + Button, + DeviceEventEmitter, + ToastAndroid +} from 'react-native'; + +import Hotword from './src/native/Hotword'; + + +export default class App extends Component { + constructor(props) { + super(props); + this.state = { isRecording: false }; + } + + onPressRecord(isRecording) { + + if(isRecording) { + Hotword.stop(); + } else { + Hotword.start(); + } + + this.setState({ + isRecording: !this.state.isRecording + }); + } + + handleHotwordDetection() { + ToastAndroid.show('Hossword Detected!', ToastAndroid.SHORT); + } + + componentDidMount() { + Hotword.initHotword(); + DeviceEventEmitter.addListener('HOTWORD_DETECTED', (e: Event) => { + this.handleHotwordDetection(); + }); + } + + componentWillUnmount() { + Hotword.destroy(); + } + + render() { + return ( + + + + Hey Hoss! + + + Say "Hey Hoss" to log detection. + + + + +