Commit Graph

82 Commits

Author SHA1 Message Date
Valentin Shergin 603cc48ceb TextInput: Refined contentSize calculation
Summary: This fixes pretty bad issue when contentSize is calculated based on an intrinsic horizontal (width) limitation, not on a real/current horizontal (width) one.

Reviewed By: mmmulani

Differential Revision: D5422114

fbshipit-source-id: 0eb582aeb59d29530990d4faabf2f41baa79c058
2017-07-18 14:46:22 -07:00
Valentin Shergin cb96f1d5d2 TextInput: Unified support of `clearsOnBeginEditing` prop
Summary: The implementation of `clearsOnBeginEditing` was unified and moved to superclass.

Reviewed By: javache

Differential Revision: D5299396

fbshipit-source-id: 98c5494a782cbe4df5b2d6021828eb7b2012f6dc
2017-07-18 14:46:22 -07:00
Adam Miskiewicz 8ea6cea39a MaskedViewIOS -- A way to apply alpha masks to views on iOS
Summary:
It's very important in complex UIs to be able to apply alpha channel-based masks to arbitrary content. Common use cases include adding gradient masks at the top or bottom of scroll views, creating masked text effects, feathering images, and generally just masking views while still allowing transparency of those views.

The original motivation for creating this component stemmed from work on `react-navigation`. As I tried to mimic behavior in the native iOS header, I needed to be able to achieve the effect pictured here (this is a screenshot from a native iOS application):

![iOS native navbar animation](https://slack-imgs.com/?c=1&url=https%3A%2F%2Fd3vv6lp55qjaqc.cloudfront.net%2Fitems%2F0N3g1Q3H423P3m1c1z3E%2FScreen%2520Shot%25202017-07-06%2520at%252011.57.29%2520AM.png)

In this image, there are two masks:

- A mask on the back button chevron
- A gradient mask on the right button

In addition, the underlying view in the navigation bar is intended to be a UIBlurView. Thus, alpha masking is the only way to achieve this effect.

Behind the scenes, the `maskView` property on `UIView` is used. This is a shortcut to setting the mask on the CALayer directly.

This gives us the ability to mask any view with any other view. While building this component (and testing in the context of an Expo app), I was able to use a `GLView` (a view that renders an OpenGL context) to mask a `Video` component!

I chose to implement this only on iOS right now, as the Android implementation is a) significantly more complicated and b) will most likely not be as performant (especially when trying to mask more complex views).

Review the `<MaskedViewIOS>` section in the RNTester app, observe that views are masked appropriately.

