Compare commits

..
18 Commits
Author SHA1 Message Date
Mike Grabowski a3268f7dd1 [0.27.2] Bump version numbers 2016-06-09 01:52:24 +02:00
Mike Grabowski 8abca24268 Add Keyboard to exported APIs 2016-06-09 01:43:54 +02:00
Martin Konicek 8074b09e7d [0.27.1] Bump version numbers 2016-06-07 00:58:08 +01:00
Andrej Badin a6b8110528 Fix scrolling issue on iOS devices.
Summary:
It was not possible to scroll due to overlaying (and visually not present) docs navigation layer.

Fixes issue introduced in PR #7669, see this [comment](https://github.com/facebook/react-native/pull/7669#issuecomment-220784882)
Additionally, script makes sure only single target is "in" and closes any other target with "in" state.
Closes https://github.com/facebook/react-native/pull/7731

Differential Revision: D3344927

Pulled By: vjeux

fbshipit-source-id: b2c64d90a2a6e531a9be79b936d6a5da61a69b22
2016-06-07 00:54:16 +01:00
Ben Alpert 877df8cb1a Change survey image
Reviewed By: vjeux

Differential Revision: D3362968

fbshipit-source-id: f6de18a5f27e32e6bb64a65bc233d741cb276f41
2016-06-07 00:54:11 +01:00
Andrej Badin fe189c18aa Improve Navigation panel column layout for landscape/portrait
Summary:
Improve column layout for _phone vs. tablet_ & _portrait vs landscape_ variations.
This change only affects handheld devices, or devices with really small (physical) screen dimensions.

See previews bellow:

