Skip to content

Commit 9377fca

Browse files
committed
Initial commit
1 parent a3b9aae commit 9377fca

40 files changed

+2277
-2
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.idea/
2+
*.npmignore

Demo/.buckconfig

+6
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

Demo/.flowconfig

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
[ignore]
2+
3+
# We fork some components by platform.
4+
.*/*.web.js
5+
.*/*.android.js
6+
7+
# Some modules have their own node_modules with overlap
8+
.*/node_modules/node-haste/.*
9+
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/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
68+
69+
70+
[include]
71+
72+
[libs]
73+
node_modules/react-native/Libraries/react-native/react-native-interface.js
74+
node_modules/react-native/flow
75+
flow/
76+
77+
[options]
78+
module.system=haste
79+
80+
esproposal.class_static_fields=enable
81+
esproposal.class_instance_fields=enable
82+
83+
munge_underscores=true
84+
85+
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
86+
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'
87+
88+
suppress_type=$FlowIssue
89+
suppress_type=$FlowFixMe
90+
suppress_type=$FixMe
91+
92+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-5]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
93+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-5]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
94+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
95+
96+
[version]
97+
^0.25.0

Demo/.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Demo/App.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
'use strict';
2+
3+
import React, { Component } from 'react';
4+
import {
5+
Text,
6+
View,
7+
Dimensions,
8+
ScrollView
9+
} from 'react-native';
10+
11+
import ViewPager from '@ldn0x7dc/react-native-view-pager';
12+
13+
export default class App extends Component {
14+
15+
constructor(props) {
16+
super(props);
17+
this.pageDataList = [];
18+
for(let i = 0; i < 100; i++) {
19+
this.pageDataList.push('page#' + i);
20+
}
21+
}
22+
23+
render() {
24+
return (
25+
<ViewPager
26+
style={{backgroundColor: 'white'}}
27+
renderPage={this.renderPage.bind(this)}
28+
pageDataList={this.pageDataList}
29+
initialPage={3}
30+
pageMargin={20}
31+
/>
32+
);
33+
}
34+
35+
renderPage(pageData, pageId, layout) {
36+
console.log('renderPage...layout=' + JSON.stringify(layout));
37+
return (
38+
<View style={{flex: 1}}>
39+
<View
40+
style={{flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: '#ccc'}}>
41+
<Text>{pageId + ' ' + pageData}</Text>
42+
</View>
43+
</View>
44+
);
45+
}
46+
}

Demo/android/app/BUCK

+66
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.demo',
50+
)
51+
52+
android_resource(
53+
name = 'res',
54+
res = 'src/main/res',
55+
package = 'com.demo',
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+
)

Demo/android/app/build.gradle

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
* // the root of your project, i.e. where "package.json" lives
37+
* root: "../../",
38+
*
39+
* // where to put the JS bundle asset in debug mode
40+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
41+
*
42+
* // where to put the JS bundle asset in release mode
43+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
44+
*
45+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
46+
* // require('./image.png')), in debug mode
47+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
48+
*
49+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
50+
* // require('./image.png')), in release mode
51+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
52+
*
53+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
54+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
55+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
56+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
57+
* // for example, you might want to remove it from here.
58+
* inputExcludes: ["android/**", "ios/**"]
59+
* ]
60+
*/
61+
62+
apply from: "../../node_modules/react-native/react.gradle"
63+
64+
/**
65+
* Set this to true to create two separate APKs instead of one:
66+
* - An APK that only works on ARM devices
67+
* - An APK that only works on x86 devices
68+
* The advantage is the size of the APK is reduced by about 4MB.
69+
* Upload all the APKs to the Play Store and people will download
70+
* the correct one based on the CPU architecture of their device.
71+
*/
72+
def enableSeparateBuildPerCPUArchitecture = false
73+
74+
/**
75+
* Run Proguard to shrink the Java bytecode in release builds.
76+
*/
77+
def enableProguardInReleaseBuilds = false
78+
79+
android {
80+
compileSdkVersion 23
81+
buildToolsVersion "23.0.1"
82+
83+
defaultConfig {
84+
applicationId "com.demo"
85+
minSdkVersion 16
86+
targetSdkVersion 22
87+
versionCode 1
88+
versionName "1.0"
89+
ndk {
90+
abiFilters "armeabi-v7a", "x86"
91+
}
92+
}
93+
splits {
94+
abi {
95+
reset()
96+
enable enableSeparateBuildPerCPUArchitecture
97+
universalApk false // If true, also generate a universal APK
98+
include "armeabi-v7a", "x86"
99+
}
100+
}
101+
buildTypes {
102+
release {
103+
minifyEnabled enableProguardInReleaseBuilds
104+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
105+
}
106+
}
107+
// applicationVariants are e.g. debug, release
108+
applicationVariants.all { variant ->
109+
variant.outputs.each { output ->
110+
// For each separate APK per architecture, set a unique version code as described here:
111+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
112+
def versionCodes = ["armeabi-v7a":1, "x86":2]
113+
def abi = output.getFilter(OutputFile.ABI)
114+
if (abi != null) { // null for the universal-debug, universal-release variants
115+
output.versionCodeOverride =
116+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
117+
}
118+
}
119+
}
120+
}
121+
122+
dependencies {
123+
compile fileTree(dir: "libs", include: ["*.jar"])
124+
compile "com.android.support:appcompat-v7:23.0.1"
125+
compile "com.facebook.react:react-native:+" // From node_modules
126+
}
127+
128+
// Run this once to be able to run the application with BUCK
129+
// puts all compile dependencies into folder libs for BUCK to use
130+
task copyDownloadableDepsToLibs(type: Copy) {
131+
from configurations.compile
132+
into 'libs'
133+
}

0 commit comments

Comments
 (0)