![example](https://d3vv6lp55qjaqc.cloudfront.net/items/250X092v2k3f212f3O16/Screen%20Recording%202017-07-07%20at%2012.18%20PM.gif?X-CloudApp-Visitor-Id=abb33b3e3769bbe2f7b26d13dc5d1442&v=5f9e2d4c)
Closes https://github.com/facebook/react-native/pull/14898

Differential Revision: D5398721

Pulled By: javache

fbshipit-source-id: 343af874e2d664541aca1fefe922cf7d82aea701
2017-07-11 15:05:57 -07:00
Seth Fitzsimmons 9afb71fde8 Replace React.createClass with create-react-class
Summary:
This replaces all uses of `React.createClass` with `createReactClass` from the `create-react-class` package, attempting to match use of `var` and `const` according to local style.

Fixes #14620
Refs #14712
Closes https://github.com/facebook/react-native/pull/14729

Differential Revision: D5321810

Pulled By: hramos

fbshipit-source-id: ae7b40640b2773fd89c3fb727ec87f688bebf585
2017-07-07 14:36:01 -07:00
Christoph Nakazawa e0eee0bb49 Revert D5321193: BREAKING: Add regenerator-runtime on demand, based on the files
Differential Revision: D5321193

fbshipit-source-id: 9113ed78e59ae9e9f3f86ca2fda2db3bd8c0dd7c
2017-07-07 10:48:37 -07:00
Miguel Jimenez Esun 361f03badb BREAKING: Add regenerator-runtime on demand, based on the files
Summary:
Adding a Babel plugin that will analyze the file looking for any potential candidate to use `regenerator-runtime`, and if so, will inject dynamically the module. The module is injected per file, so we avoid polluting the global environment. The plugin is also able to inject the `require` call beforehand, so that the inliner can pick them and inline them.

The Babel plugin is part of `react-native-babel-preset`, so as long as you are using this preset you are safe. If not, you should include the specific transformer into your list of plugins, as `react-native-babel-preset/transforms/transform-regenerator-runtime-insertion.js`.

Reviewed By: davidaurelio

Differential Revision: D5321193

fbshipit-source-id: fd4805b28c8a2b986842e23570a64003370d2067
2017-07-07 07:47:13 -07:00
Pieter De Baets 9108f98ca7 Add type for onLayout
Reviewed By: sahrens

Differential Revision: D5364203

fbshipit-source-id: ad87179422b0e595fc78db21a3108d50ba31564c
2017-07-07 03:06:21 -07:00
Christopher Chedeau c848c3820b Codemod prettier to 1.5.2
Differential Revision: D5339725

fbshipit-source-id: 631338436a7d69b0ab0721507bdab4ae4e207065
2017-06-28 12:50:30 -07:00
Valentin Shergin 2b1795c5ad Support `<TextInput keyboardType="numeric" returnKeyType="done" />` on iOS
Summary:
Standard only-numeric (number pad) keyboard on iOS does not have any "Done" or "Enter" button, and this is often very badly hurt user experience.
Usually it can be solved by implementing custom `inputAccessoryView`, but RN does not have built-in support for customizing it.
So, this commit introduced limited support only for "Done" button (returnKeyType="done") and it should suite very well for the vast majority of use cases.
This is highly requested feature, see more details here:
https://github.com/facebook/react-native/issues/1190

Reviewed By: mmmulani

Differential Revision: D5268020

fbshipit-source-id: 90bd5bffac6aaa1fb7c5c2ac539b35b04d45918f
2017-06-27 16:22:45 -07:00
Spencer Ahrens 1a5489bb70 Fix SnapshotExample
Reviewed By: fkgozali

Differential Revision: D5327149

fbshipit-source-id: 685bd2f52b6457b03db2e49df67c9830dd6c102a
2017-06-27 09:40:24 -07:00
Brian Vaughn 119959252e Remove RN fiber createClass wrapper around View
Reviewed By: spicyj

Differential Revision: D5241527

fbshipit-source-id: 9209004544e83cc0f03fcaa27c9b1acf8db09930
2017-06-21 12:38:06 -07:00
Hank Brekke ec68536e08 iOS `presentationStyle` Modal Appearance
Summary:
When using `<Modal` on larger iOS devices, esp. iPad and iPhone 7 Plus devices, there is no way to use the system functionality for controlling the appearance of modals (`presentationStyle`), which improves the native system's animation and display of smaller content appearing within large horizontal space.

I've added a new picker for selecting a `presentationStyle` within  the RNTester app. See below for the appearance of this change, as well as the relevant changes to the RN documentation.

![may-22-2017 09-49-50](https://cloud.githubusercontent.com/assets/3521186/26315020/6d4b1cb0-3ed5-11e7-8ac8-a996f1ee00f9.gif)
<img width="1051" alt="screen shot 2017-05-22 at 9 50 12 am" src="https://cloud.githubusercontent.com/assets/3521186/26315021/6d4cbf7a-3ed5-11e7-9d13-a5d20c9f3533.png">
Closes https://github.com/facebook/react-native/pull/14102

Differential Revision: D5281990

Pulled By: shergin

fbshipit-source-id: 882d8cb79e7adb0b4437cdf26e5e7ab1fc04f4c1
2017-06-20 19:22:57 -07:00
Guy Blank 60783aa6ba Expose content-available APS key for iOS silent push
Summary:
<details>
  Thanks for submitting a PR! Please read these instructions carefully:

  - [ ] Explain the **motivation** for making this change.
  - [ ] Provide a **test plan** demonstrating that the code is solid.
  - [ ] Match the **code formatting** of the rest of the codebase.
  - [ ] Target the `master` branch, NOT a "stable" branch.

  Please read the [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md) to learn more about contributing to React Native.
</details>

_What existing problem does the pull request solve?
In iOS when sending a silent push notification you need to configure the 'content-available' APS key to the value of 1 (When this key is present, the system wakes up your app in the background and delivers the notification to its app delegate, see [apple docs](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html#//apple_ref/doc/uid/TP40008194-CH17-SW1)).

This PR exposes this property to the notification event handler so app code can handle silent push scenario specifically. Currently this property is not available.

I've updated the PushNotificationIOSExample in the RNTester.

1. Open RNTester in xcode
2. Enable the  push notifications capability
3. run on device
4. Go to PushNotificationIOS
5. click on "send fake notification"
6. verify alert message contains 'content-available' with a value of 1.
Closes https://github.com/facebook/react-native/pull/14584

Differential Revision: D5279181

Pulled By: shergin

fbshipit-source-id: d2288e147d89ba267f54265d819aa0a9969095e7
2017-06-19 16:46:31 -07:00
Avik Chaudhuri 71401c1185 update xplat/js to flow 0.48.0
Reviewed By: zertosh

Differential Revision: D5243415

fbshipit-source-id: 78ea4f7f29bcd6a70650f24ceb05f06b18b39018
2017-06-14 15:47:21 -07:00
Eric Vicenti c78ddf2c3d Fix header on RNTester file
Reviewed By: hramos

Differential Revision: D5214933

fbshipit-source-id: 42ef48eead88200fc33029923ce1f4b1b5acf3b2
2017-06-13 12:18:45 -07:00
Spencer Ahrens 1d30f833a6 Add inverted option
Reviewed By: bvaughn

Differential Revision: D5210277

fbshipit-source-id: 5a8b196b90a2ac6d20397113ef4bd76446ea9fa3
2017-06-12 22:45:49 -07:00
Jean Regisser 5114b61b5e Add support for flashScrollIndicators on iOS
Summary:
Flashing scroll indicators is a standard behavior on iOS to show the user there's more content.

Launch RNTester on iOS, go to the ScrollView section, tap the "Flash scroll indicators" button.
You'll see this:

![Flash scroll indicators](https://cloud.githubusercontent.com/assets/57791/26250919/ebea607a-3cab-11e7-96c6-27579cc809ab.gif)

I've exposed the method `flashScrollIndicators` on all scrolling components that were already exposing a `scrollToXXX` method so it's usable from those components using a ref.

Let me know what you think.
Closes https://github.com/facebook/react-native/pull/14058

Differential Revision: D5103239

Pulled By: shergin

fbshipit-source-id: caad8474fbe475065418d771b17e4ea9766ffcdc
2017-06-06 13:06:48 -07:00
Koen Punt e5e3591009 replace lineBreakMode with ellipsizeMode
Summary:
lineBreakMode is a non-existing property (or maybe legacy?)

While reading the docs I encountered this prop being used in the example, but it doesn't exist in the codebase anymore.
Closes https://github.com/facebook/react-native/pull/13820

Differential Revision: D5189652

Pulled By: javache

fbshipit-source-id: 70e620fc094ae5e1628ab13ee9e410044e4f5291
2017-06-06 04:16:00 -07:00
Valentin Shergin 072d2709df Introducing `-[RCTView reactAccessibleView]`
Summary:
Sometimes, when we implement some custom RN view, we have to proxy all accessible atributes directly to some subview which actually has accesible content. So, in other words, this allows bypass some axillary views in terms of accessibility.
Concreate example which this approach supposed to fix:
https://github.com/facebook/react-native/pull/14200/files#diff-e5f6b1386b7ba07fd887bca11ec828a4R208

Reviewed By: mmmulani

Differential Revision: D5143860

fbshipit-source-id: 6d7ce747f28e5a31d32c925b8ad8fd4b98ce1de1
2017-06-02 14:19:57 -07:00
Jhen cf51aee9a0 Support `options` param for `requestIdleCallback`
Summary:
The `requestIdleCallback` sometimes doesn't work in `Debug JS Remotely` mode if I use real device, the callback will never called. I guess it may be debugger worker and device caused by the time gap, or some cause websocket blocking, so it's just sometimes happening.

I think we can support [options](https://developer.mozilla.org/zh-TW/docs/Web/API/Window/requestIdleCallback#Parameters) for that.

Added an example `Run requestIdleCallback with timeout option` for Timers of UIExplorer, it use `{ timeout: 100 }` option with burn CPU 100ms, we can see `didTimeout` is true.
Closes https://github.com/facebook/react-native/pull/13116

Differential Revision: D4894348

Pulled By: hramos

fbshipit-source-id: 29c4c2fe5634b30a8bf8d3495305cd8f635ed922
2017-06-01 11:00:40 -07:00
Valentin Shergin e13b9c6e49 RCTTextField was spliited into two classes
Summary:
Motivation:
 * We maintain two different implementation of <TextInput> (multilined and singlelined), this change makes the implementations much similar which will help us to support and improve both of them in the (near) future;
 * We have to have separated RCTView-based container view for (TextField) to support sofisticated bordering and so on;
 * It opens to us possibility to unify UITextView and UITextField subclasses and remove code duplication across RCTTextView and RCTTextField;
 * Making things decoupled in general will allow us to fix existing bugs with events.

Reviewed By: mmmulani

Differential Revision: D5083010

fbshipit-source-id: 2f2d42c2244d2b39256c51480c1f16f4e3947c01
2017-05-29 16:01:11 -07:00
Valentin Shergin 48650226e8 Multiline <TextInput> was fixed to match layout logic of singlelined one
Summary: Now padding, border and intinsic sizes are computed same way as for singlelined text input.

Reviewed By: mmmulani

Differential Revision: D5075880

fbshipit-source-id: 1bc2fd479c13a003c717b1fc3d9c69f4639d4444
2017-05-29 16:01:09 -07:00
Valentin Shergin 44af4d19d3 Fixed <TextInput>'s padding and border size computation and layout
Summary: Previosly `borderWidth` did not affect actual content inset (which was a problem).

Reviewed By: mmmulani

Differential Revision: D5072483

fbshipit-source-id: d43cba7414a9335b9f9fd4d1565d7aee403cce0e
2017-05-29 16:01:04 -07:00
Valentin Shergin ea9d6746df Singleline <TextInput> now has intrinsic size
Summary:
Singleline <TextInput> now has intrinsic size which is equal to size of placeholder.
And if <TextInput> does not have placeholder it still has intrinsic height.
So, we don't need to set the size up manually every single time anymore!

(Multiline <TextInput> already has this feature.)

Reviewed By: mmmulani

Differential Revision: D5069971

fbshipit-source-id: f65c1062a812259b66d287929314dc571dc1f3ee
2017-05-29 16:00:58 -07:00
Janic Duplessis 11424a8bc6 Native Animated - Support Animated.loop on iOS
Summary:
Follow up to #11973 to add support to Animated.loop with useNativeDriver on iOS.

**Test plan**
Test with new UIExplorer example
Run unit tests
Closes https://github.com/facebook/react-native/pull/13359

Differential Revision: D4960754

Pulled By: javache

fbshipit-source-id: caa840281f1b060df7a2b1c50405fcae1e1b0de6
2017-05-26 03:30:33 -07:00
glevi@fb.com ffdae135fd Deploy v0.47.0 to xplat/js
Reviewed By: zertosh

Differential Revision: D5135644

fbshipit-source-id: f979970f8d0c4e082ec1302084d4def6652557c8
2017-05-25 23:00:37 -07:00
Valentin Shergin 35393524a9 Fixed <TextInput>.onContentSizeChange on Android
Summary:
Previously <TextInput>'s onContentSizeChange event fires very rearly, usually just once after initial layout. This diff fixed that.
I also considered to a bunch of another things to get the native notification, but I found that overriding `onTextChanged` is the most reliable, easy and effitient way to implement this.

I tried/considered:
 * onLayout (does not fire)
 * OnPreDrawListener (fires to often)
 * OnGlobalLayoutListener (does not fire)
 * OnLayoutChangeListener (does not fire)
 * isLayoutRequested (too hacky)

(I also fixed the <AutoExpandingTextInput> demo to illustrate the fix.)

And just heads up, we will remove `contentSize` info from `onChange` event very soon.

GH issue: https://github.com/facebook/react-native/issues/11692

Reviewed By: achen1

Differential Revision: D5132589

fbshipit-source-id: e7edbd8dc5ae891a6f4a87b51d9450b8c6ce4a1e
2017-05-25 19:31:31 -07:00
Caleb Meredith f702cbecba Render section footer in <SectionList> sections with no data
Summary:
Fixes https://github.com/facebook/react-native/issues/13784

The section footer was only rendered with the last item of the section. However, that meant in sections where no items were rendered, no section footer would be rendered. This patch makes sure that when there are no items the section footer is rendered with the section header in addition to adding tests asserting the existance of section footers in empty lists.

One potential point of contention is whether or not a section separator (as defined by the `SectionSeparatorComponent` prop to `<SectionList>`) should be rendered in an empty list. I did not include a section separator for empty lists, but let me know if you think one should be included. See the test plan below for an image of an empty section rendered without a section separator.

I was also running into a lint error, `no-alert`, in `SectionListExample.js` around line 135 that blocked me from publishing. This error looks to be triggered when the `alert()` global function is called, so to fix the error I added an import for the `Alert` module and called the `alert()` function on that module.

To help debug the `scrollToLocation()` behavior that was modified as a part of this PR I added three buttons (can be seen in the test plan image) which scroll to arbitrary points in the list.

Reviewed By: sahrens

Differential Revision: D5084095

fbshipit-source-id: 4c98bebc1c3f1ceaa5a634fa144685d83d1072df
2017-05-25 10:30:55 -07:00
Douglas Lowder 9e8a39ce2c Add ART library to UIExplorer for iOS, with sample and snapshot test
Summary:
**Motivation**

The ART library is part of the react-native repo, but is not included in UIExplorer and has no native testing.  This PR adds the ART library to UIExplorer, adds an example tab for it, and adds a snapshot test.

**Test plan**

New snapshot test.
Closes https://github.com/facebook/react-native/pull/13621

Differential Revision: D4954082

Pulled By: javache

fbshipit-source-id: 83e21c5df1b766ff6ca9f8914eb3382f7323627d
2017-05-25 08:45:47 -07:00
Xinbo Wang eac399b696 Add flexWrap warning
Reviewed By: sahrens

Differential Revision: D5117970

fbshipit-source-id: 11b542bd6cd7b1ab22ba8f6822d471df94fa7da2
2017-05-25 00:00:38 -07:00
Valentin Shergin 9637dd4a1b Introducing <ImageBackground>, replacement for <Image> which supports nesting views
Summary:
We are removing support of nesting views inside <Image> component. We decided to do this because having this feature makes supporting `intrinsinc content size` of the `<Image>` impossible; so when the transition process is complete, there will be no need to specify image size explicitly, it can be inferred from actual image bitmap.

And this is the step #0.

<ImageBackground> is very simple drop-in replacement which implements this functionality via very simple styling.
Please, use <ImageBackground> instead of <Image> if you want to put something inside.

Reviewed By: yungsters

Differential Revision: D5100021

fbshipit-source-id: 640c0fb2d1066e166d974efba39b4cfaaee7dd45
2017-05-24 11:30:48 -07:00
Eric Vicenti 4a80dceac7 Re-license and rename UIExplorer integration test app as RNTester
Reviewed By: yungsters

Differential Revision: D4950085

fbshipit-source-id: 44574b5d0ef0d2ad5dfc714309b18dc69cbad9ff
2017-05-08 11:31:19 -07:00