Skip to content

Commit a38bd80

Browse files
committed
update Example to latest
1 parent 7f95392 commit a38bd80

File tree

31 files changed

+5773
-297
lines changed

31 files changed

+5773
-297
lines changed

Example/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react-native"]
3+
}

Example/.flowconfig

Lines changed: 31 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,56 @@
11
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
24

3-
# We fork some components by platform.
4-
.*/*.web.js
5-
.*/*.android.js
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
67

7-
# Some modules have their own node_modules with overlap
8-
.*/node_modules/node-haste/.*
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
910

10-
# Ugh
11-
.*/node_modules/babel.*
12-
.*/node_modules/babylon.*
13-
.*/node_modules/invariant.*
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
1415

15-
# Ignore react and fbjs where there are overlaps, but don't ignore
16-
# anything that react-native relies on
17-
.*/node_modules/fbjs/lib/Map.js
18-
.*/node_modules/fbjs/lib/ErrorUtils.js
19-
20-
# Flow has a built-in definition for the 'react' module which we prefer to use
21-
# over the currently-untyped source
22-
.*/node_modules/react/react.js
23-
.*/node_modules/react/lib/React.js
24-
.*/node_modules/react/lib/ReactDOM.js
25-
26-
.*/__mocks__/.*
27-
.*/__tests__/.*
28-
29-
.*/commoner/test/source/widget/share.js
30-
31-
# Ignore commoner tests
32-
.*/node_modules/commoner/test/.*
33-
34-
# See https://github.com/facebook/flow/issues/442
35-
.*/react-tools/node_modules/commoner/lib/reader.js
36-
37-
# Ignore jest
38-
.*/node_modules/jest-cli/.*
39-
40-
# Ignore Website
41-
.*/website/.*
42-
43-
# Ignore generators
44-
.*/local-cli/generator.*
45-
46-
# Ignore BUCK generated folders
47-
.*\.buckd/
48-
49-
# Ignore RNPM
50-
.*/local-cli/rnpm/.*
51-
52-
.*/node_modules/is-my-json-valid/test/.*\.json
53-
.*/node_modules/iconv-lite/encodings/tables/.*\.json
54-
.*/node_modules/y18n/test/.*\.json
55-
.*/node_modules/spdx-license-ids/spdx-license-ids.json
56-
.*/node_modules/spdx-exceptions/index.json
57-
.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
58-
.*/node_modules/resolve/lib/core.json
59-
.*/node_modules/jsonparse/samplejson/.*\.json
60-
.*/node_modules/json5/test/.*\.json
61-
.*/node_modules/ua-parser-js/test/.*\.json
62-
.*/node_modules/builtin-modules/builtin-modules.json
63-
.*/node_modules/binary-extensions/binary-extensions.json
64-
.*/node_modules/url-regex/tlds.json
65-
.*/node_modules/joi/.*\.json
66-
.*/node_modules/isemail/.*\.json
67-
.*/node_modules/tr46/.*\.json
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
6818

19+
; Ignore metro
20+
.*/node_modules/metro/.*
6921

7022
[include]
7123

7224
[libs]
7325
node_modules/react-native/Libraries/react-native/react-native-interface.js
74-
node_modules/react-native/flow
75-
flow/
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
7628

7729
[options]
78-
module.system=haste
30+
emoji=true
7931

80-
esproposal.class_static_fields=enable
81-
esproposal.class_instance_fields=enable
82-
83-
experimental.strict_type_args=true
32+
module.system=haste
8433

8534
munge_underscores=true
8635

87-
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
8836
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'
8937

38+
module.file_ext=.js
39+
module.file_ext=.jsx
40+
module.file_ext=.json
41+
module.file_ext=.native.js
42+
9043
suppress_type=$FlowIssue
9144
suppress_type=$FlowFixMe
92-
suppress_type=$FixMe
45+
suppress_type=$FlowFixMeProps
46+
suppress_type=$FlowFixMeState
9347

94-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-6]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
95-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-6]\\|1[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]+
9650
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
52+
53+
unsafe.enable_getters_and_setters=true
9754

9855
[version]
99-
^0.26.0
56+
^0.61.0

Example/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

Example/.gitignore

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,32 @@ DerivedData
2222
*.xcuserstate
2323
project.xcworkspace
2424

25-
# Android/IJ
25+
# Android/IntelliJ
2626
#
27-
*.iml
27+
build/
2828
.idea
2929
.gradle
3030
local.properties
31+
*.iml
3132

3233
# node.js
3334
#
3435
node_modules/
3536
npm-debug.log
37+
yarn-error.log
3638

3739
# BUCK
3840
buck-out/
3941
\.buckd/
40-
android/app/libs
41-
android/keystores/debug.keystore
42+
*.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots

Example/index.android.js renamed to Example/App.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,48 @@
33
* https://github.com/facebook/react-native
44
* @flow
55
*/
6+
67
import React, { Component } from 'react';
7-
import IntentLauncher, { IntentConstant } from 'react-native-intent-launcher'
8+
import IntentLauncher from 'react-native-intent-launcher'
9+
810
import {
9-
AppRegistry,
11+
Platform,
1012
StyleSheet,
13+
TouchableOpacity,
1114
Text,
1215
View
1316
} from 'react-native';
1417

