Skip to content

Commit 1a44783

Browse files
committed
init
0 parents  commit 1a44783

Some content is hidden

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

61 files changed

+7457
-0
lines changed

.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+
}

.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

.flowconfig

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
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
16+
17+
[include]
18+
19+
[libs]
20+
node_modules/react-native/Libraries/react-native/react-native-interface.js
21+
node_modules/react-native/flow
22+
flow/
23+
24+
[options]
25+
emoji=true
26+
27+
module.system=haste
28+
29+
experimental.strict_type_args=true
30+
31+
munge_underscores=true
32+
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'
34+
35+
suppress_type=$FlowIssue
36+
suppress_type=$FlowFixMe
37+
suppress_type=$FixMe
38+
39+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
40+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-0]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
41+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
42+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
43+
44+
unsafe.enable_getters_and_setters=true
45+
46+
[version]
47+
^0.40.0

.gitattributes

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

.gitignore

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
33+
# node.js
34+
#
35+
node_modules/
36+
npm-debug.log
37+
yarn-error.log
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
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://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
50+
51+
fastlane/report.xml
52+
fastlane/Preview.html
53+
fastlane/screenshots

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# App template for new React Native apps
2+
3+
This is a simple React Native app template which demonstrates a few basics concepts such as navigation between a few screens, ListViews, and handling text input.
4+
5+
<img src="https://cloud.githubusercontent.com/assets/346214/22697898/ced66f52-ed4a-11e6-9b90-df6daef43199.gif" alt="Android Example" height="800" style="float: left"/>
6+
7+
<img src="https://cloud.githubusercontent.com/assets/346214/22697901/cfeab3e4-ed4a-11e6-8552-d76585317ac2.gif" alt="iOS Example" height="800"/>
8+
9+
## Purpose
10+
11+
The idea is to make it easier for people to get started with React Native. Currently `react-native init` creates a very simple app that contains one screen with static text. Everyone new to React Native then needs to figure out how to do very basic things such as:
12+
- Rendering a list of items fetched from a server
13+
- Navigating between screens
14+
- Handling text input and the software keyboard
15+
16+
This app serves as a template used by `react-native init` so it is easier for anyone to get up and running quickly by having an app with a few screens and a ListView ready to go.
17+
18+
### Best practices
19+
20+
Another purpose of this app is to define best practices such as the folder structure of a standalone React Native app and naming conventions.
21+
22+
## Not using Redux
23+
24+
This template intentionally doesn't use Redux. After discussing with a few people who have experience using Redux we concluded that adding Redux to this app targeted at beginners would make the code more confusing, and wouldn't clearly show the benefits of Redux (because the app is too small). There are already a few concepts to grasp - the React component lifecycle, rendeing lists, using async / await, handling the software keyboard. We thought that's the maximum amount of things to learn at once. It's better for everyone to see patterns in their codebase as the app grows and decide for themselves whether and when they need Redux. See also the post [You Might Not Need Redux](https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367#.f3q7kq4b3) by [Dan Abramov](https://twitter.com/dan_abramov).
25+
26+
## Not using Flow (for now)
27+
28+
Many people are new to React Native, some are new to ES6 and most people will be new to Flow. Therefore we didn't want to introduce all these concepts all at once in a single codebase. However, it might make sense to later introduce a separate version of this template that uses Flow annotations.
29+
30+
## Provide feedback
31+
32+
We need your feedback. Do you have a lot of experience building React Native apps? If so, please carefully read the code of the template and if you think something should be done differently, use issues in the repo [mkonicek/AppTemplateFeedback](https://github.com/mkonicek/AppTemplateFeedback) to discuss what should be done differently.
33+
34+
## How to use the template
35+
36+
```
37+
$ react-native init MyApp --version 0.42.0-rc.2 --template navigation
38+
$ cd MyApp
39+
$ react-native run-android
40+
$ react-native run-ios
41+
```

__tests__/index.android.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 Index from '../index.android.js';
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+
<Index />
11+
);
12+
});

__tests__/index.ios.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 Index from '../index.ios.js';
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+
<Index />
11+
);
12+
});

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.myapp2",
49+
)
50+
51+
android_resource(
52+
name = "res",
53+
package = "com.myapp2",
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+
)

android/app/build.gradle

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
* // override which node gets called and with what additional arguments
61+
* nodeExecutableAndArgs: ["node"]
62+
*
63+
* // supply additional arguments to the packager
64+
* extraPackagerArgs: []
65+
* ]
66+
*/
67+
68+
apply from: "../../node_modules/react-native/react.gradle"
69+
70+
/**
71+
* Set this to true to create two separate APKs instead of one:
72+
* - An APK that only works on ARM devices
73+
* - An APK that only works on x86 devices
74+
* The advantage is the size of the APK is reduced by about 4MB.
75+
* Upload all the APKs to the Play Store and people will download
76+
* the correct one based on the CPU architecture of their device.
77+
*/
78+
def enableSeparateBuildPerCPUArchitecture = false
79+
80+
/**
81+
* Run Proguard to shrink the Java bytecode in release builds.
82+
*/
83+
def enableProguardInReleaseBuilds = false
84+
85+
android {
86+
compileSdkVersion 23
87+
buildToolsVersion "23.0.1"
88+
89+
defaultConfig {
90+
applicationId "com.myapp2"
91+
minSdkVersion 16
92+
targetSdkVersion 22
93+
versionCode 1
94+
versionName "1.0"
95+
ndk {
96+
abiFilters "armeabi-v7a", "x86"
97+
}
98+
}
99+
splits {
100+
abi {
101+
reset()
102+
enable enableSeparateBuildPerCPUArchitecture
103+
universalApk false // If true, also generate a universal APK
104+
include "armeabi-v7a", "x86"
105+
}
106+
}
107+
buildTypes {
108+
release {
109+
minifyEnabled enableProguardInReleaseBuilds
110+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
111+
}
112+
}
113+
// applicationVariants are e.g. debug, release
114+
applicationVariants.all { variant ->
115+
variant.outputs.each { output ->
116+
// For each separate APK per architecture, set a unique version code as described here:
117+
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
118+
def versionCodes = ["armeabi-v7a":1, "x86":2]
119+
def abi = output.getFilter(OutputFile.ABI)
120+
if (abi != null) { // null for the universal-debug, universal-release variants
121+
output.versionCodeOverride =
122+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
123+
}
124+
}
125+
}
126+
}
127+
128+
dependencies {
129+
compile fileTree(dir: "libs", include: ["*.jar"])
130+
compile "com.android.support:appcompat-v7:23.0.1"
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'
139+
}

0 commit comments

Comments
 (0)