Skip to content

Commit 70be740

Browse files
committed
update sample project
1 parent 4480356 commit 70be740

File tree

69 files changed

+6624
-4557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+6624
-4557
lines changed

Sample/.babelrc

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

Sample/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

Sample/.flowconfig

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,70 @@
55
; Ignore "BUCK" generated dirs
66
<PROJECT_ROOT>/\.buckd/
77

8-
; Ignore unexpected extra "@providesModule"
9-
.*/node_modules/.*/node_modules/fbjs/.*
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
1010

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
15-
.*/Libraries/react-native/ReactNative.js
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
14+
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
1620

1721
[include]
1822

1923
[libs]
20-
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
24+
node_modules/react-native/interface.js
25+
node_modules/react-native/flow/
2326

2427
[options]
2528
emoji=true
2629

27-
module.system=haste
30+
esproposal.optional_chaining=enable
31+
esproposal.nullish_coalescing=enable
2832

29-
experimental.strict_type_args=true
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
3036

3137
munge_underscores=true
3238

33-
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'
39+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
40+
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\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
3441

3542
suppress_type=$FlowIssue
3643
suppress_type=$FlowFixMe
37-
suppress_type=$FixMe
44+
suppress_type=$FlowFixMeProps
45+
suppress_type=$FlowFixMeState
3846

39-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-5]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
40-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-5]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
41-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
47+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
4249
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4350

44-
unsafe.enable_getters_and_setters=true
51+
[lints]
52+
sketchy-null-number=warn
53+
sketchy-null-mixed=warn
54+
sketchy-number=warn
55+
untyped-type-import=warn
56+
nonstrict-import=warn
57+
deprecated-type=warn
58+
unsafe-getters-setters=warn
59+
inexact-spread=warn
60+
unnecessary-invariant=warn
61+
signature-verification-failure=warn
62+
deprecated-utility=error
63+
64+
[strict]
65+
deprecated-type
66+
nonstrict-import
67+
sketchy-null
68+
unclear-type
69+
unsafe-getters-setters
70+
untyped-import
71+
untyped-type-import
4572

4673
[version]
47-
^0.45.0
74+
^0.113.0

Sample/.gitignore

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
project.xcworkspace
23+
*.xcworkspace
2424

2525
# Android/IntelliJ
2626
#
@@ -40,14 +40,21 @@ yarn-error.log
4040
buck-out/
4141
\.buckd/
4242
*.keystore
43+
!debug.keystore
4344

4445
# fastlane
4546
#
4647
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4748
# screenshots whenever they are needed.
4849
# For more information about the recommended setup visit:
49-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
50+
# https://docs.fastlane.tools/best-practices/source-control/
5051

51-
fastlane/report.xml
52-
fastlane/Preview.html
53-
fastlane/screenshots
52+
*/fastlane/report.xml
53+
*/fastlane/Preview.html
54+
*/fastlane/screenshots
55+
56+
# Bundle artifact
57+
*.jsbundle
58+
59+
# CocoaPods
60+
/ios/Pods/

Sample/.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

Sample/__tests__/App-test.js

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

Sample/android/app/BUCK

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
# - `buck install -r android/app` - compile, install and run application
99
#
1010

11+
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12+
1113
lib_deps = []
1214

13-
for jarfile in glob(['libs/*.jar']):
14-
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
15-
lib_deps.append(':' + name)
16-
prebuilt_jar(
17-
name = name,
18-
binary_jar = jarfile,
19-
)
15+
create_aar_targets(glob(["libs/*.aar"]))
2016

21-
for aarfile in glob(['libs/*.aar']):
22-
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
23-
lib_deps.append(':' + name)
24-
android_prebuilt_aar(
25-
name = name,
26-
aar = aarfile,
27-
)
17+
create_jar_targets(glob(["libs/*.jar"]))
2818