15-
class Example extends Component {
18+
const instructions = Platform.select({
19+
ios: 'Press Cmd+R to reload,\n' +
20+
'Cmd+D or shake for dev menu',
21+
android: 'Double tap R on your keyboard to reload,\n' +
22+
'Shake or press menu button for dev menu',
23+
});
24+
25+
export default class App extends Component<{}> {
1626
render() {
1727
return (
1828
<View style={styles.container}>
19-
<Text style={styles.welcome}
20-
onPress={this.jumpToSettings}>
29+
<Text style={styles.welcome}>
2130
Welcome to React Native!
2231
</Text>
2332
<Text style={styles.instructions}>
24-
To get started, edit index.android.js
33+
To get started, edit App.js
2534
</Text>
2635
<Text style={styles.instructions}>
27-
Shake or press menu button for dev menu
36+
{instructions}
2837
</Text>
38+
<TouchableOpacity onPress={this.jumpToSettings}>
39+
<Text>Open settings of the app</Text>
40+
</TouchableOpacity>
2941
</View>
3042
);
3143
}
3244

3345
jumpToSettings = () => {
3446
IntentLauncher.startActivity({action: 'android.settings.APPLICATION_DETAILS_SETTINGS', data: 'package:com.example'})
35-
};
47+
}
3648
}
3749

3850
const styles = StyleSheet.create({
@@ -53,5 +65,3 @@ const styles = StyleSheet.create({
5365
marginBottom: 5,
5466
},
5567
});
56-
57-
AppRegistry.registerComponent('Example', () => Example);

Example/__tests__/App.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'react-native';
2+
import React from 'react';
3+
import App from '../App';
4+
5+
// Note: test renderer must be required after react-native.
6+
import renderer from 'react-test-renderer';
7+
8+
it('renders correctly', () => {
9+
const tree = renderer.create(
10+
<App />
11+
);
12+
});

Example/android/app/BUCK

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,65 @@
1-
import re
2-
31
# To learn about Buck see [Docs](https://buckbuild.com/).
42
# To run your application with Buck:
53
# - install Buck
64
# - `npm start` - to start the packager
75
# - `cd android`
8-
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US`
6+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
97
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
108
# - `buck install -r android/app` - compile, install and run application
119
#
1210

1311
lib_deps = []
12+
1413
for jarfile in glob(['libs/*.jar']):
15-
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
14+
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
1615
lib_deps.append(':' + name)
1716
prebuilt_jar(
1817
name = name,
1918
binary_jar = jarfile,
2019
)
2120

2221
for aarfile in glob(['libs/*.aar']):
23-
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
22+
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
2423
lib_deps.append(':' + name)
2524
android_prebuilt_aar(
2625
name = name,
2726
aar = aarfile,
2827
)
2928

3029
android_library(
31-
name = 'all-libs',
32-
exported_deps = lib_deps
30+
name = "all-libs",
31+
exported_deps = lib_deps,
3332
)
3433

3534
android_library(
36-
name = 'app-code',
37-
srcs = glob([
38-
'src/main/java/**/*.java',
39-
]),
40-
deps = [
41-
':all-libs',
42-
':build_config',
43-
':res',
44-
],
35+
name = "app-code",
36+
srcs = glob([
37+
"src/main/java/**/*.java",
38+
]),
39+
deps = [
40+
":all-libs",
41+
":build_config",
42+
":res",
43+
],
4544
)
4645

4746
android_build_config(
48-
name = 'build_config',
49-
package = 'com.example',
47+
name = "build_config",
48+
package = "com.example",
5049
)
5150

5251
android_resource(
53-
name = 'res',
54-
res = 'src/main/res',
55-
package = 'com.example',
52+
name = "res",
53+
package = "com.example",
54+
res = "src/main/res",
5655
)
5756

5857
android_binary(
59-
name = 'app',
60-
package_type = 'debug',
61-
manifest = 'src/main/AndroidManifest.xml',
62-
keystore = '//android/keystores:debug',
63-
deps = [
64-
':app-code',
65-
],
58+
name = "app",
59+
keystore = "//android/keystores:debug",
60+
manifest = "src/main/AndroidManifest.xml",
61+
package_type = "debug",
62+
deps = [
63+
":app-code",
64+
],
6665
)

Example/android/app/build.gradle

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ import com.android.build.OutputFile
3333
* // bundleInPaidRelease: true,
3434
* // bundleInBeta: true,
3535
*
36+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
37+
* // for example: to disable dev mode in the staging build type (if configured)
38+
* devDisabledInStaging: true,
39+
* // The configuration property can be in the following formats
40+
* // 'devDisabledIn${productFlavor}${buildType}'
41+
* // 'devDisabledIn${buildType}'
42+
*
3643
* // the root of your project, i.e. where "package.json" lives
3744
* root: "../../",
3845
*
@@ -58,13 +65,17 @@ import com.android.build.OutputFile
5865
* inputExcludes: ["android/**", "ios/**"],
5966
*
6067
* // override which node gets called and with what additional arguments
61-
* nodeExecutableAndArgs: ["node"]
68+
* nodeExecutableAndArgs: ["node"],
6269
*
6370
* // supply additional arguments to the packager
6471
* extraPackagerArgs: []
6572
* ]
6673
*/
6774

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

7081
/**
@@ -135,6 +146,6 @@ dependencies {
135146
// Run this once to be able to run the application with BUCK
136147
// puts all compile dependencies into folder libs for BUCK to use
137148
task copyDownloadableDepsToLibs(type: Copy) {
138-
from configurations.compile
139-
into 'libs'
149+
from configurations.compile
150+
into 'libs'
140151
}

Example/android/app/proguard-rules.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050

5151
-dontwarn com.facebook.react.**
5252

53+
# TextLayoutBuilder uses a non-public Android constructor within StaticLayout.
54+
# See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details.
55+
-dontwarn android.text.StaticLayout
56+
5357
# okhttp
5458

5559
-keepattributes Signature

0 commit comments

Comments
 (0)