Skip to content

Commit 9ed071f

Browse files
committed
updated example app RN 0.54
1 parent 5e3ee28 commit 9ed071f

33 files changed

Lines changed: 4869 additions & 7100 deletions

File tree

example/.flowconfig

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
1414
.*/Libraries/react-native/React.js
15-
.*/Libraries/react-native/ReactNative.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
1621

1722
[include]
1823

1924
[libs]
2025
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
2328

2429
[options]
2530
emoji=true
@@ -30,16 +35,20 @@ munge_underscores=true
3035

3136
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'
3237

38+
module.file_ext=.js
39+
module.file_ext=.jsx
40+
module.file_ext=.json
41+
module.file_ext=.native.js
42+
3343
suppress_type=$FlowIssue
3444
suppress_type=$FlowFixMe
35-
suppress_type=$FixMe
45+
suppress_type=$FlowFixMeProps
46+
suppress_type=$FlowFixMeState
3647

37-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3950
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4051
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4152

42-
unsafe.enable_getters_and_setters=true
43-
4453
[version]
45-
^0.49.1
54+
^0.65.0

example/.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ buck-out/
4646
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4747
# screenshots whenever they are needed.
4848
# For more information about the recommended setup visit:
49-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
49+
# https://docs.fastlane.tools/best-practices/source-control/
5050

51-
fastlane/report.xml
52-
fastlane/Preview.html
53-
fastlane/screenshots
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots

example/App.android.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import React, { Component } from 'react';
2+
import {
3+
AppRegistry,
4+
StyleSheet,
5+
Text,
6+
View,
7+
Button
8+
} from 'react-native';
9+
10+
import Dialogflow from "react-native-dialogflow"
11+
12+
export default class App extends Component {
13+
constructor(props) {
14+
super(props);
15+
16+
this.state = {
17+
result: "",
18+
listeningState: "not started",
19+
audioLevel: 0,
20+
};
21+
22+
23+
Dialogflow.setConfiguration(
24+
"57b6ce865e6e4b138a74a88cfd8bc526", Dialogflow.LANG_GERMAN
25+
);
26+
27+
28+
29+
const contexts = [{
30+
"name": "deals",
31+
"lifespan": 1,
32+
"parameters": {
33+
"name": "Sam"
34+
}
35+
}];
36+
37+
Dialogflow.setContexts(contexts);
38+
39+
40+
const permanentContexts = [{
41+
"name": "config",
42+
"parameters": {
43+
"access_token": "42 yo 42 tiny rick"
44+
}
45+
}];
46+
47+
Dialogflow.setPermanentContexts(permanentContexts);
48+
49+
50+
const entities = [{
51+
"name": "shop",
52+
"extend": true,
53+
"entries": [
54+
{
55+
"value": "Media Markt",
56+
"synonyms": [
57+
"Media Markt",
58+
]
59+
}
60+
]
61+
}];
62+
63+
64+
Dialogflow.setEntities(entities);
65+
}
66+
67+
68+
render() {
69+
Dialogflow.requestEvent("WELCOME", null, r => console.log(r), e => console.log(e));
70+
71+
72+
return (
73+
<View style={styles.container}>
74+
75+
<View style={{ flex: 4 }}>
76+
<Text>{"Listening State: " + this.state.listeningState}</Text>
77+
<Text>{"Audio Level: " + this.state.audioLevel}</Text>
78+
<Text>{"Result: " + this.state.result}</Text>
79+
</View>
80+
<View style={{ flex: 1, padding: 10 }}>
81+
<Button title="Start Listening" onPress={() => {
82+
83+
84+
Dialogflow.onListeningStarted(() => {
85+
this.setState({ listeningState: "started" });
86+
});
87+
88+
Dialogflow.onListeningCanceled(() => {
89+
this.setState({ listeningState: "canceled" });
90+
});
91+
92+
Dialogflow.onListeningFinished(() => {
93+
this.setState({ listeningState: "finished" });
94+
});
95+
96+
Dialogflow.onAudioLevel(level => {
97+
this.setState({ audioLevel: level });
98+
});
99+
100+
Dialogflow.startListening(result => {
101+
console.log(result);
102+
this.setState({ result: JSON.stringify(result) });
103+
}, error => {
104+
this.setState({ result: JSON.stringify(error) });
105+
});
106+
107+
}} />
108+
</View>
109+
</View>
110+
);
111+
}
112+
}
113+
114+
const styles = StyleSheet.create({
115+
container: {
116+
flex: 1,
117+
backgroundColor: '#F5FCFF',
118+
},
119+
120+
});
121+
122+
AppRegistry.registerComponent('DialogflowExample', () => App);

