Skip to content

Commit d6f7b7b

Browse files
author
alvaromb
committed
closes #43 Updated RN example to 0.29.1
1 parent bd05d1b commit d6f7b7b

File tree

18 files changed

+223
-131
lines changed

18 files changed

+223
-131
lines changed

Example/button/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

Example/button/.flowconfig

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,41 @@
11
[ignore]
22

33
# We fork some components by platform.
4-
.*/*.web.js
54
.*/*.android.js
65

7-
# Some modules have their own node_modules with overlap
8-
.*/node_modules/node-haste/.*
6+
# Ignore templates with `@flow` in header
7+
.*/local-cli/generator.*
98

10-
# Ugh
11-
.*/node_modules/babel.*
12-
.*/node_modules/babylon.*
13-
.*/node_modules/invariant.*
14-
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/Promise.js
19-
.*/node_modules/fbjs/lib/fetch.js
20-
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
21-
.*/node_modules/fbjs/lib/isEmpty.js
22-
.*/node_modules/fbjs/lib/crc32.js
23-
.*/node_modules/fbjs/lib/ErrorUtils.js
24-
25-
# Flow has a built-in definition for the 'react' module which we prefer to use
26-
# over the currently-untyped source
27-
.*/node_modules/react/react.js
28-
.*/node_modules/react/lib/React.js
29-
.*/node_modules/react/lib/ReactDOM.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/.*
9+
# Ignore malformed json
10+
.*/node_modules/y18n/test/.*\.json
4211

4312
[include]
4413

4514
[libs]
4615
node_modules/react-native/Libraries/react-native/react-native-interface.js
16+
node_modules/react-native/flow
17+
flow/
4718

4819
[options]
4920
module.system=haste
5021

22+
esproposal.class_static_fields=enable
23+
esproposal.class_instance_fields=enable
24+
25+
experimental.strict_type_args=true
26+
5127
munge_underscores=true
5228

5329
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
54-
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
30+
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'
5531

5632
suppress_type=$FlowIssue
5733
suppress_type=$FlowFixMe
5834
suppress_type=$FixMe
5935

60-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
61-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
36+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
37+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
6238
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
6339

6440
[version]
65-
0.26.0
41+
^0.27.0

Example/button/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ project.xcworkspace
2424

2525
# Android/IJ
2626
#
27+
*.iml
2728
.idea
2829
.gradle
2930
local.properties
@@ -32,3 +33,9 @@ local.properties
3233
#
3334
node_modules/
3435
npm-debug.log
36+
37+
# BUCK
38+
buck-out/
39+
\.buckd/
40+
android/app/libs
41+
android/keystores/debug.keystore

Example/button/Example.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
import React, { View, StyleSheet, TouchableNativeFeedback, Platform } from 'react-native'
1+
import React from 'react'
2+
import { View, StyleSheet, TouchableNativeFeedback, Platform } from 'react-native'
23
import Button from 'apsl-react-native-button'
34