Phone - landscape
![phone-landscape](https://cloud.githubusercontent.com/assets/829963/15448311/53863428-1f5e-11e6-9e05-d98587b9752f.png)

Phone - portrait
![phone-portrait](https://cloud.githubusercontent.com/assets/829963/15448309/5385eb9e-1f5e-11e6-8d12-6bda7e1d2e7f.png)

Tablet - landscape
![tablet-landscape](https://cloud.githubusercontent.com/assets/829963/15448312/538719a6-1f5e-11e6-9a2c-52d0c9109f09.png)

Tablet - portrait
![tablet-portrait](https://cloud.githubusercontent.com/assets/829963/15448310/53862636-1f5e-11e6-87ff-727568d7dd1f.png)
Closes https://github.com/facebook/react-native/pull/7669

Differential Revision: D3332676

Pulled By: vjeux

fbshipit-source-id: 8cfc1903e35fd62c82fcd8dd1e05a1e2062c555d
2016-06-07 00:54:02 +01:00
Mike Grabowski 37cc5cfb0c [0.27.0] Bump version numbers 2016-06-06 10:21:36 +02:00
Eloy Durán 41fa6e7f45 Add C++ and standard v14 settings.
Summary:
This PR adds the C++ stdlib to the linker flags and sets the C++ standard that’s used to v14.

I have tested this with my app, without it any CP build would fail unless users add those flags to the generated projects themselves.

/cc grabbou
Closes https://github.com/facebook/react-native/pull/7800

Differential Revision: D3360421

fbshipit-source-id: 0a80030dd255f073a201acc6e1c846be114c2c2a
2016-06-06 10:19:25 +02:00
Konstantin Raev 8b734173d3 [0.27.0-rc3] Bump version numbers 2016-06-05 19:47:08 +01:00
Konstantin Raev 252102588d [0.27.0-rc.3] Bump version numbers 2016-06-05 17:19:23 +01:00
Martin Konicek 76003f3720 [0.27.0-rc2] Bump version numbers 2016-05-27 16:51:49 +01:00
Eric Rozell 3cabf4f98f Update node-haste dependency to 2.12.0
Summary:
Update to node-haste 2.12.0 to support pass through configuration of supported platforms.
Closes https://github.com/facebook/react-native/pull/7660

Differential Revision: D3335034

Pulled By: mkonicek

fbshipit-source-id: d238b90a90d51654301d61251ceb26d183fef57a
2016-05-27 16:42:19 +01:00
Mike Grabowski bbccdd5b84 [0.27.0-rc1] Bump version numbers 2016-05-25 02:26:29 +02:00
David Aurelio cacf6b1267 Respect original enumerability/writability when polyfilling globals
Summary:
Reuses the original property descriptor when overwriting / polyfilling globals to ensure enumerability and writability are the same
Closes https://github.com/facebook/react-native/pull/7704

Differential Revision: D3338119

Pulled By: davidaurelio

fbshipit-source-id: ab456324a3346cd3ec8b2c3e3a2378408c92087c
2016-05-25 01:55:58 +02:00
Konstantin Raev 934acd809d Made npm deployment to be independent of git tags cache
Summary:
Fixes npm deployment script as in https://circleci.com/gh/facebook/react-native/6745.

Example situation:
- admin is ready to release 0.26.0
- admin adds tag v0.26.0 and pushes to origin
- Circle CI build fails because of code error
- admin cherry-picks a fix and tags v0.26.0 again and pushes to origin
- Circle does not update local tag v0.26.0 because it already has it cached, compiles the code but fails to deploy to npm because v0.26.0 is not on branch HEAD from Circle point of view

The previous version of the script was checking the tags on current commit as well but it used the local branch tags.
This change fetches tags from `origin` fresh and allows us to redeploy the same version multiple times.
Closes https://github.com/facebook/react-native/pull/7619

Differential Revision: D3334469

fbshipit-source-id: b423fc19516dc4f5f7f2605224e62b8a378c8a7d
2016-05-25 01:53:59 +02:00
Marc Horowitz 24a806a9f1 Fix chrome debugging on android
Summary:
Java loadApplicationScript changed, but the C++ code in the
debug ProxyExecutor which called it did not.  This fixes the fbjni
method lookup.

fixes #7659

Reviewed By: AaaChiuuu

Differential Revision: D3331472

fbshipit-source-id: 33312dccc3c7687f51742e42f9e0397f9c925e76
2016-05-25 01:53:29 +02:00
James Ide 7d1b4d681a [React] Use React 15.1.0 and stop using the alpha 2016-05-23 11:16:31 -07:00
Mike Grabowski 0f9e31cce8 [0.27.0-rc] Bump version numbers 2016-05-20 20:23:00 +02:00
1862 changed files with 39493 additions and 83018 deletions
-2
View File
@@ -21,7 +21,6 @@
"__fbBatchedBridgeConfig": false,
"alert": false,
"cancelAnimationFrame": false,
"cancelIdleCallback": false,
"clearImmediate": true,
"clearInterval": false,
"clearTimeout": false,
@@ -41,7 +40,6 @@
"process": false,
"Promise": true,
"requestAnimationFrame": true,
"requestIdleCallback": true,
"require": false,
"Set": true,
"setImmediate": true,
+63 -24
View File
@@ -1,28 +1,71 @@
[ignore]
# We fork some components by platform.
.*/*[.]android.js
.*/*.web.js
.*/*.android.js
# Ignore templates with `@flow` in header
# Some modules have their own node_modules with overlap
.*/node_modules/node-haste/.*
# Ugh
.*/node_modules/babel.*
.*/node_modules/babylon.*
.*/node_modules/invariant.*
# 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/ErrorUtils.js
# 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
.*/__mocks__/.*
.*/__tests__/.*
.*/commoner/test/source/widget/share.js
# Ignore commoner tests
.*/node_modules/commoner/test/.*
# 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/.*
# Ignore generators
.*/local-cli/generator.*
# Ignore malformed json
# Ignore BUCK generated folders
.*\.buckd/
# Ignore RNPM
.*/local-cli/rnpm/.*
.*/node_modules/is-my-json-valid/test/.*\.json
.*/node_modules/iconv-lite/encodings/tables/.*\.json
.*/node_modules/y18n/test/.*\.json
.*/node_modules/spdx-license-ids/spdx-license-ids.json
.*/node_modules/spdx-exceptions/index.json
.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
.*/node_modules/resolve/lib/core.json
.*/node_modules/jsonparse/samplejson/.*\.json
.*/node_modules/json5/test/.*\.json
.*/node_modules/ua-parser-js/test/.*\.json
.*/node_modules/builtin-modules/builtin-modules.json
.*/node_modules/binary-extensions/binary-extensions.json
.*/node_modules/url-regex/tlds.json
.*/node_modules/joi/.*\.json
.*/node_modules/isemail/.*\.json
.*/node_modules/tr46/.*\.json
# Ignore the website subdir
<PROJECT_ROOT>/website/.*
# Ignore BUCK generated dirs
<PROJECT_ROOT>/\.buckd/
# Ignore unexpected extra @providesModule
.*/node_modules/commoner/test/source/widget/share.js
# 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__/.*
[include]
@@ -36,8 +79,6 @@ 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'
@@ -47,11 +88,9 @@ suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-2]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-2]\\|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-5]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-5]\\|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.32.0
^0.25.0
-42
View File
@@ -1,42 +0,0 @@
## Hey there and thank you for using React Native!
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. Before opening a new issue, make sure to carefully read the following guidelines.
- Is this something you can **debug and fix**?
Send a pull request! Bug fixes and documentation fixes are welcome.
- Have a **usage** question?
We use GitHub Issues for bugs. Ask your usage question on Stack Overflow: http://stackoverflow.com/questions/tagged/react-native
- Have an idea for a **feature**?
Post the feature request on Product Pains, which has a voting system to surface important issues: https://productpains.com/product/react-native/
GitHub issues should only be used for bugs. Make sure these boxes are checked before submitting your issue:
- [ ] You're using the latest release of React Native: https://github.com/facebook/react-native/releases
- [ ] You've searched through existing issues: https://github.com/facebook/react-native/issues
Chances are that your issue has been reported or resolved before.
- [ ] You have filled out the template below, or provided an equivalent amount of detail.
Issues without sufficient information will be labeled 'Needs more information' and will be closed until there is enough information.
Describe your issue in as much detail as possible. Provide **screenshots** where appropriate. Provide a **minimal code snippet** / [rnplay](https://rnplay.org/) example that reproduces the bug, or include a list of detailed list of steps that reproduce the issue.
--- delete everything above this line before submitting your issue ---
### Issue Description
[FILL THIS OUT]
### Steps to Reproduce / Code Snippets
[FILL THIS OUT]
#### Expected Results
[FILL THIS OUT]
### Additional Information
* React Native version: [FILL THIS OUT]
* Platform(s) (iOS, Android, or both?): [FILL THIS OUT]
* Operating System (macOS, Linux, or Windows?): [FILL THIS OUT]
+4 -4
View File
@@ -7,15 +7,15 @@ install:
- export NVM_DIR="/Users/travis/build/facebook/.nvm"
- brew install nvm
- source $(brew --prefix nvm)/nvm.sh
# TODO npm 2 started stalling on Travis, t11852928
- nvm install 5
# testing with npm@2 for diversity, Circle tests with npm@3
- nvm install 4.4.3
- rm -Rf "${TMPDIR}/jest_preprocess_cache"
- npm config set spin=false
- npm config set progress=false
- travis_wait npm install
- npm install
script:
- if [[ "$TEST_TYPE" = objc ]]; then travis_retry travis_wait ./scripts/objc-test.sh; fi
- if [[ "$TEST_TYPE" = objc ]]; then travis_retry ./scripts/objc-test.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
+9 -16
View File
@@ -14,29 +14,22 @@ 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!
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
```
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>`).
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.
8. Squash your commits (`git rebase -i`).
9. If you haven't already, sign the [CLA](https://code.facebook.com/cla).
#### Copyright Notice for files
@@ -101,7 +94,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
+2 -80
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;
@@ -415,7 +337,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 +377,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"
+3 -3
View File
@@ -31,8 +31,8 @@ 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') {
@@ -66,7 +66,7 @@ class MovieCell extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
textContainer: {
+12 -12
View File
@@ -29,8 +29,8 @@ 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}>
@@ -57,11 +57,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 +81,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 +100,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;
@@ -446,7 +429,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 +469,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"
+3 -3
View File
@@ -65,8 +65,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 +77,7 @@ class MoviesApp extends React.Component {
/>
);
}
}
});
var styles = StyleSheet.create({
container: {
+3 -3
View File
@@ -26,8 +26,8 @@ var {
var SearchScreen = require('./SearchScreen');
class MoviesApp extends React.Component {
render() {
var MoviesApp = React.createClass({
render: function() {
return (
<NavigatorIOS
style={styles.container}
@@ -38,7 +38,7 @@ class MoviesApp extends React.Component {
/>
);
}
}
});
var styles = StyleSheet.create({
container: {
+16 -11
View File
@@ -21,7 +21,7 @@ var ReactNative = require('react-native');
var {
Image,
Platform,
ActivityIndicator,
ProgressBarAndroid,
TextInput,
StyleSheet,
TouchableNativeFeedback,
@@ -30,8 +30,19 @@ var {
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 +69,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 +94,6 @@ var styles = StyleSheet.create({
spinner: {
width: 30,
height: 30,
marginRight: 16,
},
icon: {
width: 24,
+5 -5
View File
@@ -19,14 +19,14 @@
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicator,
ActivityIndicatorIOS,
TextInput,
StyleSheet,
View,
} = ReactNative;
class SearchBar extends React.Component {
render() {
var SearchBar = React.createClass({
render: function() {
return (
<View style={styles.searchBar}>
<TextInput
@@ -37,14 +37,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: {
+14 -6
View File
@@ -18,9 +18,10 @@
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicator,
ActivityIndicatorIOS,
ListView,
Platform,
ProgressBarAndroid,
StyleSheet,
Text,
View,
@@ -249,8 +250,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(
@@ -318,8 +326,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 +343,7 @@ class NoMovies extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
container: {
@@ -12,7 +12,6 @@
android:targetSdkVersion="22" />
<application
android:name=".MoviesApplication"
android:allowBackup="true"
android:label="@string/app_name"
android:icon="@drawable/rotten_tomatoes_icon"
@@ -14,10 +14,39 @@
package com.facebook.react.movies;
import com.facebook.react.ReactActivity;
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 MoviesActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "MoviesApp";
}
@Override
protected @Nullable String getBundleAssetName() {
return "MoviesApp.android.bundle";
};
@Override
protected String getJSMainModuleName() {
return "Examples/Movies/MoviesApp.android";
}
@Override
protected boolean getUseDeveloperSupport() {
return true;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
);
}
}
@@ -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;
}
}
@@ -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;
@@ -444,7 +397,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 +437,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"
+10 -10
View File
@@ -94,8 +94,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 +104,9 @@ class Cell extends React.Component {
default:
return null;
}
};
},
textStyle = () => {
textStyle() {
switch (this.props.player) {
case 1:
return styles.cellTextX;
@@ -115,9 +115,9 @@ class Cell extends React.Component {
default:
return {};
}
};
},
textContents = () => {
textContents() {
switch (this.props.player) {
case 1:
return 'X';
@@ -126,7 +126,7 @@ class Cell extends React.Component {
default:
return '';
}
};
},
render() {
return (
@@ -142,9 +142,9 @@ class Cell extends React.Component {
</TouchableHighlight>
);
}
}
});
class GameEndOverlay extends React.Component {
var GameEndOverlay = React.createClass({
render() {
var board = this.props.board;
@@ -175,7 +175,7 @@ class GameEndOverlay extends React.Component {
</View>
);
}
}
});
var TicTacToeApp = React.createClass({
getInitialState() {
-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,23 +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 com.facebook.react.ReactActivity;
public class TicTacToeActivity extends ReactActivity {
@Override
protected String getMainComponentName() {
return "TicTacToeApp";
}
}
@@ -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.
*
@@ -36,35 +29,40 @@ 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 +195,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.
*
@@ -29,7 +22,7 @@ var {
View,
} = ReactNative;
class AccessibilityIOSExample extends React.Component {
var AccessibilityIOSExample = React.createClass({
render() {
return (
<View>
@@ -60,14 +53,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(): ReactElement<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.
*
@@ -42,10 +35,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 +53,9 @@ class ActionSheetExample extends React.Component {
</Text>
</View>
);
}
},
showActionSheet = () => {
showActionSheet() {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
@@ -69,13 +64,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 +85,9 @@ class ActionSheetTintExample extends React.Component {
</Text>
</View>
);
}
},
showActionSheet = () => {
showActionSheet() {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
@@ -100,13 +97,15 @@ 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,9 +118,9 @@ class ShareActionSheetExample extends React.Component {
</Text>
</View>
);
}
},
showShareActionSheet = () => {
showShareActionSheet() {
ActionSheetIOS.showShareActionSheetWithOptions({
url: this.props.url,
message: 'message to go with the shared url',
@@ -140,13 +139,15 @@ class ShareActionSheetExample extends React.Component {
}
this.setState({text});
});
};
}
}
});
class ShareScreenshotExample extends React.Component {
state = {
text: ''
};
var ShareScreenshotExample = React.createClass({
getInitialState() {
return {
text: ''
};
},
render() {
return (
@@ -159,9 +160,9 @@ class ShareScreenshotExample extends React.Component {
</Text>
</View>
);
}
},
showShareActionSheet = () => {
showShareActionSheet() {
// Take the snapshot (returns a temp file uri)
UIManager.takeSnapshot('window').then((uri) => {
// Share image data
@@ -182,8 +183,8 @@ class ShareScreenshotExample extends React.Component {
this.setState({text});
});
}).catch((error) => alert(error));
};
}
}
});
var style = StyleSheet.create({
button: {
@@ -197,27 +198,27 @@ exports.description = 'Interface to show iOS\' action sheets';
exports.examples = [
{
title: 'Show Action Sheet',
render(): ReactElement<any> { return <ActionSheetExample />; }
render(): ReactElement { return <ActionSheetExample />; }
},
{
title: 'Show Action Sheet with tinted buttons',
render(): ReactElement<any> { return <ActionSheetTintExample />; }
render(): ReactElement { return <ActionSheetTintExample />; }
},
{
title: 'Show Share Action Sheet',
render(): ReactElement<any> {
render(): ReactElement {
return <ShareActionSheetExample url="https://code.facebook.com" />;
}
},
{
title: 'Share Local Image',
render(): ReactElement<any> {
render(): ReactElement {
return <ShareActionSheetExample url="bunny.png" />;
}
},
{
title: 'Share Screenshot',
render(): ReactElement<any> {
render(): ReactElement {
return <ShareScreenshotExample />;
}
}
@@ -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,76 @@
*/
'use strict';
import React, { Component } from 'react';
import { ActivityIndicator, StyleSheet, View } from 'react-native';
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicatorIOS,
StyleSheet,
View,
} = ReactNative;
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 +92,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 +142,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 +159,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.
*
@@ -38,19 +31,21 @@ exports.description = 'Example of using the ad support API.';
exports.examples = [
{
title: 'Ad Support IOS',
render: function(): ReactElement<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 +55,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 +95,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.
*
@@ -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: {
@@ -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.
*
@@ -45,7 +38,7 @@ exports.examples = [{
},
{
title: 'Prompt Options',
render(): ReactElement<any> {
render(): ReactElement {
return <PromptOptions />;
}
},
@@ -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.
*
@@ -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.
*
@@ -89,7 +82,7 @@ class Circle extends React.Component {
});
}
render(): ReactElement<any> {
render(): ReactElement {
if (this.state.panResponder) {
var handlers = this.state.panResponder.panHandlers;
var dragStyle = { // Used to position while dragging
@@ -190,7 +183,7 @@ class AnExApp extends React.Component {
this._onMove = this._onMove.bind(this);
}
render(): ReactElement<any> {
render(): ReactElement {
var circles = this.state.keys.map((key, idx) => {
if (key === this.state.activeKey) {
return <Circle key={key + 'd'} dummy={true} />;
@@ -288,6 +281,7 @@ function moveToClosest({activeKey, keys, restLayouts}, position) {
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.
*
@@ -96,7 +89,7 @@ class AnExBobble extends React.Component {
});
}
render(): ReactElement<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.
*
@@ -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.
*
@@ -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,7 +45,7 @@ class AnExSet extends React.Component {
openColor: randColor(),
};
}
render(): ReactElement<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.
*
@@ -97,7 +90,7 @@ class AnExTilt extends React.Component {
this._startBurnsZoom();
}
render(): ReactElement<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.
*
@@ -23,52 +16,36 @@
*/
'use strict';
const React = require('react');
const ReactNative = require('react-native');
const {
var React = require('react');
var ReactNative = require('react-native');
var {
AppState,
Text,
View
} = ReactNative;
class AppStateSubscription extends React.Component {
state = {
appState: AppState.currentState,
previousAppStates: [],
memoryWarnings: 0,
};
componentDidMount() {
var AppStateSubscription = React.createClass({
getInitialState() {
return {
appState: AppState.currentState,
previousAppStates: [],
};
},
componentDidMount: function() {
AppState.addEventListener('change', this._handleAppStateChange);
AppState.addEventListener('memoryWarning', this._handleMemoryWarning);
}
componentWillUnmount() {
},
componentWillUnmount: function() {
AppState.removeEventListener('change', this._handleAppStateChange);
AppState.removeEventListener('memoryWarning', this._handleMemoryWarning);
}
_handleMemoryWarning = () => {
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 (
<View>
<Text>{this.state.memoryWarnings}</Text>
</View>
);
}
if (this.props.showCurrentOnly) {
return (
<View>
@@ -82,7 +59,7 @@ class AppStateSubscription extends React.Component {
</View>
);
}
}
});
exports.title = 'AppState';
exports.description = 'app background status';
@@ -95,16 +72,10 @@ exports.examples = [
{
title: 'Subscribed AppState:',
description: 'This changes according to the current state, so you can only ever see it rendered as "active"',
render(): ReactElement<any> { return <AppStateSubscription showCurrentOnly={true} />; }
render(): ReactElement { return <AppStateSubscription showCurrentOnly={true} />; }
},
{
title: 'Previous states:',
render(): ReactElement<any> { return <AppStateSubscription showCurrentOnly={false} />; }
},
{
platform: 'ios',
title: 'Memory Warnings',
description: 'In the IOS simulator, hit Shift+Command+M to simulate a memory warning.',
render(): ReactElement<any> { return <AppStateSubscription showMemoryWarnings={true} />; }
render(): ReactElement { return <AppStateSubscription showCurrentOnly={false} />; }
},
];
+99
View File
@@ -0,0 +1,99 @@
/**
* 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.
*
* @providesModule AppStateIOSExample
* @flow
*/
'use strict';
var React = require('react');
var ReactNative = require('react-native');
var {
AppStateIOS,
Text,
View
} = ReactNative;
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: function(appState) {
var previousAppStates = this.state.previousAppStates.slice();
previousAppStates.push(this.state.appState);
this.setState({
appState,
previousAppStates,
});
},
render() {
if (this.props.showMemoryWarnings) {
return (
<View>
<Text>{this.state.memoryWarnings}</Text>
</View>
);
}
if (this.props.showCurrentOnly) {
return (
<View>
<Text>{this.state.appState}</Text>
</View>
);
}
return (
<View>
<Text>{JSON.stringify(this.state.previousAppStates)}</Text>
</View>
);
}
});
exports.title = 'AppStateIOS';
exports.description = 'iOS app background status';
exports.examples = [
{
title: 'AppStateIOS.currentState',
description: 'Can be null on app initialization',
render() { return <Text>{AppStateIOS.currentState}</Text>; }
},
{
title: 'Subscribed AppStateIOS:',
description: 'This changes according to the current state, so you can only ever see it rendered as "active"',
render(): ReactElement { return <AppStateSubscription showCurrentOnly={true} />; }
},
{
title: 'Previous states:',
render(): ReactElement { return <AppStateSubscription showCurrentOnly={false} />; }
},
{
title: 'Memory Warnings',
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.
*
@@ -31,10 +24,13 @@ var {
ScrollView
} = ReactNative;
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 +50,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.
*
@@ -35,17 +28,12 @@ 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 +45,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 +84,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 +94,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(): ReactElement<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.
*
@@ -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.
*
@@ -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.
*
@@ -27,7 +20,7 @@ const ReactNative = require('react-native');
const {
CameraRoll,
Image,
Slider,
SliderIOS,
StyleSheet,
Switch,
Text,
@@ -35,43 +28,45 @@ const {
TouchableOpacity
} = ReactNative;
const invariant = require('invariant');
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 +75,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 +91,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 +137,6 @@ exports.description = 'Example component that uses CameraRoll to list user\'s ph
exports.examples = [
{
title: 'Photos',
render(): ReactElement<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.
*
@@ -26,7 +19,7 @@
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicator,
ActivityIndicatorIOS,
CameraRoll,
Image,
ListView,
@@ -148,7 +141,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;
}
@@ -198,7 +191,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.
*
@@ -30,12 +23,14 @@ var {
Text,
} = ReactNative;
class ClipboardExample extends React.Component {
state = {
content: 'Content will appear here'
};
var ClipboardExample = React.createClass({
getInitialState() {
return {
content: 'Content will appear here'
};
},
_setClipboardContent = async () => {
async _setClipboardContent(){
Clipboard.setString('Hello World');
try {
var content = await Clipboard.getString();
@@ -43,7 +38,7 @@ class ClipboardExample extends React.Component {
} catch (e) {
this.setState({content:e.message});
}
};
},
render() {
return (
@@ -57,7 +52,7 @@ class ClipboardExample extends React.Component {
</View>
);
}
}
});
exports.title = 'Clipboard';
exports.description = 'Show Clipboard contents.';
@@ -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.
*
@@ -32,21 +25,26 @@ var {
var UIExplorerBlock = require('./UIExplorerBlock');
var UIExplorerPage = require('./UIExplorerPage');
class DatePickerAndroidExample extends React.Component {
static title = 'DatePickerAndroid';
static description = 'Standard Android date picker dialog';
var DatePickerAndroidExample = React.createClass({
state = {
presetDate: new Date(2020, 4, 5),
allDate: new Date(2020, 4, 5),
simpleText: 'pick a date',
minText: 'pick a date, no earlier than today',
maxText: 'pick a date, no later than today',
presetText: 'pick a date, preset to 2020/5/5',
allText: 'pick a date between 2020/5/1 and 2020/5/10',
};
statics: {
title: 'DatePickerAndroid',
description: 'Standard Android date picker dialog',
},
showPicker = async (stateKey, options) => {
getInitialState() {
return {
presetDate: new Date(2020, 4, 5),
allDate: new Date(2020, 4, 5),
simpleText: 'pick a date',
minText: 'pick a date, no earlier than today',
maxText: 'pick a date, no later than today',
presetText: 'pick a date, preset to 2020/5/5',
allText: 'pick a date between 2020/5/1 and 2020/5/10',
};
},
async showPicker(stateKey, options) {
try {
var newState = {};
const {action, year, month, day} = await DatePickerAndroid.open(options);
@@ -61,7 +59,7 @@ class DatePickerAndroidExample extends React.Component {
} catch ({code, message}) {
console.warn(`Error in example '${stateKey}': `, message);
}
};
},
render() {
return (
@@ -108,8 +106,8 @@ class DatePickerAndroidExample extends React.Component {
</UIExplorerBlock>
</UIExplorerPage>
);
}
}
},
});
var styles = StyleSheet.create({
text: {
@@ -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.
*
@@ -32,30 +25,34 @@ var {
View,
} = ReactNative;
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 +96,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 +112,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 +124,7 @@ class Heading extends React.Component {
</View>
);
}
}
});
exports.displayName = (undefined: ?string);
exports.title = '<DatePickerIOS>';
@@ -135,7 +132,7 @@ exports.description = 'Select dates and times using the native UIDatePicker.';
exports.examples = [
{
title: '<DatePickerIOS>',
render: function(): ReactElement<any> {
render: function(): ReactElement {
return <DatePickerExample />;
},
}];
@@ -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.
*
@@ -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.
*
@@ -39,40 +32,42 @@ exports.description = 'Examples of using the Geolocation API.';
exports.examples = [
{
title: 'navigator.geolocation',
render: function(): ReactElement<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 +81,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.
*
@@ -32,8 +25,8 @@ var {
View,
} = ReactNative;
class ImageCapInsetsExample extends React.Component {
render() {
var ImageCapInsetsExample = React.createClass({
render: function() {
return (
<View>
<View style={styles.background}>
@@ -61,7 +54,7 @@ class ImageCapInsetsExample extends React.Component {
</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.
*
@@ -25,12 +25,12 @@
var React = require('react');
var ReactNative = require('react-native');
var {
ActivityIndicator,
Image,
Platform,
StyleSheet,
Text,
View,
ActivityIndicatorIOS
} = ReactNative;
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==';
@@ -61,15 +61,7 @@ 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)`);
}
}}
onLoad={() => this._loadEventFired(`✔ onLoad (+${new Date() - mountTime}ms)`)}
onLoadEnd={() => {
this._loadEventFired(`✔ onLoadEnd (+${new Date() - mountTime}ms)`);
this.setState({startLoadPrefetched: true}, () => {
@@ -86,15 +78,7 @@ var NetworkImageCallbackExample = React.createClass({
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)`);
}
}}
onLoad={() => this._loadEventFired(`✔ (prefetched) onLoad (+${new Date() - mountTime}ms)`)}
onLoadEnd={() => this._loadEventFired(`✔ (prefetched) onLoadEnd (+${new Date() - mountTime}ms)`)}
/>
: null}
@@ -124,7 +108,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 +156,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>';
@@ -521,18 +448,6 @@ exports.examples = [
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]}>
@@ -594,57 +509,7 @@ exports.examples = [
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!LegacyImage')}
/>
);
},
},
{
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>
);
},
platform: 'ios',
},
];
@@ -703,8 +568,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.
*
@@ -32,22 +25,25 @@ const {
TouchableOpacity,
} = ReactNative;
class AddRemoveExample extends React.Component {
state = {
views: [],
};
const AddRemoveExample = React.createClass({
getInitialState() {
return {
views: [],
};
},
componentWillUpdate() {
LayoutAnimation.easeInEaseOut();
}
},
_onPressAddView = () => {
_onPressAddView() {
this.setState((state) => ({views: [...state.views, {}]}));
};
},
_onPressRemoveView = () => {
_onPressRemoveView() {
this.setState((state) => ({views: state.views.slice(0, -1)}));
};
},
render() {
const views = this.state.views.map((view, i) =>
@@ -72,8 +68,8 @@ class AddRemoveExample extends React.Component {
</View>
</View>
);
}
}
},
});
const GreenSquare = () =>
<View style={styles.greenSquare}>
@@ -85,15 +81,18 @@ const BlueSquare = () =>
<Text>Blue square</Text>
</View>;
class CrossFadeExample extends React.Component {
state = {
toggled: false,
};
const CrossFadeExample = React.createClass({
_onPressToggle = () => {
getInitialState() {
return {
toggled: false,
};
},
_onPressToggle() {
LayoutAnimation.easeInEaseOut();
this.setState((state) => ({toggled: !state.toggled}));
};
},
render() {
return (
@@ -112,8 +111,8 @@ class CrossFadeExample extends React.Component {
</View>
</View>
);
}
}
},
});
const styles = StyleSheet.create({
container: {
@@ -161,12 +160,12 @@ exports.title = 'Layout Animation';
exports.description = 'Layout animation';
exports.examples = [{
title: 'Add and remove views',
render(): ReactElement<any> {
render(): ReactElement {
return <AddRemoveExample />;
},
}, {
title: 'Cross fade views',
render(): ReactElement<any> {
render(): ReactElement {
return <CrossFadeExample />;
},
}];
@@ -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.
*
@@ -54,14 +47,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 +68,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 +124,7 @@ class LayoutEventExample extends React.Component {
</View>
);
}
}
});
var styles = StyleSheet.create({
view: {
@@ -170,7 +158,7 @@ exports.description = 'Examples that show how Layout events can be used to ' +
exports.examples = [
{
title: 'LayoutEventExample',
render: function(): ReactElement<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.
*
@@ -33,15 +26,14 @@ var {
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 +41,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 +58,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 +88,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 +144,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.
*
@@ -26,17 +19,18 @@ var {
Linking,
StyleSheet,
Text,
TouchableOpacity,
TouchableNativeFeedback,
View,
} = ReactNative;
var UIExplorerBlock = require('./UIExplorerBlock');
class OpenURLButton extends React.Component {
static propTypes = {
url: React.PropTypes.string,
};
var OpenURLButton = React.createClass({
handleClick = () => {
propTypes: {
url: React.PropTypes.string,
},
handleClick: function() {
Linking.canOpenURL(this.props.url).then(supported => {
if (supported) {
Linking.openURL(this.props.url);
@@ -44,25 +38,28 @@ class OpenURLButton extends React.Component {
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: 'Linking',
description: 'Shows how to use Linking to open URLs.',
},
render: function() {
return (
<UIExplorerBlock title="Open external URLs">
<OpenURLButton url={'https://www.facebook.com'} />
@@ -73,8 +70,8 @@ class IntentAndroidExample extends React.Component {
<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.
*
@@ -65,7 +58,7 @@ var ListViewSimpleExample = React.createClass({
dataSource={this.state.dataSource}
renderRow={this._renderRow}
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
renderSeparator={this._renderSeparator}
renderSeparator={this._renderSeperator}
/>
</UIExplorerPage>
);
@@ -107,7 +100,7 @@ var ListViewSimpleExample = React.createClass({
)});
},
_renderSeparator: function(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
_renderSeperator: function(sectionID: number, rowID: number, adjacentRowHighlighted: bool) {
return (
<View
key={`${sectionID}-${rowID}`}
@@ -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.
*
@@ -130,8 +123,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.
*
@@ -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): ReactElement<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}
@@ -197,14 +186,15 @@ class ListViewPagingExample extends React.Component {
scrollRenderAheadDistance={500}
/>
);
}
},
_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.
*
@@ -160,13 +153,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 +180,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 +204,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 +248,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: {
@@ -383,7 +338,12 @@ exports.examples = [
{
title: 'Draggable pin',
render() {
return <DraggableAnnotationExample/>;
return <AnnotationExample style={styles.map} annotation={{
draggable: true,
onDragStateChange: (event) => {
console.log('Drag state: ' + event.state);
},
}}/>;
}
},
{
@@ -400,7 +360,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 +377,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.
*
@@ -26,7 +19,6 @@ var React = require('react');
var ReactNative = require('react-native');
var {
Modal,
Picker,
StyleSheet,
Switch,
Text,
@@ -34,25 +26,25 @@ var {
View,
} = ReactNative;
const Item = Picker.Item;
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 +61,28 @@ class Button extends React.Component {
</TouchableHighlight>
);
}
}
});
const supportedOrientationsPickerValues = [
['portrait'],
['landscape'],
['landscape-left'],
['portrait', 'landscape-right'],
['portrait', 'landscape'],
[],
];
var ModalExample = React.createClass({
getInitialState() {
return {
animationType: 'none',
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) => {
_setAnimationType(type) {
this.setState({animationType: type});
};
},
_toggleTransparent = () => {
_toggleTransparent() {
this.setState({transparent: !this.state.transparent});
};
},
render() {
var modalBackgroundStyle = {
@@ -118,14 +101,11 @@ class ModalExample extends React.Component {
animationType={this.state.animationType}
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})}
onRequestClose={() => {this._setModalVisible(false)}}
>
<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>
<Button
onPress={this._setModalVisible.bind(this, false)}
style={styles.modalButton}>
@@ -152,29 +132,13 @@ class ModalExample extends React.Component {
<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>
</View>
<Button onPress={this._setModalVisible.bind(this, true)}>
Present
</Button>
</View>
);
}
}
},
});
exports.examples = [
{
@@ -220,7 +184,4 @@ var styles = StyleSheet.create({
modalButton: {
marginTop: 10,
},
pickerItem: {
fontSize: 16,
},
});
@@ -0,0 +1,164 @@
/**
* 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.
*
* 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');
const ReactNative = require('react-native');
const {
Animated,
NavigationExperimental,
StyleSheet,
ScrollView,
} = ReactNative;
const NavigationExampleRow = require('./NavigationExampleRow');
const {
AnimatedView: NavigationAnimatedView,
Card: NavigationCard,
Header: NavigationHeader,
Reducer: NavigationReducer,
} = NavigationExperimental;
const ExampleReducer = NavigationReducer.StackReducer({
getPushedReducerForAction: (action) => {
if (action.type === 'push') {
return (state) => state || {key: action.key};
}
return null;
},
getReducerForState: (initialState) => (state) => state || initialState,
initialState: {
key: 'AnimatedExampleStackKey',
index: 0,
children: [
{key: 'First Route'},
],
},
});
class NavigationAnimatedExample extends React.Component {
constructor(props, context) {
super(props, context);
this.state = ExampleReducer();
}
componentWillMount() {
this._renderCard = this._renderCard.bind(this);
this._renderHeader = this._renderHeader.bind(this);
this._renderScene = this._renderScene.bind(this);
this._renderTitleComponent = this._renderTitleComponent.bind(this);
this._handleAction = this._handleAction.bind(this);
}
_handleAction(action): boolean {
if (!action) {
return false;
}
const newState = ExampleReducer(this.state, action);
if (newState === this.state) {
return false;
}
this.setState(newState);
return true;
}
handleBackAction(): boolean {
return this._handleAction({ type: 'BackAction', });
}
render() {
return (
<NavigationAnimatedView
navigationState={this.state}
style={styles.animatedView}
onNavigate={this._handleAction}
renderOverlay={this._renderHeader}
applyAnimation={(pos, navState) => {
Animated.timing(pos, {toValue: navState.index, duration: 500}).start();
}}
renderScene={this._renderCard}
/>
);
}
_renderHeader(/*NavigationSceneRendererProps*/ props) {
return (
<NavigationHeader
{...props}
renderTitleComponent={this._renderTitleComponent}
/>
);
}
_renderTitleComponent(/*NavigationSceneRendererProps*/ props) {
return (
<NavigationHeader.Title>
{props.scene.navigationState.key}
</NavigationHeader.Title>
);
}
_renderCard(/*NavigationSceneRendererProps*/ props) {
return (
<NavigationCard
{...props}
key={'card_' + props.scene.navigationState.key}
renderScene={this._renderScene}
/>
);
}
_renderScene(/*NavigationSceneRendererProps*/ props) {
return (
<ScrollView style={styles.scrollView}>
<NavigationExampleRow
text={props.scene.navigationState.key}
/>
<NavigationExampleRow
text="Push!"
onPress={() => {
props.onNavigate({
type: 'push',
key: 'Route #' + props.scenes.length,
});
}}
/>
<NavigationExampleRow
text="Exit Animated Nav Example"
onPress={this.props.onExampleExit}
/>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
animatedView: {
flex: 1,
},
scrollView: {
marginTop: NavigationHeader.HEIGHT,
},
});
module.exports = NavigationAnimatedExample;
@@ -0,0 +1,110 @@
/**
* 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.
*
* 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');
const ReactNative = require('react-native');
const {
NavigationExperimental,
ScrollView,
StyleSheet,
} = ReactNative;
const NavigationExampleRow = require('./NavigationExampleRow');
const {
Reducer: NavigationReducer,
} = NavigationExperimental;
const ExampleReducer = NavigationReducer.StackReducer({
getPushedReducerForAction: (action) => {
if (action.type === 'push') {
return (state) => state || {key: action.key};
}
return null;
},
getReducerForState: (initialState) => (state) => state || initialState,
initialState: {
key: 'BasicExampleStackKey',
index: 0,
children: [
{key: 'First Route'},
],
},
});
const NavigationBasicExample = React.createClass({
getInitialState: function() {
return ExampleReducer();
},
render: function() {
return (
<ScrollView style={styles.topView}>
<NavigationExampleRow
text={`Current page: ${this.state.children[this.state.index].key}`}
/>
<NavigationExampleRow
text={`Push page #${this.state.children.length}`}
onPress={() => {
this._handleAction({ type: 'push', key: 'page #' + this.state.children.length });
}}
/>
<NavigationExampleRow
text="pop"
onPress={() => {
this._handleAction({ type: 'BackAction' });
}}
/>
<NavigationExampleRow
text="Exit Basic Nav Example"
onPress={this.props.onExampleExit}
/>
</ScrollView>
);
},
_handleAction(action) {
if (!action) {
return false;
}
const newState = ExampleReducer(this.state, action);
if (newState === this.state) {
return false;
}
this.setState(newState);
return true;
},
handleBackAction() {
return this._handleAction({ type: 'BackAction' });
},
});
const styles = StyleSheet.create({
topView: {
backgroundColor: '#E9E9EF',
flex: 1,
paddingTop: 30,
},
});
module.exports = NavigationBasicExample;
@@ -0,0 +1,165 @@
/**
* 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.
*
* 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 NavigationExampleRow = require('./NavigationExampleRow');
const React = require('react');
const ReactNative = require('react-native');
const {
NavigationExperimental,
StyleSheet,
ScrollView,
} = ReactNative;
const {
CardStack: NavigationCardStack,
StateUtils: NavigationStateUtils,
} = NavigationExperimental;
function createReducer(initialState) {
return (currentState = initialState, action) => {
switch (action.type) {
case 'push':
return NavigationStateUtils.push(currentState, {key: action.key});
case 'BackAction':
case 'back':
case 'pop':
return currentState.index > 0 ?
NavigationStateUtils.pop(currentState) :
currentState;
default:
return currentState;
}
};
}
const ExampleReducer = createReducer({
index: 0,
key: 'exmaple',
children: [{key: 'First Route'}],
});
class NavigationCardStackExample extends React.Component {
constructor(props, context) {
super(props, context);
this.state = {
isHorizontal: true,
navState: ExampleReducer(undefined, {}),
};
}
componentWillMount() {
this._renderScene = this._renderScene.bind(this);
this._toggleDirection = this._toggleDirection.bind(this);
this._handleAction = this._handleAction.bind(this);
}
render() {
return (
<NavigationCardStack
direction={this.state.isHorizontal ? 'horizontal' : 'vertical'}
navigationState={this.state.navState}
onNavigate={this._handleAction}
renderScene={this._renderScene}
style={styles.main}
/>
);
}
_handleAction(action): boolean {
if (!action) {
return false;
}
const newState = ExampleReducer(this.state.navState, action);
if (newState === this.state.navState) {
return false;
}
this.setState({
navState: newState,
});
return true;
}
handleBackAction(): boolean {
return this._handleAction({ type: 'BackAction', });
}
_renderScene(/*NavigationSceneRendererProps*/ props) {
return (
<ScrollView style={styles.scrollView}>
<NavigationExampleRow
text={
this.state.isHorizontal ?
'direction = "horizontal"' :
'direction = "vertical"'
}
onPress={this._toggleDirection}
/>
<NavigationExampleRow
text={'route = ' + props.scene.navigationState.key}
/>
<NavigationExampleRow
text="Push Route"
onPress={() => {
props.onNavigate({
type: 'push',
key: 'Route ' + props.scenes.length,
});
}}
/>
<NavigationExampleRow
text="Pop Route"
onPress={() => {
props.onNavigate({
type: 'pop',
});
}}
/>
<NavigationExampleRow
text="Exit Card Stack Example"
onPress={this.props.onExampleExit}
/>
</ScrollView>
);
}
_toggleDirection() {
this.setState({
isHorizontal: !this.state.isHorizontal,
});
}
}
const styles = StyleSheet.create({
main: {
flex: 1,
},
scrollView: {
marginTop: 64
},
});
module.exports = NavigationCardStackExample;
@@ -0,0 +1,321 @@
/**
* 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.
*
* 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');
const ReactNative = require('react-native');
const NavigationExampleRow = require('./NavigationExampleRow');
const NavigationExampleTabBar = require('./NavigationExampleTabBar');
const {
NavigationExperimental,
ScrollView,
StyleSheet,
View,
} = ReactNative;
const {
CardStack: NavigationCardStack,
Header: NavigationHeader,
Reducer: NavigationReducer,
} = NavigationExperimental;
import type {
NavigationParentState,
NavigationSceneRenderer,
NavigationSceneRendererProps,
} from 'NavigationTypeDefinition';
type Action = {
isExitAction?: boolean,
};
const ExampleExitAction = () => ({
isExitAction: true,
});
ExampleExitAction.match = (action: Action) => (
action && action.isExitAction === true
);
const PageAction = (type) => ({
type,
isPageAction: true,
});
PageAction.match = (action) => (
action && action.isPageAction === true
);
const ExampleProfilePageAction = (type) => ({
...PageAction(type),
isProfilePageAction: true,
});
ExampleProfilePageAction.match = (action) => (
action && action.isProfilePageAction === true
);
const ExampleInfoAction = () => PageAction('InfoPage');
const ExampleNotifProfileAction = () => ExampleProfilePageAction('NotifProfilePage');
const _jsInstanceUniqueId = '' + Date.now();
let _uniqueIdCount = 0;
function pageStateActionMap(action) {
return {
key: 'page-' + _jsInstanceUniqueId + '-' + (_uniqueIdCount++),
type: action.type,
};
}
const ExampleAppReducer = NavigationReducer.TabsReducer({
key: 'AppNavigationState',
initialIndex: 0,
tabReducers: [
NavigationReducer.StackReducer({
getPushedReducerForAction: (action) => {
if (PageAction.match(action) && !ExampleProfilePageAction.match(action)) {
return (state) => (state || pageStateActionMap(action));
}
return null;
},
initialState: {
key: 'notifs',
index: 0,
children: [
{key: 'base', type: 'NotifsPage'},
],
},
}),
NavigationReducer.StackReducer({
getPushedReducerForAction: (action) => {
if (PageAction.match(action) && !ExampleProfilePageAction.match(action)) {
return (state) => (state || pageStateActionMap(action));
}
return null;
},
initialState: {
key: 'settings',
index: 0,
children: [
{key: 'base', type: 'SettingsPage'},
],
},
}),
NavigationReducer.StackReducer({
getPushedReducerForAction: (action) => {
if (PageAction.match(action) || ExampleProfilePageAction.match(action)) {
return (state) => (state || pageStateActionMap(action));
}
return null;
},
initialState: {
key: 'profile',
index: 0,
children: [
{key: 'base', type: 'ProfilePage'},
],
},
}),
],
});
function stateTypeTitleMap(pageState: any) {
switch (pageState.type) {
case 'ProfilePage':
return 'Profile Page';
case 'NotifsPage':
return 'Notifications';
case 'SettingsPage':
return 'Settings';
case 'InfoPage':
return 'Info Page';
case 'NotifProfilePage':
return 'Page in Profile';
}
}
class ExampleTabScreen extends React.Component {
_renderCard: NavigationSceneRenderer;
_renderHeader: NavigationSceneRenderer;
_renderScene: NavigationSceneRenderer;
componentWillMount() {
this._renderHeader = this._renderHeader.bind(this);
this._renderScene = this._renderScene.bind(this);
}
render() {
return (
<NavigationCardStack
style={styles.tabContent}
navigationState={this.props.navigationState}
onNavigate={this.props.onNavigate}
renderOverlay={this._renderHeader}
renderScene={this._renderScene}
/>
);
}
_renderHeader(props: NavigationSceneRendererProps) {
return (
<NavigationHeader
{...props}
renderTitleComponent={this._renderTitleComponent}
/>
);
}
_renderTitleComponent(props: NavigationSceneRendererProps) {
return (
<NavigationHeader.Title>
{stateTypeTitleMap(props.scene.navigationState)}
</NavigationHeader.Title>
);
}
_renderScene(props: NavigationSceneRendererProps) {
const {onNavigate} = props;
return (
<ScrollView style={styles.scrollView}>
<NavigationExampleRow
text="Open page"
onPress={() => {
onNavigate(ExampleInfoAction());
}}
/>
<NavigationExampleRow
text="Open a page in the profile tab"
onPress={() => {
onNavigate(ExampleNotifProfileAction());
}}
/>
<NavigationExampleRow
text="Exit Composition Example"
onPress={() => {
onNavigate(ExampleExitAction());
}}
/>
</ScrollView>
);
}
}
class NavigationCompositionExample extends React.Component {
state: NavigationParentState;
constructor() {
super();
this.state = ExampleAppReducer(undefined, {});
}
handleAction(action: Object): boolean {
if (!action) {
return false;
}
const newState = ExampleAppReducer(this.state, action);
if (newState === this.state) {
return false;
}
this.setState(newState);
return true;
}
handleBackAction(): boolean {
return this.handleAction({ type: 'BackAction' });
}
render() {
if (!this.state) {
return null;
}
return (
<View style={styles.topView}>
<ExampleMainView
navigationState={this.state}
onExampleExit={this.props.onExampleExit}
onNavigate={this.handleAction.bind(this)}
/>
<NavigationExampleTabBar
tabs={this.state.children}
index={this.state.index}
onNavigate={this.handleAction.bind(this)}
/>
</View>
);
}
}
class ExampleMainView extends React.Component {
_renderScene: Function;
_handleNavigation: Function;
componentWillMount() {
this._renderScene = this._renderScene.bind(this);
this._handleNavigation = this._handleNavigation.bind(this);
}
render() {
return (
<View style={styles.tabsContent}>
{this._renderScene()}
</View>
);
}
_renderScene(): ReactElement {
const {navigationState} = this.props;
const childState = navigationState.children[navigationState.index];
return (
<ExampleTabScreen
key={'tab_screen' + childState.key}
navigationState={childState}
onNavigate={this._handleNavigation}
/>
);
}
_handleNavigation(action: Object) {
if (ExampleExitAction.match(action)) {
this.props.onExampleExit();
return;
}
this.props.onNavigate(action);
}
}
const styles = StyleSheet.create({
topView: {
flex: 1,
},
tabsContent: {
flex: 1,
},
scrollView: {
marginTop: NavigationHeader.HEIGHT
},
tabContent: {
flex: 1,
},
});
module.exports = NavigationCompositionExample;
@@ -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.
*
@@ -30,8 +23,8 @@ var {
TouchableHighlight,
} = ReactNative;
class NavigationExampleRow extends React.Component {
render() {
var NavigationExampleRow = React.createClass({
render: function() {
if (this.props.onPress) {
return (
<TouchableHighlight
@@ -51,8 +44,8 @@ class NavigationExampleRow extends React.Component {
</Text>
</View>
);
}
}
},
});
const styles = StyleSheet.create({
row: {
@@ -0,0 +1,83 @@
/**
* 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.
*
* 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 NavigationExperimental = require('NavigationExperimental');
const React = require('react');
const StyleSheet = require('StyleSheet');
const Text = require('Text');
const TouchableOpacity = require('TouchableOpacity');
const View = require('View');
const {
Reducer: NavigationReducer,
} = NavigationExperimental;
const {
JumpToAction,
} = NavigationReducer.TabsReducer;
const NavigationExampleTabBar = React.createClass({
render: function() {
return (
<View style={styles.tabBar}>
{this.props.tabs.map(this._renderTab)}
</View>
);
},
_renderTab: function(tab, index) {
const textStyle = [styles.tabButtonText];
if (this.props.index === index) {
textStyle.push(styles.selectedTabButtonText);
}
return (
<TouchableOpacity
style={styles.tabButton}
key={tab.key}
onPress={() => {
this.props.onNavigate(JumpToAction(index));
}}>
<Text style={textStyle}>
{tab.key}
</Text>
</TouchableOpacity>
);
},
});
const styles = StyleSheet.create({
tabBar: {
height: 50,
flexDirection: 'row',
},
tabButton: {
flex: 1,
},
tabButtonText: {
paddingTop: 20,
textAlign: 'center',
fontSize: 17,
fontWeight: '500',
},
selectedTabButtonText: {
color: 'blue',
},
});
module.exports = NavigationExampleTabBar;
@@ -33,23 +33,28 @@ const View = require('View');
* To learn how to use the Navigation API, take a look at the following example files:
*/
const EXAMPLES = {
'CardStack + Header + Tabs Example': require('./NavigationCardStack-NavigationHeader-Tabs-example'),
'CardStack Example': require('./NavigationCardStack-example'),
'CardStack Without Gestures Example': require('./NavigationCardStack-NoGesture-example'),
'Transitioner + Animated View Example': require('./NavigationTransitioner-AnimatedView-example'),
'Transitioner + Animated View Pager Example': require('./NavigationTransitioner-AnimatedView-pager-example'),
'Tabs': require('./NavigationTabsExample'),
'Basic': require('./NavigationBasicExample'),
'Animated Example': require('./NavigationAnimatedExample'),
'Composition': require('./NavigationCompositionExample'),
'Card Stack Example': require('./NavigationCardStackExample'),
'Tic Tac Toe': require('./NavigationTicTacToeExample'),
};
const EXAMPLE_STORAGE_KEY = 'NavigationExperimentalExample';
class NavigationExperimentalExample extends React.Component {
static title = 'Navigation (Experimental)';
static description = 'Upcoming navigation APIs and animated navigation views';
static external = true;
const NavigationExperimentalExample = React.createClass({
statics: {
title: 'Navigation (Experimental)',
description: 'Upcoming navigation APIs and animated navigation views',
external: true,
},
state = {
example: null,
};
getInitialState: function() {
return {
example: null,
};
},
componentDidMount() {
AsyncStorage.getItem(EXAMPLE_STORAGE_KEY, (err, example) => {
@@ -63,16 +68,16 @@ class NavigationExperimentalExample extends React.Component {
example,
});
});
}
},
setExample = (example) => {
setExample: function(example) {
this.setState({
example,
});
AsyncStorage.setItem(EXAMPLE_STORAGE_KEY, example);
};
},
_renderMenu = () => {
_renderMenu: function() {
let exitRow = null;
if (this.props.onExampleExit) {
exitRow = (
@@ -90,9 +95,9 @@ class NavigationExperimentalExample extends React.Component {
</ScrollView>
</View>
);
};
},
_renderExampleList = () => {
_renderExampleList: function() {
return Object.keys(EXAMPLES).map(exampleName => (
<NavigationExampleRow
key={exampleName}
@@ -102,13 +107,13 @@ class NavigationExperimentalExample extends React.Component {
}}
/>
));
};
},
_exitInnerExample = () => {
_exitInnerExample: function() {
this.setExample('menu');
};
},
handleBackAction = () => {
handleBackAction: function() {
const wasHandledByExample = (
this.exampleRef &&
this.exampleRef.handleBackAction &&
@@ -122,9 +127,9 @@ class NavigationExperimentalExample extends React.Component {
return true;
}
return false;
};
},
render() {
render: function() {
if (this.state.example === 'menu') {
return this._renderMenu();
}
@@ -138,8 +143,8 @@ class NavigationExperimentalExample extends React.Component {
);
}
return null;
}
}
},
});
const styles = StyleSheet.create({
menu: {
@@ -0,0 +1,120 @@
/**
* 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.
*
* 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');
const ReactNative = require('react-native');
const {
NavigationExperimental,
ScrollView,
StyleSheet,
View,
} = ReactNative;
const {
Reducer: NavigationReducer,
} = NavigationExperimental;
const NavigationExampleRow = require('./NavigationExampleRow');
const NavigationExampleTabBar = require('./NavigationExampleTabBar');
class ExmpleTabPage extends React.Component {
render() {
const currentTabRoute = this.props.tabs[this.props.index];
return (
<ScrollView style={styles.tabPage}>
<NavigationExampleRow
text={`Current Tab is: ${currentTabRoute.key}`}
/>
{this.props.tabs.map((tab, index) => (
<NavigationExampleRow
key={tab.key}
text={`Go to ${tab.key}`}
onPress={() => {
this.props.onNavigate(NavigationReducer.TabsReducer.JumpToAction(index));
}}
/>
))}
<NavigationExampleRow
text="Exit Tabs Example"
onPress={this.props.onExampleExit}
/>
</ScrollView>
);
}
}
const ExampleTabsReducer = NavigationReducer.TabsReducer({
tabReducers: [
(lastRoute) => lastRoute || {key: 'one'},
(lastRoute) => lastRoute || {key: 'two'},
(lastRoute) => lastRoute || {key: 'three'},
],
});
class NavigationTabsExample extends React.Component {
constructor() {
super();
this.state = ExampleTabsReducer(undefined, {});
}
render() {
return (
<View style={styles.topView}>
<ExmpleTabPage
tabs={this.state.children}
index={this.state.index}
onExampleExit={this.props.onExampleExit}
onNavigate={this.handleAction.bind(this)}
/>
<NavigationExampleTabBar
tabs={this.state.children}
index={this.state.index}
onNavigate={this.handleAction.bind(this)}
/>
</View>
);
}
handleAction(action) {
if (!action) {
return false;
}
const newState = ExampleTabsReducer(this.state, action);
if (newState === this.state) {
return false;
}
this.setState(newState);
return true;
}
handleBackAction() {
return this.handleAction({ type: 'BackAction' });
}
}
const styles = StyleSheet.create({
topView: {
flex: 1,
paddingTop: 30,
},
tabPage: {
backgroundColor: '#E9E9EF',
},
});
module.exports = NavigationTabsExample;
@@ -0,0 +1,326 @@
/**
* 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.
*
* 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.
*
* @providesModule NavigationTicTacToeExample
* @flow
*/
'use strict';
const React = require('react');
const StyleSheet = require('StyleSheet');
const Text = require('Text');
const TouchableHighlight = require('TouchableHighlight');
const View = require('View');
type GameGrid = Array<Array<?string>>;
const evenOddPlayerMap = ['O', 'X'];
const rowLetterMap = ['a', 'b', 'c'];
function parseGame(game: string): GameGrid {
const gameTurns = game ? game.split('-') : [];
const grid = Array(3);
for (let i = 0; i < 3; i++) {
const row = Array(3);
for (let j = 0; j < 3; j++) {
const turnIndex = gameTurns.indexOf(rowLetterMap[i] + j);
if (turnIndex === -1) {
row[j] = null;
} else {
row[j] = evenOddPlayerMap[turnIndex % 2];
}
}
grid[i] = row;
}
return grid;
}
function playTurn(game: string, row: number, col: number): string {
const turn = rowLetterMap[row] + col;
return game ? (game + '-' + turn) : turn;
}
function getWinner(gameString: string): ?string {
const game = parseGame(gameString);
for (let i = 0; i < 3; i++) {
if (game[i][0] !== null && game[i][0] === game[i][1] &&
game[i][0] === game[i][2]) {
return game[i][0];
}
}
for (let i = 0; i < 3; i++) {
if (game[0][i] !== null && game[0][i] === game[1][i] &&
game[0][i] === game[2][i]) {
return game[0][i];
}
}
if (game[0][0] !== null && game[0][0] === game[1][1] &&
game[0][0] === game[2][2]) {
return game[0][0];
}
if (game[0][2] !== null && game[0][2] === game[1][1] &&
game[0][2] === game[2][0]) {
return game[0][2];
}
return null;
}
function isGameOver(gameString: string): boolean {
if (getWinner(gameString)) {
return true;
}
const game = parseGame(gameString);
for (let i = 0; i < 3; i++) {
for (let j = 0; j < 3; j++) {
if (game[i][j] === null) {
return false;
}
}
}
return true;
}
class Cell extends React.Component {
props: any;
cellStyle() {
switch (this.props.player) {
case 'X':
return styles.cellX;
case 'O':
return styles.cellO;
default:
return null;
}
}
textStyle() {
switch (this.props.player) {
case 'X':
return styles.cellTextX;
case 'O':
return styles.cellTextO;
default:
return {};
}
}
render() {
return (
<TouchableHighlight
onPress={this.props.onPress}
underlayColor="transparent"
activeOpacity={0.5}>
<View style={[styles.cell, this.cellStyle()]}>
<Text style={[styles.cellText, this.textStyle()]}>
{this.props.player}
</Text>
</View>
</TouchableHighlight>
);
}
}
function GameEndOverlay(props) {
if (!isGameOver(props.game)) {
return <View />;
}
const winner = getWinner(props.game);
return (
<View style={styles.overlay}>
<Text style={styles.overlayMessage}>
{winner ? winner + ' wins!' : 'It\'s a tie!'}
</Text>
<TouchableHighlight
onPress={() => props.onNavigate(GameActions.Reset())}
underlayColor="transparent"
activeOpacity={0.5}>
<View style={styles.newGame}>
<Text style={styles.newGameText}>New Game</Text>
</View>
</TouchableHighlight>
</View>
);
}
function TicTacToeGame(props) {
const rows = parseGame(props.game).map((cells, row) =>
<View key={'row' + row} style={styles.row}>
{cells.map((player, col) =>
<Cell
key={'cell' + col}
player={player}
onPress={() => props.onNavigate(GameActions.Turn(row, col))}
/>
)}
</View>
);
return (
<View style={styles.container}>
<Text
style={styles.closeButton}
onPress={props.onExampleExit}>
Close
</Text>
<Text style={styles.title}>EXTREME T3</Text>
<View style={styles.board}>
{rows}
</View>
<GameEndOverlay
game={props.game}
onNavigate={props.onNavigate}
/>
</View>
);
}
const GameActions = {
Turn: (row, col) => ({type: 'TicTacToeTurnAction', row, col }),
Reset: (row, col) => ({type: 'TicTacToeResetAction' }),
};
function GameReducer(lastGame: ?string, action: Object): string {
if (!lastGame) {
lastGame = '';
}
if (action.type === 'TicTacToeResetAction') {
return '';
}
if (!isGameOver(lastGame) && action.type === 'TicTacToeTurnAction') {
return playTurn(lastGame, action.row, action.col);
}
return lastGame;
}
type AppState = {
game: string,
};
class NavigationTicTacToeExample extends React.Component {
_handleAction: Function;
state: AppState;
constructor() {
super();
this._handleAction = this._handleAction.bind(this);
this.state = {
game: ''
};
}
_handleAction(action: Object) {
const newState = GameReducer(this.state.game, action);
if (newState !== this.state.game) {
this.setState({
game: newState,
});
}
}
render() {
return (
<TicTacToeGame
game={this.state && this.state.game}
onExampleExit={this.props.onExampleExit}
onNavigate={this._handleAction}
/>
);
}
}
const styles = StyleSheet.create({
closeButton: {
position: 'absolute',
left: 10,
top: 30,
fontSize: 14,
},
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white'
},
title: {
fontFamily: 'Chalkduster',
fontSize: 39,
marginBottom: 20,
},
board: {
padding: 5,
backgroundColor: '#47525d',
borderRadius: 10,
},
row: {
flexDirection: 'row',
},
cell: {
width: 80,
height: 80,
borderRadius: 5,
backgroundColor: '#7b8994',
margin: 5,
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
cellX: {
backgroundColor: '#72d0eb',
},
cellO: {
backgroundColor: '#7ebd26',
},
cellText: {
fontSize: 50,
fontFamily: 'AvenirNext-Bold',
},
cellTextX: {
color: '#19a9e5',
},
cellTextO: {
color: '#b9dc2f',
},
overlay: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
backgroundColor: 'rgba(221, 221, 221, 0.5)',
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
},
overlayMessage: {
fontSize: 40,
marginBottom: 20,
marginLeft: 20,
marginRight: 20,
fontFamily: 'AvenirNext-DemiBold',
textAlign: 'center',
},
newGame: {
backgroundColor: '#887766',
padding: 20,
borderRadius: 5,
},
newGameText: {
color: 'white',
fontSize: 20,
fontFamily: 'AvenirNext-DemiBold',
},
});
module.exports = NavigationTicTacToeExample;
@@ -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.
*
@@ -50,8 +43,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 +75,9 @@ class BreadcrumbNavSample extends React.Component {
);
}
};
}
},
_renderScene = (route, navigator) => {
_renderScene: function(route, navigator) {
return (
<ScrollView style={styles.scene}>
<NavButton
@@ -108,9 +102,9 @@ class BreadcrumbNavSample extends React.Component {
/>
</ScrollView>
);
};
},
render() {
render: function() {
return (
<Navigator
style={styles.container}
@@ -123,8 +117,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.
*
@@ -106,8 +99,8 @@ class JumpingNavBar extends React.Component {
}
}
class JumpingNavSample extends React.Component {
render() {
var JumpingNavSample = React.createClass({
render: function() {
return (
<Navigator
debugOverlay={false}
@@ -133,9 +126,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 +178,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.
*
@@ -92,8 +85,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 +106,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 +147,9 @@ class NavigationBarSample 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.
*
@@ -112,11 +105,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 +129,9 @@ class TabBarExample extends React.Component {
/>
);
}
};
},
render() {
render: function() {
return (
<Navigator
ref={this._setNavigatorRef}
@@ -150,13 +146,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 +175,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.
*
@@ -30,8 +23,9 @@ var {
View
} = ReactNative;
class EmptyPage extends React.Component {
render() {
var EmptyPage = React.createClass({
render: function() {
return (
<View style={styles.emptyPage}>
<Text style={styles.emptyPageText}>
@@ -39,14 +33,18 @@ 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');
@@ -72,8 +70,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.
*
@@ -36,8 +29,8 @@ const {
View,
} = ReactNative;
class EmptyPage extends React.Component {
render() {
const EmptyPage = React.createClass({
render: function() {
return (
<View style={styles.emptyPage}>
<Text style={styles.emptyPageText}>
@@ -45,11 +38,11 @@ class EmptyPage extends React.Component {
</Text>
</View>
);
}
}
},
});
class NavigatorIOSExamplePage extends React.Component {
render() {
const NavigatorIOSExamplePage = React.createClass({
render: function() {
var recurseTitle = 'Recurse Navigation';
if (!this.props.depth || this.props.depth === 1) {
recurseTitle += ' - more examples here';
@@ -72,13 +65,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 +76,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,30 +100,6 @@ 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();
})}
@@ -163,9 +114,9 @@ class NavigatorIOSExamplePage extends React.Component {
<View style={styles.line}/>
</ScrollView>
);
}
},
_renderReplace = () => {
_renderReplace: function() {
if (!this.props.depth) {
// this is to avoid replacing the top of the stack
return null;
@@ -183,9 +134,9 @@ class NavigatorIOSExamplePage extends React.Component {
}
});
});
};
},
_renderReplacePrevious = () => {
_renderReplacePrevious: function() {
if (!this.props.depth || this.props.depth < 2) {
// this is to avoid replacing the top of the stack
return null;
@@ -200,9 +151,9 @@ class NavigatorIOSExamplePage extends React.Component {
wrapperStyle: styles.customWrapperStyle,
});
});
};
},
_renderReplacePreviousAndPop = () => {
_renderReplacePreviousAndPop: function() {
if (!this.props.depth || this.props.depth < 2) {
// this is to avoid replacing the top of the stack
return null;
@@ -217,9 +168,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,15 +183,17 @@ 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;
const NavigatorIOSExample = React.createClass({
statics: {
title: '<NavigatorIOS>',
description: 'iOS navigation capabilities',
external: true,
},
render() {
render: function() {
const {onExampleExit} = this.props;
return (
<NavigatorIOS
@@ -250,11 +203,12 @@ class NavigatorIOSExample extends React.Component {
component: NavigatorIOSExamplePage,
passProps: {onExampleExit},
}}
itemWrapperStyle={styles.itemWrapper}
tintColor="#008888"
/>
);
}
}
},
});
const 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.
*
@@ -31,33 +24,31 @@ const {
TouchableWithoutFeedback,
} = ReactNative;
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 +56,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 +72,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 +91,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 +107,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 +126,19 @@ class IsConnected extends React.Component {
</View>
);
}
}
});
class IsConnectionExpensive extends React.Component {
state = {
isConnectionExpensive: (null : ?boolean),
};
_checkIfExpensive = () => {
const IsConnectionExpensive = React.createClass({
getInitialState() {
return {
isConnectionExpensive: (null : ?boolean),
};
},
_checkIfExpensive() {
NetInfo.isConnectionExpensive().then(
isConnectionExpensive => { this.setState({isConnectionExpensive}); }
);
};
},
render() {
return (
<View>
@@ -167,7 +154,7 @@ class IsConnectionExpensive extends React.Component {
</View>
);
}
}
});
exports.title = 'NetInfo';
exports.description = 'Monitor network status';
@@ -175,22 +162,22 @@ exports.examples = [
{
title: 'NetInfo.isConnected',
description: 'Asynchronously load and observe connectivity',
render(): ReactElement<any> { return <IsConnected />; }
render(): ReactElement { return <IsConnected />; }
},
{
title: 'NetInfo.update',
description: 'Asynchronously load and observe connectionInfo',
render(): ReactElement<any> { return <ConnectionInfoCurrent />; }
render(): ReactElement { return <ConnectionInfoCurrent />; }
},
{
title: 'NetInfo.updateHistory',
description: 'Observed updates to connectionInfo',
render(): ReactElement<any> { return <ConnectionInfoSubscription />; }
render(): ReactElement { return <ConnectionInfoSubscription />; }
},
{
platform: 'android',
title: 'NetInfo.isConnectionExpensive (Android)',
description: 'Asynchronously check isConnectionExpensive',
render(): ReactElement<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.
*
@@ -33,22 +26,26 @@ const {
Text,
TouchableWithoutFeedback,
} = ReactNative;
const Item = Picker.Item;
class PickerExample extends React.Component {
static title = '<Picker>';
static description = 'Provides multiple options to choose from, using either a dropdown menu or a dialog.';
const PickerExample = React.createClass({
state = {
selected1: 'key1',
selected2: 'key1',
selected3: 'key1',
color: 'red',
mode: Picker.MODE_DIALOG,
};
statics: {
title: '<Picker>',
description: 'Provides multiple options to choose from, using either a dropdown menu or a dialog.',
},
render() {
getInitialState: function() {
return {
selected1: 'key1',
selected2: 'key1',
selected3: 'key1',
color: 'red',
mode: Picker.MODE_DIALOG,
};
},
render: function() {
return (
<UIExplorerPage title="<Picker>">
<UIExplorerBlock title="Basic Picker">
@@ -117,21 +114,21 @@ class PickerExample extends React.Component {
</UIExplorerBlock>
</UIExplorerPage>
);
}
},
changeMode = () => {
changeMode: function() {
const newMode = this.state.mode === Picker.MODE_DIALOG
? Picker.MODE_DROPDOWN
: Picker.MODE_DIALOG;
this.setState({mode: newMode});
};
},
onValueChange = (key: string, value: string) => {
onValueChange: function(key: string, value: string) {
const newState = {};
newState[key] = value;
this.setState(newState);
};
}
},
});
var styles = StyleSheet.create({
picker: {
@@ -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.
*
@@ -73,13 +66,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 +107,18 @@ 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 (
@@ -138,8 +135,8 @@ class PickerStyleExample extends React.Component {
))}
</PickerIOS>
);
}
}
},
});
exports.displayName = (undefined: ?string);
exports.title = '<PickerIOS>';
@@ -147,13 +144,13 @@ exports.description = 'Render lists of selectable options with UIPickerView.';
exports.examples = [
{
title: '<PickerIOS>',
render: function(): ReactElement<any> {
render: function(): ReactElement {
return <PickerExample />;
},
},
{
title: '<PickerIOS> with custom styling',
render: function(): ReactElement<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.
*
@@ -30,28 +23,26 @@ var {
View,
} = ReactNative;
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 +59,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 +89,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 +106,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 +143,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,7 +180,7 @@ class BoxOnlyExample extends React.Component {
</View>
);
}
}
});
type ExampleClass = {
Component: ReactClass<any>,
@@ -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.
*
@@ -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.
*
@@ -33,8 +26,8 @@ var {
View,
} = ReactNative;
class Button extends React.Component {
render() {
var Button = React.createClass({
render: function() {
return (
<TouchableHighlight
underlayColor={'white'}
@@ -46,22 +39,20 @@ 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);
// Add listener for push notifications
PushNotificationIOS.addEventListener('notification', this._onNotification);
// Add listener for local notifications
PushNotificationIOS.addEventListener('localNotification', this._onLocalNotification);
PushNotificationIOS.requestPermissions();
}
componentWillUnmount() {
PushNotificationIOS.removeEventListener('register', this._onRegistered);
PushNotificationIOS.removeEventListener('registrationError', this._onRegistrationError);
PushNotificationIOS.removeEventListener('notification', this._onRemoteNotification);
// Remove listener for push notifications
PushNotificationIOS.removeEventListener('notification', this._onNotification);
// Remove listener for local notifications
PushNotificationIOS.removeEventListener('localNotification', this._onLocalNotification);
}
@@ -103,29 +94,7 @@ class NotificationExample extends React.Component {
});
}
_onRegistered(deviceToken) {
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) {
_onNotification(notification) {
AlertIOS.alert(
'Push Notification Received',
'Alert message: ' + notification.getMessage(),
@@ -193,7 +162,9 @@ exports.description = 'Apple PushNotification and badge value';
exports.examples = [
{
title: 'Badge Number',
render(): ReactElement<any> {
render(): ReactElement {
PushNotificationIOS.requestPermissions();
return (
<View>
<Button
@@ -210,13 +181,13 @@ exports.examples = [
},
{
title: 'Push Notifications',
render(): ReactElement<any> {
render(): ReactElement {
return <NotificationExample />;
}
},
{
title: 'Notifications Permissions',
render(): ReactElement<any> {
render(): ReactElement {
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.
*
@@ -90,7 +83,7 @@ exports.description = 'Examples that show useful methods when embedding React Na
exports.examples = [
{
title: 'Updating app properties in runtime',
render(): ReactElement<any> {
render(): ReactElement {
return (
<AppPropertiesUpdateExample/>
);
@@ -98,7 +91,7 @@ exports.examples = [
},
{
title: 'RCTRootView\'s size flexibility',
render(): ReactElement<any> {
render(): ReactElement {
return (
<RootViewSizeFlexibilityExample/>
);
@@ -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.
*
@@ -49,12 +42,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 +56,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) => {
@@ -106,9 +102,9 @@ class RefreshControlExample extends React.Component {
{rows}
</ScrollView>
);
}
},
_onRefresh = () => {
_onRefresh() {
this.setState({isRefreshing: true});
setTimeout(() => {
// prepend 10 items
@@ -125,7 +121,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.
*
@@ -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.
*
@@ -84,19 +77,18 @@ exports.examples = [
}
}];
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