Compare commits

..
Author SHA1 Message Date
Konstantin Raev 2f1ed20a6e [0.19.0-rc] Bump version numbers 2016-01-20 15:07:26 +00:00
2441 changed files with 63518 additions and 151151 deletions
+1 -3
View File
@@ -5,6 +5,4 @@
[maven_repositories]
central = https://repo1.maven.org/maven2
[alias]
movies = //Examples/Movies/android/app:app
uiexplorer = //Examples/UIExplorer/android/app:app
-1
View File
@@ -1 +0,0 @@
-Xmx512m -XX:+HeapDumpOnOutOfMemoryError
-3
View File
@@ -9,6 +9,3 @@ end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
[*.gradle]
indent_size = 4
+16 -42
View File
@@ -19,20 +19,15 @@
"__DEV__": true,
"__dirname": false,
"__fbBatchedBridgeConfig": false,
"alert": false,
"cancelAnimationFrame": false,
"cancelIdleCallback": false,
"clearImmediate": true,
"clearInterval": false,
"clearTimeout": false,
"console": false,
"document": false,
"escape": false,
"Event": false,
"EventTarget": false,
"exports": false,
"fetch": false,
"FormData": false,
"global": false,
"jest": false,
"Map": true,
@@ -41,7 +36,6 @@
"process": false,
"Promise": true,
"requestAnimationFrame": true,
"requestIdleCallback": true,
"require": false,
"Set": true,
"setImmediate": true,
@@ -49,29 +43,7 @@
"setTimeout": false,
"window": false,
"XMLHttpRequest": false,
"pit": false,
// Flow global types.
"ReactComponent": false,
"ReactClass": false,
"ReactElement": false,
"ReactPropsCheckType": false,
"ReactPropsChainableTypeChecker": false,
"ReactPropTypes": false,
"SyntheticEvent": false,
"$Either": false,
"$All": false,
"$Tuple": false,
"$Supertype": false,
"$Subtype": false,
"$Shape": false,
"$Diff": false,
"$Keys": false,
"$Enum": false,
"$Exports": false,
"$FlowIssue": false,
"$FlowFixMe": false,
"$FixMe": false
"pit": false
},
"rules": {
@@ -109,12 +81,13 @@
"curly": 1, // specify curly brace conventions for all control statements
"default-case": 0, // require default case in switch statements (off by default)
"dot-notation": 1, // encourages use of dot notation whenever possible
"eqeqeq": [1, "allow-null"], // require the use of === and !==
"eqeqeq": 1, // require the use of === and !==
"guard-for-in": 0, // make sure for-in loops have an if statement (off by default)
"no-alert": 1, // disallow the use of alert, confirm, and prompt
"no-caller": 1, // disallow use of arguments.caller or arguments.callee
"no-div-regex": 1, // disallow division operators explicitly at beginning of regular expression (off by default)
"no-else-return": 0, // disallow else after a return in an if (off by default)
"no-empty-label": 1, // disallow use of labels for anything other then loops and switches
"no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default)
"no-eval": 1, // disallow use of eval()
"no-extend-native": 1, // disallow adding to native types
@@ -149,6 +122,11 @@
"wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default)
"yoda": 1, // require or disallow Yoda conditions
// Strict Mode
// These rules relate to using strict mode.
"strict": [2, "global"], // require or disallow the "use strict" pragma in the global scope (off by default in the node environment)
// Variables
// These rules have to do with variable declarations.
@@ -178,8 +156,6 @@
// These rules are purely matters of style and are quite subjective.
"key-spacing": 0,
"keyword-spacing": 1, // enforce spacing before and after keywords
"jsx-quotes": [1, "prefer-double"],
"comma-spacing": 0,
"no-multi-spaces": 0,
"brace-style": 0, // enforce one true brace style (off by default)
@@ -203,9 +179,11 @@
"quote-props": 0, // require quotes around object literal property names (off by default)
"semi": 1, // require or disallow use of semicolons instead of ASI
"sort-vars": 0, // sort variables within the same declaration block (off by default)
"space-after-keywords": 1, // require a space after certain keywords (off by default)
"space-in-brackets": 0, // require or disallow spaces inside brackets (off by default)
"space-in-parens": 0, // require or disallow spaces inside parentheses (off by default)
"space-infix-ops": 1, // require spaces around operators
"space-return-throw-case": 1, // require a space after return, throw, and case
"space-unary-ops": [1, { "words": true, "nonwords": false }], // require or disallow spaces before/after unary operators (words on by default, nonwords off by default)
"max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default)
"one-var": 0, // allow just one var statement per function (off by default)
@@ -221,24 +199,20 @@
"no-bitwise": 1, // disallow use of bitwise operators (off by default)
"no-plusplus": 0, // disallow use of unary operators, ++ and -- (off by default)
// React Plugin
// The following rules are made available via `eslint-plugin-react`.
"react/display-name": 0,
"react/jsx-boolean-value": 0,
"react/jsx-no-duplicate-props": 2,
"react/jsx-quotes": [1, "double", "avoid-escape"],
"react/jsx-no-undef": 1,
"react/jsx-sort-props": 0,
"react/jsx-uses-react": 1,
"react/jsx-uses-react": 0,
"react/jsx-uses-vars": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-did-mount-set-state": [1, "allow-in-func"],
"react/no-did-update-set-state": [1, "allow-in-func"],
"react/no-multi-comp": 0,
"react/no-string-refs": 1,
"react/no-unknown-property": 0,
"react/prop-types": 0,
"react/react-in-jsx-scope": 1,
"react/react-in-jsx-scope": 0,
"react/self-closing-comp": 1,
"react/wrap-multilines": 0,
"react/wrap-multilines": 0
}
}
+36 -28
View File
@@ -1,57 +1,65 @@
[ignore]
# We fork some components by platform.
.*/*[.]android.js
.*/*.web.js
.*/*.android.js
# Ignore templates with `@flow` in header
.*/local-cli/generator.*
# Some modules have their own node_modules with overlap
.*/node_modules/node-haste/.*
# Ignore malformed json
.*/node_modules/y18n/test/.*\.json
# Ugh
.*/node_modules/babel.*
.*/node_modules/babylon.*
.*/node_modules/invariant.*
# Ignore the website subdir
<PROJECT_ROOT>/website/.*
# Ignore react and fbjs where there are overlaps, but don't ignore
# anything that react-native relies on
.*/node_modules/fbjs/lib/Map.js
.*/node_modules/fbjs/lib/Promise.js
.*/node_modules/fbjs/lib/fetch.js
.*/node_modules/fbjs/lib/ExecutionEnvironment.js
.*/node_modules/fbjs/lib/isEmpty.js
.*/node_modules/fbjs/lib/crc32.js
.*/node_modules/fbjs/lib/ErrorUtils.js
# Ignore BUCK generated dirs
<PROJECT_ROOT>/\.buckd/
# Flow has a built-in definition for the 'react' module which we prefer to use
# over the currently-untyped source
.*/node_modules/react/react.js
.*/node_modules/react/lib/React.js
.*/node_modules/react/lib/ReactDOM.js
# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js
# Ignore commoner tests
.*/node_modules/commoner/test/.*
# Ignore duplicate module providers
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
.*/Libraries/react-native/React.js
.*/Libraries/react-native/ReactNative.js
.*/node_modules/jest-runtime/build/__tests__/.*
# See https://github.com/facebook/flow/issues/442
.*/react-tools/node_modules/commoner/lib/reader.js
# Ignore jest
.*/node_modules/jest-cli/.*
# Ignore Website
.*/website/.*
[include]
[libs]
Libraries/react-native/react-native-interface.js
flow/
[options]
module.system=haste
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
experimental.strict_type_args=true
munge_underscores=true
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
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'
module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub'
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
unsafe.enable_getters_and_setters=true
[version]
^0.33.0
0.20.1
-21
View File
@@ -1,21 +0,0 @@
We use GitHub Issues for bugs.
If you have a non-bug question, ask on Stack Overflow: http://stackoverflow.com/questions/tagged/react-native
If you have a feature request, post it on Product Pains: https://productpains.com/product/react-native/
--- Please use this template, and delete everything above this line before submitting your issue ---
### Description
[FILL THIS OUT: Explain what you did, what you expected to happen, and what actually happens.]
### Reproduction
[FILL THIS OUT: Try to reproduce your bug on rnplay.org and provide a link. If you can't reproduce the bug on rnplay.org, provide a sample project.]
### Additional Information
* React Native version: [FILL THIS OUT]
* Platform: [FILL THIS OUT: iOS, Android, or both?]
* Operating System: [FILL THIS OUT: MacOS, Linux, or Windows?]
-19
View File
@@ -1,19 +0,0 @@
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:
> **Unless you are a React Native release maintainer and cherry-picking an *existing* commit into a current release, ensure your pull request is targeting the `master` React Native branch.**
Explain the **motivation** for making this change. What existing problem does the pull request solve?
Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.
**Test plan (required)**
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
Make sure tests pass on both Travis and Circle CI.
**Code formatting**
Look around. Match the style of the rest of the codebase. See also the simple [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide).
For more info, see the ["Pull Requests" section of our "Contributing" guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests).
-14
View File
@@ -24,24 +24,13 @@ project.xcworkspace
# Gradle
/build/
/Examples/**/android/app/build/
/Examples/**/android/app/gradle/
/Examples/**/android/app/gradlew
/Examples/**/android/app/gradlew.bat
/ReactAndroid/build/
# Buck
.buckd
buck-out
/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/
/ReactAndroid/src/main/jni/prebuilt/lib/x86/
/ReactAndroid/src/main/gen
# Android
.idea
.gradle
local.properties
*.iml
/android/
# Node
node_modules
@@ -50,6 +39,3 @@ node_modules
# OS X
.DS_Store
# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
-2
View File
@@ -1,2 +0,0 @@
# rnpm
/local-cli/rnpm
+69 -23
View File
@@ -1,41 +1,87 @@
language: objective-c
osx_image: xcode8
osx_image: xcode7.2
cache:
directories:
- node_modules
- .nvm
install:
- mkdir -p /Users/travis/build/facebook/.nvm
- export NVM_DIR="/Users/travis/build/facebook/.nvm"
- brew install nvm
- brew reinstall nvm
- mkdir -p .nvm
- export NVM_DIR="$PWD/.nvm"
- source $(brew --prefix nvm)/nvm.sh
# TODO npm 2 started stalling on Travis, t11852928
- nvm install 5
- rm -Rf "${TMPDIR}/jest_preprocess_cache"
- wget https://github.com/yarnpkg/yarn/releases/download/v0.16.0/yarn-0.16.0.js
- export yarn="node $(pwd)/yarn-0.16.0.js"
- $yarn install
- npm config set spin=false
- npm install -g flow-bin@`node -p "require('fs').readFileSync('.flowconfig', 'utf8').split('[version]')[1].trim()"`
- npm install
script:
- if [[ "$TEST_TYPE" = objc-ios ]]; then travis_retry travis_wait ./scripts/objc-test-ios.sh; fi
- if [[ "$TEST_TYPE" = objc-tvos ]]; then travis_retry travis_wait ./scripts/objc-test-tvos.sh; fi
- if [[ "$TEST_TYPE" = e2e-objc ]]; then node ./scripts/run-ci-e2e-tests.js --ios --js --retries 3; fi
- if [[ "$TEST_TYPE" = js ]]; then npm run flow check; fi
- if [[ "$TEST_TYPE" = js ]]; then npm test -- --maxWorkers=1; fi
- |
if [ "$TEST_TYPE" = objc ]
then
./scripts/objc-test.sh
elif [ "$TEST_TYPE" = js ]
then
npm install github@0.2.4
cat <(echo eslint; npm run lint --silent -- --format=json; echo flow; flow --json) | GITHUB_TOKEN="af6ef0d15709bc91d""06a6217a5a826a226fb57b7" node bots/code-analysis-bot.js
flow check && npm test -- '\/Libraries\/'
elif [ "$TEST_TYPE" = packager ]
then
npm test -- '\/packager\/'
elif [ "$TEST_TYPE" = cli ]
then
npm test -- '\/(local|private|react-native)-cli\/'
elif [ "$TEST_TYPE" = build_website ]
then
cd website
$(which npm) install
./setup.sh
if [ "$TRAVIS_PULL_REQUEST" = false ] && [ "$TRAVIS_BRANCH" = master ]; then
# Automatically publish the website
echo "machine github.com login reactjs-bot password $GITHUB_TOKEN" >~/.netrc
./publish.sh
else
# Make sure the website builds without error
node server/generate.js
fi
elif [ "$TEST_TYPE" = e2e ]
then
./scripts/e2e-test.sh
else
echo "Unknown test type: $TEST_TYPE"
exit 1
fi
env:
matrix:
- TEST_TYPE=e2e-objc
- TEST_TYPE=objc-ios
- TEST_TYPE=objc-tvos
- TEST_TYPE=objc
- TEST_TYPE=js
- TEST_TYPE=packager
- TEST_TYPE=cli
- TEST_TYPE=build_website
- TEST_TYPE=e2e
global:
# $GITHUB_TOKEN
- secure: "HlmG8M2DmBUSBh6KH1yVIe/8gR4iibg4WfcHq1x/xYQxGbvleq7NOo04V6eFHnl9cvZCu+PKH0841WLnGR7c4BBf47GVu/o16nXzggPumHKy++lDzxFPlJ1faMDfjg/5vjbAxRUe7D3y98hQSeGHH4tedc8LvTaFLVu7iiGqvjU="
# $APPETIZE_TOKEN
- secure: "egsvVSpszTzrNd6bN62DsVAzMiSZI/OHgdizfPryqvqWBf655ztE6XFQSEFNpuIAzSKDDF25ioT8iPfVsbC1iK6HDWHfmqYxML0L+OoU0gi+hV2oKUBFZDZ1fwSnFoWuBdNdMDpLlUxvJp6N1WyfNOB2dxuZUt8eTt48Hi3+Hpc="
# $S3_TOKEN
- secure: "lY8JZPA0A7zT7L5KF9BBg34XYWIeR/RJiEvE7l7oVr88KnEPtyd//79eHhhVKnUnav7zsk5QJwkcX0MxKTp/dp4G0Am+zOX+sfA8kQrJ+2/+FzFW7AEsW/kHByfaIEIly9DQvUFt4I4oMm8nQZysJLahDgNWglyI3RTuJp//hcY="
branches:
only:
- master
- /^.*-stable$/
notifications:
email:
recipients:
- bestander@gmail.com
on_failure: change
on_success: change
+6 -20
View File
@@ -14,29 +14,16 @@ We will do our best to keep `master` in good shape, with tests passing at all ti
The core team will be monitoring for pull requests. When we get one, we'll run some Facebook-specific integration tests on it first. From here, we'll need to get another person to sign off on the changes and then merge the pull request. For API changes we may need to fix internal uses, which could cause some delay. We'll do our best to provide updates and feedback throughout the process.
**Please submit your pull request on the `master` branch**. If the fix is critical and should be included in a stable branch please mention it and it will be cherry picked into it.
*Before* submitting a pull request, please make sure the following is done…
1. Fork the repo and create your branch from `master`.
2. **Describe your test plan in your commit.** If you've added code that should be tested, add tests!
2. If you've added code that should be tested, add tests!
3. If you've changed APIs, update the documentation.
4. If you've updated the docs, verify the website locally and submit screenshots if applicable.
```
$ cd website
$ npm install && npm start
go to: http://localhost:8079/react-native/index.html
```
5. Add the copyright notice to the top of any new files you've added.
6. Ensure tests pass on Travis and Circle CI.
7. Make sure your code lints (`node linter.js <files touched>`).
4. Add the copyright notice to the top of any new files you've added.
5. Ensure tests pass on Travis and Circle CI.
6. Make sure your code lints (`node linter.js <files touched>`).
7. Squash your commits (`git rebase -i`).
8. If you haven't already, sign the [CLA](https://code.facebook.com/cla).
9. Squash your commits (`git rebase -i`).
one intent alongs with one commit makes it clearer for people to review and easier to understand your intention
Note: It is not necessary to keep clicking `Merge master to your branch` on PR page. You would want to merge master if there are conflicts or tests are failing. The facebook-bot ultimately squashes all commits to a single one before merging your PR.
#### Copyright Notice for files
@@ -86,7 +73,6 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
#### General
* **Most important: Look around.** Match the style you see used in the rest of the project. This includes formatting, naming things in code, naming things in documentation.
* Add trailing commas,
* 2 spaces for indentation (no tabs)
* "Attractive"
@@ -101,7 +87,7 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
#### JSX
* Prefer `"` over `'` for string literal props
* Prefer `'` over `"` for string literal props
* When wrapping opening tags over multiple lines, place one prop per line
* `{}` of props should hug their values (no spaces)
* Place the closing `>` of opening tags on the same line as the last prop
-5
View File
@@ -1,5 +0,0 @@
{
"rules": {
"no-alert": 0
}
}
+4 -88
View File
@@ -14,8 +14,6 @@
1461632D1AC3E23900C2F5AD /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1461632C1AC3E22900C2F5AD /* libReact.a */; };
5F82F1781B85785200FAE87E /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F82F1771B85784500FAE87E /* libRCTWebSocket.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
E730D7501D4EE4E2000B7DA8 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E730D74C1D4EE4D0000B7DA8 /* libRCTNetwork.a */; };
E730D7571D4EE538000B7DA8 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E730D7561D4EE534000B7DA8 /* libRCTImage.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -40,20 +38,6 @@
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
E730D74B1D4EE4D0000B7DA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E730D7471D4EE4D0000B7DA8 /* RCTNetwork.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511DB1A9E6C8500147676;
remoteInfo = RCTNetwork;
};
E730D7551D4EE534000B7DA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E730D7511D4EE534000B7DA8 /* RCTImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
remoteInfo = RCTImage;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@@ -67,8 +51,6 @@
146163271AC3E22900C2F5AD /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../../React/React.xcodeproj; sourceTree = "<group>"; };
5F82F1721B85784500FAE87E /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../../Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = "<group>"; };
E730D7471D4EE4D0000B7DA8 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../../Libraries/Network/RCTNetwork.xcodeproj; sourceTree = "<group>"; };
E730D7511D4EE534000B7DA8 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../../Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -76,8 +58,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E730D7571D4EE538000B7DA8 /* libRCTImage.a in Frameworks */,
E730D7501D4EE4E2000B7DA8 /* libRCTNetwork.a in Frameworks */,
5F82F1781B85785200FAE87E /* libRCTWebSocket.a in Frameworks */,
1461632D1AC3E23900C2F5AD /* libReact.a in Frameworks */,
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
@@ -119,8 +99,6 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
E730D7511D4EE534000B7DA8 /* RCTImage.xcodeproj */,
E730D7471D4EE4D0000B7DA8 /* RCTNetwork.xcodeproj */,
5F82F1721B85784500FAE87E /* RCTWebSocket.xcodeproj */,
146163271AC3E22900C2F5AD /* React.xcodeproj */,
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
@@ -155,22 +133,6 @@
name = Products;
sourceTree = "<group>";
};
E730D7481D4EE4D0000B7DA8 /* Products */ = {
isa = PBXGroup;
children = (
E730D74C1D4EE4D0000B7DA8 /* libRCTNetwork.a */,
);
name = Products;
sourceTree = "<group>";
};
E730D7521D4EE534000B7DA8 /* Products */ = {
isa = PBXGroup;
children = (
E730D7561D4EE534000B7DA8 /* libRCTImage.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -181,7 +143,6 @@
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
68ACCCD51D2BE2D2008E368A /* Run Script */,
);
buildRules = (
);
@@ -213,14 +174,6 @@
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = E730D7521D4EE534000B7DA8 /* Products */;
ProjectRef = E730D7511D4EE534000B7DA8 /* RCTImage.xcodeproj */;
},
{
ProductGroup = E730D7481D4EE4D0000B7DA8 /* Products */;
ProjectRef = E730D7471D4EE4D0000B7DA8 /* RCTNetwork.xcodeproj */;
},
{
ProductGroup = 832341B11AAA6A8300B99B32 /* Products */;
ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
@@ -263,20 +216,6 @@
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
E730D74C1D4EE4D0000B7DA8 /* libRCTNetwork.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTNetwork.a;
remoteRef = E730D74B1D4EE4D0000B7DA8 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
E730D7561D4EE534000B7DA8 /* libRCTImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTImage.a;
remoteRef = E730D7551D4EE534000B7DA8 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@@ -291,23 +230,6 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
68ACCCD51D2BE2D2008E368A /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Run Script";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n$SRCROOT/../../packager/react-native-xcode.sh Examples/2048/Game2048.js\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
13B07F871A680F5B00A75B9A /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -345,10 +267,7 @@
INFOPLIST_FILE = "$(SRCROOT)/2048/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = 2048;
};
@@ -366,10 +285,7 @@
INFOPLIST_FILE = "$(SRCROOT)/2048/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = 2048;
};
@@ -415,7 +331,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -455,7 +371,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
+29 -2
View File
@@ -14,14 +14,41 @@
#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/2048/Game2048" fallbackResource:nil];
NSURL *jsCodeLocation;
/**
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/2048/Game2048.bundle?platform=ios&dev=true"];
/**
* OPTION 2
* Load from pre-bundled file on disk. To re-generate the static bundle, `cd`
* to your Xcode project folder in the terminal, and run
*
* $ curl 'http://localhost:8081/Examples/2048/Game2048.bundle?platform=ios' -o main.jsbundle
*
* then add the `main.jsbundle` file to your project and uncomment this line:
*/
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Game2048"
+2 -6
View File
@@ -16,14 +16,13 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var Animated = require('Animated');
var GameBoard = require('GameBoard');
@@ -54,8 +53,6 @@ class Board extends React.Component {
}
class Tile extends React.Component {
state: any;
static _getPosition(index): number {
return BOARD_PADDING + (index * (CELL_SIZE + CELL_MARGIN * 2) + CELL_MARGIN);
}
@@ -150,7 +147,6 @@ class GameEndOverlay extends React.Component {
class Game2048 extends React.Component {
startX: number;
startY: number;
state: any;
constructor(props: {}) {
super(props);
+8 -6
View File
@@ -15,8 +15,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
Platform,
@@ -25,14 +24,14 @@ var {
TouchableHighlight,
TouchableNativeFeedback,
View
} = ReactNative;
} = React;
var getStyleFromScore = require('./getStyleFromScore');
var getImageSource = require('./getImageSource');
var getTextFromScore = require('./getTextFromScore');
class MovieCell extends React.Component {
render() {
var MovieCell = React.createClass({
render: function() {
var criticsScore = this.props.movie.ratings.critics_score;
var TouchableElement = TouchableHighlight;
if (Platform.OS === 'android') {
@@ -45,6 +44,9 @@ class MovieCell extends React.Component {
onShowUnderlay={this.props.onHighlight}
onHideUnderlay={this.props.onUnhighlight}>
<View style={styles.row}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Image
source={getImageSource(this.props.movie, 'det')}
style={styles.cellImage}
@@ -66,7 +68,7 @@ class MovieCell extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
textContainer: {
+17 -15
View File
@@ -15,25 +15,27 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
ScrollView,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var getImageSource = require('./getImageSource');
var getStyleFromScore = require('./getStyleFromScore');
var getTextFromScore = require('./getTextFromScore');
class MovieScreen extends React.Component {
render() {
var MovieScreen = React.createClass({
render: function() {
return (
<ScrollView contentContainerStyle={styles.contentContainer}>
<View style={styles.mainSection}>
{/* $FlowIssue #7363964 - There's a bug in Flow where you cannot
* omit a property or set it to undefined if it's inside a shape,
* even if it isn't required */}
<Image
source={getImageSource(this.props.movie, 'det')}
style={styles.detailsImage}
@@ -57,11 +59,11 @@ class MovieScreen extends React.Component {
<Cast actors={this.props.movie.abridged_cast} />
</ScrollView>
);
}
}
},
});
class Ratings extends React.Component {
render() {
var Ratings = React.createClass({
render: function() {
var criticsScore = this.props.ratings.critics_score;
var audienceScore = this.props.ratings.audience_score;
@@ -81,11 +83,11 @@ class Ratings extends React.Component {
</View>
</View>
);
}
}
},
});
class Cast extends React.Component {
render() {
var Cast = React.createClass({
render: function() {
if (!this.props.actors) {
return null;
}
@@ -100,8 +102,8 @@ class Cast extends React.Component {
)}
</View>
);
}
}
},
});
var styles = StyleSheet.create({
contentContainer: {
@@ -200,7 +200,6 @@
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
68ACCCEE1D2BE57F008E368A /* ShellScript */,
);
buildRules = (
);
@@ -321,22 +320,6 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
68ACCCEE1D2BE57F008E368A /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n$SRCROOT/../../packager/react-native-xcode.sh Examples/Movies/MoviesApp.ios.js\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
13B07F871A680F5B00A75B9A /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -374,10 +357,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Movies/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Movies;
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../Libraries/**";
@@ -396,10 +376,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Movies/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Movies;
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../Libraries/**";
@@ -446,7 +423,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -486,7 +463,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
+29 -2
View File
@@ -14,7 +14,6 @@
#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTLinkingManager.h"
#import "RCTRootView.h"
@@ -22,7 +21,35 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/Movies/MoviesApp.ios" fallbackResource:nil];
NSURL *jsCodeLocation;
/**
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/Movies/MoviesApp.ios.bundle?platform=ios&dev=true"];
/**
* OPTION 2
* Load from pre-bundled file on disk. To re-generate the static bundle, `cd`
* to your Xcode project folder in the terminal, and run
*
* $ curl 'http://localhost:8081/Examples/Movies/MoviesApp.ios.bundle?platform=ios&dev=true' -o main.jsbundle
*
* then add the `main.jsbundle` file to your project and uncomment this line:
*/
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MoviesApp"
+5 -6
View File
@@ -16,8 +16,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AppRegistry,
BackAndroid,
@@ -25,7 +24,7 @@ var {
StyleSheet,
ToolbarAndroid,
View,
} = ReactNative;
} = React;
var MovieScreen = require('./MovieScreen');
var SearchScreen = require('./SearchScreen');
@@ -65,8 +64,8 @@ var RouteMapper = function(route, navigationOperations, onComponentRef) {
}
};
class MoviesApp extends React.Component {
render() {
var MoviesApp = React.createClass({
render: function() {
var initialRoute = {name: 'search'};
return (
<Navigator
@@ -77,7 +76,7 @@ class MoviesApp extends React.Component {
/>
);
}
}
});
var styles = StyleSheet.create({
container: {
+5 -6
View File
@@ -16,18 +16,17 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AppRegistry,
NavigatorIOS,
StyleSheet,
} = ReactNative;
} = React;
var SearchScreen = require('./SearchScreen');
class MoviesApp extends React.Component {
render() {
var MoviesApp = React.createClass({
render: function() {
return (
<NavigatorIOS
style={styles.container}
@@ -38,7 +37,7 @@ class MoviesApp extends React.Component {
/>
);
}
}
});
var styles = StyleSheet.create({
container: {
-15
View File
@@ -35,21 +35,6 @@ Open the Movies app in your emulator.
See [Running on Device](https://facebook.github.io/react-native/docs/running-on-device-android.html) in case you want to use a physical device.
### Running with Buck
Follow the same setup as running with gradle.
Install Buck from [here](https://buckbuild.com/setup/install.html).
Run the following commands from the react-native folder:
./gradlew :ReactAndroid:packageReactNdkLibsForBuck
buck fetch movies
buck install -r movies
./packager/packager.sh
_Note: The native libs are still built using gradle. Full build with buck is coming soon(tm)._
## Built from source
Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.
+18 -14
View File
@@ -16,22 +16,32 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
Platform,
ActivityIndicator,
ProgressBarAndroid,
TextInput,
StyleSheet,
TouchableNativeFeedback,
View,
} = ReactNative;
} = React;
var IS_RIPPLE_EFFECT_SUPPORTED = Platform.Version >= 21;
class SearchBar extends React.Component {
render() {
var SearchBar = React.createClass({
render: function() {
var loadingView;
if (this.props.isLoading) {
loadingView = (
<ProgressBarAndroid
styleAttr="Large"
style={styles.spinner}
/>
);
} else {
loadingView = <View style={styles.spinner} />;
}
var background = IS_RIPPLE_EFFECT_SUPPORTED ?
TouchableNativeFeedback.SelectableBackgroundBorderless() :
TouchableNativeFeedback.SelectableBackground();
@@ -58,16 +68,11 @@ class SearchBar extends React.Component {
onFocus={this.props.onFocus}
style={styles.searchBarInput}
/>
<ActivityIndicator
animating={this.props.isLoading}
color="white"
size="large"
style={styles.spinner}
/>
{loadingView}
</View>
);
}
}
});
var styles = StyleSheet.create({
searchBar: {
@@ -88,7 +93,6 @@ var styles = StyleSheet.create({
spinner: {
width: 30,
height: 30,
marginRight: 16,
},
icon: {
width: 24,
+7 -8
View File
@@ -16,17 +16,16 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ActivityIndicator,
ActivityIndicatorIOS,
TextInput,
StyleSheet,
View,
} = ReactNative;
} = React;
class SearchBar extends React.Component {
render() {
var SearchBar = React.createClass({
render: function() {
return (
<View style={styles.searchBar}>
<TextInput
@@ -37,14 +36,14 @@ class SearchBar extends React.Component {
onFocus={this.props.onFocus}
style={styles.searchBarInput}
/>
<ActivityIndicator
<ActivityIndicatorIOS
animating={this.props.isLoading}
style={styles.spinner}
/>
</View>
);
}
}
});
var styles = StyleSheet.create({
searchBar: {
+18 -11
View File
@@ -15,19 +15,19 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ActivityIndicator,
ActivityIndicatorIOS,
ListView,
Platform,
ProgressBarAndroid,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var TimerMixin = require('react-timer-mixin');
var invariant = require('fbjs/lib/invariant');
var invariant = require('invariant');
var dismissKeyboard = require('dismissKeyboard');
var MovieCell = require('./MovieCell');
@@ -249,8 +249,15 @@ var SearchScreen = React.createClass({
if (!this.hasMore() || !this.state.isLoadingTail) {
return <View style={styles.scrollSpinner} />;
}
return <ActivityIndicator style={styles.scrollSpinner} />;
if (Platform.OS === 'ios') {
return <ActivityIndicatorIOS style={styles.scrollSpinner} />;
} else {
return (
<View style={{alignItems: 'center'}}>
<ProgressBarAndroid styleAttr="Large"/>
</View>
);
}
},
renderSeparator: function(
@@ -309,7 +316,7 @@ var SearchScreen = React.createClass({
onSearchChange={this.onSearchChange}
isLoading={this.state.isLoading}
onFocus={() =>
this.refs.listview && this.refs.listview.getScrollResponder().scrollTo({ x: 0, y: 0 })}
this.refs.listview && this.refs.listview.getScrollResponder().scrollTo(0, 0)}
/>
<View style={styles.separator} />
{content}
@@ -318,8 +325,8 @@ var SearchScreen = React.createClass({
},
});
class NoMovies extends React.Component {
render() {
var NoMovies = React.createClass({
render: function() {
var text = '';
if (this.props.filter) {
text = `No results for "${this.props.filter}"`;
@@ -335,7 +342,7 @@ class NoMovies extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
container: {
@@ -3,7 +3,7 @@
*/
'use strict';
jest.unmock('../getImageSource');
jest.dontMock('../getImageSource');
var getImageSource = require('../getImageSource');
-31
View File
@@ -1,31 +0,0 @@
include_defs('//ReactAndroid/DEFS')
android_binary(
name = 'app',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//keystores:debug',
deps = [
':movies-lib',
],
)
android_library(
name = 'movies-lib',
srcs = glob(['src/main/java/**/*.java']),
deps = [
':res',
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/shell:shell'),
react_native_target('java/com/facebook/react:react'),
react_native_target('jni/prebuilt:android-jsc'),
# .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck`
react_native_target('jni/prebuilt:reactnative-libs'),
],
)
android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.facebook.react.movies',
)
@@ -1,18 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.react.movies"
android:versionCode="1"
android:versionName="1.0">
package="com.facebook.react.movies">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".MoviesApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/rotten_tomatoes_icon"
@@ -11,13 +11,79 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.facebook.react.movies;
import com.facebook.react.ReactActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import com.facebook.react.LifecycleState;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactRootView;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.shell.MainReactPackage;
public class MoviesActivity extends Activity implements DefaultHardwareBackBtnHandler {
private ReactInstanceManager mReactInstanceManager;
public class MoviesActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "MoviesApp";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("MoviesApp.android.bundle")
.setJSMainModuleName("Examples/Movies/MoviesApp.android")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(true)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
((ReactRootView) findViewById(R.id.react_root_view))
.startReactApplication(mReactInstanceManager, "MoviesApp", null);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
mReactInstanceManager.showDevOptionsDialog();
return true;
}
return super.onKeyUp(keyCode, event);
}
@Override
protected void onPause() {
super.onPause();
if (mReactInstanceManager != null) {
mReactInstanceManager.onPause();
}
}
@Override
protected void onResume() {
super.onResume();
if (mReactInstanceManager != null) {
mReactInstanceManager.onResume(this, this);
}
}
@Override
public void onBackPressed() {
if (mReactInstanceManager != null) {
mReactInstanceManager.onBackPressed();
} else {
super.onBackPressed();
}
}
@Override
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
}
@@ -1,58 +0,0 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.facebook.react.movies;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
public class MoviesApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public String getJSMainModuleName() {
return "Examples/Movies/MoviesApp.android";
}
@Override
public @Nullable String getBundleAssetName() {
return "MoviesApp.android.bundle";
}
@Override
protected boolean getUseDeveloperSupport() {
return true;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
+2 -2
View File
@@ -15,10 +15,10 @@
*/
'use strict';
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
} = ReactNative;
} = React;
var MAX_VALUE = 200;
@@ -16,7 +16,6 @@
58C572511AA6229D00CDF9C8 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58C5724D1AA6224400CDF9C8 /* libRCTText.a */; };
5FF8942E1B85571A007731BE /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5FF8942D1B8556F8007731BE /* libRCTWebSocket.a */; };
832044981B492C2500E297FC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832044951B492C1E00E297FC /* libRCTSettings.a */; };
E730D7731D4EE604000B7DA8 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E730D76E1D4EE5FC000B7DA8 /* libRCTNetwork.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -55,13 +54,6 @@
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTSettings;
};
E730D76D1D4EE5FC000B7DA8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = E730D7681D4EE5FC000B7DA8 /* RCTNetwork.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511DB1A9E6C8500147676;
remoteInfo = RCTNetwork;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@@ -77,7 +69,6 @@
587650DA1A9EB0DB008B8F17 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../../Libraries/Text/RCTText.xcodeproj; sourceTree = "<group>"; };
5FF894281B8556F8007731BE /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../../Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = "<group>"; };
8320448F1B492C1E00E297FC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../../Libraries/Settings/RCTSettings.xcodeproj; sourceTree = "<group>"; };
E730D7681D4EE5FC000B7DA8 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../../Libraries/Network/RCTNetwork.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -85,7 +76,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E730D7731D4EE604000B7DA8 /* libRCTNetwork.a in Frameworks */,
5FF8942E1B85571A007731BE /* libRCTWebSocket.a in Frameworks */,
144C5F691AC3E5E300B004E7 /* libReact.a in Frameworks */,
1341803E1AA91802003F314A /* libRCTImage.a in Frameworks */,
@@ -129,7 +119,6 @@
58C572071AA6126D00CDF9C8 /* Libraries */ = {
isa = PBXGroup;
children = (
E730D7681D4EE5FC000B7DA8 /* RCTNetwork.xcodeproj */,
5FF894281B8556F8007731BE /* RCTWebSocket.xcodeproj */,
144C5F631AC3E5D800B004E7 /* React.xcodeproj */,
134180381AA917ED003F314A /* RCTImage.xcodeproj */,
@@ -182,14 +171,6 @@
name = Products;
sourceTree = "<group>";
};
E730D7691D4EE5FC000B7DA8 /* Products */ = {
isa = PBXGroup;
children = (
E730D76E1D4EE5FC000B7DA8 /* libRCTNetwork.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -200,7 +181,6 @@
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
681C70ED1D2BE73C00E71791 /* ShellScript */,
);
buildRules = (
);
@@ -236,10 +216,6 @@
ProductGroup = 134180391AA917ED003F314A /* Products */;
ProjectRef = 134180381AA917ED003F314A /* RCTImage.xcodeproj */;
},
{
ProductGroup = E730D7691D4EE5FC000B7DA8 /* Products */;
ProjectRef = E730D7681D4EE5FC000B7DA8 /* RCTNetwork.xcodeproj */;
},
{
ProductGroup = 832044901B492C1E00E297FC /* Products */;
ProjectRef = 8320448F1B492C1E00E297FC /* RCTSettings.xcodeproj */;
@@ -300,13 +276,6 @@
remoteRef = 832044941B492C1E00E297FC /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
E730D76E1D4EE5FC000B7DA8 /* libRCTNetwork.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTNetwork.a;
remoteRef = E730D76D1D4EE5FC000B7DA8 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@@ -321,22 +290,6 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
681C70ED1D2BE73C00E71791 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n$SRCROOT/../../packager/react-native-xcode.sh Examples/TicTacToe/TicTacToeApp.js\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
13B07F871A680F5B00A75B9A /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -374,10 +327,7 @@
INFOPLIST_FILE = "$(SRCROOT)/TicTacToe/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TicTacToe;
};
@@ -395,10 +345,7 @@
INFOPLIST_FILE = "$(SRCROOT)/TicTacToe/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = TicTacToe;
};
@@ -444,7 +391,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -484,7 +431,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../React/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
+29 -2
View File
@@ -14,14 +14,41 @@
#import "AppDelegate.h"
#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/TicTacToe/TicTacToeApp" fallbackResource:nil];
NSURL *jsCodeLocation;
/**
* Loading JavaScript code - uncomment the one you want.
*
* OPTION 1
* Load from development server. Start the server from the repository root:
*
* $ npm start
*
* To run on device, change `localhost` to the IP address of your computer
* (you can get this by typing `ifconfig` into the terminal and selecting the
* `inet` value under `en0:`) and make sure your computer and iOS device are
* on the same Wi-Fi network.
*/
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/TicTacToe/TicTacToeApp.bundle?platform=ios&dev=true"];
/**
* OPTION 2
* Load from pre-bundled file on disk. To re-generate the static bundle, `cd`
* to your Xcode project folder in the terminal, and run
*
* $ curl 'http://localhost:8081/Examples/TicTacToe/TicTacToeApp.bundle?platform=ios' -o main.jsbundle
*
* then add the `main.jsbundle` file to your project and uncomment this line:
*/
// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"TicTacToeApp"
+14 -14
View File
@@ -16,15 +16,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
View,
} = ReactNative;
} = React;
class Board {
grid: Array<Array<number>>;
@@ -94,8 +93,8 @@ class Board {
}
}
class Cell extends React.Component {
cellStyle = () => {
var Cell = React.createClass({
cellStyle() {
switch (this.props.player) {
case 1:
return styles.cellX;
@@ -104,9 +103,9 @@ class Cell extends React.Component {
default:
return null;
}
};
},
textStyle = () => {
textStyle() {
switch (this.props.player) {
case 1:
return styles.cellTextX;
@@ -115,9 +114,9 @@ class Cell extends React.Component {
default:
return {};
}
};
},
textContents = () => {
textContents() {
switch (this.props.player) {
case 1:
return 'X';
@@ -126,7 +125,7 @@ class Cell extends React.Component {
default:
return '';
}
};
},
render() {
return (
@@ -142,9 +141,9 @@ class Cell extends React.Component {
</TouchableHighlight>
);
}
}
});
class GameEndOverlay extends React.Component {
var GameEndOverlay = React.createClass({
render() {
var board = this.props.board;
@@ -175,7 +174,7 @@ class GameEndOverlay extends React.Component {
</View>
);
}
}
});
var TicTacToeApp = React.createClass({
getInitialState() {
@@ -272,6 +271,7 @@ var styles = StyleSheet.create({
// CELL TEXT
cellText: {
borderRadius: 5,
fontSize: 50,
fontFamily: 'AvenirNext-Bold',
},
@@ -305,7 +305,7 @@ var styles = StyleSheet.create({
textAlign: 'center',
},
newGame: {
backgroundColor: '#887765',
backgroundColor: '#887766',
padding: 20,
borderRadius: 5,
},
-31
View File
@@ -1,31 +0,0 @@
include_defs('//ReactAndroid/DEFS')
android_binary(
name = 'app',
manifest = 'src/main/AndroidManifest.xml',
keystore = '//keystores:debug',
deps = [
':tictactoe-lib',
],
)
android_library(
name = 'tictactoe-lib',
srcs = glob(['src/main/java/**/*.java']),
deps = [
':res',
react_native_dep('third-party/java/jsr-305:jsr-305'),
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/shell:shell'),
react_native_target('java/com/facebook/react:react'),
react_native_target('jni/prebuilt:android-jsc'),
# .so files are prebuilt by Gradle with `./gradlew :ReactAndroid:packageReactNdkLibsForBuck`
react_native_target('jni/prebuilt:reactnative-libs'),
],
)
android_resource(
name = 'res',
res = 'src/main/res',
package = 'com.facebook.react.tictactoe',
)
@@ -1,31 +0,0 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.facebook.react.tictactoe"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
// Build React Native from source
compile project(':ReactAndroid')
}
@@ -1 +0,0 @@
android.useDeprecatedNdk=true
-17
View File
@@ -1,17 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -1,30 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.react.tictactoe"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="22" />
<application
android:name=".TicTacToeApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/launcher_icon"
android:theme="@style/AppTheme">
<activity
android:name=".TicTacToeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
@@ -1,58 +0,0 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.facebook.react.tictactoe;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
public class TicTacToeApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public String getJSMainModuleName() {
return "Examples/TicTacToe/TicTacToeApp";
}
@Override
public @Nullable String getBundleAssetName() {
return "TicTacToeApp.bundle";
}
@Override
protected boolean getUseDeveloperSupport() {
return true;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

@@ -1,12 +0,0 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".TicTacToeApp">
<com.facebook.react.ReactRootView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/react_root_view"/>
</RelativeLayout>
@@ -1,3 +0,0 @@
<resources>
<string name="app_name">TicTacToeApp</string>
</resources>
@@ -1,8 +0,0 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -21,50 +14,54 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
Text,
View,
ToastAndroid,
TouchableWithoutFeedback,
} = ReactNative;
} = React;
var UIExplorerBlock = require('./UIExplorerBlock');
var UIExplorerPage = require('./UIExplorerPage');
var importantForAccessibilityValues = ['auto', 'yes', 'no', 'no-hide-descendants'];
class AccessibilityAndroidExample extends React.Component {
static title = 'Accessibility';
static description = 'Examples of using Accessibility API.';
var AccessibilityAndroidExample = React.createClass({
state = {
count: 0,
backgroundImportantForAcc: 0,
forgroundImportantForAcc: 0,
};
statics: {
title: 'Accessibility',
description: 'Examples of using Accessibility API.',
},
_addOne = () => {
getInitialState: function() {
return {
count: 0,
backgroundImportantForAcc: 0,
forgroundImportantForAcc: 0,
};
},
_addOne: function() {
this.setState({
count: ++this.state.count,
});
};
},
_changeBackgroundImportantForAcc = () => {
_changeBackgroundImportantForAcc: function() {
this.setState({
backgroundImportantForAcc: (this.state.backgroundImportantForAcc + 1) % 4,
});
};
},
_changeForgroundImportantForAcc = () => {
_changeForgroundImportantForAcc: function() {
this.setState({
forgroundImportantForAcc: (this.state.forgroundImportantForAcc + 1) % 4,
});
};
},
render() {
render: function() {
return (
<UIExplorerPage title={'Accessibility'}>
@@ -197,8 +194,8 @@ class AccessibilityAndroidExample extends React.Component {
</UIExplorerPage>
);
}
}
},
});
var styles = StyleSheet.create({
embedded: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,14 +15,13 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Text,
View,
} = ReactNative;
} = React;
class AccessibilityIOSExample extends React.Component {
var AccessibilityIOSExample = React.createClass({
render() {
return (
<View>
@@ -60,14 +52,14 @@ class AccessibilityIOSExample extends React.Component {
</View>
</View>
);
}
}
},
});
exports.title = 'AccessibilityIOS';
exports.description = 'Interface to show iOS\' accessibility samples';
exports.examples = [
{
title: 'Accessibility elements',
render(): React.Element<any> { return <AccessibilityIOSExample />; }
render(): ReactElement { return <AccessibilityIOSExample />; }
},
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,15 +15,13 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ActionSheetIOS,
StyleSheet,
Text,
UIManager,
View,
} = ReactNative;
} = React;
var BUTTONS = [
'Option 0',
@@ -42,10 +33,12 @@ var BUTTONS = [
var DESTRUCTIVE_INDEX = 3;
var CANCEL_INDEX = 4;
class ActionSheetExample extends React.Component {
state = {
clicked: 'none',
};
var ActionSheetExample = React.createClass({
getInitialState() {
return {
clicked: 'none',
};
},
render() {
return (
@@ -58,9 +51,9 @@ class ActionSheetExample extends React.Component {
</Text>
</View>
);
}
},
showActionSheet = () => {
showActionSheet() {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
@@ -69,13 +62,15 @@ class ActionSheetExample extends React.Component {
(buttonIndex) => {
this.setState({ clicked: BUTTONS[buttonIndex] });
});
};
}
}
});
class ActionSheetTintExample extends React.Component {
state = {
clicked: 'none',
};
var ActionSheetTintExample = React.createClass({
getInitialState() {
return {
clicked: 'none',
};
},
render() {
return (
@@ -88,9 +83,9 @@ class ActionSheetTintExample extends React.Component {
</Text>
</View>
);
}
},
showActionSheet = () => {
showActionSheet() {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
@@ -100,13 +95,16 @@ class ActionSheetTintExample extends React.Component {
(buttonIndex) => {
this.setState({ clicked: BUTTONS[buttonIndex] });
});
};
}
}
});
class ShareActionSheetExample extends React.Component {
state = {
text: ''
};
var ShareActionSheetExample = React.createClass({
getInitialState() {
return {
text: ''
};
},
render() {
return (
@@ -119,18 +117,20 @@ class ShareActionSheetExample extends React.Component {
</Text>
</View>
);
}
},
showShareActionSheet = () => {
showShareActionSheet() {
ActionSheetIOS.showShareActionSheetWithOptions({
url: this.props.url,
url: 'https://code.facebook.com',
message: 'message to go with the shared url',
subject: 'a subject to go in the email heading',
excludedActivityTypes: [
'com.apple.UIKit.activity.PostToTwitter'
]
},
(error) => alert(error),
(error) => {
console.error(error);
},
(success, method) => {
var text;
if (success) {
@@ -140,50 +140,8 @@ class ShareActionSheetExample extends React.Component {
}
this.setState({text});
});
};
}
class ShareScreenshotExample extends React.Component {
state = {
text: ''
};
render() {
return (
<View>
<Text onPress={this.showShareActionSheet} style={style.button}>
Click to show the Share ActionSheet
</Text>
<Text>
{this.state.text}
</Text>
</View>
);
}
showShareActionSheet = () => {
// Take the snapshot (returns a temp file uri)
UIManager.takeSnapshot('window').then((uri) => {
// Share image data
ActionSheetIOS.showShareActionSheetWithOptions({
url: uri,
excludedActivityTypes: [
'com.apple.UIKit.activity.PostToTwitter'
]
},
(error) => alert(error),
(success, method) => {
var text;
if (success) {
text = `Shared via ${method}`;
} else {
text = 'You didn\'t share';
}
this.setState({text});
});
}).catch((error) => alert(error));
};
}
});
var style = StyleSheet.create({
button: {
@@ -197,28 +155,14 @@ exports.description = 'Interface to show iOS\' action sheets';
exports.examples = [
{
title: 'Show Action Sheet',
render(): React.Element<any> { return <ActionSheetExample />; }
render(): ReactElement { return <ActionSheetExample />; }
},
{
title: 'Show Action Sheet with tinted buttons',
render(): React.Element<any> { return <ActionSheetTintExample />; }
render(): ReactElement { return <ActionSheetTintExample />; }
},
{
title: 'Show Share Action Sheet',
render(): React.Element<any> {
return <ShareActionSheetExample url="https://code.facebook.com" />;
}
},
{
title: 'Share Local Image',
render(): React.Element<any> {
return <ShareActionSheetExample url="bunny.png" />;
}
},
{
title: 'Share Screenshot',
render(): React.Element<any> {
return <ShareScreenshotExample />;
}
render(): ReactElement { return <ShareActionSheetExample />; }
}
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,84 +15,75 @@
*/
'use strict';
import React, { Component } from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
var React = require('react-native');
var {
ActivityIndicatorIOS,
StyleSheet,
View,
} = React;
var TimerMixin = require('react-timer-mixin');
/**
* Optional Flowtype state and timer types definition
*/
type State = { animating: boolean; };
type Timer = number;
var ToggleAnimatingActivityIndicator = React.createClass({
mixins: [TimerMixin],
class ToggleAnimatingActivityIndicator extends Component {
/**
* Optional Flowtype state and timer types
*/
state: State;
_timer: Timer;
constructor(props) {
super(props);
this.state = {
getInitialState: function() {
return {
animating: true,
};
}
},
componentDidMount() {
setToggleTimeout: function() {
this.setTimeout(
() => {
this.setState({animating: !this.state.animating});
this.setToggleTimeout();
},
1200
);
},
componentDidMount: function() {
this.setToggleTimeout();
}
},
componentWillUnmount() {
clearTimeout(this._timer);
}
setToggleTimeout() {
this._timer = setTimeout(() => {
this.setState({animating: !this.state.animating});
this.setToggleTimeout();
}, 2000);
}
render() {
render: function() {
return (
<ActivityIndicator
<ActivityIndicatorIOS
animating={this.state.animating}
style={[styles.centering, {height: 80}]}
size="large"
/>
);
}
}
});
exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<ActivityIndicator>';
exports.title = '<ActivityIndicatorIOS>';
exports.description = 'Animated loading indicators.';
exports.examples = [
{
title: 'Default (small, white)',
render() {
render: function() {
return (
<ActivityIndicator
style={[styles.centering, styles.gray]}
<ActivityIndicatorIOS
style={[styles.centering, styles.gray, {height: 40}]}
color="white"
/>
/>
);
}
},
{
title: 'Gray',
render() {
render: function() {
return (
<View>
<ActivityIndicator
style={[styles.centering]}
<ActivityIndicatorIOS
style={[styles.centering, {height: 40}]}
/>
<ActivityIndicator
style={[styles.centering, {backgroundColor: '#eeeeee'}]}
<ActivityIndicatorIOS
style={[styles.centering, {backgroundColor: '#eeeeee', height: 40}]}
/>
</View>
);
@@ -107,47 +91,47 @@ exports.examples = [
},
{
title: 'Custom colors',
render() {
render: function() {
return (
<View style={styles.horizontal}>
<ActivityIndicator color="#0000ff" />
<ActivityIndicator color="#aa00aa" />
<ActivityIndicator color="#aa3300" />
<ActivityIndicator color="#00aa00" />
<ActivityIndicatorIOS color="#0000ff" />
<ActivityIndicatorIOS color="#aa00aa" />
<ActivityIndicatorIOS color="#aa3300" />
<ActivityIndicatorIOS color="#00aa00" />
</View>
);
}
},
{
title: 'Large',
render() {
render: function() {
return (
<ActivityIndicator
style={[styles.centering, styles.gray]}
size="large"
<ActivityIndicatorIOS
style={[styles.centering, styles.gray, {height: 80}]}
color="white"
size="large"
/>
);
}
},
{
title: 'Large, custom colors',
render() {
render: function() {
return (
<View style={styles.horizontal}>
<ActivityIndicator
<ActivityIndicatorIOS
size="large"
color="#0000ff"
/>
<ActivityIndicator
<ActivityIndicatorIOS
size="large"
color="#aa00aa"
/>
<ActivityIndicator
<ActivityIndicatorIOS
size="large"
color="#aa3300"
/>
<ActivityIndicator
<ActivityIndicatorIOS
size="large"
color="#00aa00"
/>
@@ -157,41 +141,16 @@ exports.examples = [
},
{
title: 'Start/stop',
render() {
render: function(): ReactElement {
return <ToggleAnimatingActivityIndicator />;
}
},
{
title: 'Custom size',
render() {
return (
<ActivityIndicator
style={[styles.centering, {transform: [{scale: 1.5}]}]}
size="large"
/>
);
}
},
{
platform: 'android',
title: 'Custom size (size: 75)',
render() {
return (
<ActivityIndicator
style={styles.centering}
size={75}
/>
);
}
},
];
const styles = StyleSheet.create({
var styles = StyleSheet.create({
centering: {
alignItems: 'center',
justifyContent: 'center',
padding: 8,
},
gray: {
backgroundColor: '#cccccc',
@@ -199,6 +158,5 @@ const styles = StyleSheet.create({
horizontal: {
flexDirection: 'row',
justifyContent: 'space-around',
padding: 8,
},
});
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,14 +15,13 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AdSupportIOS,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
exports.framework = 'React';
exports.title = 'Advertising ID';
@@ -38,19 +30,21 @@ exports.description = 'Example of using the ad support API.';
exports.examples = [
{
title: 'Ad Support IOS',
render: function(): React.Element<any> {
render: function(): ReactElement {
return <AdSupportIOSExample />;
},
}
];
class AdSupportIOSExample extends React.Component {
state = {
deviceID: 'No IDFA yet',
hasAdvertiserTracking: 'unset',
};
var AdSupportIOSExample = React.createClass({
getInitialState: function() {
return {
deviceID: 'No IDFA yet',
hasAdvertiserTracking: 'unset',
};
},
componentDidMount() {
componentDidMount: function() {
AdSupportIOS.getAdvertisingId(
this._onDeviceIDSuccess,
this._onDeviceIDFailure
@@ -60,33 +54,33 @@ class AdSupportIOSExample extends React.Component {
this._onHasTrackingSuccess,
this._onHasTrackingFailure
);
}
},
_onHasTrackingSuccess = (hasTracking) => {
_onHasTrackingSuccess: function(hasTracking) {
this.setState({
'hasAdvertiserTracking': hasTracking,
});
};
},
_onHasTrackingFailure = (e) => {
_onHasTrackingFailure: function(e) {
this.setState({
'hasAdvertiserTracking': 'Error!',
});
};
},
_onDeviceIDSuccess = (deviceID) => {
_onDeviceIDSuccess: function(deviceID) {
this.setState({
'deviceID': deviceID,
});
};
},
_onDeviceIDFailure = (e) => {
_onDeviceIDFailure: function(e) {
this.setState({
'deviceID': 'Error!',
});
};
},
render() {
render: function() {
return (
<View>
<Text>
@@ -100,7 +94,7 @@ class AdSupportIOSExample extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
title: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,15 +15,15 @@
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Alert,
Platform,
StyleSheet,
Text,
TouchableHighlight,
View,
} = ReactNative;
} = React;
var UIExplorerBlock = require('./UIExplorerBlock');
@@ -41,8 +34,9 @@ var alertMessage = 'Credibly reintermediate next-generation potentialities after
/**
* Simple alert examples.
*/
class SimpleAlertExampleBlock extends React.Component {
render() {
var SimpleAlertExampleBlock = React.createClass({
render: function() {
return (
<View>
<TouchableHighlight style={styles.wrapper}
@@ -106,40 +100,25 @@ class SimpleAlertExampleBlock extends React.Component {
<Text>Alert with too many buttons</Text>
</View>
</TouchableHighlight>
<TouchableHighlight style={styles.wrapper}
onPress={() => Alert.alert(
'Alert Title',
null,
[
{text: 'OK', onPress: () => console.log('OK Pressed!')},
],
{
cancelable: false
}
)}>
<View style={styles.button}>
<Text>Alert that cannot be dismissed</Text>
</View>
</TouchableHighlight>
</View>
);
}
}
},
});
class AlertExample extends React.Component {
static title = 'Alert';
static description = 'Alerts display a concise and informative message ' +
'and prompt the user to make a decision.';
render() {
var AlertExample = React.createClass({
statics: {
title: 'Alert',
description: 'Alerts display a concise and informative message ' +
'and prompt the user to make a decision.',
},
render: function() {
return (
<UIExplorerBlock title={'Alert'}>
<SimpleAlertExampleBlock />
</UIExplorerBlock>
);
}
}
});
var styles = StyleSheet.create({
wrapper: {
@@ -155,4 +134,4 @@ var styles = StyleSheet.create({
module.exports = {
AlertExample,
SimpleAlertExampleBlock,
};
}
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,15 +15,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
View,
Text,
TouchableHighlight,
AlertIOS,
} = ReactNative;
} = React;
var { SimpleAlertExampleBlock } = require('./AlertExample');
@@ -44,19 +36,37 @@ exports.examples = [{
}
},
{
title: 'Prompt Options',
render(): React.Element<any> {
return <PromptOptions />;
}
},
{
title: 'Prompt Types',
title: 'Alert Types',
render() {
return (
<View>
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Plain Text Entry')}>
onPress={() => AlertIOS.alert(
'Hello World',
null,
[
{text: 'OK', onPress: (text) => console.log('OK pressed'), type: 'default'}
]
)}>
<View style={styles.button}>
<Text>
{'default'}
</Text>
</View>
</TouchableHighlight>
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.alert(
'Plain Text Entry',
null,
[
{text: 'Submit', onPress: (text) => console.log('Text: ' + text), type: 'plain-text'},
{text: 'Cancel', onPress: () => console.log('Cancel'), style: 'cancel'}
]
)}>
<View style={styles.button}>
<Text>
@@ -67,7 +77,14 @@ exports.examples = [{
</TouchableHighlight>
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Secure Text', null, null, 'secure-text')}>
onPress={() => AlertIOS.alert(
'Secure Text Entry',
null,
[
{text: 'Submit', onPress: (text) => console.log('Password: ' + text), type: 'secure-text'},
{text: 'Cancel', onPress: () => console.log('Cancel'), style: 'cancel'}
]
)}>
<View style={styles.button}>
<Text>
@@ -78,7 +95,14 @@ exports.examples = [{
</TouchableHighlight>
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Login & Password', null, null, 'login-password')}>
onPress={() => AlertIOS.alert(
'Login & Password',
null,
[
{text: 'Submit', onPress: (details) => console.log('Login: ' + details.login + '; Password: ' + details.password), type: 'login-password'},
{text: 'Cancel', onPress: () => console.log('Cancel'), style: 'cancel'}
]
)}>
<View style={styles.button}>
<Text>
@@ -90,29 +114,32 @@ exports.examples = [{
</View>
);
}
},
{
title: 'Prompt',
render(): React.Component {
return <PromptExample />;
}
}];
class PromptOptions extends React.Component {
state: any;
customButtons: Array<Object>;
class PromptExample extends React.Component {
constructor(props) {
super(props);
// $FlowFixMe this seems to be a Flow bug, `saveResponse` is defined below
this.saveResponse = this.saveResponse.bind(this);
this.promptResponse = this.promptResponse.bind(this);
this.state = {
promptValue: undefined,
};
this.customButtons = [{
this.title = 'Type a value';
this.defaultValue = 'Default value';
this.buttons = [{
text: 'Custom OK',
onPress: this.saveResponse
onPress: this.promptResponse
}, {
text: 'Custom Cancel',
style: 'cancel',
}];
this.state = {
promptValue: undefined,
};
}
render() {
@@ -124,7 +151,7 @@ class PromptOptions extends React.Component {
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Type a value', null, this.saveResponse)}>
onPress={this.prompt.bind(this, this.title, null, null, this.promptResponse)}>
<View style={styles.button}>
<Text>
@@ -135,7 +162,7 @@ class PromptOptions extends React.Component {
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Type a value', null, this.customButtons)}>
onPress={this.prompt.bind(this, this.title, null, this.buttons, null)}>
<View style={styles.button}>
<Text>
@@ -146,22 +173,22 @@ class PromptOptions extends React.Component {
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Type a value', null, this.saveResponse, undefined, 'Default value')}>
onPress={this.prompt.bind(this, this.title, this.defaultValue, null, this.promptResponse)}>
<View style={styles.button}>
<Text>
prompt with title, callback & default value
prompt with title, default value & callback
</Text>
</View>
</TouchableHighlight>
<TouchableHighlight
style={styles.wrapper}
onPress={() => AlertIOS.prompt('Type a value', null, this.customButtons, 'login-password', 'admin@site.com')}>
onPress={this.prompt.bind(this, this.title, this.defaultValue, this.buttons, null)}>
<View style={styles.button}>
<Text>
prompt with title, custom buttons, login/password & default value
prompt with title, default value & custom buttons
</Text>
</View>
</TouchableHighlight>
@@ -169,8 +196,13 @@ class PromptOptions extends React.Component {
);
}
saveResponse(promptValue) {
this.setState({ promptValue: JSON.stringify(promptValue) });
prompt() {
// Flow's apply support is broken: #7035621
((AlertIOS.prompt: any).apply: any)(AlertIOS, arguments);
}
promptResponse(promptValue) {
this.setState({ promptValue });
}
}
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,15 +15,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
Easing,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var UIExplorerButton = require('./UIExplorerButton');
exports.framework = 'React';
@@ -47,8 +39,6 @@ exports.examples = [
'mounts.',
render: function() {
class FadeInView extends React.Component {
state: any;
constructor(props) {
super(props);
this.state = {
@@ -76,8 +66,6 @@ exports.examples = [
}
}
class FadeInExample extends React.Component {
state: any;
constructor(props) {
super(props);
this.state = {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,15 +16,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
LayoutAnimation,
PanResponder,
StyleSheet,
View,
} = ReactNative;
} = React;
var AnExSet = require('AnExSet');
@@ -40,10 +32,6 @@ var CIRCLE_MARGIN = 18;
var NUM_CIRCLES = 30;
class Circle extends React.Component {
state: any;
props: any;
longTimer: number;
_onLongPress: () => void;
_toggleIsActive: () => void;
constructor(props: Object): void {
@@ -89,7 +77,7 @@ class Circle extends React.Component {
});
}
render(): React.Element<any> {
render(): ReactElement {
if (this.state.panResponder) {
var handlers = this.state.panResponder.panHandlers;
var dragStyle = { // Used to position while dragging
@@ -168,13 +156,6 @@ class Circle extends React.Component {
}
class AnExApp extends React.Component {
state: any;
props: any;
static title = 'Animated - Gratuitous App';
static description = 'Bunch of Animations - tap a circle to ' +
'open a view with more animations, or longPress and drag to reorder circles.';
_onMove: (position: Point) => void;
constructor(props: any): void {
super(props);
@@ -190,7 +171,7 @@ class AnExApp extends React.Component {
this._onMove = this._onMove.bind(this);
}
render(): React.Element<any> {
render(): ReactElement {
var circles = this.state.keys.map((key, idx) => {
if (key === this.state.activeKey) {
return <Circle key={key + 'd'} dummy={true} />;
@@ -285,9 +266,14 @@ function moveToClosest({activeKey, keys, restLayouts}, position) {
}
}
AnExApp.title = 'Animated - Gratuitous App';
AnExApp.description = 'Bunch of Animations - tap a circle to ' +
'open a view with more animations, or longPress and drag to reorder circles.';
var styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 64, // push content below nav bar
},
grid: {
flex: 1,
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,14 +16,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
Image,
PanResponder,
StyleSheet,
View,
} = ReactNative;
} = React;
var NUM_BOBBLES = 5;
var RAD_EACH = Math.PI / 2 / (NUM_BOBBLES - 2);
@@ -43,8 +36,6 @@ var BOBBLE_SPOTS = [...Array(NUM_BOBBLES)].map((_, i) => { // static positions
});
class AnExBobble extends React.Component {
state: any;
constructor(props: Object) {
super(props);
this.state = {};
@@ -95,7 +86,7 @@ class AnExBobble extends React.Component {
});
}
render(): React.Element<any> {
render(): ReactElement {
return (
<View style={styles.bobbleContainer}>
{this.state.bobbles.map((_, i) => {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,18 +16,16 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
Image,
PanResponder,
StyleSheet,
View,
} = ReactNative;
} = React;
class AnExChained extends React.Component {
state: any;
constructor(props: Object) {
super(props);
this.state = {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -19,12 +12,10 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule AnExScroll
* @flow
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
Image,
@@ -32,10 +23,15 @@ var {
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
class AnExScroll extends React.Component {
state: any = { scrollX: new Animated.Value(0) };
constructor(props) {
super(props);
this.state = {
scrollX: new Animated.Value(0),
};
}
render() {
var width = this.props.panelWidth;
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,15 +16,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
PanResponder,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var AnExBobble = require('./AnExBobble');
var AnExChained = require('./AnExChained');
@@ -39,8 +31,6 @@ var AnExScroll = require('./AnExScroll');
var AnExTilt = require('./AnExTilt');
class AnExSet extends React.Component {
state: any;
constructor(props: Object) {
super(props);
function randColor() {
@@ -52,7 +42,7 @@ class AnExSet extends React.Component {
openColor: randColor(),
};
}
render(): React.Element<any> {
render(): ReactElement {
var backgroundColor = this.props.openVal ?
this.props.openVal.interpolate({
inputRange: [0, 1],
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,17 +16,16 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Animated,
Image,
PanResponder,
StyleSheet,
} = ReactNative;
View,
} = React;
class AnExTilt extends React.Component {
state: any;
constructor(props: Object) {
super(props);
this.state = {
@@ -95,7 +87,7 @@ class AnExTilt extends React.Component {
this._startBurnsZoom();
}
render(): React.Element<any> {
render(): ReactElement {
return (
<Animated.View
{...this.state.tiltPanResponder.panHandlers}
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -18,49 +11,45 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule AppStateExample
* @providesModule AppStateIOSExample
* @flow
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const {
AppState,
var React = require('react-native');
var {
AppStateIOS,
Text,
View
} = ReactNative;
} = React;
class AppStateSubscription extends React.Component {
state = {
appState: AppState.currentState,
previousAppStates: [],
memoryWarnings: 0,
};
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
AppState.addEventListener('memoryWarning', this._handleMemoryWarning);
}
componentWillUnmount() {
AppState.removeEventListener('change', this._handleAppStateChange);
AppState.removeEventListener('memoryWarning', this._handleMemoryWarning);
}
_handleMemoryWarning = () => {
var AppStateSubscription = React.createClass({
getInitialState() {
return {
appState: AppStateIOS.currentState,
previousAppStates: [],
memoryWarnings: 0,
};
},
componentDidMount: function() {
AppStateIOS.addEventListener('change', this._handleAppStateChange);
AppStateIOS.addEventListener('memoryWarning', this._handleMemoryWarning);
},
componentWillUnmount: function() {
AppStateIOS.removeEventListener('change', this._handleAppStateChange);
AppStateIOS.removeEventListener('memoryWarning', this._handleMemoryWarning);
},
_handleMemoryWarning: function() {
this.setState({memoryWarnings: this.state.memoryWarnings + 1});
};
_handleAppStateChange = (appState) => {
},
_handleAppStateChange: function(appState) {
var previousAppStates = this.state.previousAppStates.slice();
previousAppStates.push(this.state.appState);
this.setState({
appState,
previousAppStates,
});
};
},
render() {
if (this.props.showMemoryWarnings) {
return (
@@ -82,29 +71,28 @@ class AppStateSubscription extends React.Component {
</View>
);
}
}
});
exports.title = 'AppState';
exports.description = 'app background status';
exports.title = 'AppStateIOS';
exports.description = 'iOS app background status';
exports.examples = [
{
title: 'AppState.currentState',
title: 'AppStateIOS.currentState',
description: 'Can be null on app initialization',
render() { return <Text>{AppState.currentState}</Text>; }
render() { return <Text>{AppStateIOS.currentState}</Text>; }
},
{
title: 'Subscribed AppState:',
title: 'Subscribed AppStateIOS:',
description: 'This changes according to the current state, so you can only ever see it rendered as "active"',
render(): React.Element<any> { return <AppStateSubscription showCurrentOnly={true} />; }
render(): ReactElement { return <AppStateSubscription showCurrentOnly={true} />; }
},
{
title: 'Previous states:',
render(): React.Element<any> { return <AppStateSubscription showCurrentOnly={false} />; }
render(): ReactElement { return <AppStateSubscription showCurrentOnly={false} />; }
},
{
platform: 'ios',
title: 'Memory Warnings',
description: 'In the IOS simulator, hit Shift+Command+M to simulate a memory warning.',
render(): React.Element<any> { return <AppStateSubscription showMemoryWarnings={true} />; }
description: 'In the simulator, hit Shift+Command+M to simulate a memory warning.',
render(): ReactElement { return <AppStateSubscription showMemoryWarnings={true} />; }
},
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,19 +15,21 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
StyleSheet,
View,
ScrollView
} = ReactNative;
} = React;
class AssetScaledImageExample extends React.Component {
state = {
asset: this.props.asset
};
var AssetScaledImageExample = React.createClass({
getInitialState() {
return {
asset: this.props.asset
};
},
render() {
var image = this.state.asset.node.image;
@@ -54,8 +49,8 @@ class AssetScaledImageExample extends React.Component {
</View>
</ScrollView>
);
}
}
},
});
var styles = StyleSheet.create({
row: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,30 +15,24 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AsyncStorage,
PickerIOS,
Text,
View
} = ReactNative;
} = React;
var PickerItemIOS = PickerIOS.Item;
var STORAGE_KEY = '@AsyncStorageExample:key';
var COLORS = ['red', 'orange', 'yellow', 'green', 'blue'];
class BasicStorageExample extends React.Component {
state = {
selectedValue: COLORS[0],
messages: [],
};
var BasicStorageExample = React.createClass({
componentDidMount() {
this._loadInitialState().done();
}
},
_loadInitialState = async () => {
async _loadInitialState() {
try {
var value = await AsyncStorage.getItem(STORAGE_KEY);
if (value !== null){
@@ -57,7 +44,14 @@ class BasicStorageExample extends React.Component {
} catch (error) {
this._appendMessage('AsyncStorage error: ' + error.message);
}
};
},
getInitialState() {
return {
selectedValue: COLORS[0],
messages: [],
};
},
render() {
var color = this.state.selectedValue;
@@ -89,9 +83,9 @@ class BasicStorageExample extends React.Component {
{this.state.messages.map((m) => <Text key={m}>{m}</Text>)}
</View>
);
}
},
_onValueChange = async (selectedValue) => {
async _onValueChange(selectedValue) {
this.setState({selectedValue});
try {
await AsyncStorage.setItem(STORAGE_KEY, selectedValue);
@@ -99,27 +93,27 @@ class BasicStorageExample extends React.Component {
} catch (error) {
this._appendMessage('AsyncStorage error: ' + error.message);
}
};
},
_removeStorage = async () => {
async _removeStorage() {
try {
await AsyncStorage.removeItem(STORAGE_KEY);
this._appendMessage('Selection removed from disk.');
} catch (error) {
this._appendMessage('AsyncStorage error: ' + error.message);
}
};
},
_appendMessage = (message) => {
_appendMessage(message) {
this.setState({messages: this.state.messages.concat(message)});
};
}
},
});
exports.title = 'AsyncStorage';
exports.description = 'Asynchronous local disk storage.';
exports.examples = [
{
title: 'Basics - getItem, setItem, removeItem',
render(): React.Element<any> { return <BasicStorageExample />; }
render(): ReactElement { return <BasicStorageExample />; }
},
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -20,12 +13,11 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
View
} = ReactNative;
} = React;
var styles = StyleSheet.create({
box: {
@@ -106,34 +98,6 @@ var styles = StyleSheet.create({
marginRight: 10,
backgroundColor: 'lightgrey',
},
border9: {
borderWidth: 10,
borderTopLeftRadius: 10,
borderBottomRightRadius: 20,
borderColor: 'black',
},
border10: {
borderWidth: 10,
backgroundColor: 'white',
borderTopLeftRadius: 10,
borderBottomRightRadius: 20,
borderColor: 'black',
elevation: 10,
},
border11: {
width: 0,
height: 0,
borderStyle: 'solid',
overflow: 'hidden',
borderTopWidth: 50,
borderRightWidth: 0,
borderBottomWidth: 50,
borderLeftWidth: 100,
borderTopColor: 'transparent',
borderRightColor: 'transparent',
borderBottomColor: 'transparent',
borderLeftColor: 'red',
},
});
exports.title = 'Border';
@@ -216,26 +180,4 @@ exports.examples = [
);
}
},
{
title: 'Corner Radii',
description: 'borderTopLeftRadius & borderBottomRightRadius',
render() {
return <View style={[styles.box, styles.border9]} />;
}
},
{
title: 'Corner Radii / Elevation',
description: 'borderTopLeftRadius & borderBottomRightRadius & elevation',
platform: 'android',
render() {
return <View style={[styles.box, styles.border10]} />;
}
},
{
title: 'CSS Trick - Triangle',
description: 'create a triangle by manipulating border colors and widths',
render() {
return <View style={[styles.border11]} />;
}
},
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -20,13 +13,12 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
StyleSheet,
View
} = ReactNative;
} = React;
var styles = StyleSheet.create({
box: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,56 +15,57 @@
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const React = require('react-native');
const {
CameraRoll,
Image,
Slider,
SliderIOS,
StyleSheet,
Switch,
Text,
View,
TouchableOpacity
} = ReactNative;
const invariant = require('fbjs/lib/invariant');
} = React;
const CameraRollView = require('./CameraRollView');
const AssetScaledImageExampleView = require('./AssetScaledImageExample');
class CameraRollExample extends React.Component {
state = {
groupTypes: 'SavedPhotos',
sliderValue: 1,
bigImages: true,
};
_cameraRollView: ?CameraRollView;
const CAMERA_ROLL_VIEW = 'camera_roll_view';
const CameraRollExample = React.createClass({
getInitialState() {
return {
groupTypes: 'SavedPhotos',
sliderValue: 1,
bigImages: true,
};
},
render() {
return (
<View>
<Switch
onValueChange={this._onSwitchChange}
value={this.state.bigImages}
/>
value={this.state.bigImages} />
<Text>{(this.state.bigImages ? 'Big' : 'Small') + ' Images'}</Text>
<Slider
<SliderIOS
value={this.state.sliderValue}
onValueChange={this._onSliderChange}
/>
<Text>{'Group Type: ' + this.state.groupTypes}</Text>
<CameraRollView
ref={(ref) => { this._cameraRollView = ref; }}
ref={CAMERA_ROLL_VIEW}
batchSize={20}
groupTypes={this.state.groupTypes}
renderImage={this._renderImage}
/>
</View>
);
}
},
loadAsset = (asset) => {
loadAsset(asset){
if (this.props.navigator) {
this.props.navigator.push({
title: 'Camera Roll Image',
@@ -80,13 +74,13 @@ class CameraRollExample extends React.Component {
passProps: { asset: asset },
});
}
};
},
_renderImage = (asset) => {
_renderImage(asset) {
const imageSize = this.state.bigImages ? 150 : 75;
const imageStyle = [styles.image, {width: imageSize, height: imageSize}];
const {location} = asset.node;
const locationStr = location ? JSON.stringify(location) : 'Unknown location';
const location = asset.node.location.longitude ?
JSON.stringify(asset.node.location) : 'Unknown location';
return (
<TouchableOpacity key={asset} onPress={ this.loadAsset.bind( this, asset ) }>
<View style={styles.row}>
@@ -96,30 +90,29 @@ class CameraRollExample extends React.Component {
/>
<View style={styles.info}>
<Text style={styles.url}>{asset.node.image.uri}</Text>
<Text>{locationStr}</Text>
<Text>{location}</Text>
<Text>{asset.node.group_name}</Text>
<Text>{new Date(asset.node.timestamp).toString()}</Text>
</View>
</View>
</TouchableOpacity>
);
};
},
_onSliderChange = (value) => {
_onSliderChange(value) {
const options = CameraRoll.GroupTypesOptions;
const index = Math.floor(value * options.length * 0.99);
const groupTypes = options[index];
if (groupTypes !== this.state.groupTypes) {
this.setState({groupTypes: groupTypes});
}
};
},
_onSwitchChange = (value) => {
invariant(this._cameraRollView, 'ref should be set');
this._cameraRollView.rendererChanged();
_onSwitchChange(value) {
this.refs[CAMERA_ROLL_VIEW].rendererChanged();
this.setState({ bigImages: value });
};
}
}
});
const styles = StyleSheet.create({
row: {
@@ -143,6 +136,6 @@ exports.description = 'Example component that uses CameraRoll to list user\'s ph
exports.examples = [
{
title: 'Photos',
render(): React.Element<any> { return <CameraRollExample />; }
render(): ReactElement { return <CameraRollExample />; }
}
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,17 +16,16 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ActivityIndicator,
ActivityIndicatorIOS,
CameraRoll,
Image,
ListView,
Platform,
StyleSheet,
View,
} = ReactNative;
} = React;
var groupByEveryN = require('groupByEveryN');
var logError = require('logError');
@@ -148,7 +140,7 @@ var CameraRollView = React.createClass({
groupTypes: this.props.groupTypes,
assetType: this.props.assetType,
};
if (Platform.OS === 'android') {
if (Platform.OS === "android") {
// not supported in android
delete fetchParams.groupTypes;
}
@@ -156,8 +148,7 @@ var CameraRollView = React.createClass({
fetchParams.after = this.state.lastCursor;
}
CameraRoll.getPhotos(fetchParams)
.then((data) => this._appendAssets(data), (e) => logError(e));
CameraRoll.getPhotos(fetchParams, this._appendAssets, logError);
},
/**
@@ -198,7 +189,7 @@ var CameraRollView = React.createClass({
_renderFooterSpinner: function() {
if (!this.state.noMore) {
return <ActivityIndicator />;
return <ActivityIndicatorIOS style={styles.spinner} />;
}
return null;
},
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,33 +15,31 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Clipboard,
View,
Text,
} = ReactNative;
} = React;
class ClipboardExample extends React.Component {
state = {
content: 'Content will appear here'
};
_setClipboardContent = async () => {
var ClipboardExample = React.createClass({
getInitialState: function() {
return {
content: 'Content will appear here'
};
},
_setContentToClipboard:function(){
Clipboard.setString('Hello World');
try {
var content = await Clipboard.getString();
Clipboard.getString(content => {
this.setState({content});
} catch (e) {
this.setState({content:e.message});
}
};
});
},
render() {
return (
<View>
<Text onPress={this._setClipboardContent} style={{color: 'blue'}}>
<Text onPress={this._setContentToClipboard} style={{color: 'blue'}}>
Tap to put "Hello World" in the clipboard
</Text>
<Text style={{color: 'red', marginTop: 20}}>
@@ -57,15 +48,13 @@ class ClipboardExample extends React.Component {
</View>
);
}
}
});
exports.title = 'Clipboard';
exports.description = 'Show Clipboard contents.';
exports.examples = [
{
title: 'Clipboard.setString() and getString()',
render() {
return <ClipboardExample/>;
}
render(): ReactElement { return <ClipboardExample />; }
}
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,40 +15,43 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
DatePickerIOS,
StyleSheet,
Text,
TextInput,
View,
} = ReactNative;
} = React;
class DatePickerExample extends React.Component {
static defaultProps = {
date: new Date(),
timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60,
};
var DatePickerExample = React.createClass({
getDefaultProps: function () {
return {
date: new Date(),
timeZoneOffsetInHours: (-1) * (new Date()).getTimezoneOffset() / 60,
};
},
state = {
date: this.props.date,
timeZoneOffsetInHours: this.props.timeZoneOffsetInHours,
};
getInitialState: function() {
return {
date: this.props.date,
timeZoneOffsetInHours: this.props.timeZoneOffsetInHours,
};
},
onDateChange = (date) => {
onDateChange: function(date) {
this.setState({date: date});
};
},
onTimezoneChange = (event) => {
onTimezoneChange: function(event) {
var offset = parseInt(event.nativeEvent.text, 10);
if (isNaN(offset)) {
return;
}
this.setState({timeZoneOffsetInHours: offset});
};
},
render() {
render: function() {
// Ideally, the timezone input would be a picker rather than a
// text input, but we don't have any pickers yet :(
return (
@@ -99,11 +95,11 @@ class DatePickerExample extends React.Component {
/>
</View>
);
}
}
},
});
class WithLabel extends React.Component {
render() {
var WithLabel = React.createClass({
render: function() {
return (
<View style={styles.labelContainer}>
<View style={styles.labelView}>
@@ -115,10 +111,10 @@ class WithLabel extends React.Component {
</View>
);
}
}
});
class Heading extends React.Component {
render() {
var Heading = React.createClass({
render: function() {
return (
<View style={styles.headingContainer}>
<Text style={styles.heading}>
@@ -127,7 +123,7 @@ class Heading extends React.Component {
</View>
);
}
}
});
exports.displayName = (undefined: ?string);
exports.title = '<DatePickerIOS>';
@@ -135,7 +131,7 @@ exports.description = 'Select dates and times using the native UIDatePicker.';
exports.examples = [
{
title: '<DatePickerIOS>',
render: function(): React.Element<any> {
render: function(): ReactElement {
return <DatePickerExample />;
},
}];
@@ -10,14 +10,23 @@
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule ExampleTypes
* @flow
*/
package com.facebook.react.tictactoe;
'use strict';
import com.facebook.react.ReactActivity;
export type Example = {
title: string,
/* $FlowFixMe(>=0.16.0) */
render: () => ?ReactElement<any, any, any>,
description?: string,
platform?: string;
};
public class TicTacToeActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "TicTacToeApp";
}
}
export type ExampleModule = {
title: string;
description: string;
examples: Array<Example>;
external?: bool;
};
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -24,13 +17,12 @@
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
exports.framework = 'React';
exports.title = 'Geolocation';
@@ -39,40 +31,42 @@ exports.description = 'Examples of using the Geolocation API.';
exports.examples = [
{
title: 'navigator.geolocation',
render: function(): React.Element<any> {
render: function(): ReactElement {
return <GeolocationExample />;
},
}
];
class GeolocationExample extends React.Component {
state = {
initialPosition: 'unknown',
lastPosition: 'unknown',
};
var GeolocationExample = React.createClass({
watchID: (null: ?number),
watchID: ?number = null;
getInitialState: function() {
return {
initialPosition: 'unknown',
lastPosition: 'unknown',
};
},
componentDidMount() {
componentDidMount: function() {
navigator.geolocation.getCurrentPosition(
(position) => {
var initialPosition = JSON.stringify(position);
this.setState({initialPosition});
},
(error) => alert(JSON.stringify(error)),
(error) => alert(error.message),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
this.watchID = navigator.geolocation.watchPosition((position) => {
var lastPosition = JSON.stringify(position);
this.setState({lastPosition});
});
}
},
componentWillUnmount() {
componentWillUnmount: function() {
navigator.geolocation.clearWatch(this.watchID);
}
},
render() {
render: function() {
return (
<View>
<Text>
@@ -86,7 +80,7 @@ class GeolocationExample extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
title: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,17 +16,16 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
class ImageCapInsetsExample extends React.Component {
render() {
var ImageCapInsetsExample = React.createClass({
render: function() {
return (
<View>
<View style={styles.background}>
@@ -54,14 +46,13 @@ class ImageCapInsetsExample extends React.Component {
<Image
source={require('image!story-background')}
style={styles.storyBackground}
resizeMode={Image.resizeMode.stretch}
capInsets={{left: 15, right: 15, bottom: 15, top: 15}}
/>
</View>
</View>
);
}
}
});
var styles = StyleSheet.create({
background: {
@@ -1,11 +1,5 @@
/*
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,19 +16,21 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
CameraRoll,
Image,
ImageEditor,
Platform,
NativeModules,
ScrollView,
StyleSheet,
Text,
TouchableHighlight,
UIManager,
View,
} = ReactNative;
} = React;
var RCTScrollViewConsts = UIManager.RCTScrollView.Constants;
var PAGE_SIZE = 20;
@@ -52,11 +48,10 @@ type ImageCropData = {
offset: ImageOffset;
size: ImageSize;
displaySize?: ?ImageSize;
resizeMode?: ?any;
resizeMode?: ?any;
};
class SquareImageCropper extends React.Component {
state: any;
_isMounted: boolean;
_transformData: ImageCropData;
@@ -72,21 +67,22 @@ class SquareImageCropper extends React.Component {
this._fetchRandomPhoto();
}
async _fetchRandomPhoto() {
try {
const data = await CameraRoll.getPhotos({first: PAGE_SIZE});
if (!this._isMounted) {
return;
}
var edges = data.edges;
var edge = edges[Math.floor(Math.random() * edges.length)];
var randomPhoto = edge && edge.node && edge.node.image;
if (randomPhoto) {
this.setState({randomPhoto});
}
} catch (error) {
console.warn("Can't get a photo from camera roll", error);
}
_fetchRandomPhoto() {
CameraRoll.getPhotos(
{first: PAGE_SIZE},
(data) => {
if (!this._isMounted) {
return;
}
var edges = data.edges;
var edge = edges[Math.floor(Math.random() * edges.length)];
var randomPhoto = edge && edge.node && edge.node.image;
if (randomPhoto) {
this.setState({randomPhoto});
}
},
(error) => undefined
);
}
componentWillUnmount() {
@@ -194,49 +190,29 @@ class SquareImageCropper extends React.Component {
}
class ImageCropper extends React.Component {
_contentOffset: ImageOffset;
_maximumZoomScale: number;
_minimumZoomScale: number;
_scaledImageSize: ImageSize;
_horizontal: boolean;
_contentOffset: ImageOffset;
componentWillMount() {
// Scale an image to the minimum size that is large enough to completely
// fill the crop box.
var widthRatio = this.props.image.width / this.props.size.width;
var heightRatio = this.props.image.height / this.props.size.height;
this._horizontal = widthRatio > heightRatio;
if (this._horizontal) {
this._scaledImageSize = {
width: this.props.image.width / heightRatio,
height: this.props.size.height,
};
} else {
if (widthRatio < heightRatio) {
this._scaledImageSize = {
width: this.props.size.width,
height: this.props.image.height / widthRatio,
};
if (Platform.OS === 'android') {
// hack to work around Android ScrollView a) not supporting zoom, and
// b) not supporting vertical scrolling when nested inside another
// vertical ScrollView (which it is, when displayed inside UIExplorer)
this._scaledImageSize.width *= 2;
this._scaledImageSize.height *= 2;
this._horizontal = true;
}
} else {
this._scaledImageSize = {
width: this.props.image.width / heightRatio,
height: this.props.size.height,
};
}
this._contentOffset = {
x: (this._scaledImageSize.width - this.props.size.width) / 2,
y: (this._scaledImageSize.height - this.props.size.height) / 2,
};
this._maximumZoomScale = Math.min(
this.props.image.width / this._scaledImageSize.width,
this.props.image.height / this._scaledImageSize.height
);
this._minimumZoomScale = Math.max(
this.props.size.width / this._scaledImageSize.width,
this.props.size.height / this._scaledImageSize.height
);
this._updateTransformData(
this._contentOffset,
this._scaledImageSize,
@@ -272,15 +248,19 @@ class ImageCropper extends React.Component {
}
render() {
var decelerationRate =
RCTScrollViewConsts && RCTScrollViewConsts.DecelerationRate ?
RCTScrollViewConsts.DecelerationRate.Fast :
0;
return (
<ScrollView
alwaysBounceVertical={true}
automaticallyAdjustContentInsets={false}
contentOffset={this._contentOffset}
decelerationRate="fast"
horizontal={this._horizontal}
maximumZoomScale={this._maximumZoomScale}
minimumZoomScale={this._minimumZoomScale}
decelerationRate={decelerationRate}
horizontal={true}
maximumZoomScale={3.0}
onMomentumScrollEnd={this._onScroll.bind(this)}
onScrollEndDrag={this._onScroll.bind(this)}
showsHorizontalScrollIndicator={false}
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,28 +15,23 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ActivityIndicator,
Image,
Platform,
StyleSheet,
Text,
View,
} = ReactNative;
ActivityIndicatorIOS
} = React;
var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
var ImageCapInsetsExample = require('./ImageCapInsetsExample');
const IMAGE_PREFETCH_URL = 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1&t=' + Date.now();
var prefetchTask = Image.prefetch(IMAGE_PREFETCH_URL);
var NetworkImageCallbackExample = React.createClass({
getInitialState: function() {
return {
events: [],
startLoadPrefetched: false,
mountTime: new Date(),
};
},
@@ -61,43 +49,10 @@ var NetworkImageCallbackExample = React.createClass({
source={this.props.source}
style={[styles.base, {overflow: 'visible'}]}
onLoadStart={() => this._loadEventFired(`✔ onLoadStart (+${new Date() - mountTime}ms)`)}
onLoad={(event) => {
// Currently this image source feature is only available on iOS.
if (event.nativeEvent.source) {
const url = event.nativeEvent.source.url;
this._loadEventFired(`✔ onLoad (+${new Date() - mountTime}ms) for URL ${url}`);
} else {
this._loadEventFired(`✔ onLoad (+${new Date() - mountTime}ms)`);
}
}}
onLoadEnd={() => {
this._loadEventFired(`✔ onLoadEnd (+${new Date() - mountTime}ms)`);
this.setState({startLoadPrefetched: true}, () => {
prefetchTask.then(() => {
this._loadEventFired(`✔ Prefetch OK (+${new Date() - mountTime}ms)`);
}, error => {
this._loadEventFired(`✘ Prefetch failed (+${new Date() - mountTime}ms)`);
});
});
}}
onLoad={() => this._loadEventFired(`✔ onLoad (+${new Date() - mountTime}ms)`)}
onLoadEnd={() => this._loadEventFired(`✔ onLoadEnd (+${new Date() - mountTime}ms)`)}
/>
{this.state.startLoadPrefetched ?
<Image
source={this.props.prefetchedSource}
style={[styles.base, {overflow: 'visible'}]}
onLoadStart={() => this._loadEventFired(`✔ (prefetched) onLoadStart (+${new Date() - mountTime}ms)`)}
onLoad={(event) => {
// Currently this image source feature is only available on iOS.
if (event.nativeEvent.source) {
const url = event.nativeEvent.source.url;
this._loadEventFired(`✔ (prefetched) onLoad (+${new Date() - mountTime}ms) for URL ${url}`);
} else {
this._loadEventFired(`✔ (prefetched) onLoad (+${new Date() - mountTime}ms)`);
}
}}
onLoadEnd={() => this._loadEventFired(`✔ (prefetched) onLoadEnd (+${new Date() - mountTime}ms)`)}
/>
: null}
<Text style={{marginTop: 20}}>
{this.state.events.join('\n')}
</Text>
@@ -124,7 +79,7 @@ var NetworkImageExample = React.createClass({
var loader = this.state.loading ?
<View style={styles.progress}>
<Text>{this.state.progress}%</Text>
<ActivityIndicator style={{marginLeft:5}} />
<ActivityIndicatorIOS style={{marginLeft:5}}/>
</View> : null;
return this.state.error ?
<Text>{this.state.error}</Text> :
@@ -172,63 +127,6 @@ var ImageSizeExample = React.createClass({
},
});
var MultipleSourcesExample = React.createClass({
getInitialState: function() {
return {
width: 30,
height: 30,
};
},
render: function() {
return (
<View>
<View style={{flexDirection: 'row', justifyContent: 'space-between'}}>
<Text
style={styles.touchableText}
onPress={this.decreaseImageSize} >
Decrease image size
</Text>
<Text
style={styles.touchableText}
onPress={this.increaseImageSize} >
Increase image size
</Text>
</View>
<Text>Container image size: {this.state.width}x{this.state.height} </Text>
<View
style={{height: this.state.height, width: this.state.width}} >
<Image
style={{flex: 1}}
source={[
{uri: 'http://facebook.github.io/react/img/logo_small.png', width: 38, height: 38},
{uri: 'http://facebook.github.io/react/img/logo_small_2x.png', width: 76, height: 76},
{uri: 'http://facebook.github.io/react/img/logo_og.png', width: 400, height: 400}
]}
/>
</View>
</View>
);
},
increaseImageSize: function() {
if (this.state.width >= 100) {
return;
}
this.setState({
width: this.state.width + 10,
height: this.state.height + 10,
});
},
decreaseImageSize: function() {
if (this.state.width <= 10) {
return;
}
this.setState({
width: this.state.width - 10,
height: this.state.height - 10,
});
},
});
exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<Image>';
@@ -250,15 +148,15 @@ exports.examples = [
},
{
title: 'Plain Static Image',
description: 'Static assets should be placed in the source code tree, and ' +
'required in the same way as JavaScript modules.',
description: 'Static assets should be required by prefixing with `image!` ' +
'and are located in the app bundle.',
render: function() {
return (
<View style={styles.horizontal}>
<Image source={require('./uie_thumb_normal.png')} style={styles.icon} />
<Image source={require('./uie_thumb_selected.png')} style={styles.icon} />
<Image source={require('./uie_comment_normal.png')} style={styles.icon} />
<Image source={require('./uie_comment_highlighted.png')} style={styles.icon} />
<Image source={require('image!uie_thumb_normal')} style={styles.icon} />
<Image source={require('image!uie_thumb_selected')} style={styles.icon} />
<Image source={require('image!uie_comment_normal')} style={styles.icon} />
<Image source={require('image!uie_comment_highlighted')} style={styles.icon} />
</View>
);
},
@@ -267,8 +165,7 @@ exports.examples = [
title: 'Image Loading Events',
render: function() {
return (
<NetworkImageCallbackExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1&t=' + Date.now()}}
prefetchedSource={{uri: IMAGE_PREFETCH_URL}}/>
<NetworkImageCallbackExample source={{uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg?r=1'}}/>
);
},
},
@@ -290,20 +187,6 @@ exports.examples = [
},
platform: 'ios',
},
{
title: 'defaultSource',
description: 'Show a placeholder image when a network image is loading',
render: function() {
return (
<Image
defaultSource={require('./bunny.png')}
source={{uri: 'http://facebook.github.io/origami/public/images/birds.jpg'}}
style={styles.base}
/>
);
},
platform: 'ios',
},
{
title: 'Border Color',
render: function() {
@@ -437,19 +320,19 @@ exports.examples = [
<View>
<View style={styles.horizontal}>
<Image
source={require('./uie_thumb_normal.png')}
source={require('image!uie_thumb_normal')}
style={[styles.icon, {borderRadius: 5, tintColor: '#5ac8fa' }]}
/>
<Image
source={require('./uie_thumb_normal.png')}
source={require('image!uie_thumb_normal')}
style={[styles.icon, styles.leftMargin, {borderRadius: 5, tintColor: '#4cd964' }]}
/>
<Image
source={require('./uie_thumb_normal.png')}
source={require('image!uie_thumb_normal')}
style={[styles.icon, styles.leftMargin, {borderRadius: 5, tintColor: '#ff2d55' }]}
/>
<Image
source={require('./uie_thumb_normal.png')}
source={require('image!uie_thumb_normal')}
style={[styles.icon, styles.leftMargin, {borderRadius: 5, tintColor: '#8e8e93' }]}
/>
</View>
@@ -484,71 +367,37 @@ exports.examples = [
'rendered within the frame.',
render: function() {
return (
<View>
{[smallImage, fullImage].map((image, index) => {
return (
<View key={index}>
<View style={styles.horizontal}>
<View>
<Text style={[styles.resizeModeText]}>
Contain
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.contain}
source={image}
/>
</View>
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>
Cover
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.cover}
source={image}
/>
</View>
</View>
<View style={styles.horizontal}>
<View>
<Text style={[styles.resizeModeText]}>
Stretch
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.stretch}
source={image}
/>
</View>
{ Platform.OS === 'ios' ?
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>
Repeat
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.repeat}
source={image}
/>
</View>
: null }
{ Platform.OS === 'android' ?
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>
Center
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.center}
source={image}
/>
</View>
: null }
</View>
</View>
);
})}
<View style={styles.horizontal}>
<View>
<Text style={[styles.resizeModeText]}>
Contain
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.contain}
source={fullImage}
/>
</View>
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>
Cover
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.cover}
source={fullImage}
/>
</View>
<View style={styles.leftMargin}>
<Text style={[styles.resizeModeText]}>
Stretch
</Text>
<Image
style={styles.resizeMode}
resizeMode={Image.resizeMode.stretch}
source={fullImage}
/>
</View>
</View>
);
},
@@ -592,58 +441,7 @@ exports.examples = [
{
title: 'Image Size',
render: function() {
return <ImageSizeExample source={fullImage} />;
},
},
{
title: 'MultipleSourcesExample',
description:
'The `source` prop allows passing in an array of uris, so that native to choose which image ' +
'to diplay based on the size of the of the target image',
render: function() {
return <MultipleSourcesExample />;
},
},
{
title: 'Legacy local image',
description:
'Images shipped with the native bundle, but not managed ' +
'by the JS packager',
render: function() {
return (
<Image
source={require('image!legacy_image')}
/>
);
},
},
{
title: 'Bundled images',
description:
'Images shipped in a separate native bundle',
render: function() {
return (
<View style={{flexDirection: 'row'}}>
<Image
source={{
url: 'ImageInBundle',
bundle: 'UIExplorerBundle',
width: 100,
height: 100,
}}
style={{borderColor: 'yellow', borderWidth: 4}}
/>
<Image
source={{
url: 'ImageInAssetCatalog',
bundle: 'UIExplorerBundle',
width: 100,
height: 100,
}}
style={{marginLeft: 10, borderColor: 'blue', borderWidth: 4}}
/>
</View>
);
return <ImageSizeExample source={fullImage} />;
},
platform: 'ios',
},
@@ -704,8 +502,4 @@ var styles = StyleSheet.create({
height: 50,
resizeMode: 'contain',
},
touchableText: {
fontWeight: '500',
color: 'blue',
},
});
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -20,61 +13,62 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Linking,
IntentAndroid,
StyleSheet,
Text,
TouchableOpacity,
TouchableNativeFeedback,
View,
} = ReactNative;
} = React;
var UIExplorerBlock = require('./UIExplorerBlock');
class OpenURLButton extends React.Component {
static propTypes = {
url: React.PropTypes.string,
};
var OpenURLButton = React.createClass({
handleClick = () => {
Linking.canOpenURL(this.props.url).then(supported => {
propTypes: {
url: React.PropTypes.string,
},
handleClick: function() {
IntentAndroid.canOpenURL(this.props.url, (supported) => {
if (supported) {
Linking.openURL(this.props.url);
IntentAndroid.openURL(this.props.url);
} else {
console.log('Don\'t know how to open URI: ' + this.props.url);
}
});
};
},
render() {
render: function() {
return (
<TouchableOpacity
<TouchableNativeFeedback
onPress={this.handleClick}>
<View style={styles.button}>
<Text style={styles.text}>Open {this.props.url}</Text>
</View>
</TouchableOpacity>
</TouchableNativeFeedback>
);
}
}
});
class IntentAndroidExample extends React.Component {
static title = 'Linking';
static description = 'Shows how to use Linking to open URLs.';
var IntentAndroidExample = React.createClass({
render() {
statics: {
title: 'IntentAndroid',
description: 'Shows how to use Android Intents to open URLs.',
},
render: function() {
return (
<UIExplorerBlock title="Open external URLs">
<OpenURLButton url={'https://www.facebook.com'} />
<OpenURLButton url={'http://www.facebook.com'} />
<OpenURLButton url={'http://facebook.com'} />
<OpenURLButton url={'fb://notifications'} />
<OpenURLButton url={'geo:37.484847,-122.148386'} />
<OpenURLButton url={'tel:9876543210'} />
</UIExplorerBlock>
);
}
}
},
});
var styles = StyleSheet.create({
container: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,15 +15,14 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
LayoutAnimation,
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
type Layout = {
x: number;
@@ -54,14 +46,15 @@ type State = {
viewStyle: { margin: number },
};
class LayoutEventExample extends React.Component {
state: State = {
viewStyle: {
margin: 20,
},
};
animateViewLayout = () => {
var LayoutEventExample = React.createClass({
getInitialState(): State {
return {
viewStyle: {
margin: 20,
},
};
},
animateViewLayout: function() {
LayoutAnimation.configureNext(
LayoutAnimation.Presets.spring,
() => {
@@ -74,35 +67,29 @@ class LayoutEventExample extends React.Component {
margin: this.state.viewStyle.margin > 20 ? 20 : 60,
}
});
};
addWrapText = () => {
},
addWrapText: function() {
this.setState(
{extraText: ' And a bunch more text to wrap around a few lines.'},
this.changeContainer
);
};
changeContainer = () => {
},
changeContainer: function() {
this.setState({containerStyle: {width: 280}});
};
onViewLayout = (e: LayoutEvent) => {
},
onViewLayout: function(e: LayoutEvent) {
console.log('received view layout event\n', e.nativeEvent);
this.setState({viewLayout: e.nativeEvent.layout});
};
onTextLayout = (e: LayoutEvent) => {
},
onTextLayout: function(e: LayoutEvent) {
console.log('received text layout event\n', e.nativeEvent);
this.setState({textLayout: e.nativeEvent.layout});
};
onImageLayout = (e: LayoutEvent) => {
},
onImageLayout: function(e: LayoutEvent) {
console.log('received image layout event\n', e.nativeEvent);
this.setState({imageLayout: e.nativeEvent.layout});
};
render() {
},
render: function() {
var viewStyle = [styles.view, this.state.viewStyle];
var textLayout = this.state.textLayout || {width: '?', height: '?'};
var imageLayout = this.state.imageLayout || {x: '?', y: '?'};
@@ -136,7 +123,7 @@ class LayoutEventExample extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
view: {
@@ -170,7 +157,7 @@ exports.description = 'Examples that show how Layout events can be used to ' +
exports.examples = [
{
title: 'LayoutEventExample',
render: function(): React.Element<any> {
render: function(): ReactElement {
return <LayoutEventExample />;
},
}];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,26 +15,24 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var UIExplorerBlock = require('./UIExplorerBlock');
var UIExplorerPage = require('./UIExplorerPage');
class Circle extends React.Component {
render() {
var Circle = React.createClass({
render: function() {
var size = this.props.size || 20;
var backgroundColor = this.props.bgColor || '#527fe4';
return (
<View
style={{
borderRadius: size / 2,
backgroundColor: backgroundColor,
backgroundColor: '#527fe4',
width: size,
height: size,
margin: 1,
@@ -49,10 +40,10 @@ class Circle extends React.Component {
/>
);
}
}
});
class CircleBlock extends React.Component {
render() {
var CircleBlock = React.createClass({
render: function() {
var circleStyle = {
flexDirection: 'row',
backgroundColor: '#f6f7f8',
@@ -66,40 +57,27 @@ class CircleBlock extends React.Component {
</View>
);
}
}
});
class LayoutExample extends React.Component {
static title = 'Layout - Flexbox';
static description = 'Examples of using the flexbox API to layout views.';
static displayName = 'LayoutExample';
var LayoutExample = React.createClass({
statics: {
title: 'Layout - Flexbox',
description: 'Examples of using the flexbox API to layout views.',
},
render() {
var fiveColoredCircles = [
<Circle bgColor="#527fe4" key="blue" />,
<Circle bgColor="#D443E3" key="violet" />,
<Circle bgColor="#FF9049" key="orange" />,
<Circle bgColor="#FFE649" key="yellow" />,
<Circle bgColor="#7FE040" key="green" />
];
displayName: 'LayoutExample',
render: function() {
return (
<UIExplorerPage title={this.props.navigator ? null : 'Layout'}>
<UIExplorerBlock title="Flex Direction">
<Text>row</Text>
<CircleBlock style={{flexDirection: 'row'}}>
{fiveColoredCircles}
</CircleBlock>
<Text>row-reverse</Text>
<CircleBlock style={{flexDirection: 'row-reverse'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
<Text>column</Text>
<CircleBlock style={{flexDirection: 'column'}}>
{fiveColoredCircles}
</CircleBlock>
<Text>column-reverse</Text>
<CircleBlock style={{flexDirection: 'column-reverse'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
<View style={[styles.overlay, {position: 'absolute', top: 15, left: 160}]}>
<Text>{'top: 15, left: 160'}</Text>
@@ -109,23 +87,23 @@ class LayoutExample extends React.Component {
<UIExplorerBlock title="Justify Content - Main Direction">
<Text>flex-start</Text>
<CircleBlock style={{justifyContent: 'flex-start'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
<Text>center</Text>
<CircleBlock style={{justifyContent: 'center'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
<Text>flex-end</Text>
<CircleBlock style={{justifyContent: 'flex-end'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
<Text>space-between</Text>
<CircleBlock style={{justifyContent: 'space-between'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
<Text>space-around</Text>
<CircleBlock style={{justifyContent: 'space-around'}}>
{fiveColoredCircles}
<Circle /><Circle /><Circle /><Circle /><Circle />
</CircleBlock>
</UIExplorerBlock>
<UIExplorerBlock title="Align Items - Other Direction">
@@ -165,7 +143,7 @@ class LayoutExample extends React.Component {
</UIExplorerPage>
);
}
}
});
var styles = StyleSheet.create({
overlay: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,8 +15,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
ListView,
@@ -32,13 +24,13 @@ var {
RecyclerViewBackedScrollView,
Text,
View,
} = ReactNative;
} = React;
var UIExplorerPage = require('./UIExplorerPage');
var ListViewSimpleExample = React.createClass({
statics: {
title: '<ListView>',
title: '<ListView> - Simple',
description: 'Performant, scrollable list of data.'
},
@@ -58,27 +50,23 @@ var ListViewSimpleExample = React.createClass({
render: function() {
return (
<UIExplorerPage
title={this.props.navigator ? null : '<ListView>'}
title={this.props.navigator ? null : '<ListView> - Simple'}
noSpacer={true}
noScroll={true}>
<ListView
dataSource={this.state.dataSource}
renderRow={this._renderRow}
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
renderSeparator={this._renderSeparator}
/>
</UIExplorerPage>
);
},
_renderRow: function(rowData: string, sectionID: number, rowID: number, highlightRow: (sectionID: number, rowID: number) => void) {
_renderRow: function(rowData: string, sectionID: number, rowID: number) {
var rowHash = Math.abs(hashCode(rowData));
var imgSource = THUMB_URLS[rowHash % THUMB_URLS.length];
return (
<TouchableHighlight onPress={() => {
this._pressRow(rowID);
highlightRow(sectionID, rowID);
}}>
<TouchableHighlight onPress={() => this._pressRow(rowID)}>
<View>
<View style={styles.row}>
<Image style={styles.thumb} source={imgSource} />
@@ -86,6 +74,7 @@ var ListViewSimpleExample = React.createClass({
{rowData + ' - ' + LOREM_IPSUM.substr(0, rowHash % 301 + 10)}
</Text>
</View>
<View style={styles.separator} />
</View>
</TouchableHighlight>
);
@@ -106,18 +95,6 @@ var ListViewSimpleExample = React.createClass({
this._genRows(this._pressData)
)});
},
_renderSeparator: function(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
return (
<View
key={`${sectionID}-${rowID}`}
style={{
height: adjacentRowHighlighted ? 4 : 1,
backgroundColor: adjacentRowHighlighted ? '#3B5998' : '#CCCCCC',
}}
/>
);
}
});
var THUMB_URLS = [
@@ -152,6 +129,10 @@ var styles = StyleSheet.create({
padding: 10,
backgroundColor: '#F6F6F6',
},
separator: {
height: 1,
backgroundColor: '#CCCCCC',
},
thumb: {
width: 64,
height: 64,
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,8 +15,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
ListView,
@@ -31,7 +23,7 @@ var {
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
var THUMB_URLS = [
require('./Thumbnails/like.png'),
@@ -75,9 +67,6 @@ var ListViewGridLayoutExample = React.createClass({
<ListView
contentContainerStyle={styles.list}
dataSource={this.state.dataSource}
initialListSize={21}
pageSize={3} // should be a multiple of the no. of visible cells per row
scrollRenderAheadDistance={500}
renderRow={this._renderRow}
/>
);
@@ -130,8 +119,7 @@ var styles = StyleSheet.create({
list: {
justifyContent: 'space-around',
flexDirection: 'row',
flexWrap: 'wrap',
alignItems: 'flex-start'
flexWrap: 'wrap'
},
row: {
justifyContent: 'center',
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,8 +16,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Image,
LayoutAnimation,
@@ -33,13 +25,14 @@ var {
Text,
TouchableOpacity,
View,
} = ReactNative;
} = React;
var NativeModules = require('NativeModules');
var {
UIManager,
} = NativeModules;
var PAGE_SIZE = 4;
var THUMB_URLS = [
require('./Thumbnails/like.png'),
require('./Thumbnails/dislike.png'),
@@ -57,28 +50,26 @@ var THUMB_URLS = [
var NUM_SECTIONS = 100;
var NUM_ROWS_PER_SECTION = 10;
class Thumb extends React.Component {
componentWillMount() {
var Thumb = React.createClass({
getInitialState: function() {
return {thumbIndex: this._getThumbIdx(), dir: 'row'};
},
componentWillMount: function() {
UIManager.setLayoutAnimationEnabledExperimental &&
UIManager.setLayoutAnimationEnabledExperimental(true);
}
_getThumbIdx = () => {
},
_getThumbIdx: function() {
return Math.floor(Math.random() * THUMB_URLS.length);
};
_onPressThumb = () => {
},
_onPressThumb: function() {
var config = layoutAnimationConfigs[this.state.thumbIndex % layoutAnimationConfigs.length];
LayoutAnimation.configureNext(config);
this.setState({
thumbIndex: this._getThumbIdx(),
dir: this.state.dir === 'row' ? 'column' : 'row',
});
};
state = {thumbIndex: this._getThumbIdx(), dir: 'row'};
render() {
},
render: function() {
return (
<TouchableOpacity
onPress={this._onPressThumb}
@@ -96,16 +87,15 @@ class Thumb extends React.Component {
</TouchableOpacity>
);
}
}
});
class ListViewPagingExample extends React.Component {
state: *;
static title = '<ListView> - Paging';
static description = 'Floating headers & layout animations.';
var ListViewPagingExample = React.createClass({
statics: {
title: '<ListView> - Paging',
description: 'Floating headers & layout animations.'
},
// $FlowFixMe found when converting React.createClass to ES6
constructor(props) {
super(props);
getInitialState: function() {
var getSectionData = (dataBlob, sectionID) => {
return dataBlob[sectionID];
};
@@ -135,18 +125,17 @@ class ListViewPagingExample extends React.Component {
dataBlob[rowName] = rowName;
}
}
this.state = {
return {
dataSource: dataSource.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs),
headerPressCount: 0,
};
}
},
renderRow = (rowData: string, sectionID: string, rowID: string): React.Element<any> => {
renderRow: function(rowData: string, sectionID: string, rowID: string): ReactElement {
return (<Thumb text={rowData}/>);
};
},
renderSectionHeader = (sectionData: string, sectionID: string) => {
renderSectionHeader: function(sectionData: string, sectionID: string) {
return (
<View style={styles.section}>
<Text style={styles.text}>
@@ -154,9 +143,9 @@ class ListViewPagingExample extends React.Component {
</Text>
</View>
);
};
},
renderHeader = () => {
renderHeader: function() {
var headerLikeText = this.state.headerPressCount % 2 ?
<View><Text style={styles.text}>1 Like</Text></View> :
null;
@@ -170,9 +159,9 @@ class ListViewPagingExample extends React.Component {
</View>
</TouchableOpacity>
);
};
},
renderFooter = () => {
renderFooter: function() {
return (
<View style={styles.header}>
<Text onPress={() => console.log('Footer!')} style={styles.text}>
@@ -180,9 +169,9 @@ class ListViewPagingExample extends React.Component {
</Text>
</View>
);
};
},
render() {
render: function() {
return (
<ListView
style={styles.listview}
@@ -193,18 +182,19 @@ class ListViewPagingExample extends React.Component {
renderSectionHeader={this.renderSectionHeader}
renderRow={this.renderRow}
initialListSize={10}
pageSize={4}
scrollRenderAheadDistance={500}
pageSize={PAGE_SIZE}
scrollRenderAheadDistance={2000}
/>
);
}
},
_onPressHeader = () => {
_onPressHeader: function() {
var config = layoutAnimationConfigs[Math.floor(this.state.headerPressCount / 2) % layoutAnimationConfigs.length];
LayoutAnimation.configureNext(config);
this.setState({headerPressCount: this.state.headerPressCount + 1});
};
}
},
});
var styles = StyleSheet.create({
listview: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,18 +15,17 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var { PropTypes } = React;
var React = require('react-native');
var {
Image,
MapView,
PropTypes,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
} = ReactNative;
} = React;
var regionText = {
latitude: '0',
@@ -160,13 +152,16 @@ var MapRegionInput = React.createClass({
});
class MapViewExample extends React.Component {
state = {
isFirstLoad: true,
mapRegion: undefined,
mapRegionInput: undefined,
annotations: [],
};
var MapViewExample = React.createClass({
getInitialState() {
return {
isFirstLoad: true,
mapRegion: undefined,
mapRegionInput: undefined,
annotations: [],
};
},
render() {
return (
@@ -184,23 +179,23 @@ class MapViewExample extends React.Component {
/>
</View>
);
}
},
_getAnnotations = (region) => {
_getAnnotations(region) {
return [{
longitude: region.longitude,
latitude: region.latitude,
title: 'You Are Here',
}];
};
},
_onRegionChange = (region) => {
_onRegionChange(region) {
this.setState({
mapRegionInput: region,
});
};
},
_onRegionChangeComplete = (region) => {
_onRegionChangeComplete(region) {
if (this.state.isFirstLoad) {
this.setState({
mapRegionInput: region,
@@ -208,23 +203,27 @@ class MapViewExample extends React.Component {
isFirstLoad: false,
});
}
};
},
_onRegionInputChanged = (region) => {
_onRegionInputChanged(region) {
this.setState({
mapRegion: region,
mapRegionInput: region,
annotations: this._getAnnotations(region),
});
};
}
},
class AnnotationExample extends React.Component {
state = {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
});
var AnnotationExample = React.createClass({
getInitialState() {
return {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
},
render() {
if (this.state.isFirstLoad) {
@@ -248,54 +247,9 @@ class AnnotationExample extends React.Component {
annotations={this.state.annotations}
/>
);
}
}
},
class DraggableAnnotationExample extends React.Component {
state = {
isFirstLoad: true,
annotations: [],
mapRegion: undefined,
};
createAnnotation = (longitude, latitude) => {
return {
longitude,
latitude,
draggable: true,
onDragStateChange: (event) => {
if (event.state === 'idle') {
this.setState({
annotations: [this.createAnnotation(event.longitude, event.latitude)],
});
}
console.log('Drag state: ' + event.state);
},
};
};
render() {
if (this.state.isFirstLoad) {
var onRegionChangeComplete = (region) => {
//When the MapView loads for the first time, we can create the annotation at the
//region that was loaded.
this.setState({
isFirstLoad: false,
annotations: [this.createAnnotation(region.longitude, region.latitude)],
});
};
}
return (
<MapView
style={styles.map}
onRegionChangeComplete={onRegionChangeComplete}
region={this.state.mapRegion}
annotations={this.state.annotations}
/>
);
}
}
});
var styles = StyleSheet.create({
map: {
@@ -359,31 +313,22 @@ exports.examples = [
}}>
<Image
style={{width:30, height:30}}
source={require('./uie_thumb_selected.png')}
source={require('image!uie_thumb_selected')}
/>
</TouchableOpacity>
),
}}/>;
}
},
{
title: 'Annotation focus example',
render() {
return <AnnotationExample style={styles.map} annotation={{
title: 'More Info...',
onFocus: () => {
alert('Annotation gets focus');
},
onBlur: () => {
alert('Annotation lost focus');
}
}}/>;
}
},
{
title: 'Draggable pin',
render() {
return <DraggableAnnotationExample/>;
return <AnnotationExample style={styles.map} annotation={{
draggable: true,
onDragStateChange: (event) => {
console.log('Drag state: ' + event.state);
},
}}/>;
}
},
{
@@ -400,7 +345,7 @@ exports.examples = [
render() {
return <AnnotationExample style={styles.map} annotation={{
title: 'Thumbs Up!',
image: require('./uie_thumb_big.png'),
image: require('image!uie_thumb_big'),
}}/>;
}
},
@@ -417,7 +362,7 @@ exports.examples = [
</Text>
<Image
style={{width: 90, height: 65, resizeMode: 'cover'}}
source={require('./uie_thumb_big.png')}
source={require('image!uie_thumb_big')}
/>
</View>,
}}/>;
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,37 +15,35 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Modal,
Picker,
StyleSheet,
Switch,
SwitchIOS,
Text,
TouchableHighlight,
View,
} = ReactNative;
const Item = Picker.Item;
} = React;
exports.displayName = (undefined: ?string);
exports.framework = 'React';
exports.title = '<Modal>';
exports.description = 'Component for presenting modal views.';
class Button extends React.Component {
state = {
active: false,
};
var Button = React.createClass({
getInitialState() {
return {
active: false,
};
},
_onHighlight = () => {
_onHighlight() {
this.setState({active: true});
};
},
_onUnhighlight = () => {
_onUnhighlight() {
this.setState({active: false});
};
},
render() {
var colorStyle = {
@@ -69,37 +60,28 @@ class Button extends React.Component {
</TouchableHighlight>
);
}
}
});
const supportedOrientationsPickerValues = [
['portrait'],
['landscape'],
['landscape-left'],
['portrait', 'landscape-right'],
['portrait', 'landscape'],
[],
];
var ModalExample = React.createClass({
getInitialState() {
return {
animated: true,
modalVisible: false,
transparent: false,
};
},
class ModalExample extends React.Component {
state = {
animationType: 'none',
modalVisible: false,
transparent: false,
selectedSupportedOrientation: 0,
currentOrientation: 'unknown',
};
_setModalVisible = (visible) => {
_setModalVisible(visible) {
this.setState({modalVisible: visible});
};
},
_setAnimationType = (type) => {
this.setState({animationType: type});
};
_toggleAnimated() {
this.setState({animated: !this.state.animated});
},
_toggleTransparent = () => {
_toggleTransparent() {
this.setState({transparent: !this.state.transparent});
};
},
render() {
var modalBackgroundStyle = {
@@ -108,24 +90,16 @@ class ModalExample extends React.Component {
var innerContainerTransparentStyle = this.state.transparent
? {backgroundColor: '#fff', padding: 20}
: null;
var activeButtonStyle = {
backgroundColor: '#ddd'
};
return (
<View>
<Modal
animationType={this.state.animationType}
animated={this.state.animated}
transparent={this.state.transparent}
visible={this.state.modalVisible}
onRequestClose={() => this._setModalVisible(false)}
supportedOrientations={supportedOrientationsPickerValues[this.state.selectedSupportedOrientation]}
onOrientationChange={evt => this.setState({currentOrientation: evt.nativeEvent.orientation})}
>
visible={this.state.modalVisible}>
<View style={[styles.container, modalBackgroundStyle]}>
<View style={[styles.innerContainer, innerContainerTransparentStyle]}>
<Text>This modal was presented {this.state.animationType === 'none' ? 'without' : 'with'} animation.</Text>
<Text>It is currently displayed in {this.state.currentOrientation} mode.</Text>
<Text>This modal was presented {this.state.animated ? 'with' : 'without'} animation.</Text>
<Button
onPress={this._setModalVisible.bind(this, false)}
style={styles.modalButton}>
@@ -134,38 +108,15 @@ class ModalExample extends React.Component {
</View>
</View>
</Modal>
<View style={styles.row}>
<Text style={styles.rowTitle}>Animation Type</Text>
<Button onPress={this._setAnimationType.bind(this, 'none')} style={this.state.animationType === 'none' ? activeButtonStyle : {}}>
none
</Button>
<Button onPress={this._setAnimationType.bind(this, 'slide')} style={this.state.animationType === 'slide' ? activeButtonStyle : {}}>
slide
</Button>
<Button onPress={this._setAnimationType.bind(this, 'fade')} style={this.state.animationType === 'fade' ? activeButtonStyle : {}}>
fade
</Button>
<Text style={styles.rowTitle}>Animated</Text>
<SwitchIOS value={this.state.animated} onValueChange={this._toggleAnimated} />
</View>
<View style={styles.row}>
<Text style={styles.rowTitle}>Transparent</Text>
<Switch value={this.state.transparent} onValueChange={this._toggleTransparent} />
</View>
<View>
<Text style={styles.rowTitle}>Supported orientations</Text>
<Picker
selectedValue={this.state.selectedSupportedOrientation}
onValueChange={(_, i) => this.setState({selectedSupportedOrientation: i})}
itemStyle={styles.pickerItem}
>
<Item label="Portrait" value={0} />
<Item label="Landscape" value={1} />
<Item label="Landscape left" value={2} />
<Item label="Portrait and landscape right" value={3} />
<Item label="Portrait and landscape" value={4} />
<Item label="Default supportedOrientations" value={5} />
</Picker>
<SwitchIOS value={this.state.transparent} onValueChange={this._toggleTransparent} />
</View>
<Button onPress={this._setModalVisible.bind(this, true)}>
@@ -173,8 +124,8 @@ class ModalExample extends React.Component {
</Button>
</View>
);
}
}
},
});
exports.examples = [
{
@@ -220,7 +171,4 @@ var styles = StyleSheet.create({
modalButton: {
marginTop: 10,
},
pickerItem: {
fontSize: 16,
},
});
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -20,8 +13,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Navigator,
StyleSheet,
@@ -29,7 +21,7 @@ var {
Text,
TouchableHighlight,
TouchableOpacity
} = ReactNative;
} = React;
var _getRandomRoute = function() {
return {
@@ -50,8 +42,9 @@ class NavButton extends React.Component {
}
}
class BreadcrumbNavSample extends React.Component {
componentWillMount() {
var BreadcrumbNavSample = React.createClass({
componentWillMount: function() {
this._navBarRouteMapper = {
rightContentForRoute: function(route, navigator) {
return null;
@@ -81,9 +74,9 @@ class BreadcrumbNavSample extends React.Component {
);
}
};
}
},
_renderScene = (route, navigator) => {
_renderScene: function(route, navigator) {
return (
<ScrollView style={styles.scene}>
<NavButton
@@ -108,9 +101,9 @@ class BreadcrumbNavSample extends React.Component {
/>
</ScrollView>
);
};
},
render() {
render: function() {
return (
<Navigator
style={styles.container}
@@ -123,8 +116,11 @@ class BreadcrumbNavSample extends React.Component {
}
/>
);
}
}
},
});
var styles = StyleSheet.create({
scene: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -20,8 +13,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Navigator,
StyleSheet,
@@ -30,7 +22,7 @@ var {
Text,
TouchableHighlight,
View,
} = ReactNative;
} = React;
var _getRandomRoute = function() {
return {
@@ -106,8 +98,8 @@ class JumpingNavBar extends React.Component {
}
}
class JumpingNavSample extends React.Component {
render() {
var JumpingNavSample = React.createClass({
render: function() {
return (
<Navigator
debugOverlay={false}
@@ -133,9 +125,9 @@ class JumpingNavSample extends React.Component {
}
/>
);
}
},
renderScene = (route, navigator) => {
renderScene: function(route, navigator) {
var backBtn;
var forwardBtn;
if (ROUTE_STACK.indexOf(route) !== 0) {
@@ -185,8 +177,8 @@ class JumpingNavSample extends React.Component {
/>
</ScrollView>
);
};
}
},
});
var styles = StyleSheet.create({
button: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -21,8 +14,7 @@
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Navigator,
ScrollView,
@@ -30,7 +22,9 @@ var {
Text,
TouchableHighlight,
TouchableOpacity,
} = ReactNative;
} = React;
var cssVar = require('cssVar');
class NavButton extends React.Component {
render() {
@@ -92,8 +86,9 @@ function newRandomRoute() {
};
}
class NavigationBarSample extends React.Component {
componentWillMount() {
var NavigationBarSample = React.createClass({
componentWillMount: function() {
var navigator = this.props.navigator;
var callback = (event) => {
@@ -112,13 +107,13 @@ class NavigationBarSample extends React.Component {
navigator.navigationContext.addListener('willfocus', callback),
navigator.navigationContext.addListener('didfocus', callback),
];
}
},
componentWillUnmount() {
componentWillUnmount: function() {
this._listeners && this._listeners.forEach(listener => listener.remove());
}
},
render() {
render: function() {
return (
<Navigator
debugOverlay={false}
@@ -153,8 +148,9 @@ class NavigationBarSample extends React.Component {
}
/>
);
}
}
},
});
var styles = StyleSheet.create({
messageText: {
@@ -182,7 +178,7 @@ var styles = StyleSheet.create({
marginVertical: 10,
},
navBarTitleText: {
color: '#373E4D',
color: cssVar('fbui-bluegray-60'),
fontWeight: '500',
marginVertical: 9,
},
@@ -193,7 +189,7 @@ var styles = StyleSheet.create({
paddingRight: 10,
},
navBarButtonText: {
color: '#5890FF',
color: cssVar('fbui-accent-blue'),
},
scene: {
flex: 1,
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -17,20 +10,17 @@
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule NavigatorExample
*/
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
Navigator,
ScrollView,
StyleSheet,
Text,
TouchableHighlight,
} = ReactNative;
} = React;
var BreadcrumbNavSample = require('./BreadcrumbNavSample');
var NavigationBarSample = require('./NavigationBarSample');
var JumpingNavSample = require('./JumpingNavSample');
@@ -112,11 +102,14 @@ class NavMenu extends React.Component {
}
}
class TabBarExample extends React.Component {
static title = '<Navigator>';
static description = 'JS-implemented navigation';
var TabBarExample = React.createClass({
renderScene = (route, nav) => {
statics: {
title: '<Navigator>',
description: 'JS-implemented navigation',
},
renderScene: function(route, nav) {
switch (route.id) {
case 'navbar':
return <NavigationBarSample navigator={nav} />;
@@ -133,9 +126,9 @@ class TabBarExample extends React.Component {
/>
);
}
};
},
render() {
render: function() {
return (
<Navigator
ref={this._setNavigatorRef}
@@ -150,13 +143,14 @@ class TabBarExample extends React.Component {
}}
/>
);
}
},
componentWillUnmount() {
componentWillUnmount: function() {
this._listeners && this._listeners.forEach(listener => listener.remove());
}
},
_setNavigatorRef = (navigator) => {
_setNavigatorRef: function(navigator) {
if (navigator !== this._navigator) {
this._navigator = navigator;
@@ -178,8 +172,8 @@ class TabBarExample extends React.Component {
];
}
}
};
}
},
});
var styles = StyleSheet.create({
messageText: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -20,18 +13,18 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
NavigatorIOS,
StatusBar,
StatusBarIOS,
StyleSheet,
Text,
View
} = ReactNative;
} = React;
class EmptyPage extends React.Component {
render() {
var EmptyPage = React.createClass({
render: function() {
return (
<View style={styles.emptyPage}>
<Text style={styles.emptyPageText}>
@@ -39,16 +32,20 @@ class EmptyPage extends React.Component {
</Text>
</View>
);
}
}
},
class NavigatorIOSColors extends React.Component {
static title = '<NavigatorIOS> - Custom';
static description = 'iOS navigation with custom nav bar colors';
});
render() {
var NavigatorIOSColors = React.createClass({
statics: {
title: '<NavigatorIOS> - Custom',
description: 'iOS navigation with custom nav bar colors',
},
render: function() {
// Set StatusBar with light contents to get better contrast
StatusBar.setBarStyle('light-content');
StatusBarIOS.setStyle('light-content');
return (
<NavigatorIOS
@@ -58,7 +55,7 @@ class NavigatorIOSColors extends React.Component {
title: '<NavigatorIOS>',
rightButtonTitle: 'Done',
onRightButtonPress: () => {
StatusBar.setBarStyle('default');
StatusBarIOS.setStyle('default');
this.props.onExampleExit();
},
passProps: {
@@ -72,8 +69,9 @@ class NavigatorIOSColors extends React.Component {
translucent={true}
/>
);
}
}
},
});
var styles = StyleSheet.create({
container: {
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,22 +15,21 @@
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const ViewExample = require('./ViewExample');
const createExamplePage = require('./createExamplePage');
const {
var React = require('react-native');
var ViewExample = require('./ViewExample');
var createExamplePage = require('./createExamplePage');
var {
AlertIOS,
NavigatorIOS,
ScrollView,
StyleSheet,
Text,
TouchableHighlight,
View,
} = ReactNative;
} = React;
class EmptyPage extends React.Component {
render() {
var EmptyPage = React.createClass({
render: function() {
return (
<View style={styles.emptyPage}>
<Text style={styles.emptyPageText}>
@@ -45,25 +37,42 @@ class EmptyPage extends React.Component {
</Text>
</View>
);
}
}
},
class NavigatorIOSExamplePage extends React.Component {
render() {
});
var NavigatorIOSExample = React.createClass({
statics: {
title: '<NavigatorIOS>',
description: 'iOS navigation capabilities',
},
render: function() {
var recurseTitle = 'Recurse Navigation';
if (!this.props.depth || this.props.depth === 1) {
if (!this.props.topExampleRoute) {
recurseTitle += ' - more examples here';
}
return (
<ScrollView style={styles.list}>
<View style={styles.line}/>
<View style={styles.group}>
<View style={styles.row}>
<Text style={styles.rowNote}>
See &lt;UIExplorerApp&gt; for top-level usage.
</Text>
</View>
</View>
<View style={styles.line}/>
<View style={styles.groupSpace}/>
<View style={styles.line}/>
<View style={styles.group}>
{this._renderRow(recurseTitle, () => {
this.props.navigator.push({
title: NavigatorIOSExample.title,
component: NavigatorIOSExamplePage,
component: NavigatorIOSExample,
backButtonTitle: 'Custom Back',
passProps: {depth: this.props.depth ? this.props.depth + 1 : 1},
passProps: {topExampleRoute: this.props.topExampleRoute || this.props.route},
});
})}
{this._renderRow('Push View Example', () => {
@@ -72,13 +81,6 @@ class NavigatorIOSExamplePage extends React.Component {
component: createExamplePage(null, ViewExample),
});
})}
{this._renderRow('Custom title image Example', () => {
this.props.navigator.push({
title: 'Custom title image Example',
titleImage: require('./relay.png'),
component: createExamplePage(null, ViewExample),
});
})}
{this._renderRow('Custom Right Button', () => {
this.props.navigator.push({
title: NavigatorIOSExample.title,
@@ -90,17 +92,6 @@ class NavigatorIOSExamplePage extends React.Component {
}
});
})}
{this._renderRow('Custom Right System Button', () => {
this.props.navigator.push({
title: NavigatorIOSExample.title,
component: EmptyPage,
rightButtonSystemIcon: 'bookmarks',
onRightButtonPress: () => this.props.navigator.pop(),
passProps: {
text: 'This page has a right system button in the nav bar',
}
});
})}
{this._renderRow('Custom Left & Right Icons', () => {
this.props.navigator.push({
title: NavigatorIOSExample.title,
@@ -125,69 +116,46 @@ class NavigatorIOSExamplePage extends React.Component {
}
});
})}
{this._renderRow('Custom Left & Right System Icons', () => {
this.props.navigator.push({
title: NavigatorIOSExample.title,
component: EmptyPage,
leftButtonSystemIcon: 'cancel',
onLeftButtonPress: () => this.props.navigator.pop(),
rightButtonSystemIcon: 'search',
onRightButtonPress: () => {
AlertIOS.alert(
'Bar Button Action',
'Recognized a tap on the bar button icon',
[
{
text: 'OK',
onPress: () => console.log('Tapped OK'),
},
]
);
},
passProps: {
text: 'This page has an icon for the right button in the nav bar',
}
});
})}
{this._renderRow('Pop', () => {
this.props.navigator.pop();
})}
{this._renderRow('Pop to top', () => {
this.props.navigator.popToTop();
})}
{this._renderReplace()}
{this._renderRow('Replace here', () => {
var prevRoute = this.props.route;
this.props.navigator.replace({
title: 'New Navigation',
component: EmptyPage,
rightButtonTitle: 'Undo',
onRightButtonPress: () => this.props.navigator.replace(prevRoute),
passProps: {
text: 'The component is replaced, but there is currently no ' +
'way to change the right button or title of the current route',
}
});
})}
{this._renderReplacePrevious()}
{this._renderReplacePreviousAndPop()}
{this._renderRow('Exit NavigatorIOS Example', this.props.onExampleExit)}
{this._renderPopToTopNavExample()}
</View>
<View style={styles.line}/>
</ScrollView>
);
}
},
_renderReplace = () => {
if (!this.props.depth) {
// this is to avoid replacing the top of the stack
_renderPopToTopNavExample: function() {
if (!this.props.topExampleRoute) {
return null;
}
return this._renderRow('Replace here', () => {
var prevRoute = this.props.route;
this.props.navigator.replace({
title: 'New Navigation',
component: EmptyPage,
rightButtonTitle: 'Undo',
onRightButtonPress: () => this.props.navigator.replace(prevRoute),
passProps: {
text: 'The component is replaced, but there is currently no ' +
'way to change the right button or title of the current route',
}
});
return this._renderRow('Pop to top NavigatorIOSExample', () => {
this.props.navigator.popToRoute(this.props.topExampleRoute);
});
};
},
_renderReplacePrevious = () => {
if (!this.props.depth || this.props.depth < 2) {
// this is to avoid replacing the top of the stack
_renderReplacePrevious: function() {
if (!this.props.topExampleRoute) {
// this is to avoid replacing the UIExplorerList at the top of the stack
return null;
}
return this._renderRow('Replace previous', () => {
@@ -200,11 +168,11 @@ class NavigatorIOSExamplePage extends React.Component {
wrapperStyle: styles.customWrapperStyle,
});
});
};
},
_renderReplacePreviousAndPop = () => {
if (!this.props.depth || this.props.depth < 2) {
// this is to avoid replacing the top of the stack
_renderReplacePreviousAndPop: function() {
if (!this.props.topExampleRoute) {
// this is to avoid replacing the UIExplorerList at the top of the stack
return null;
}
return this._renderRow('Replace previous and pop', () => {
@@ -217,9 +185,9 @@ class NavigatorIOSExamplePage extends React.Component {
wrapperStyle: styles.customWrapperStyle,
});
});
};
},
_renderRow = (title: string, onPress: Function) => {
_renderRow: function(title: string, onPress: Function) {
return (
<View>
<TouchableHighlight onPress={onPress}>
@@ -232,34 +200,10 @@ class NavigatorIOSExamplePage extends React.Component {
<View style={styles.separator} />
</View>
);
};
}
class NavigatorIOSExample extends React.Component {
static title = '<NavigatorIOS>';
static description = 'iOS navigation capabilities';
static external = true;
render() {
const {onExampleExit} = this.props;
return (
<NavigatorIOS
style={styles.container}
initialRoute={{
title: NavigatorIOSExample.title,
component: NavigatorIOSExamplePage,
passProps: {onExampleExit},
}}
tintColor="#008888"
/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
var styles = StyleSheet.create({
customWrapperStyle: {
backgroundColor: '#bbdddd',
},
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,42 +15,39 @@
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const React = require('react-native');
const {
NetInfo,
Text,
View,
TouchableWithoutFeedback,
} = ReactNative;
} = React;
class ConnectionInfoSubscription extends React.Component {
state = {
connectionInfoHistory: [],
};
componentDidMount() {
const ConnectionInfoSubscription = React.createClass({
getInitialState() {
return {
connectionInfoHistory: [],
};
},
componentDidMount: function() {
NetInfo.addEventListener(
'change',
this._handleConnectionInfoChange
);
}
componentWillUnmount() {
},
componentWillUnmount: function() {
NetInfo.removeEventListener(
'change',
this._handleConnectionInfoChange
);
}
_handleConnectionInfoChange = (connectionInfo) => {
},
_handleConnectionInfoChange: function(connectionInfo) {
const connectionInfoHistory = this.state.connectionInfoHistory.slice();
connectionInfoHistory.push(connectionInfo);
this.setState({
connectionInfoHistory,
});
};
},
render() {
return (
<View>
@@ -65,14 +55,15 @@ class ConnectionInfoSubscription extends React.Component {
</View>
);
}
}
});
class ConnectionInfoCurrent extends React.Component {
state = {
connectionInfo: null,
};
componentDidMount() {
const ConnectionInfoCurrent = React.createClass({
getInitialState() {
return {
connectionInfo: null,
};
},
componentDidMount: function() {
NetInfo.addEventListener(
'change',
this._handleConnectionInfoChange
@@ -80,21 +71,18 @@ class ConnectionInfoCurrent extends React.Component {
NetInfo.fetch().done(
(connectionInfo) => { this.setState({connectionInfo}); }
);
}
componentWillUnmount() {
},
componentWillUnmount: function() {
NetInfo.removeEventListener(
'change',
this._handleConnectionInfoChange
);
}
_handleConnectionInfoChange = (connectionInfo) => {
},
_handleConnectionInfoChange: function(connectionInfo) {
this.setState({
connectionInfo,
});
};
},
render() {
return (
<View>
@@ -102,14 +90,15 @@ class ConnectionInfoCurrent extends React.Component {
</View>
);
}
}
});
class IsConnected extends React.Component {
state = {
isConnected: null,
};
componentDidMount() {
const IsConnected = React.createClass({
getInitialState() {
return {
isConnected: null,
};
},
componentDidMount: function() {
NetInfo.isConnected.addEventListener(
'change',
this._handleConnectivityChange
@@ -117,21 +106,18 @@ class IsConnected extends React.Component {
NetInfo.isConnected.fetch().done(
(isConnected) => { this.setState({isConnected}); }
);
}
componentWillUnmount() {
},
componentWillUnmount: function() {
NetInfo.isConnected.removeEventListener(
'change',
this._handleConnectivityChange
);
}
_handleConnectivityChange = (isConnected) => {
},
_handleConnectivityChange: function(isConnected) {
this.setState({
isConnected,
});
};
},
render() {
return (
<View>
@@ -139,19 +125,19 @@ class IsConnected extends React.Component {
</View>
);
}
}
});
class IsConnectionExpensive extends React.Component {
state = {
isConnectionExpensive: (null : ?boolean),
};
_checkIfExpensive = () => {
NetInfo.isConnectionExpensive().then(
isConnectionExpensive => { this.setState({isConnectionExpensive}); }
const IsConnectionExpensive = React.createClass({
getInitialState() {
return {
isConnectionExpensive: (null : ?boolean),
};
},
_checkIfExpensive() {
NetInfo.isConnectionExpensive(
(isConnectionExpensive) => { this.setState({isConnectionExpensive}); }
);
};
},
render() {
return (
<View>
@@ -167,7 +153,7 @@ class IsConnectionExpensive extends React.Component {
</View>
);
}
}
});
exports.title = 'NetInfo';
exports.description = 'Monitor network status';
@@ -175,22 +161,22 @@ exports.examples = [
{
title: 'NetInfo.isConnected',
description: 'Asynchronously load and observe connectivity',
render(): React.Element<any> { return <IsConnected />; }
render(): ReactElement { return <IsConnected />; }
},
{
title: 'NetInfo.update',
description: 'Asynchronously load and observe connectionInfo',
render(): React.Element<any> { return <ConnectionInfoCurrent />; }
render(): ReactElement { return <ConnectionInfoCurrent />; }
},
{
title: 'NetInfo.updateHistory',
description: 'Observed updates to connectionInfo',
render(): React.Element<any> { return <ConnectionInfoSubscription />; }
render(): ReactElement { return <ConnectionInfoSubscription />; }
},
{
platform: 'android',
title: 'NetInfo.isConnectionExpensive (Android)',
description: 'Asynchronously check isConnectionExpensive',
render(): React.Element<any> { return <IsConnectionExpensive />; }
render(): ReactElement { return <IsConnectionExpensive />; }
},
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,15 +15,17 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
PanResponder,
StyleSheet,
View,
} = ReactNative;
processColor,
} = React;
var CIRCLE_SIZE = 80;
var CIRCLE_COLOR = 'blue';
var CIRCLE_HIGHLIGHT_COLOR = 'green';
var PanResponderExample = React.createClass({
@@ -59,14 +54,13 @@ var PanResponderExample = React.createClass({
this._circleStyles = {
style: {
left: this._previousLeft,
top: this._previousTop,
backgroundColor: 'green',
top: this._previousTop
}
};
},
componentDidMount: function() {
this._updateNativeStyles();
this._updatePosition();
},
render: function() {
@@ -85,16 +79,24 @@ var PanResponderExample = React.createClass({
},
_highlight: function() {
this._circleStyles.style.backgroundColor = 'blue';
this._updateNativeStyles();
const circle = this.circle;
circle && circle.setNativeProps({
style: {
backgroundColor: processColor(CIRCLE_HIGHLIGHT_COLOR)
}
});
},
_unHighlight: function() {
this._circleStyles.style.backgroundColor = 'green';
this._updateNativeStyles();
const circle = this.circle;
circle && circle.setNativeProps({
style: {
backgroundColor: processColor(CIRCLE_COLOR)
}
});
},
_updateNativeStyles: function() {
_updatePosition: function() {
this.circle && this.circle.setNativeProps(this._circleStyles);
},
@@ -114,7 +116,7 @@ var PanResponderExample = React.createClass({
_handlePanResponderMove: function(e: Object, gestureState: Object) {
this._circleStyles.style.left = this._previousLeft + gestureState.dx;
this._circleStyles.style.top = this._previousTop + gestureState.dy;
this._updateNativeStyles();
this._updatePosition();
},
_handlePanResponderEnd: function(e: Object, gestureState: Object) {
this._unHighlight();
@@ -128,6 +130,7 @@ var styles = StyleSheet.create({
width: CIRCLE_SIZE,
height: CIRCLE_SIZE,
borderRadius: CIRCLE_SIZE / 2,
backgroundColor: CIRCLE_COLOR,
position: 'absolute',
left: 0,
top: 0,
+142
View File
@@ -0,0 +1,142 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @flow
*/
'use strict';
const React = require('react-native');
const UIExplorerBlock = require('UIExplorerBlock');
const UIExplorerPage = require('UIExplorerPage');
const {
PickerAndroid,
Text,
TouchableWithoutFeedback,
} = React;
const Item = PickerAndroid.Item;
const PickerAndroidExample = React.createClass({
getInitialState: function() {
return {
selected1: 'key1',
selected2: 'key1',
selected3: 'key1',
selected4: 'key1',
color: 'red',
mode: PickerAndroid.MODE_DIALOG,
};
},
displayName: 'Android Picker',
render: function() {
return (
<UIExplorerPage title="<PickerAndroid>">
<UIExplorerBlock title="Basic Picker">
<PickerAndroid
style={{width: 100, height: 56}}
onSelect={this.onSelect.bind(this, 'selected1')}>
<Item text="hello" value="key0" selected={this.state.selected1 === 'key0'} />
<Item text="world" value="key1" selected={this.state.selected1 === 'key1'} />
</PickerAndroid>
</UIExplorerBlock>
<UIExplorerBlock title="Disabled picker">
<PickerAndroid style={{width: 100, height: 56}} enabled={false}>
<Item text="hello" value="key0" selected={this.state.selected1 === 'key0'} />
<Item text="world" value="key1" selected={this.state.selected1 === 'key1'} />
</PickerAndroid>
</UIExplorerBlock>
<UIExplorerBlock title="Dropdown Picker">
<PickerAndroid
style={{width: 100, height: 56}}
onSelect={this.onSelect.bind(this, 'selected2')}
mode="dropdown">
<Item text="hello" value="key0" selected={this.state.selected2 === 'key0'} />
<Item text="world" value="key1" selected={this.state.selected2 === 'key1'} />
</PickerAndroid>
</UIExplorerBlock>
<UIExplorerBlock title="Alternating Picker">
<PickerAndroid
style={{width: 100, height: 56}}
onSelect={this.onSelect.bind(this, 'selected3')}
mode={this.state.mode}>
<Item text="hello" value="key0" selected={this.state.selected3 === 'key0'} />
<Item text="world" value="key1" selected={this.state.selected3 === 'key1'} />
</PickerAndroid>
<TouchableWithoutFeedback onPress={this.changeMode}>
<Text>Tap here to switch between dialog/dropdown.</Text>
</TouchableWithoutFeedback>
</UIExplorerBlock>
<UIExplorerBlock title="Picker with prompt message">
<PickerAndroid
style={{width: 100, height: 56}}
onSelect={this.onSelect.bind(this, 'selected4')}
prompt="Pick one, just one">
<Item text="hello" value="key0" selected={this.state.selected4 === 'key0'} />
<Item text="world" value="key1" selected={this.state.selected4 === 'key1'} />
</PickerAndroid>
</UIExplorerBlock>
<UIExplorerBlock title="Picker with no listener">
<PickerAndroid style={{width: 100, height: 56}}>
<Item text="hello" value="key0" />
<Item text="world" value="key1" />
</PickerAndroid>
<Text>
You can not change the value of this picker because it doesn't set a selected prop on
its items.
</Text>
</UIExplorerBlock>
<UIExplorerBlock title="Colorful pickers">
<PickerAndroid style={{width: 100, height: 56, color: 'black'}}
onSelect={this.onSelect.bind(this, 'color')}
mode="dropdown">
<Item text="red" color="red" value="red" selected={this.state.color === 'red'}/>
<Item text="green" color="green" value="green" selected={this.state.color === 'green'}/>
<Item text="blue" color="blue" value="blue" selected={this.state.color === 'blue'}/>
</PickerAndroid>
<PickerAndroid style={{width: 100, height: 56}}
onSelect={this.onSelect.bind(this, 'color')}
mode="dialog">
<Item text="red" color="red" value="red" selected={this.state.color === 'red'}/>
<Item text="green" color="green" value="green" selected={this.state.color === 'green'}/>
<Item text="blue" color="blue" value="blue" selected={this.state.color === 'blue'} />
</PickerAndroid>
</UIExplorerBlock>
</UIExplorerPage>
);
},
changeMode: function() {
const newMode = this.state.mode === PickerAndroid.MODE_DIALOG
? PickerAndroid.MODE_DROPDOWN
: PickerAndroid.MODE_DIALOG;
this.setState({mode: newMode});
},
onSelect: function(key, value) {
const newState = {};
newState[key] = value;
this.setState(newState);
},
});
exports.title = '<PickerAndroid>';
exports.displayName = 'PickerAndroidExample';
exports.description = 'The Android Picker component provides multiple options to choose from';
exports.examples = [
{
title: 'PickerAndroidExample',
render(): ReactElement { return <PickerAndroidExample />; }
},
];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,13 +15,12 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
PickerIOS,
Text,
View,
} = ReactNative;
} = React;
var PickerItemIOS = PickerIOS.Item;
@@ -73,13 +65,15 @@ var CAR_MAKES_AND_MODELS = {
},
};
class PickerExample extends React.Component {
state = {
carMake: 'cadillac',
modelIndex: 3,
};
var PickerExample = React.createClass({
getInitialState: function() {
return {
carMake: 'cadillac',
modelIndex: 3,
};
},
render() {
render: function() {
var make = CAR_MAKES_AND_MODELS[this.state.carMake];
var selectionString = make.name + ' ' + make.models[this.state.modelIndex];
return (
@@ -112,16 +106,20 @@ class PickerExample extends React.Component {
<Text>You selected: {selectionString}</Text>
</View>
);
}
}
},
});
class PickerStyleExample extends React.Component {
state = {
carMake: 'cadillac',
modelIndex: 0,
};
var PickerStyleExample = React.createClass({
getInitialState: function() {
return {
carMake: 'cadillac',
modelIndex: 0,
};
},
render() {
render: function() {
var make = CAR_MAKES_AND_MODELS[this.state.carMake];
var selectionString = make.name + ' ' + make.models[this.state.modelIndex];
return (
<PickerIOS
itemStyle={{fontSize: 25, color: 'red', textAlign: 'left', fontWeight: 'bold'}}
@@ -136,8 +134,8 @@ class PickerStyleExample extends React.Component {
))}
</PickerIOS>
);
}
}
},
});
exports.displayName = (undefined: ?string);
exports.title = '<PickerIOS>';
@@ -145,13 +143,13 @@ exports.description = 'Render lists of selectable options with UIPickerView.';
exports.examples = [
{
title: '<PickerIOS>',
render: function(): React.Element<any> {
render: function(): ReactElement {
return <PickerExample />;
},
},
{
title: '<PickerIOS> with custom styling',
render: function(): React.Element<any> {
render: function(): ReactElement {
return <PickerStyleExample />;
},
}];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,36 +15,33 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
class ExampleBox extends React.Component {
state = {
log: [],
};
handleLog = (msg) => {
var ExampleBox = React.createClass({
getInitialState: function() {
return {
log: [],
};
},
handleLog: function(msg) {
this.state.log = this.state.log.concat([msg]);
};
flushReactChanges = () => {
},
flushReactChanges: function() {
this.forceUpdate();
};
},
/**
* Capture phase of bubbling to append separator before any of the bubbling
* happens.
*/
handleTouchCapture = () => {
handleTouchCapture: function() {
this.state.log = this.state.log.concat(['---']);
};
render() {
},
render: function() {
return (
<View>
<View
@@ -68,10 +58,11 @@ class ExampleBox extends React.Component {
</View>
);
}
}
});
class NoneExample extends React.Component {
render() {
var NoneExample = React.createClass({
render: function() {
return (
<View
onTouchStart={() => this.props.onLog('A unspecified touched')}
@@ -97,14 +88,14 @@ class NoneExample extends React.Component {
</View>
);
}
}
});
/**
* Special demo text that makes itself untouchable so that it doesn't destroy
* the experiment and confuse the output.
*/
class DemoText extends React.Component {
render() {
var DemoText = React.createClass({
render: function() {
return (
<View pointerEvents="none">
<Text
@@ -114,10 +105,10 @@ class DemoText extends React.Component {
</View>
);
}
}
});
class BoxNoneExample extends React.Component {
render() {
var BoxNoneExample = React.createClass({
render: function() {
return (
<View
onTouchStart={() => this.props.onLog('A unspecified touched')}
@@ -151,10 +142,10 @@ class BoxNoneExample extends React.Component {
</View>
);
}
}
});
class BoxOnlyExample extends React.Component {
render() {
var BoxOnlyExample = React.createClass({
render: function() {
return (
<View
onTouchStart={() => this.props.onLog('A unspecified touched')}
@@ -188,10 +179,10 @@ class BoxOnlyExample extends React.Component {
</View>
);
}
}
});
type ExampleClass = {
Component: ReactClass<any>,
Component: ReactClass<any, any, any>,
title: string,
description: string,
};
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -52,13 +45,45 @@ var MovingBar = React.createClass({
},
});
class ProgressBarAndroidExample extends React.Component {
static title = '<ProgressBarAndroid>';
static description = 'Horizontal bar to show the progress of some operation.';
var ProgressBarAndroidExample = React.createClass({
render() {
statics: {
title: '<ProgressBarAndroid>',
description: 'Visual indicator of progress of some operation. ' +
'Shows either a cyclic animation or a horizontal bar.',
},
render: function() {
return (
<UIExplorerPage title="ProgressBar Examples">
<UIExplorerBlock title="Default ProgressBar">
<ProgressBar />
</UIExplorerBlock>
<UIExplorerBlock title="Normal ProgressBar">
<ProgressBar styleAttr="Normal" />
</UIExplorerBlock>
<UIExplorerBlock title="Small ProgressBar">
<ProgressBar styleAttr="Small" />
</UIExplorerBlock>
<UIExplorerBlock title="Large ProgressBar">
<ProgressBar styleAttr="Large" />
</UIExplorerBlock>
<UIExplorerBlock title="Inverse ProgressBar">
<ProgressBar styleAttr="Inverse" />
</UIExplorerBlock>
<UIExplorerBlock title="Small Inverse ProgressBar">
<ProgressBar styleAttr="SmallInverse" />
</UIExplorerBlock>
<UIExplorerBlock title="Large Inverse ProgressBar">
<ProgressBar styleAttr="LargeInverse" />
</UIExplorerBlock>
<UIExplorerBlock title="Horizontal Indeterminate ProgressBar">
<ProgressBar styleAttr="Horizontal" />
</UIExplorerBlock>
@@ -67,6 +92,10 @@ class ProgressBarAndroidExample extends React.Component {
<MovingBar styleAttr="Horizontal" indeterminate={false} />
</UIExplorerBlock>
<UIExplorerBlock title="Large Red ProgressBar">
<ProgressBar styleAttr="Large" color="red" />
</UIExplorerBlock>
<UIExplorerBlock title="Horizontal Black Indeterminate ProgressBar">
<ProgressBar styleAttr="Horizontal" color="black" />
</UIExplorerBlock>
@@ -76,7 +105,7 @@ class ProgressBarAndroidExample extends React.Component {
</UIExplorerBlock>
</UIExplorerPage>
);
}
}
},
});
module.exports = ProgressBarAndroidExample;
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,13 +15,12 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ProgressViewIOS,
StyleSheet,
View,
} = ReactNative;
} = React;
var TimerMixin = require('react-timer-mixin');
var ProgressViewExample = React.createClass({
@@ -0,0 +1,128 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
'use strict';
const React = require('react-native');
const {
ScrollView,
StyleSheet,
PullToRefreshViewAndroid,
Text,
TouchableWithoutFeedback,
View,
} = React;
const styles = StyleSheet.create({
row: {
borderColor: 'grey',
borderWidth: 1,
padding: 20,
backgroundColor: '#3a5795',
margin: 5,
},
text: {
alignSelf: 'center',
color: '#fff',
},
layout: {
flex: 1,
},
scrollview: {
flex: 1,
},
});
const Row = React.createClass({
_onClick: function() {
this.props.onClick(this.props.data);
},
render: function() {
return (
<TouchableWithoutFeedback onPress={this._onClick} >
<View style={styles.row}>
<Text style={styles.text}>
{this.props.data.text + ' (' + this.props.data.clicks + ' clicks)'}
</Text>
</View>
</TouchableWithoutFeedback>
);
},
});
const PullToRefreshViewAndroidExample = React.createClass({
statics: {
title: '<PullToRefreshViewAndroid>',
description: 'Container that adds pull-to-refresh support to its child view.'
},
getInitialState() {
return {
isRefreshing: false,
loaded: 0,
rowData: Array.from(new Array(20)).map(
(val, i) => ({text: 'Initial row' + i, clicks: 0})
),
};
},
_onClick(row) {
row.clicks++;
this.setState({
rowData: this.state.rowData,
});
},
render() {
const rows = this.state.rowData.map((row, ii) => {
return <Row key={ii} data={row} onClick={this._onClick}/>;
});
return (
<PullToRefreshViewAndroid
style={styles.layout}
refreshing={this.state.isRefreshing}
onRefresh={this._onRefresh}
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor={'#ffff00'}
>
<ScrollView style={styles.scrollview}>
{rows}
</ScrollView>
</PullToRefreshViewAndroid>
);
},
_onRefresh() {
this.setState({isRefreshing: true});
setTimeout(() => {
// prepend 10 items
const rowData = Array.from(new Array(10))
.map((val, i) => ({
text: 'Loaded row' + (+this.state.loaded + i),
clicks: 0,
}))
.concat(this.state.rowData);
this.setState({
loaded: this.state.loaded + 10,
isRefreshing: false,
rowData: rowData,
});
}, 5000);
},
});
module.exports = PullToRefreshViewAndroidExample;
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,8 +15,7 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
AlertIOS,
PushNotificationIOS,
@@ -31,10 +23,10 @@ var {
Text,
TouchableHighlight,
View,
} = ReactNative;
} = React;
class Button extends React.Component {
render() {
var Button = React.createClass({
render: function() {
return (
<TouchableHighlight
underlayColor={'white'}
@@ -46,23 +38,15 @@ class Button extends React.Component {
</TouchableHighlight>
);
}
}
});
class NotificationExample extends React.Component {
componentWillMount() {
PushNotificationIOS.addEventListener('register', this._onRegistered);
PushNotificationIOS.addEventListener('registrationError', this._onRegistrationError);
PushNotificationIOS.addEventListener('notification', this._onRemoteNotification);
PushNotificationIOS.addEventListener('localNotification', this._onLocalNotification);
PushNotificationIOS.requestPermissions();
PushNotificationIOS.addEventListener('notification', this._onNotification);
}
componentWillUnmount() {
PushNotificationIOS.removeEventListener('register', this._onRegistered);
PushNotificationIOS.removeEventListener('registrationError', this._onRegistrationError);
PushNotificationIOS.removeEventListener('notification', this._onRemoteNotification);
PushNotificationIOS.removeEventListener('localNotification', this._onLocalNotification);
PushNotificationIOS.removeEventListener('notification', this._onNotification);
}
render() {
@@ -72,11 +56,6 @@ class NotificationExample extends React.Component {
onPress={this._sendNotification}
label="Send fake notification"
/>
<Button
onPress={this._sendLocalNotification}
label="Send fake local notification"
/>
</View>
);
}
@@ -92,53 +71,9 @@ class NotificationExample extends React.Component {
});
}
_sendLocalNotification() {
require('RCTDeviceEventEmitter').emit('localNotificationReceived', {
aps: {
alert: 'Sample local notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE'
},
});
}
_onRegistered(deviceToken) {
_onNotification(notification) {
AlertIOS.alert(
'Registered For Remote Push',
`Device Token: ${deviceToken}`,
[{
text: 'Dismiss',
onPress: null,
}]
);
}
_onRegistrationError(error) {
AlertIOS.alert(
'Failed To Register For Remote Push',
`Error (${error.code}): ${error.message}`,
[{
text: 'Dismiss',
onPress: null,
}]
);
}
_onRemoteNotification(notification) {
AlertIOS.alert(
'Push Notification Received',
'Alert message: ' + notification.getMessage(),
[{
text: 'Dismiss',
onPress: null,
}]
);
}
_onLocalNotification(notification){
AlertIOS.alert(
'Local Notification Received',
'Notification Received',
'Alert message: ' + notification.getMessage(),
[{
text: 'Dismiss',
@@ -149,8 +84,6 @@ class NotificationExample extends React.Component {
}
class NotificationPermissionExample extends React.Component {
state: any;
constructor(props) {
super(props);
this.state = {permissions: null};
@@ -193,7 +126,9 @@ exports.description = 'Apple PushNotification and badge value';
exports.examples = [
{
title: 'Badge Number',
render(): React.Element<any> {
render(): React.Component {
PushNotificationIOS.requestPermissions();
return (
<View>
<Button
@@ -210,13 +145,13 @@ exports.examples = [
},
{
title: 'Push Notifications',
render(): React.Element<any> {
render(): React.Component {
return <NotificationExample />;
}
},
{
title: 'Notifications Permissions',
render(): React.Element<any> {
render(): React.Component {
return <NotificationPermissionExample />;
}
}];
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -23,13 +16,12 @@
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const React = require('react-native');
const {
StyleSheet,
Text,
View,
} = ReactNative;
} = React;
const requireNativeComponent = require('requireNativeComponent');
@@ -90,7 +82,7 @@ exports.description = 'Examples that show useful methods when embedding React Na
exports.examples = [
{
title: 'Updating app properties in runtime',
render(): React.Element<any> {
render(): React.Component {
return (
<AppPropertiesUpdateExample/>
);
@@ -98,7 +90,7 @@ exports.examples = [
},
{
title: 'RCTRootView\'s size flexibility',
render(): React.Element<any> {
render(): React.Component {
return (
<RootViewSizeFlexibilityExample/>
);
-15
View File
@@ -35,21 +35,6 @@ Open the UIExplorer app in your emulator.
See [Running on Device](https://facebook.github.io/react-native/docs/running-on-device-android.html) in case you want to use a physical device.
### Running with Buck
Follow the same setup as running with gradle.
Install Buck from [here](https://buckbuild.com/setup/install.html).
Run the following commands from the react-native folder:
./gradlew :ReactAndroid:packageReactNdkLibsForBuck
buck fetch uiexplorer
buck install -r uiexplorer
./packager/packager.sh
_Note: The native libs are still built using gradle. Full build with buck is coming soon(tm)._
## Built from source
Building the app on both iOS and Android means building the React Native framework from source. This way you're running the latest native and JS code the way you see it in your clone of the github repo.
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -21,8 +14,7 @@
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const React = require('react-native');
const {
ScrollView,
StyleSheet,
@@ -30,7 +22,7 @@ const {
Text,
TouchableWithoutFeedback,
View,
} = ReactNative;
} = React;
const styles = StyleSheet.create({
row: {
@@ -49,12 +41,11 @@ const styles = StyleSheet.create({
},
});
class Row extends React.Component {
_onClick = () => {
const Row = React.createClass({
_onClick: function() {
this.props.onClick(this.props.data);
};
render() {
},
render: function() {
return (
<TouchableWithoutFeedback onPress={this._onClick} >
<View style={styles.row}>
@@ -64,26 +55,30 @@ class Row extends React.Component {
</View>
</TouchableWithoutFeedback>
);
}
}
},
});
class RefreshControlExample extends React.Component {
static title = '<RefreshControl>';
static description = 'Adds pull-to-refresh support to a scrollview.';
const RefreshControlExample = React.createClass({
statics: {
title: '<RefreshControl>',
description: 'Adds pull-to-refresh support to a scrollview.'
},
state = {
isRefreshing: false,
loaded: 0,
rowData: Array.from(new Array(20)).map(
(val, i) => ({text: 'Initial row ' + i, clicks: 0})),
};
getInitialState() {
return {
isRefreshing: false,
loaded: 0,
rowData: Array.from(new Array(20)).map(
(val, i) => ({text: 'Initial row' + i, clicks: 0})),
};
},
_onClick = (row) => {
_onClick(row) {
row.clicks++;
this.setState({
rowData: this.state.rowData,
});
};
},
render() {
const rows = this.state.rowData.map((row, ii) => {
@@ -98,7 +93,6 @@ class RefreshControlExample extends React.Component {
onRefresh={this._onRefresh}
tintColor="#ff0000"
title="Loading..."
titleColor="#00ff00"
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#ffff00"
/>
@@ -106,15 +100,15 @@ class RefreshControlExample extends React.Component {
{rows}
</ScrollView>
);
}
},
_onRefresh = () => {
_onRefresh() {
this.setState({isRefreshing: true});
setTimeout(() => {
// prepend 10 items
const rowData = Array.from(new Array(10))
.map((val, i) => ({
text: 'Loaded row ' + (+this.state.loaded + i),
text: 'Loaded row' + (+this.state.loaded + i),
clicks: 0,
}))
.concat(this.state.rowData);
@@ -125,7 +119,7 @@ class RefreshControlExample extends React.Component {
rowData: rowData,
});
}, 5000);
};
}
},
});
module.exports = RefreshControlExample;
@@ -1,11 +1,4 @@
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
@@ -22,16 +15,13 @@
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var React = require('react-native');
var {
ScrollView,
StyleSheet,
Text,
TouchableOpacity,
View,
Image
} = ReactNative;
} = React;
exports.displayName = (undefined: ?string);
exports.title = '<ScrollView>';
@@ -41,62 +31,43 @@ exports.examples = [
title: '<ScrollView>',
description: 'To make content scrollable, wrap it within a <ScrollView> component',
render: function() {
var _scrollView: ScrollView;
return (
<View>
<ScrollView
ref={(scrollView) => { _scrollView = scrollView; }}
automaticallyAdjustContentInsets={false}
onScroll={() => { console.log('onScroll!'); }}
scrollEventThrottle={200}
style={styles.scrollView}>
{THUMBS.map(createThumbRow)}
</ScrollView>
<TouchableOpacity
style={styles.button}
onPress={() => { _scrollView.scrollTo({y: 0}); }}>
<Text>Scroll to top</Text>
</TouchableOpacity>
</View>
<ScrollView
automaticallyAdjustContentInsets={false}
onScroll={() => { console.log('onScroll!'); }}
scrollEventThrottle={200}
style={styles.scrollView}>
{THUMBS.map(createThumbRow)}
</ScrollView>
);
}
}, {
title: '<ScrollView> (horizontal = true)',
description: 'You can display <ScrollView>\'s child components horizontally rather than vertically',
render: function() {
var _scrollView: ScrollView;
return (
<View>
<ScrollView
ref={(scrollView) => { _scrollView = scrollView; }}
automaticallyAdjustContentInsets={false}
horizontal={true}
style={[styles.scrollView, styles.horizontalScrollView]}>
{THUMBS.map(createThumbRow)}
</ScrollView>
<TouchableOpacity
style={styles.button}
onPress={() => { _scrollView.scrollTo({x: 0}); }}>
<Text>Scroll to start</Text>
</TouchableOpacity>
</View>
<ScrollView
automaticallyAdjustContentInsets={false}
horizontal={true}
style={[styles.scrollView, styles.horizontalScrollView]}>
{THUMBS.map(createThumbRow)}
</ScrollView>
);
}
}];
class Thumb extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
var Thumb = React.createClass({
shouldComponentUpdate: function(nextProps, nextState) {
return false;
}
render() {
},
render: function() {
return (
<View style={styles.button}>
<Image style={styles.img} source={{uri:this.props.uri}} />
</View>
);
}
}
});
var THUMBS = ['https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851549_767334479959628_274486868_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851561_767334496626293_1958532586_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851579_767334503292959_179092627_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851589_767334513292958_1747022277_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851563_767334559959620_1193692107_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851593_767334566626286_1953955109_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851591_767334523292957_797560749_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851567_767334529959623_843148472_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851548_767334489959627_794462220_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851575_767334539959622_441598241_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/t39.1997/p128x128/851573_767334549959621_534583464_n.png', 'https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/t39.1997/p128x128/851583_767334573292952_1519550680_n.png'];
THUMBS = THUMBS.concat(THUMBS); // double length of THUMBS

Some files were not shown because too many files have changed in this diff Show More