4-
export default class Example extends React.Component {
5+
class Example extends React.Component {
6+
constructor (props: Object) {
7+
super(props)
8+
this.state = {
9+
isOnPressing: false
10+
}
11+
}
12+
513
render () {
614
var onPressProps;
7-
if(this.state.isOnPressing) {
15+
if (this.state.isOnPressing) {
816
onPressProps = styles.buttonStylePressing
917
} else {
1018
onPressProps = styles.buttonStyle1
@@ -152,3 +160,5 @@ const styles = StyleSheet.create({
152160
color: '#333',
153161
}
154162
})
163+
164+
export default Example

Example/button/android/app/BUCK

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import re
2+
3+
# To learn about Buck see [Docs](https://buckbuild.com/).
4+
# To run your application with Buck:
5+
# - install Buck
6+
# - `npm start` - to start the packager
7+
# - `cd android`
8+
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US`
9+
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
10+
# - `buck install -r android/app` - compile, install and run application
11+
#
12+
13+
lib_deps = []
14+
for jarfile in glob(['libs/*.jar']):
15+
name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile)
16+
lib_deps.append(':' + name)
17+
prebuilt_jar(
18+
name = name,
19+
binary_jar = jarfile,
20+
)
21+
22+
for aarfile in glob(['libs/*.aar']):
23+
name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile)
24+
lib_deps.append(':' + name)
25+
android_prebuilt_aar(
26+
name = name,
27+
aar = aarfile,
28+
)
29+
30+
android_library(
31+
name = 'all-libs',
32+
exported_deps = lib_deps
33+
)
34+
35+
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+
],
45+
)
46+
47+
android_build_config(
48+
name = 'build_config',
49+
package = 'com.button',
50+
)
51+
52+
android_resource(
53+
name = 'res',
54+
res = 'src/main/res',
55+
package = 'com.button',
56+
)
57+
58+
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+
],
66+
)

Example/button/android/app/build.gradle

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ apply plugin: "com.android.application"
33
import com.android.build.OutputFile
44

55
/**
6-
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
78
* These basically call `react-native bundle` with the correct arguments during the Android build
89
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
910
* bundle directly from the development server. Below you can see all the possible configurations
1011
* and their defaults. If you decide to add a configuration block, make sure to add it before the
11-
* `apply from: "react.gradle"` line.
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
1213
*
1314
* project.ext.react = [
1415
* // the name of the generated asset file containing your JS bundle
@@ -23,6 +24,15 @@ import com.android.build.OutputFile
2324
* // whether to bundle JS and assets in release mode
2425
* bundleInRelease: true,
2526
*
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+
*
2636
* // the root of your project, i.e. where "package.json" lives
2737
* root: "../../",
2838
*
@@ -45,15 +55,20 @@ import com.android.build.OutputFile
4555
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
4656
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
4757
* // for example, you might want to remove it from here.
48-
* inputExcludes: ["android/**", "ios/**"]
58+
* inputExcludes: ["android/**", "ios/**"],
59+
*
60+
* // override which node gets called and with what additional arguments
61+
* nodeExecutableAndArgs: ["node"]
62+
*
63+
* // supply additional arguments to the packager
64+
* extraPackagerArgs: []
4965
* ]
5066
*/
5167

52-
apply from: "react.gradle"
68+
apply from: "../../node_modules/react-native/react.gradle"
5369

5470
/**
55-
* Set this to true to create three separate APKs instead of one:
56-
* - A universal APK that works on all devices
71+
* Set this to true to create two separate APKs instead of one:
5772
* - An APK that only works on ARM devices
5873
* - An APK that only works on x86 devices
5974
* The advantage is the size of the APK is reduced by about 4MB.
@@ -83,9 +98,9 @@ android {
8398
}
8499
splits {
85100
abi {
86-
enable enableSeparateBuildPerCPUArchitecture
87-
universalApk true
88101
reset()
102+
enable enableSeparateBuildPerCPUArchitecture
103+
universalApk false // If true, also generate a universal APK
89104
include "armeabi-v7a", "x86"
90105
}
91106
}
@@ -113,5 +128,12 @@ android {
113128
dependencies {
114129
compile fileTree(dir: "libs", include: ["*.jar"])
115130
compile "com.android.support:appcompat-v7:23.0.1"
116-
compile "com.facebook.react:react-native:0.18.+"
131+
compile "com.facebook.react:react-native:+" // From node_modules
132+
}
133+
134+
// Run this once to be able to run the application with BUCK
135+
// puts all compile dependencies into folder libs for BUCK to use
136+
task copyDownloadableDepsToLibs(type: Copy) {
137+
from configurations.compile
138+
into 'libs'
117139
}

Example/button/android/app/proguard-rules.pro

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@
2626
# See http://sourceforge.net/p/proguard/bugs/466/
2727
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
2828
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
29+
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
2930

3031
# Do not strip any method/class that is annotated with @DoNotStrip
3132
-keep @com.facebook.proguard.annotations.DoNotStrip class *
33+
-keep @com.facebook.common.internal.DoNotStrip class *
3234
-keepclassmembers class * {
3335
@com.facebook.proguard.annotations.DoNotStrip *;
36+
@com.facebook.common.internal.DoNotStrip *;
3437
}
3538

3639
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
@@ -42,26 +45,22 @@
4245
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
4346
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
4447
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
45-
-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp <methods>; }
46-
-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup <methods>; }
48+
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
49+
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
4750

4851
-dontwarn com.facebook.react.**
4952

5053
# okhttp
5154

5255
-keepattributes Signature
5356
-keepattributes *Annotation*
54-
-keep class com.squareup.okhttp.** { *; }
55-
-keep interface com.squareup.okhttp.** { *; }
56-
-dontwarn com.squareup.okhttp.**
57+
-keep class okhttp3.** { *; }
58+
-keep interface okhttp3.** { *; }
59+
-dontwarn okhttp3.**
5760

5861
# okio
5962

6063
-keep class sun.misc.Unsafe { *; }
6164
-dontwarn java.nio.file.*
6265
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
6366
-dontwarn okio.**
64-
65-
# stetho
66-
67-
-dontwarn com.facebook.stetho.**

Example/button/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<uses-permission android:name="android.permission.INTERNET" />
55

66
<application
7+
android:name=".MainApplication"
78
android:allowBackup="true"
89
android:label="@string/app_name"
910
android:icon="@mipmap/ic_launcher"
Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
package com.button;
22

33
import com.facebook.react.ReactActivity;
4-
import com.facebook.react.ReactPackage;
5-
import com.facebook.react.shell.MainReactPackage;
6-
7-
import java.util.Arrays;
8-
import java.util.List;
94

105
public class MainActivity extends ReactActivity {
116

@@ -17,23 +12,4 @@ public class MainActivity extends ReactActivity {
1712
protected String getMainComponentName() {
1813
return "button";
1914
}
20-
21-
/**
22-
* Returns whether dev mode should be enabled.
23-
* This enables e.g. the dev menu.
24-
*/
25-
@Override
26-
protected boolean getUseDeveloperSupport() {
27-
return BuildConfig.DEBUG;
28-
}
29-
30-
/**
31-
* A list of packages used by the app. If the app uses additional views
32-
* or modules besides the default ones, add more packages here.
33-
*/
34-
@Override
35-
protected List<ReactPackage> getPackages() {
36-
return Arrays.<ReactPackage>asList(
37-
new MainReactPackage());
38-
}
3915
}

0 commit comments

Comments
 (0)