Commit Graph

520 Commits

Author SHA1 Message Date
Alex Kotliarskyi 63b8262843 [ReactNative] Allow TouchableWithoutFeedback override accessible attribute 2015-06-03 16:37:11 -08:00
Andrei Coman 6d25ff83ec [react_native] Fix sync 2015-06-03 15:07:39 -08:00
Andrew Imm 89a1e94a15 Add an event for remote notification registration, and improve permissions request
Summary:
In order to add Push support to the Parse JS SDK in React Native, we need a way to receive the APNS device token from the JS context. This adds another event to PushNotificationIOS, so that code can respond to a successful registration.

Additionally, I've updated the `requestPermissions` call to accept an optional map of parameters. This way, developers can request a subset of user notification types.
Closes https://github.com/facebook/react-native/pull/1304
Github Author: Andrew Imm <andrewi@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-03 14:06:44 -08:00
Jared Forsyth b2b89c0b68 add style inspector + more margin + styles
Summary:
- make overlay transparent to avoid obscuring the app
- show style in the inspector pane
- show margin+padding values, also width/height and abs position

@public

Test Plan:
Open the inspector somewhere, start selecting things. You should see correct
padding, margin, and dimentions values; in addition to all style properties
enumerated.
2015-06-03 14:02:18 -08:00
jmstout 074fa759a6 [Touchable] Add custom delay props to Touchable components
Summary:
@public
This PR adds quite a bit of functionality to the Touchable components, allowing the ms delays of each of the handlers (`onPressIn, onPressOut, onPress, onLongPress`) to be configured.

It adds the following props to `TouchableWithoutFeedback, TouchableOpacity, and TouchableHighlight`:
```javascript
/**
 * Delay in ms, from the release of the touch, before onPress is called.
 */
delayOnPress: React.PropTypes.number,
/**
 * Delay in ms, from the start of the touch, before onPressIn is called.
 */
delayOnPressIn: React.PropTypes.number,
/**
 * Delay in ms, from the release of the touch, before onPressOut is called.
 */
delayOnPressOut: React.PropTypes.number,
/**
 * Delay in ms, from onPressIn, before onLongPress is called.
 */
delayOnLongPress: React.PropTypes.number,
```

`TouchableHighlight` also gets an additional set of props:
```javascript
/**
 * Delay in ms, from the start of the touch, before the highlight is shown.
 */
delayHighlightShow: React.PropTypes.number,
/**
 * Del
...
```

Closes https://github.com/facebook/react-native/pull/1255
Github Author: jmstout <git@jmstout.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-03 12:57:28 -08:00
Jared Forsyth 7be471d1fe visualize padding and margin in inspector
Summary:
This shows margin and padding visually when inspecting an element.

@public

Test Plan:
Go to the "UIExplorer", to the <View> page. Open the inspector, and start
selecting things. Padding and margin should be indicated. (Padding in dark
blue and margin in orange).
2015-06-03 12:49:19 -08:00
Andy Street 435125f4a0 Revert "[ReactNative] Run UIExplorer tests on sandcastle" 2015-06-03 10:57:19 -08:00
Nick Lockwood e68f89bfad Added ProgressViewIOS 2015-06-03 09:49:35 -08:00
Tadeu Zagallo e1454c29c5 [ReactNative] Run UIExplorer tests on sandcastle 2015-06-03 06:24:12 -08:00
Nick Lockwood 10b13512b9 Simplify RKDataManager 2015-06-03 05:36:25 -08:00
Andy Street 95d2843362 Revert "[Timers] Batch setImmediate handlers" 2015-06-03 03:15:20 -08:00
Klein Lieu b243236404 [Cosmetic] Fixing comment typo
Summary:
Closes https://github.com/facebook/react-native/pull/780
Github Author: Klein Lieu <klieu@constantcontact.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-02 20:23:34 -08:00
Spencer Ahrens d796584b6c [ReactNative] ErrorUtils.reportError shouldn't redbox
Summary:
@public

ErrorUtils.reportError is intended for reporting handled errors to the
server, like timeouts, which means that we shouldn't shove them in the
developer's face.