example/App.ios.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import React, { Component } from 'react';
2+
import {
3+
AppRegistry,
4+
StyleSheet,
5+
Text,
6+
View,
7+
Button
8+
} from 'react-native';
9+
10+
import ApiAi from "react-native-dialogflow"
11+
12+
export default class App extends Component {
13+
constructor(props) {
14+
super(props);
15+
16+
this.state = {
17+
result: "",
18+
buttonText: "Start Listening",
19+
listening: false
20+
};
21+
22+
console.log(ApiAi);
23+
24+
ApiAi.setConfiguration(
25+
"INSERT_YOUR_CLENT_ACCESS_TOKEN_HERE", ApiAi.LANG_GERMAN
26+
);
27+
}
28+
29+
30+
render() {
31+
return (
32+
<View style={styles.container}>
33+
34+
<View style={{ flex: 4 }}>
35+
<Text>{"Result: " + this.state.result}</Text>
36+
</View>
37+
<View style={{ flex: 1, padding: 10 }}>
38+
<Button title={this.state.buttonText} onPress={() => {
39+
40+
if (this.state.listening) {
41+
ApiAi.finishListening();
42+
this.setState({ buttonText: "Start Listening", listening: false })
43+
} else {
44+
ApiAi.startListening(result => {
45+
this.setState({ result: JSON.stringify(result) });
46+
}, error => {
47+
this.setState({ result: JSON.stringify(error) });
48+
});
49+
this.setState({ buttonText: "Stop Listening", listening: true })
50+
}
51+
}} />
52+
</View>
53+
</View>
54+
);
55+
}
56+
}
57+
58+
const styles = StyleSheet.create({
59+
container: {
60+
flex: 1,
61+
paddingTop: 20,
62+
backgroundColor: '#F5FCFF',
63+
},
64+
65+
});
66+
67+
AppRegistry.registerComponent('ApiAiExample', () => App);

example/README.md

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'react-native';
22
import React from 'react';
3-
import Index from '../index.ios.js';
3+
import App from '../App';
44

55
// Note: test renderer must be required after react-native.
66
import renderer from 'react-test-renderer';
77

88
it('renders correctly', () => {
99
const tree = renderer.create(
10-
<Index />
10+
<App />
1111
);
1212
});

example/__tests__/index.android.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

example/android/app/BUCK

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ android_library(
4545

4646
android_build_config(
4747
name = "build_config",
48-
package = "com.apiaiexample",
48+
package = "com.dialogflowexample",
4949
)
5050

5151
android_resource(
5252
name = "res",
53-
package = "com.apiaiexample",
53+
package = "com.dialogflowexample",
5454
res = "src/main/res",
5555
)
5656

example/android/app/build.gradle

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import com.android.build.OutputFile
7272
* ]
7373
*/
7474

75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
7579
apply from: "../../node_modules/react-native/react.gradle"
7680

7781
/**
@@ -130,19 +134,6 @@ android {
130134
}
131135
}
132136
}
133-
134-
packagingOptions {
135-
exclude 'META-INF/DEPENDENCIES.txt'
136-
exclude 'META-INF/LICENSE.txt'
137-
exclude 'META-INF/NOTICE.txt'
138-
exclude 'META-INF/NOTICE'
139-
exclude 'META-INF/LICENSE'
140-
exclude 'META-INF/DEPENDENCIES'
141-
exclude 'META-INF/notice.txt'
142-
exclude 'META-INF/license.txt'
143-
exclude 'META-INF/dependencies.txt'
144-
exclude 'META-INF/LGPL2.1'
145-
}
146137
}
147138

148139
dependencies {

example/android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.dialogflowexample"
3-
android:versionCode="1"
4-
android:versionName="1.0">
2+
package="com.dialogflowexample">
53

64
<uses-permission android:name="android.permission.INTERNET" />
75
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
86

9-
<uses-sdk
10-
android:minSdkVersion="16"
11-
android:targetSdkVersion="22" />
12-
137
<application
148
android:name=".MainApplication"
15-
android:allowBackup="true"
169
android:label="@string/app_name"
1710
android:icon="@mipmap/ic_launcher"
11+
android:allowBackup="false"
1812
android:theme="@style/AppTheme">
1913
<activity
2014
android:name=".MainActivity"

0 commit comments

Comments
 (0)