Skip to content
This repository was archived by the owner on Feb 8, 2020. It is now read-only.

Commit d16c20c

Browse files
brentvatnesatya164
authored andcommitted
feat: make example run as bare react-native project as well (#85)
1 parent 9563a27 commit d16c20c

Some content is hidden

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

57 files changed

+2749
-1157
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
.vscode
44
.idea
55
.expo
6+
.gradle
67

78
/coverage/
89
/types/
910
/dist/
1011
/lib/
11-
/packages/**/lib/
1212

1313
node_modules/
1414
web-build/
1515
web-report/
1616

17+
xcuserdata
18+
generated
19+
lib
20+
build
21+
1722
npm-debug.*
1823

1924
*.log

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
},
4343
"resolutions": {
4444
"react": "16.8.3",
45-
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
46-
"react-native-safe-area-view": "0.14.6"
45+
"react-native": "0.59.10",
46+
"react-native-safe-area-view": "0.14.7"
4747
},
4848
"husky": {
4949
"hooks": {
@@ -69,6 +69,5 @@
6969
"useTabs": false,
7070
"singleQuote": true,
7171
"trailingComma": "es5"
72-
},
73-
"name": "react-navigation"
72+
}
7473
}

packages/bottom-tabs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@types/react-native": "^0.60.2",
4343
"del-cli": "^2.0.0",
4444
"react": "16.8.3",
45-
"react-native": "^0.59.8",
45+
"react-native": "0.59.10",
4646
"typescript": "^3.5.3"
4747
},
4848
"peerDependencies": {

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"del-cli": "^2.0.0",
4141
"react": "^16.8.3",
4242
"react-native-testing-library": "^1.9.1",
43-
"react-test-renderer": "^16.8.3",
43+
"react-test-renderer": "16.8.3",
4444
"typescript": "^3.5.3"
4545
},
4646
"peerDependencies": {

packages/drawer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@types/react-native": "^0.60.2",
4444
"del-cli": "^2.0.0",
4545
"react": "16.8.3",
46-
"react-native": "^0.59.8",
46+
"react-native": "0.59.10",
4747
"react-native-gesture-handler": "^1.3.0",
4848
"react-native-reanimated": "^1.1.0",
4949
"react-native-screens": "^1.0.0-alpha.22",

packages/example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ios/Pods

packages/example/android/app/BUCK

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# To learn about Buck see [Docs](https://buckbuild.com/).
2+
# To run your application with Buck:
3+
# - install Buck
4+
# - `npm start` - to start the packager
5+
# - `cd android`
6+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8+
# - `buck install -r android/app` - compile, install and run application
9+
#
10+
11+
lib_deps = []
12+
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+
)
20+
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+
)
28+
29+
android_library(
30+
name = "all-libs",
31+
exported_deps = lib_deps,
32+
)
33+
34+
android_library(
35+
name = "app-code",
36+
srcs = glob([
37+
"src/main/java/**/*.java",
38+
]),
39+
deps = [
40+
":all-libs",
41+
":build_config",
42+
":res",
43+
],
44+
)
45+
46+
android_build_config(
47+
name = "build_config",
48+
package = "com.reactnavigationexample",
49+
)
50+
51+
android_resource(
52+
name = "res",
53+
package = "com.reactnavigationexample",
54+
res = "src/main/res",
55+
)
56+
57+
android_binary(
58+
name = "app",
59+
keystore = "//android/keystores:debug",
60+
manifest = "src/main/AndroidManifest.xml",
61+
package_type = "debug",
62+
deps = [
63+
":app-code",
64+
],
65+
)
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
apply plugin: "com.android.application"
2+
3+
import com.android.build.OutputFile
4+
5+
/**
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
8+
* These basically call `react-native bundle` with the correct arguments during the Android build
9+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10+
* bundle directly from the development server. Below you can see all the possible configurations
11+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
13+
*
14+
* project.ext.react = [
15+
* // the name of the generated asset file containing your JS bundle
16+
* bundleAssetName: "index.android.bundle",
17+
*
18+
* // the entry file for bundle generation
19+
* entryFile: "index.android.js",
20+
*
21+
* // whether to bundle JS and assets in debug mode
22+
* bundleInDebug: false,
23+
*
24+
* // whether to bundle JS and assets in release mode
25+
* bundleInRelease: true,
26+
*
27+
* // whether to bundle JS and assets in another build variant (if configured).
28+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29+
* // The configuration property can be in the following formats
30+
* // 'bundleIn${productFlavor}${buildType}'
31+
* // 'bundleIn${buildType}'
32+
* // bundleInFreeDebug: true,
33+
* // bundleInPaidRelease: true,
34+
* // bundleInBeta: true,
35+
*
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+
*
43+
* // the root of your project, i.e. where "package.json" lives
44+
* root: "../../",
45+
*
46+
* // where to put the JS bundle asset in debug mode
47+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
48+
*
49+
* // where to put the JS bundle asset in release mode
50+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
51+
*
52+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
53+
* // require('./image.png')), in debug mode
54+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
55+
*
56+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
57+
* // require('./image.png')), in release mode
58+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
59+
*
60+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
61+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
62+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
63+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
64+
* // for example, you might want to remove it from here.
65+
* inputExcludes: ["android/**", "ios/**"],
66+
*
67+
* // override which node gets called and with what additional arguments
68+
* nodeExecutableAndArgs: ["node"],
69+
*
70+
* // supply additional arguments to the packager
71+
* extraPackagerArgs: []
72+
* ]
73+
*/
74+
75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
79+
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
80+
apply from: "../../node_modules/react-native/react.gradle"
81+
82+
/**
83+
* Set this to true to create two separate APKs instead of one:
84+
* - An APK that only works on ARM devices
85+
* - An APK that only works on x86 devices
86+
* The advantage is the size of the APK is reduced by about 4MB.
87+
* Upload all the APKs to the Play Store and people will download
88+
* the correct one based on the CPU architecture of their device.
89+
*/
90+
def enableSeparateBuildPerCPUArchitecture = false
91+
92+
/**
93+
* Run Proguard to shrink the Java bytecode in release builds.
94+
*/
95+
def enableProguardInReleaseBuilds = false
96+
97+
android {
98+
compileSdkVersion rootProject.ext.compileSdkVersion
99+
buildToolsVersion rootProject.ext.buildToolsVersion
100+
101+
defaultConfig {
102+
applicationId "com.reactnavigationexample"
103+
minSdkVersion rootProject.ext.minSdkVersion
104+
targetSdkVersion rootProject.ext.targetSdkVersion
105+
versionCode 1
106+
versionName "1.0"
107+
}
108+
splits {
109+
abi {
110+
reset()
111+
enable enableSeparateBuildPerCPUArchitecture
112+
universalApk false // If true, also generate a universal APK
113+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
114+
}
115+
}
116+
buildTypes {
117+
release {
118+
minifyEnabled enableProguardInReleaseBuilds
119+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
120+
}
121+
}
122+
// applicationVariants are e.g. debug, release
123+
applicationVariants.all { variant ->
124+
variant.outputs.each { output ->
125+
// For each separate APK per architecture, set a unique version code as described here:
126+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
127+
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
128+
def abi = output.getFilter(OutputFile.ABI)
129+
if (abi != null) { // null for the universal-debug, universal-release variants
130+
output.versionCodeOverride =
131+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
132+
}
133+
}
134+
}
135+
compileOptions {
136+
sourceCompatibility JavaVersion.VERSION_1_8
137+
targetCompatibility JavaVersion.VERSION_1_8
138+
}
139+
}
140+
141+
dependencies {
142+
implementation project(':react-native-reanimated')
143+
implementation project(':react-native-gesture-handler')
144+
implementation fileTree(dir: "libs", include: ["*.jar"])
145+
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
146+
implementation "com.facebook.react:react-native:+" // From node_modules
147+
addUnimodulesDependencies()
148+
}
149+
150+
// Run this once to be able to run the application with BUCK
151+
// puts all compile dependencies into folder libs for BUCK to use
152+
task copyDownloadableDepsToLibs(type: Copy) {
153+
from configurations.compile
154+
into 'libs'
155+
}
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+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.reactnavigationexample">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6+
7+
<!-- OPTIONAL PERMISSIONS, REMOVE WHATEVER YOU DO NOT NEED -->
8+
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
9+
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
10+
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
11+
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
12+
<uses-permission android:name="android.permission.VIBRATE" />
13+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
14+
15+
<!-- These require runtime permissions on M -->
16+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
17+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
18+
<uses-permission android:name="android.permission.CAMERA" />
19+
<uses-permission android:name="android.permission.READ_CONTACTS" />
20+
<uses-permission android:name="android.permission.READ_CALENDAR" />
21+
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
22+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
23+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
24+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
25+
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
26+
<!-- END OPTIONAL PERMISSIONS -->
27+
28+
<application
29+
android:name=".MainApplication"
30+
android:label="@string/app_name"
31+
android:icon="@mipmap/ic_launcher"
32+
android:roundIcon="@mipmap/ic_launcher_round"
33+
android:allowBackup="false"
34+
android:theme="@style/AppTheme">
35+
<activity
36+
android:name=".MainActivity"
37+
android:label="@string/app_name"
38+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
39+
android:windowSoftInputMode="adjustResize">
40+
<intent-filter>
41+
<action android:name="android.intent.action.MAIN" />
42+
<category android:name="android.intent.category.LAUNCHER" />
43+
</intent-filter>
44+
</activity>
45+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
46+
</application>
47+
48+
</manifest>

0 commit comments

Comments
 (0)