Test Plan: add `require('ErrorUtils').reportError(new Error('error'))` and see a useful error message with stack but no redbox.  Debugger confirms `reportSoftException` is called but it doesn't do anything yet.  `reportFatalError` and throwing exceptions still show redboxes.
2015-06-02 17:47:49 -08:00
Andrei Coman 9b455c8677 [react_native] JS files from D2115306: implement ExceptionsManager.report(Fatal|Soft)Exception 2015-06-02 07:41:40 -08:00
Tadeu Zagallo 0f16d15d64 [ReactNative] Optimize console.profile and add markers on JS entry points
Summary:
@public

Right now the profiler shows how long the executor took on JS but doesn't show
how long each of the batched calls took, this adds a *very* high level view of JS
execution (still doesn't show properly calls dispatched with setImmediate)

Also added a global property on JS to avoid trips to Native when profiling is
disabled.

Test Plan:
Run the Profiler on any app

{F22491690}
2015-06-02 06:22:49 -08:00
Andrei Coman 0aa7f3f8d5 [react_native] Implement connectivity module 2015-06-02 05:41:16 -08:00
Chace Liang 1ed2542b46 Revert "[Bridge] Add support for JS async functions to RCT_EXPORT_METHOD" 2015-06-01 20:26:37 -08:00
Jared Forsyth e6c04df5a1 fix bug with inspector clicking
Summary:
Previously, if you were already inspecting an element, touching again would
select a completely different element because the touch position was
calculated relative to the current overlay.

This fixes it.

@public

Test Plan:
Open the inspector, click around, verify that every click selects the thing
you clicked on.
2015-06-01 18:02:26 -08:00
Eric Vicenti 219a7c1bfd [ReactNative] Navigator block touches on scene when navigating 2015-06-01 16:35:43 -08:00
James Ide 2a6fe079c0 [Timers] Batch setImmediate handlers
Summary:
Wraps the setImmediate handlers in a `batchUpdates` call before they are synchronously executed at the end of the JS execution loop.

Closes https://github.com/facebook/react-native/pull/1242
Github Author: James Ide <ide@jameside.com>

Test Plan:
 Added two `setImmediate` calls to `componentDidMount` in UIExplorerApp. Each handler calls `setState`, and `componentWillUpdate` logs its state. With this diff, we can see the state updates are successfully batched.

```javascript
componentDidMount() {
  setImmediate(() => {
    console.log('immediate 1');
    this.setState({a: 1});
  });
  setImmediate(() => {
    console.log('immediate 2');
    this.setState({a: 2});
  });
},

componentWillUpdate(nextProps, nextState) {
  console.log('componentWillUpdate with next state.a =', nextState.a);
},
```

**Before:**

"immediate 1"
"componentWillUpdate with next state.a =", 1
"immediate 2"
"componentWillUpdate with next state.a =", 2

**After:**

"immediate 1"
"immediate 2"
"componentWillUpdate with next state.a =", 2

Addresses the batching issue in #1232. cc @vjeux @spicyj
2015-06-01 16:23:12 -08:00
Joshua Sierles 43adb7b02c [CameraRoll] support fetching videos from the camera roll
Summary:
This adds a parameter for fetching videos from the camera roll. It also changes the default to fetch both videos and photos.
Closes https://github.com/facebook/react-native/pull/774
Github Author: Joshua Sierles <joshua@diluvia.net>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-01 15:57:32 -08:00
Spencer Ahrens 34cef28a10 [ReactNative] kill setInterval in ListView 2015-06-01 13:34:06 -08:00
Alex Kotliarskyi d723e17629 [ReactNative] Copy assets to corresponding folders on Android 2015-06-01 12:21:53 -08:00
James Ide d548c85da6 [Bridge] Add support for JS async functions to RCT_EXPORT_METHOD
Summary:
Adds support for JS async methods and helps guide people writing native modules w.r.t. the callbacks. With this diff, on the native side you write:

```objc
RCT_EXPORT_METHOD(getValueAsync:(NSString *)key
                       resolver:(RCTPromiseResolver)resolve
                       rejecter:(RCTPromiseRejecter)reject)
{
  NSError *error = nil;
  id value = [_nativeDataStore valueForKey:key error:&error];

  // "resolve" and "reject" are automatically defined blocks that take
  // any object (nil is OK) and an NSError, respectively
  if (!error) {
    resolve(value);
  } else {
    reject(error);
  }
}
```

On the JS side, you can write:

```js
var {DemoDataStore} = require('react-native').NativeModules;
DemoDataStore.getValueAsync('sample-key').then((value) => {
  console.log('Got:', value);
}, (error) => {
  console.error(error);
  // "error" is an Error object whose message is the NSError's description.
  // The NSError's code and domain are also set, and the native trace i
Closes https://github.com/facebook/react-native/pull/1232
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-01 10:50:06 -08:00
Felix Oghina 2b4daf228d Expose fontScale to JS 2015-06-01 10:25:38 -08:00
Nick Lockwood 49e87af934 Fixed text update on OSS 2015-06-01 08:44:11 -08:00
Nick Lockwood a2db4a4a5b Removed redundant JSON encode/decode from RCTDataManager
Summary:
@public

For some reason we were manually JSON-encoding the RCTDataManager responses, and then decoding them again on the JS side. Since all data sent over the bridge is JSON-encoded anyway, this is pretty pointless.

Test Plan:
* Test Movies app in OSS, which uses RCTDataManager
* Test any code that uses RKHTTPQueryGenericExecutor to make network requests (e.g. Groups)
* Test the Groups photo upload feature, which uses RKHTTPQueryWithImageUploadExecutor
2015-06-01 08:35:56 -08:00
Peter Cottle 595eae8b67 [ErrorMessage] Change error message when app is not registered
Summary:
So when I first started porting JS files over from LearnGitBranching into a react native project, I some had require errors (for whatever reason) and I hit this error message a decent amount. I eventually understood it had nothing to do with failing to register the component (which btw sounds like some sign-up process, not actually an internal concept) but I figured we could expand on this message and describe why it might be happening.

I'm not 100% sure on what the second half should be, but open to feedback on this
Closes https://github.com/facebook/react-native/pull/826
Github Author: Peter Cottle <pcottle@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-31 13:14:02 -08:00
Ben Alpert c37509727f Set constructor properly in createReactNativeComponentClass
Summary:
Without this, the displayName property wasn't found when looking at
`.constructor` on a component instance. Fixes facebook/react-devtools#92.
Closes https://github.com/facebook/react-native/pull/1471
Github Author: Ben Alpert <balpert@fb.com>

Test Plan:
Used devtools on MoviesApp and saw RCTView instead of Unknown:

{F22491590}
2015-05-31 12:59:53 -08:00
Nick Lockwood 09cef03cd3 revert D2087892 2015-05-31 11:35:55 -08:00
Tadeu Zagallo f8b3c98bc6 [ReactNative] Remove AnimationUtils tests 2015-05-29 15:24:47 -08:00
Christopher Chedeau 6bffa6c8a8 [ReactNative] Unbreak flow errors 2015-05-29 14:24:00 -08:00
Krzysztof Magiera e2dc2db9dc [react_native] JS files from D2091817: Support nested text nodes in TextInput. 2015-05-29 12:39:47 -08:00
Krzysztof Magiera ff48f78742 [react_native] JS files from D2091792: Introduce vitual text node and adapt TextViewManager to shadowview-less design. 2015-05-29 12:37:55 -08:00
Alex Kotliarskyi 228dc5f936 [MAdMan] Possibly fix "Cannot find breadcrumb interpolators for -1" 2015-05-29 11:23:40 -08:00
Nick Lockwood 36c33b4a60 Fixed delayed text layout bug 2015-05-29 10:43:13 -08:00
Alex Akers 4097459dc9 [React Native] Remove layout-only nodes from RCTText in RN OSS 2015-05-29 06:22:45 -08:00
Alex Akers 40da2c7e08 [React Native] Add E2E tests for Catalyst that test login, app launcher, and opening UIExplorer, MAdMan, Groups 2015-05-29 05:30:09 -08:00
Christopher Chedeau 3c1eaf7a6e [ReactNative] Fix inspect element crash 2015-05-28 10:03:06 -08:00
Bill Fisher 474ac651d5 [ReactNative] Allow decomposedMatrix style property to go to native view 2015-05-28 09:32:50 -08:00
Nick Lockwood 45c1dc1c65 Fixed text background color
Summary:
@public

This fixes an issue with the containerBackgroundColor property of `<Text>` nodes, where containerBackgroundColor was being overridden by the backgroundColor. I also fixed up the example so that it demonstrates the feature more clearly.

Test Plan:
* Check UIExplorer text example
* Run Catalyst snapshot tests and check MAdMan, Groups
2015-05-28 09:31:57 -08:00
Spencer Ahrens a4442e4576 [ReactNative] rename nativeProps const to NativeProps 2015-05-26 19:28:07 -08:00
Nick Lockwood 0689c0790e Fixed crash in RCTText due to NSTextContainer/NSLayoutManager being accessed concurrently from main and shadow queues 2015-05-26 18:52:46 -08:00
Stan Chollet 76ea00483d TabBarIOS tintColor
Summary:
[Origin Pull request](https://github.com/facebook/react-native/pull/961) from [cmcewen](https://github.com/cmcewen)

All the work have been done by @cmcewen, I just rebased his work with the master.
Closes https://github.com/facebook/react-native/pull/1337
Github Author: Stan Chollet <stanislas.chollet@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-26 17:21:36 -08:00
Changgeng Li 84783dbac4 Add renderSeparator support to ListView 2015-05-26 15:20:29 -08:00
Jared Forsyth b839ab32be add missing require("Map") 2015-05-26 15:08:33 -08:00
henter 2a76ca635e [GeoLocation] invalidate timer after success or error callback
Summary:
Just trying to [getCurrentPosition](https://github.com/facebook/react-native/blob/master/Libraries/Geolocation/Geolocation.js#L45) , and found the `errorBlock` of location request in timeout handler would cause red error like this:

```
2015-05-10 17:50:39.607 [warn][tid:com.facebook.React.JavaScript] "Warning: Cannot find callback with CBID 5. Native module may have invoked both the success callback and the error callback."
2015-05-10 17:50:39.610 [error][tid:com.facebook.React.JavaScript] "Error: null is not an object (evaluating 'cb.apply')
 stack:
  _invokeCallback  index.ios.bundle:7593
  <unknown>        index.ios.bundle:7656
  <unknown>        index.ios.bundle:7648
  perform          index.ios.bundle:6157
  batchedUpdates   index.ios.bundle:13786
  batchedUpdates   index.ios.bundle:4689
  <unknown>        index.ios.bundle:7647
  applyWithGuard   index.ios.bundle:882
  guardReturn      index.ios.bundle:7421
  processBatch     index.ios.bundle:7646
 URL: http://192.168.100.182:8081/index
Closes https://github.com/facebook/react-native/pull/1226
Github Author: henter <henter@henter.me>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-26 14:59:14 -08:00
Philipp von Weitershausen 3269af227f Back out D2098670: Allow uploading a native file (e.g. photo) via XMLHttpRequest 2015-05-26 12:50:25 -08:00
Alex Kotliarskyi cfa4b13472 [ReactNative] Element Inspector
Summary:
This adds new development feature to React Native that provides information
about selected element (see the demo in Test Plan).

This is how it works:

App's root component is rendered to a container that also has a hidden layer called
`<InspectorOverlay/>`. When activated, it shows full screen view and captures all
touches. On every touch we ask UIManager to find a view for given {x,y} coordinates.

Then, we use React's internals to find corresponding React component. `setRootInstance`
is used to remember the top level component to start search from, lmk if you have a
better idea how to do this. Given a component, we can climb up its owners tree
to provice more context on how/where the component is used.

In future we could use the `hierarchy` array to inspect and print their props/state.

Known bugs and limitations:
* InspectorOverlay sometimes receives touches with incorrect coordinates (wtf)
* Not integrated with React Chrome Devtools (maybe in followup diffs)
* Doesn't work with popovers (maybe put the element inspector into an `<Overlay/>`?)

@public

Test Plan:
https://www.facebook.com/pxlcld/mn5k
Works nicely with scrollviews
2015-05-26 11:19:49 -08:00
Philipp von Weitershausen 4273af9e29 Allow uploading a native file (e.g. photo) via XMLHttpRequest
Summary:
With this in place, it's possible to upload a picture from the `CameraRoll` to Parse, for instance:

    xhr = new XMLHttpRequest();
    xhr.onload = function() {
      data = JSON.parse(xhr.responseText);
      var parseFile = new Parse.File(data.name);
      parseFile._url = data.url;
      callback(parseFile);
    };
    xhr.setRequestHeader('X-Parse-Application-Id', appID);
    xhr.setRequestHeader('X-Parse-JavaScript-Key', appKey);
    xhr.open('POST', 'https://api.parse.com/1/files/image.jpg');
    // assetURI as provided e.g. by the CameraRoll API
    xhr.send(new NativeFile(assetURI));

Closes https://github.com/facebook/react-native/pull/1357
Github Author: Philipp von Weitershausen <philikon@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-26 09:45:34 -08:00