Commit Graph

924 Commits

Author SHA1 Message Date
Andrei Coman 35d60ecac8 Reinstate view example for screenshot tests
Reviewed By: javache

Differential Revision: D3716630

fbshipit-source-id: 07381f0afe541d0bfea8de6a719d0fa176ccbc3f
2016-08-16 04:58:30 -07:00
Emil Sjolander f7a22bc33c Use single function for margin, position, padding, and border
Reviewed By: lucasr

Differential Revision: D3715201

fbshipit-source-id: ea81ed426f0f7853bb542355c01fc16ae4360238
2016-08-15 09:28:41 -07:00
Connor McEwen 0fb2ccfcc3 Add JS library for requesting Android M Permissions
Summary:
Explain the **motivation** for making this change. What existing problem does the pull request solve?

The Android permissions native module was open sourced recently (b7352b4667) but it is currently undocumented and requires directly interfacing with the native module.

This provides a JS wrapper to make it easier to use the permissions module and documents it.

This could be cleaner if the native code used Promise blocks instead of callbacks, but I didn't want to change the native code without a thumbs up since I'm guessing this is used in one of facebook's apps. Happy to do that if it makes sense

I also tried to make the `PERMISSIONS` object a class property - it works in the actual code but not in the documentation (think it's a jsdocs problem), so decided to initialize in the constructor.

**Test plan (required)**

If the API looks good, I will change the UIExplorer example to use this.

cc andreicoman11
Closes https://github.com/facebook/react-native/pull/9292

Differential Revision: D3716303

Pulled By: andreicoman11

fbshipit-source-id: cd40b8757fdf70ea8faecfb58caa00e99a99789e
2016-08-15 05:58:33 -07:00
Janic Duplessis 0e204e1141 Add support for value listener
Summary:
Adds support for `Animated.Value#addListener` for native driven animated values. Same as #8844 but for iOS. This depends on some JS code in #8844 so only review the 2nd commit and let's wait for #8844 to land first.

**Test plan**
Tested using the UIExplorer example.
Closes https://github.com/facebook/react-native/pull/9194

Differential Revision: D3681749

fbshipit-source-id: 521a61e2221c1ad1f6f40c75dd2dc957361d0271
2016-08-11 18:13:31 -07:00
Jacob Parker 68d483e041 Centre text in case where the distance between baselines is larger th…
Summary:
…an the font size (per CSS spec)

Extending upon work https://github.com/facebook/react-native/pull/7603
Closes https://github.com/facebook/react-native/pull/8851

![screen shot 2016-08-04 at 14 49 21](https://cloud.githubusercontent.com/assets/7275322/17404165/bd67bc48-5a52-11e6-9ba1-5a8524f18867.png)
![screen shot 2016-08-04 at 14 49 24](https://cloud.githubusercontent.com/assets/7275322/17404167/be5f4044-5a52-11e6-9014-391349f9c5e1.png)
Closes https://github.com/facebook/react-native/pull/9211

Differential Revision: D3706347

fbshipit-source-id: 0adfff8e8418b02f9b5d6671f5c89669e41abec3
2016-08-11 16:58:33 -07:00
leeight 4963a37e80 Move `getLaunchOptions` from ReactActivity to ReactActivityDelegate
Summary:
After 3c4fd42749, `getLaunchOptions` no longer exists in class `ReactActivity`.
We need refactor UIExplorerActivity to fix the build error.
Closes https://github.com/facebook/react-native/pull/9320

Differential Revision: D3696381

Pulled By: astreet

fbshipit-source-id: 5700cf2363029a95cfbdaf6230e4f82ea69fb472
2016-08-11 04:13:40 -07:00
tfallon@mail.depaul.edu c6b6f53ae7 Initial implementation of adjustsFontSizeToFit.
Summary: Closes https://github.com/facebook/react-native/pull/4026

Differential Revision: D2678492

Pulled By: nicklockwood

fbshipit-source-id: 0467814f810fee997ac50960ffb1daa74d52acba
2016-08-10 11:28:37 -07:00
Jacob Parker f951da912d Add iOS support for CSS property font-variant, accepting tabular-nums…
Summary:
Ground work for allowing `font-variant`s. Currently allows switching between `tabular-nums` and `proportional-nums`. I will need guidance on how to test this, and a few pointers on code style (new to Objective C, and had to make one or two hacks).
Closes https://github.com/facebook/react-native/pull/9045

Reviewed By: majak

Differential Revision: D3664338

Pulled By: javache

fbshipit-source-id: 032f326c37ee6150348da2b33b6a3fc1988e8920
2016-08-09 08:43:34 -07:00
funorpain ced272d906 Android: TicTacToe Example Project
Summary:
**Motivation**

Android project for TicTacToe example is missing.

**Test plan (required)**

Open Android Studio and run TicTacToe-android-app. It builds and runs as expected.
Closes https://github.com/facebook/react-native/pull/8918

Differential Revision: D3684375

Pulled By: foghina

fbshipit-source-id: cd4112467179d3d334cab198d817ed8b5b32599b
2016-08-09 07:58:30 -07:00
Rickard Ekman 8e2906ae89 Android: Implement cancelable option for Alerts
Summary:
**Motivation**
In iOS you cannot dismiss alerts by clicking outside of their box, while on Android you can. This can create some inconsistency if you want to have identical behavior on both platforms. This change makes it possible for Android apps to have irremovable/required alert boxes just like in iOS.

This adds an additional parameter to the Alert method. The way to use it is by providing an object with the cancelable property. The cancelable property accepts a boolean value.

This utilizes the Android DialogFragment method [setCancelable](https://developer.android.com/reference/android/app/DialogFragment.html#setCancelable(boolean))

**Usage example**
```js
Alert.alert(
   'Alert Title',
   null,
   [
     {text: 'OK', onPress: () => console.log('OK Pressed!')},
   ],
   {
     cancelable: false
   }
);
```

**Test plan (required)**

I added an additional alert to the UIExplorer project where it can be tested. I also added a part in the Dialog Module test to make sure setting canc
Closes https://github.com/facebook/react-native/pull/8652

Differential Revision: D3690093

fbshipit-source-id: 4cf6cfc56f464b37ce88451acf33413393454721
2016-08-09 06:13:48 -07:00
Adrian Paul Matos 8af6aefd54 Fix alert's error message
Summary:
`error` is not an object so `error.message` will return 'undefined'
Closes https://github.com/facebook/react-native/pull/9271

Differential Revision: D3689980

Pulled By: javache

fbshipit-source-id: 07de946f04cdff0e8013faa2c5512c51c82147b9
2016-08-09 04:43:34 -07:00
Janic Duplessis df05311777 Add transform support for native animated on Android
Summary:
This adds support for the `transform` animated node. This brings feature parity with the iOS implementation and allows running the NativeAnimated UIExplorer example that was created with the iOS implementation on Android. This is based on some work by kmagiera in the exponent RN fork.

This also adds support for mixing static values with animated ones in the same transform as well which is not supported on iOS at the moment. It is also implemented in a way that rebuilds the transform matrix the same way as we build it in JS so it will be easy to remove some of the current limitations like forcing the transforms order and only supporting one of each type.

**Test plan (required)**

Tested with the NativeAnimated example on Android and iOS. Also tested mixing in static values in a transform (`[{ rotate: '45deg' }, { translateX: animatedValue }]`).
Closes https://github.com/facebook/react-native/pull/8839

Differential Revision: D3682143

fbshipit-source-id: 5e6fd4b0b8be6a76053f24a36d1785771690a6f8
2016-08-07 00:58:36 -07:00
Pieter De Baets c5a44b7ca3 Move font helpers to RCTFont
Reviewed By: majak

Differential Revision: D3662804

fbshipit-source-id: 2c03a094a74c617c0d6172e327bd77d23d0d44c2
2016-08-05 12:44:20 -07:00
Hedger Wang 38979f9c68 NavigationExperimental: Stop using absolute position for NavigationHeader.
Summary:
Not a API change, but this may break the layout of exisitng apps that
uses NavigationHeader.

For now, NavigationHeader uses absolute position, which makes it hard for
NavigationCardStack to determine the height of the scenes.

Theoretically, the height of the scenes would be the height of the cards
stack minus the height of the header.

That said, if we want to support the headers with different height (e.g.
MyIOSHeader or MyAndroidHeader), we're forced to expose the height of the
headers and manually compute the height of the scenes.

Alternatively, if the header does not use absolute position, the height
of the scenes can adjust automatically with flex box, and that's what this
commit is about to do.

Reviewed By: ericvicenti

Differential Revision: D3671119

fbshipit-source-id: 26e48f801da3661c5d7dce4752ba927621172f4a
2016-08-04 15:28:30 -07:00
Janic Duplessis 158d435f36 Implement native Animated value listeners on Android
Summary:
Adds support for `Animated.Value#addListener` for native driven nodes on Android. This is based on work by skevy in the exponent RN fork. Also adds a UIExplorer example.

** Test plan **
Run unit tests

Tested that by adding a listener to a native driven animated node and checked that the listener callback is called properly.

Also tested that it doesn't crash on iOS that doesn't support this yet.
Closes https://github.com/facebook/react-native/pull/8844

Differential Revision: D3670906

fbshipit-source-id: 15700ed7b93db140d907ce80af4dae6be3102135
2016-08-04 13:13:33 -07:00
Eric Vicenti e3c6d8c931 Fix UIExplorer iOS swipe back
Reviewed By: hedgerwang

Differential Revision: D3670396

fbshipit-source-id: 76aafa951d869227f32c2d4c585bb1513e5eea37
2016-08-04 12:43:50 -07:00
Hedger Wang ca8531105e NavigationExperimental: Rename `renderOverlay` to `renderHeader`
Summary:
NavigationCardStack is a custom component, and its API should be explicit, not
too generic..

In NavigationCardStack, the prop `renderOverlay` is actually used to render
the NavigationHeader, and we uses absolute position to build the layout for
the header and the body.

One of the problem with using absolute postion and fixed height to build the
layout that contains the header is that the header can't have variant height
easily.

Ideally, if the layout for the header used flex-box, we'd ve able to be more
adaptive to deal with the header that has variant height.

That said, let's rename `renderOverlay` to `renderHeader`, then build the
proper layout that explicitly works better with the header.

If we to need to support overlay in navigation, we may consider add
`renderOverlay` later, if it's really necessary.

Reviewed By: ericvicenti

Differential Revision: D3670224

fbshipit-source-id: ff04acfe9dc995cb57117b3fd9b07d5f97b9c6ee
2016-08-04 11:28:31 -07:00
sam 1d980188f8 clean UIExplorer NavigationExperimental example code
Summary:
1. Explain the **motivation** for making this change.

    Those codes cleaned are not used anywhere, remove them would make the example much more clear to users.

2. **Test plan (required)**

    ![navigationexperimental](https://cloud.githubusercontent.com/assets/1091472/17392196/4f28cba4-5a4e-11e6-9ef1-727edc784f1f.gif)
Closes https://github.com/facebook/react-native/pull/9203

Differential Revision: D3668848

fbshipit-source-id: c604a21c84dba72a5a3c857fc16bc7febfe20377
2016-08-04 10:28:31 -07:00
G. Grau 063f221e56 UIExplorer: fix navigation animation by using props passed to renderTitleComponent
Summary:
The animation shown in the UIExplorer example for NavigationExperimental's NavigationHeader is not working correctly. Due to an incomplete use of the `renderTitleComponent()` callback, interpolation is not working correctly in this example.

Even if the animation error is subtle, since the examples are followed by developers quite closely, the bug may multiply if not corrected in the sample code.

This is a really *tiny* modification that fixes that particular animation.
Closes https://github.com/facebook/react-native/pull/9067

Differential Revision: D3669140

Pulled By: javache

fbshipit-source-id: 6dab36a9132da2f704e9a074ae26e744c3420cde
2016-08-04 03:44:25 -07:00
R0CKSTAR 916bc38d89 Fix libraries missing in examples: 2048 and TicTacToe
Summary:
The examples: 2048 and TicTacToe will display errors when click the run on Xcode. I imported RCTNetwork and RCTImage for 2048 and RCTNetwork for TicTacToe and it works on the simulator.
Closes https://github.com/facebook/react-native/pull/9123

Differential Revision: D3662099

Pulled By: javache

fbshipit-source-id: 2e2d88336ea83eae58088f4cc1d5003ba2a2f71b
2016-08-03 04:58:28 -07:00
alvaromb e52cab5a7f Adds the ability to use UIManager to check if a node is an ancestor
Summary:
Sometimes is handy to check if a React node is a descendant of another node or not. For instance, I want to check if the focused `TextInput` is descendant of an specific `ScrollView`:

```js
const currentlyFocusedField = TextInput.State.currentlyFocusedField()
UIManager.viewIsAncestorOf(
  currentlyFocusedField,
  this.getInnerViewNode(),
  (isAncestor) => {
    if (isAncestor) {
      console.log('The focused field is a descendant of this ScrollView!')
    }
  }
)
```

This function uses the same strategy as the `measureLayout` method to check if one node is an ancestor of other node. As the `measureLayout` method, this is performed outside the main thread.

By now I've only implemented the iOS version and its tests, but if this function is going to be merged I'll implement the Android version too. I have objc experience but no Java or Android, so I prefer to validate this functionality before jumping into developing the Android part.
Closes https://github.com/facebook/react-native/pull/7876

Differential Revision: D3662045

Pulled By: javache

fbshipit-source-id: b9668e8ea94fd01db76651f16243926cf9c2566f
2016-08-03 04:13:43 -07:00
Artyom Trityak 5617d41327 ActivityIndicator Example ES6 classes migration and TimerMixin removal
Summary:
**This is the first part of `React.createClass` -> ES2015 classes migration.
1. Rewritten UI Explorer ActivityIndicator example to ES2015 classes
2. Removed TimerMixin from example.

Motivation:

- ES2015 classes do not support mixins so due to the classes / pure functions as "best practices" it would be better to avoid mixins in examples.

- TimerMixin is covered later and is out of scope of current example.
Closes https://github.com/facebook/react-native/pull/8342

Differential Revision: D3659349

fbshipit-source-id: e1c6f1a3091d60c589303fe6da55b8d132adedc3
2016-08-02 17:13:30 -07:00
Pieter De Baets e762d961cd Use new enqueueJSCall method everywhere
Reviewed By: majak

Differential Revision: D3605263

fbshipit-source-id: 215f896d675b937593c8b796ed6ec5261ac74dbf
2016-08-02 11:14:06 -07:00
yueshuaijie 15bf2c57b8 Add TextInput.dataDetectorTypes prop.
Summary:
On iOS, if `TextInput` is used with prop `multiline={true}`, the backend view is `UITextView`. Sometimes we need `UITextView.dataDetectorTypes` to detect clickable url in the text view. The PR add this prop to `TextInput`, so we can use it like this:

`<TextInput`
`    defaultValue="Detect phone number: 88888888."`
`    editable={false}`
`    multiline={true}`
`    dataDetectorTypes="all"`
`    />`

Similar as #8743 .
Closes https://github.com/facebook/react-native/pull/8863

Differential Revision: D3648027

fbshipit-source-id: 987bd4f46fb5be74099b62988135a32115d9269c
2016-07-31 14:28:28 -07:00
Fadil Sutomo 63d15af18d Activity indicator: add size prop
Summary:
**motivation**

Previously, size can only accept either 'small' or 'large'. And to obtain a custom size, scale transformation is used. This is to let users to possibly pass number value directly to define ActivityIndicator's size.

**Test plan**

I have also modified the current example to reflect the new size prop in action.
Closes https://github.com/facebook/react-native/pull/8935

Differential Revision: D3637910

fbshipit-source-id: 6b8e1d4504964916df327b2d3eaaef1bb8cd5112
2016-07-28 15:28:43 -07:00
David Goldman fd48bc3cff Implement multi-source Images on iOS
Summary: Mirrors Android's support for multiple sources for Image, allowing us to fetch new images as the size of the view changes.

Reviewed By: mmmulani

Differential Revision: D3615134

fbshipit-source-id: 3d0bf2b75f63a4379e0e49f2dab9aea351b31d5f
2016-07-28 14:13:46 -07:00
sam 7971cca4f0 add UIExplorer example of SwipeableListView
Summary:
Q: Explain the **motivation** for making this change. What existing problem does the pull request solve?

A: There is no example for [`SwipeableListView`](https://github.com/facebook/react-native/tree/master/Libraries/Experimental/SwipeableRow) component, it would be helpful to add one.

**Test plan (required)**

Some screenshots here:

<img width="377" alt="screen shot 2016-07-14 at 21 47 50" src="https://cloud.githubusercontent.com/assets/1091472/16841629/af8392c4-4a0c-11e6-9f92-208aba514f36.png">

Tested on:

1. Simulators

    iPhone 4s, 5, 5s, 6, 6 Plus
Closes https://github.com/facebook/react-native/pull/8782

Differential Revision: D3624365

fbshipit-source-id: 76598ac69bca1dca6ae928d2d19c9f1384d8e161
2016-07-27 17:58:36 -07:00
Ben Alpert a2fb703bbb Convert from React.createClass to ES6 classes
Reviewed By: cpojer

Differential Revision: D3619143

fbshipit-source-id: e14e81468d467437ee3d79c34c34b7780a46ca1c
2016-07-26 01:13:31 -07:00
Sokovikov 857d2b8eae change lineBreakMode to ellipsizeMode
Summary:
lineBreakMode only in rc so I think we can replace property without any deprecation warnings. satya164
Closes https://github.com/facebook/react-native/pull/9008

Differential Revision: D3614901

fbshipit-source-id: 724227c0a89192825a24850b930b80884571a51f
2016-07-25 13:13:35 -07:00
SangYeob Bono Yu 3b35732800 Add Share module
Summary:
revision of https://github.com/facebook/react-native/pull/5476

It has only one method `shareTextContent` and next will be`shareBinaryContent`.

In Android, Promise can't receive a result, because `startActivityForResult` is not working with `Intent.ACTION_SEND`. Maybe we can use `createChooser(Intent target, CharSequence title, IntentSender sender)` which requires API level 22.
Closes https://github.com/facebook/react-native/pull/5904

Differential Revision: D3612889

fbshipit-source-id: 0e7aaf34b076a99089cc76bd649e6da067d9a760
2016-07-25 03:43:29 -07:00
Janic Duplessis 5903949ad6 Load local assets synchronously to prevent image flicker
Summary:
This uses `[UIImage imageNamed:]` to load local assets that are bundled using `require('../image/path.png')` and makes sure it is done synchronously on the main queue to prevent images from flickering. This improves user experience a lot when using large local images and prevents icon flickers to match the behaviour of most native apps.

This adds to methods to the ImageLoader protocol, one to tell if the image loader must be executed on the url cache queue and one to tell if the result of the image loader should be cached. I then use these to make the LocalImageLoader bypass the url cache queue and avoid caching images twice.

Note that this doesn't affect debug builds since images are loaded from the packager.

I'm not sure if we want to still support async loading of local images as I'm not sure how much of a perf difference this will make. Maybe someone at fb can benchmark this see how it affects your apps but there wasn't a noticeable one in mine. Also I only enabled this for loading png and jpg im
Closes https://github.com/facebook/react-native/pull/8102

Reviewed By: bnham

Differential Revision: D3433647

Pulled By: javache

fbshipit-source-id: 37bd6aff20c0465c163db3cdbcaeaedff55f7b1f
2016-07-21 07:58:51 -07:00
Emil Sjolander 1af9270e45 Revamp API
Reviewed By: majak

Differential Revision: D3579423

fbshipit-source-id: 040ecab2f20216aa136ccb8a9e7e15ffa882b313
2016-07-20 08:58:59 -07:00
Don Yu 12ec213c0d Add support for layout gravity to ToastAndroid
Summary: Add support for top, bottom, and center layout gravity to ToastAndroid

Reviewed By: AaaChiuuu

Differential Revision: D3590224

fbshipit-source-id: 84dbbcfbe4133f291d62723c5c261acd7b32b46e
2016-07-20 08:13:37 -07:00
Emil Sjolander 1aa7ad0ab8 CamelCase
Reviewed By: majak

Differential Revision: D3576069

fbshipit-source-id: cecda2cdb67f2f66ac92e336068d58731ccdb101
2016-07-20 06:43:32 -07:00
Tobias Ritzau d343eaabff Added the native animation demo to the android UIExplorer
Reviewed By: javache

Differential Revision: D3569816

fbshipit-source-id: ab03f3f3ad10b3921d428628c87e4091c07ceafe
2016-07-19 02:43:24 -07:00
sasaki takeru fa062aab14 fix UIExplorer build path
Summary:
UIExplorerApp.ios.js is moved into js directory.
Closes https://github.com/facebook/react-native/pull/8884

Differential Revision: D3586032

Pulled By: nathanajah

fbshipit-source-id: 93793681e33a0922e3d8503da3f1c0d01fd4fa93
2016-07-19 01:58:36 -07:00
Brent Vatne a564af853f Throw flow error when trying to access a style that is not defined on a stylesheet
Summary:
I thought it would be useful to help clear out references to no longer used styles and also catch typos on style names to have flow error when we try to access a style that isn't defined.

Example:

```javascript
export default class AuthenticationScreen extends React.Component {
  render() {
    // This throws an error because `continer` is misspelled
    return (
      <View style={styles.continer} />
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
}
```

```javascript
export default class AuthenticationScreen extends React.Component {
  render() {
    // This throws an error because no fancyContainer style is defined
    return (
      <View style={[styles.container, styles.fancyContainer]} />
    )
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
}
```

All credit goes to jeffmo in this tweet: https://twitter.com/lbljeffmo/status/755179096271888385

Also included in the PR is some cleanup on styles that
Closes https://github.com/facebook/react-native/pull/8876

Differential Revision: D3584983

Pulled By: yungsters

fbshipit-source-id: 0ee0e12ff3d976c137d932688e323c26690e0a52
2016-07-18 23:28:25 -07:00
Ernest Walzel 83336130ef Fix minor typo in ListViewExample.js
Summary:
s/_renderSeperator/_renderSeparator/
Closes https://github.com/facebook/react-native/pull/8816

Differential Revision: D3580181

Pulled By: javache

fbshipit-source-id: e9cf35d50512b490efafa880f8d99ca13aa4df15
2016-07-18 10:30:53 -07:00
Pieter De Baets 7fa677f7c3 Add MessageQueue method for executing function and returning its result
Reviewed By: majak

Differential Revision: D3175793

fbshipit-source-id: e1e66e3dcde8b1fb35973340e12d947a0e955775
2016-07-18 07:13:32 -07:00
Janic Duplessis df8c88e000 Fix UIExplorer entry file on iOS
Summary:
Files were moved to the js/ directory so UIExplorer did not work anymore on iOS, this fixes the path.
Closes https://github.com/facebook/react-native/pull/8841

Differential Revision: D3576752

fbshipit-source-id: 921ddc2e158ee0c74dcf691a32504900c5d79e1d
2016-07-17 01:43:28 -07:00
Nathan Azaria 87124383ac Changed JS location of examples to source from RCTBundleURLProvider instead.
Summary:
This changes the JS location of the examples (2048, UIExplorer, Movies, and TicTacToe) to be set from RCTBundleURLProvider instead.
This also makes the example apps run the bundle script, which makes the build time longer.

Reviewed By: javache

Differential Revision: D3516371

fbshipit-source-id: 70e53c62feb81c067df4e2298e7d1f1458777490
2016-07-15 10:13:29 -07:00
Pieter De Baets 0b6f0fcf55 Correctly specify run_tests for all apps in ci_config
Reviewed By: talah

Differential Revision: D3552776

fbshipit-source-id: 690ab316fa3dc761cf8f2903542ee6ed5cb15b37
2016-07-15 08:58:28 -07:00
Pieter De Baets 23e087fc26 Fix TextInput stack overflow when pasting text in multiline input with maxlength
Summary: When pasting text longer than maxlenght, the textDidChange: call we did would end calling back into textView:shouldChange: because we saw an unexpected multi-character change. Since this is an expected mutation, update predictedText appropriately.

Reviewed By: majak

Differential Revision: D3561524

fbshipit-source-id: 07bb78d830ccfa3aed6ee274dc30adeadce9e1f8
2016-07-14 07:43:32 -07:00
Janic Duplessis 5618c3ff09 Initial implementation of requestIdleCallback on iOS
Summary:
iOS follow up to #8569. This currently depends on the Android PR since it contains the JS implementation, only review the last commit. Just putting this out here for visibility, don't merge this before the Android PR.

**Test plan**
Tested by running a background task that burns all remaining idle time (see UIExplorer example).

Tested that native only calls into JS when there are pending idle callbacks.

Tested that timers are executed before idle callback.
Closes https://github.com/facebook/react-native/pull/8734

Differential Revision: D3560818

fbshipit-source-id: a28d3092377a7fd4331647148d40fe69e4198c7e
2016-07-13 22:58:30 -07:00
Janic Duplessis 18394fb179 Initial implementation of requestIdleCallback on Android
Summary:
This is a follow up of the work by brentvatne in #5052. This addresses the feedback by astreet.

- Uses ReactChoreographer with a new callback type
- Callback dispatch logic moved to JS
- Only calls into JS when needed, when there are pending callbacks, it even removes the Choreographer listener when no JS context listen for idle events.

** Test plan **
Tested by running a background task that burns all remaining idle time (see new UIExplorer example) and made sure that UI and JS fps stayed near 60 on a real device (Nexus 6) with dev mode disabled. Also tried adding a JS driven animation and it stayed smooth.

Tested that native only calls into JS when there are pending idle callbacks.

Also tested that timers are executed before idle callback.
```
requestIdleCallback(() => console.log(1));
setTimeout(() => console.log(2), 100);
burnCPU(1000);
// 2
// 1
```

I did *not* test with webworkers but it should work as I'm using executor tokens.
Closes https://github.com/facebook/react-native/pull/8569

Differential Revision: D3558869

Pulled By: astreet

fbshipit-source-id: 61fa82eb26001d2b8c2ea69c35bf3eb5ce5454ba
2016-07-13 18:58:20 -07:00
Eric Vicenti 38157f0175 Fix UIExplorer List
Summary:
NavigationCardStack has a race condition when replacing routes quickly (like on keystrokes).

This change reverts some capability of the UIExplorerList but makes it feel nice for the meantime while we fix the issue in NavigationTransitioner. If we used flux/redux for UIExplorer, this issue would have been avoided.

Reviewed By: javache

Differential Revision: D3556035

fbshipit-source-id: 36b3e7b5abb1ec11cd68acda40db588920ff7e11
2016-07-13 14:28:45 -07:00
Philipp von Weitershausen 08c375f828 Add responseType as a concept to RCTNetworking, send binary data as base64
Summary:
In preparation for Blob support (wherein binary XHR and WebSocket responses can be retained as native data blobs on the native side and JS receives a web-like opaque Blob object), this change makes RCTNetworking aware of the responseType that JS requests. A `xhr.responseType` of `''` or `'text'` translates to a native response type of `'text'`. A `xhr.responseType` of `arraybuffer` translates to a native response type of `base64`, as we currently lack an API to transmit TypedArrays directly to JS. This is analogous to how the WebSocket module already works, and it's a lot more versatile and much less brittle than converting a JS *string* back to a TypedArray, which is what's currently going on.

Now that we don't always send text down to JS, JS consumers might still want to get progress updates about a binary download. This is what the `'progress'` event is designed for, so this change also implements that. This change also follows the XHR spec with regards to `xhr.response` and `xhr.responseText`:

- if the response type is `'text'`, `xhr.responseText` can be peeked at by the JS consumer. It will be updated periodically as the download progresses, so long as there's either an `onreadystatechange` or `onprogress` handler on the XHR.

- if the response type is not `'text'`, `xhr.responseText` can't be accessed and `xhr.response` remains `null` until the response is fully received. `'progress'` events containing response details (total bytes, downloaded so far) are dispatched if there's an `onprogress` handler.

Once Blobs are landed, `xhr.responseType` of `'blob'` will correspond to the same native response type, which will cause RCTNetworking to only send a blob ID down to JS, which can then create a `Blob` object from that for consumers.

Closes https://github.com/facebook/react-native/pull/8324

Reviewed By: javache

Differential Revision: D3508822

Pulled By: davidaurelio

fbshipit-source-id: 441b2d4d40265b6036559c3ccb9fa962999fa5df
2016-07-13 04:58:37 -07:00
弘树 262397d5b1 Fix UIExplorer example AppDelegate.m for pre-bundle comment
Summary:
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

(You can skip this if you're fixing a typo or adding an app to the Showcase.)

Explain the **motivation** for making this change. What existing problem does the pull request solve?

UIExplorer example doc fix.

**Test plan (required)**

Unnecessary.

**Code formatting**

Just fix comment, not related to code

Fix pre-bundle doc
Closes https://github.com/facebook/react-native/pull/8733

Differential Revision: D3554930

fbshipit-source-id: 76ed3da17df840f90987f7468cea7cd65741313f
2016-07-13 02:13:24 -07:00
Pieter De Baets 2f73ca8f76 Cleanup UIExplorer folder
Summary: Move all JS to a js/ subfolder so we get some overview of this folder again.

Reviewed By: bestander

Differential Revision: D3542598

fbshipit-source-id: 7637133fe4152f4d39e461b443b38510272d5bc8
2016-07-12 05:59:13 -07:00
Pieter De Baets 81f59dfdc2 Remove code for testing without JS bundle
Reviewed By: mmmulani

Differential Revision: D3542347

fbshipit-source-id: d0dcfb65645faf515e6e48e6ff733646e1bcf907
2016-07-11 13:33:55 -07:00