2919
android_library(
3020
name = "all-libs",
@@ -45,12 +35,12 @@ android_library(
4535

4636
android_build_config(
4737
name = "build_config",
48-
package = "com.sample",
38+
package = "com.samplesimpledialogs",
4939
)
5040

5141
android_resource(
5242
name = "res",
53-
package = "com.sample",
43+
package = "com.samplesimpledialogs",
5444
res = "src/main/res",
5545
)
5646

Sample/android/app/build.gradle

Lines changed: 94 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ import com.android.build.OutputFile
1515
* // the name of the generated asset file containing your JS bundle
1616
* bundleAssetName: "index.android.bundle",
1717
*
18-
* // the entry file for bundle generation
18+
* // the entry file for bundle generation. If none specified and
19+
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20+
* // default. Can be overridden with ENTRY_FILE environment variable.
1921
* entryFile: "index.android.js",
2022
*
23+
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
24+
* bundleCommand: "ram-bundle",
25+
*
2126
* // whether to bundle JS and assets in debug mode
2227
* bundleInDebug: false,
2328
*
@@ -72,6 +77,10 @@ import com.android.build.OutputFile
7277
* ]
7378
*/
7479

80+
project.ext.react = [
81+
enableHermes: false, // clean and rebuild if changing
82+
]
83+
7584
apply from: "../../node_modules/react-native/react.gradle"
7685

7786
/**
@@ -89,53 +98,121 @@ def enableSeparateBuildPerCPUArchitecture = false
8998
*/
9099
def enableProguardInReleaseBuilds = false
91100

101+
/**
102+
* The preferred build flavor of JavaScriptCore.
103+
*
104+
* For example, to use the international variant, you can use:
105+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
106+
*
107+
* The international variant includes ICU i18n library and necessary data
108+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
109+
* give correct results when using with locales other than en-US. Note that
110+
* this variant is about 6MiB larger per architecture than default.
111+
*/
112+
def jscFlavor = 'org.webkit:android-jsc:+'
113+
114+
/**
115+
* Whether to enable the Hermes VM.
116+
*
117+
* This should be set on project.ext.react and mirrored here. If it is not set
118+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119+
* and the benefits of using Hermes will therefore be sharply reduced.
120+
*/
121+
def enableHermes = project.ext.react.get("enableHermes", false);
122+
92123
android {
93-
compileSdkVersion 26
94-
buildToolsVersion "26.0.3"
124+
compileSdkVersion rootProject.ext.compileSdkVersion
125+
126+
compileOptions {
127+
sourceCompatibility JavaVersion.VERSION_1_8
128+
targetCompatibility JavaVersion.VERSION_1_8
129+
}
95130

96131
defaultConfig {
97-
applicationId "com.sample"
98-
minSdkVersion 16
99-
targetSdkVersion 26
132+
applicationId "com.samplesimpledialogs"
133+
minSdkVersion rootProject.ext.minSdkVersion
134+
targetSdkVersion rootProject.ext.targetSdkVersion
100135
versionCode 1
101136
versionName "1.0"
102-
ndk {
103-
abiFilters "armeabi-v7a", "x86"
104-
}
105137
}
106138
splits {
107139
abi {
108140
reset()
109141
enable enableSeparateBuildPerCPUArchitecture
110142
universalApk false // If true, also generate a universal APK
111-
include "armeabi-v7a", "x86"
143+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
144+
}
145+
}
146+
signingConfigs {
147+
debug {
148+
storeFile file('debug.keystore')
149+
storePassword 'android'
150+
keyAlias 'androiddebugkey'
151+
keyPassword 'android'
112152
}
113153
}
114154
buildTypes {
155+
debug {
156+
signingConfig signingConfigs.debug
157+
}
115158
release {
159+
// Caution! In production, you need to generate your own keystore file.
160+
// see https://facebook.github.io/react-native/docs/signed-apk-android.
161+
signingConfig signingConfigs.debug
116162
minifyEnabled enableProguardInReleaseBuilds
117163
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
118164
}
119165
}
166+
167+
packagingOptions {
168+
pickFirst "lib/armeabi-v7a/libc++_shared.so"
169+
pickFirst "lib/arm64-v8a/libc++_shared.so"
170+
pickFirst "lib/x86/libc++_shared.so"
171+
pickFirst "lib/x86_64/libc++_shared.so"
172+
}
173+
120174
// applicationVariants are e.g. debug, release
121175
applicationVariants.all { variant ->
122176
variant.outputs.each { output ->
123177
// For each separate APK per architecture, set a unique version code as described here:
124-
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
125-
def versionCodes = ["armeabi-v7a":1, "x86":2]
178+
// https://developer.android.com/studio/build/configure-apk-splits.html
179+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
126180
def abi = output.getFilter(OutputFile.ABI)
127181
if (abi != null) { // null for the universal-debug, universal-release variants
128182
output.versionCodeOverride =
129183
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
130184
}
185+
131186
}
132187
}
133188
}
134189

135190
dependencies {
136-
compile fileTree(dir: "libs", include: ["*.jar"])
137-
compile "com.android.support:appcompat-v7:${androidSupportVersion}"
138-
compile "com.facebook.react:react-native:+" // From node_modules
191+
implementation fileTree(dir: "libs", include: ["*.jar"])
192+
//noinspection GradleDynamicVersion
193+
implementation "com.facebook.react:react-native:+" // From node_modules
194+
195+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
196+
197+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
198+
exclude group:'com.facebook.fbjni'
199+
}
200+
201+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202+
exclude group:'com.facebook.flipper'
203+
}
204+
205+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
206+
exclude group:'com.facebook.flipper'
207+
}
208+
209+
if (enableHermes) {
210+
def hermesPath = "../../node_modules/hermes-engine/android/";
211+
debugImplementation files(hermesPath + "hermes-debug.aar")
212+
releaseImplementation files(hermesPath + "hermes-release.aar")
213+
} else {
214+
implementation jscFlavor
215+
}
139216
}
140217

141218
// Run this once to be able to run the application with BUCK
@@ -144,3 +221,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
144221
from configurations.compile
145222
into 'libs'
146223
}
224+
225+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Sample/android/app/build_defs.bzl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""Helper definitions to glob .aar and .jar targets"""
2+
3+
def create_aar_targets(aarfiles):
4+
for aarfile in aarfiles:
5+
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6+
lib_deps.append(":" + name)
7+
android_prebuilt_aar(
8+
name = name,
9+
aar = aarfile,
10+
)
11+
12+
def create_jar_targets(jarfiles):
13+
for jarfile in jarfiles:
14+
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15+
lib_deps.append(":" + name)
16+
prebuilt_jar(
17+
name = name,
18+
binary_jar = jarfile,
19+
)

Sample/android/app/debug.keystore

2.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)