Commit Graph

386 Commits

Author SHA1 Message Date
Miguel Jimenez Esun 33bbfb7125 Fix test for RN asset
Reviewed By: cpojer, rafeca

Differential Revision: D5777553

fbshipit-source-id: 3bc8559076435c6254972552095967b88acb0576
2017-09-07 01:55:56 -07:00
Marshall Roch 91b6b4efb9 @allow-large-files Flow v0.54.0
Reviewed By: leebyron

Differential Revision: D5773490

fbshipit-source-id: 2c54bb6326f23edbe9a969f3010f79da8189923e
2017-09-06 03:33:43 -07:00
Martin Yrjölä 25639176ff Asset basenames in Jest snapshots
Summary:
This change only affects tests run with Jest. `require('/images/image1.png')` will be replaced with

```
Object {
  "testUri": "relative/path/to/images/image1.png",
}
```

in the Jest snapshot instead of always being 1 returned by RelativeImageStub. This change makes it possible to test conditional asset loading in components.

The problem with this change is that it will probably break a lot of existing snapshots, but that should be easily fixed when a project updates to a new version of React Native by running `jest -u` to update all snapshots.

A component can have conditional asset loading based on its props, this logic would be nice to test with Jest snapshots. This problem has been discussed in https://github.com/facebook/jest/issues/2838.

* **Who does this affect**: Everyone using `Image` in Jest snapshots
* **How to migrate**: Running `jest -u` will update the snapshots, the snapshots should be reviewed that they are correct.
* **Why make this breaking change**: It enables testing of conditional asset loading.
* **Severity (number of people affected x effort)**: Low.
Closes https://github.com/facebook/react-native/pull/13319

Reviewed By: rafeca

Differential Revision: D5708180

Pulled By: mjesun

fbshipit-source-id: 16ac42004d597db08545a21d4fffe95c5ee7e21f
2017-09-06 03:33:43 -07:00
Mark Smith 998197f444 Clean up some URL path handling
Reviewed By: sahrens

Differential Revision: D5753338

fbshipit-source-id: 0eb1b4ae64ad7170f1b97f398ff11b713c695b12
2017-09-01 13:45:03 -07:00
Aleksei Androsov ccc11f2f30 Fix Image.getSize() according to image orientation
Summary:
This is fix for issue https://github.com/facebook/react-native/issues/14097

I've prepared images with different exif orientation (https://yadi.sk/d/is_xcEEo3MRAxF)
0-4 should have size 200x100
5-8 should have size 100x200
Closes https://github.com/facebook/react-native/pull/15690

Differential Revision: D5731414

Pulled By: shergin

fbshipit-source-id: 7ced00ac7ac812c91216dccf0c76acd0e913dda0
2017-08-30 00:33:44 -07:00
Caleb Meredith 63f990121a Fix React Native open source
Reviewed By: hramos, TheSavior

Differential Revision: D5728356

fbshipit-source-id: fb751d67c16ba9273de93d9b6d5acd65b1555dca
2017-08-29 15:01:05 -07:00
Pieter De Baets 7542f3d659 Call reloadImage less often when setting Image props
Summary: Came across multiple calls to reload while we we're setting properties on the image. During the initial setup they should no-op pretty quickly, but this should avoid us making multiple requests when changing an image that's already visible.

Reviewed By: mmmulani

Differential Revision: D5536014

fbshipit-source-id: 3c2abb83cbb66f9d8928f20fc7f461562f666f43
2017-08-29 04:23:04 -07:00
Caleb Meredith 90eaeb019b Upgrade fbsource/xplat/js to Flow v0.53.0
Reviewed By: avikchaudhuri

Differential Revision:
D5648819
Ninja: T20988071

fbshipit-source-id: 66e5b6747c79ae66b6eb69d40ede5e982c26174f
2017-08-17 18:45:01 -07:00
Adlai Holler 114b0801ce RCTImage: Use C atomics instead of OSAtomic
Summary:
The next in my series of :atom: migrations.
Closes https://github.com/facebook/react-native/pull/15278

Differential Revision: D5526468

Pulled By: javache

fbshipit-source-id: 91511c69bc37a6f1382bcf0b0dd847adf10fd43a
2017-08-01 02:51:03 -07:00
Adlai Holler 0f440130b6 Standardize project indentation settings on 2 spaces
Summary:
Hi React Native folks! Love your work!

To make contributing easier, this sets the indentation settings of all the Xcode projects to 2 spaces to match their contents.
Closes https://github.com/facebook/react-native/pull/15275

Differential Revision: D5526462

Pulled By: javache

fbshipit-source-id: cbf0a8a87a1dbe31fceed2f0fffc53839cc06e59
2017-07-31 05:20:03 -07:00
Aleksei Androsov 6555f9bee8 Fix photo orientation from ImagePickerIOS
Summary:
Original PR: https://github.com/facebook/react-native/pull/12249

ImagePickerIOS saves photos to ImageStoreManager without meta information. So photo has wrong orientation.

**Test plan**
1. Take the 2 photos (in landspape and portrait orientation) with this code:
```
ImagePickerIOS.openCameraDialog(
  {},
  (uri) => CameraRoll.saveToCameraRoll(uri),
  () => {}
);
```
2. Ensure that photos in Photos app have right orientation.
Closes https://github.com/facebook/react-native/pull/15060

Differential Revision: D5487595

Pulled By: shergin

fbshipit-source-id: ce1a47f4d5ba33e03070f318f3d6a8dd0df5ab88
2017-07-24 21:51:51 -07:00
Shir Levkowitz ced1513b62 Pass actual loaded image size to load (iOS).
Summary:
Motivation: The JavaScript image component's onLoad callback optionally
accepts dimensions width and height, allowing the parent of the image to
obtain the native size (without an extra bridge call). It was found that
the dimensions passed into this callback on iOS are frequently (0,0),
not the true native dimensions. This change ensures that the image's
dimensions are passed to the callback. (Examination of the initializer
for RCTImageSource, + (RCTImageSource *)RCTImageSource:(id)json,
indicates that not all code paths produce a size other than CGSizeZero.)
Closes https://github.com/facebook/react-native/pull/15116

Differential Revision: D5460979

Pulled By: javache

fbshipit-source-id: 2dca03c3aae974ef70e981039aa6a804b8e128c8
2017-07-20 03:05:11 -07:00
Felix Oghina 999851a389 Update OSS Fresco dependency
Reviewed By: oprisnik

Differential Revision: D5406106

fbshipit-source-id: 3d928f431701b783fa0862d0dff818ec61d8b737
2017-07-12 07:54:09 -07:00
harry-g ec8118b637 Better doc for 'data:' uri scheme & mandatory size
Summary:
It is quite confusing that the 'data:' uri scheme is not documented, but working.
It is very useful when getting e.g. an icon from a REST call.

Also, the mandatory size style for network & data images should be mentioned here, not only in the image guide.

<!--
Thank you for sending the PR!

If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos!

Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native.

Happy contributing!
-->
Closes https://github.com/facebook/react-native/pull/14826

Differential Revision: D5401671

Pulled By: hramos

fbshipit-source-id: 8f1f28a94095eeaccae9234e059e0983ba3556b2
2017-07-11 15:33:37 -07:00
Patrick dc97e3fb4e Fixed ImageBackground could't be wrapped by Touchable* component
Summary:
In 0.46, as warning's advice, I use `ImageBackground` to replace `Image`s which used as background image wrapper, and in some cases, I also wrap `ImageBackground` with `TouchableHighlight` to make it clickable.

But here comes an error:

> Touchable child must either be native or forward setNativeProps to a native component

![2017-07-07 3 25 19](https://user-images.githubusercontent.com/3055294/27948869-f7c5832c-632d-11e7-97ba-5074cca82961.png)

So I pick some code from `Image.ios.js` into `ImageBackground.js` to solve it.

Please help to review, thanks!
Closes https://github.com/facebook/react-native/pull/14884

Reviewed By: shergin

Differential Revision: D5380988

Pulled By: javache

fbshipit-source-id: 35fda029030a39e720b6266f5d0a27ea3ff145ef
2017-07-10 05:03:25 -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
James Ide 6e13adbf56 Remove remnants of the packager
Summary:
There were still some references to "packager/" that are no longer used since the `packager` directory has been deleted after moving to Metro. Cleaned up the ones that were doing nothing and updated the references that are still meaningful.
Closes https://github.com/facebook/react-native/pull/14881

Reviewed By: cpojer

Differential Revision: D5380731

Pulled By: javache

fbshipit-source-id: 1355268f48db47343d0d38fae2598b64c8c01475
2017-07-07 03:06:21 -07:00
Aleksei Androsov 8377b30b8d ImageBackground: use cached styles
Summary:
Replace object with cached styles from StyleSheet

Create new style object may cause performance problems

Check that ImageBackground position works the same way.
Closes https://github.com/facebook/react-native/pull/14486

Differential Revision: D5274503

Pulled By: shergin

fbshipit-source-id: 09b81e6f7ae2ada7f68854e409909caafd85e56a
2017-06-19 08:46:32 -07:00
James Burnett 51c0e81557 remove disableAutomock from jest tests (new default) @bypass-lint
Reviewed By: cpojer

Differential Revision: D5237192

fbshipit-source-id: dccca52a91259d7fea27931f92bca94184a82d4a
2017-06-13 15:04:09 -07:00
Valentin Shergin 7707905550 Improved <ImageBackground>
Reviewed By: sahrens

Differential Revision: D5214113

fbshipit-source-id: 1eca2347f97a1ff13f71906688a33b9ed7a3a7f4
2017-06-13 14:02:40 -07:00
Fred Liu 8dd15f2c87 Allow video uploads
Summary: Allows video uploads from native iOS by using the proper network handler, `RCTAssetsLibrary` rather than `RCTImageLoader`. Currently, uploading a camera roll video via its `assets-library://` URI would upload the first image frame. This fixes it by checking if the `assets-library://` URI is of the extension `MOV`, and if so, declines to process it from `RCTImageLoader`.

Reviewed By: javache

Differential Revision: D5223351

fbshipit-source-id: 8de92c5bb72acb02ed4d9fb92d69f68c8b5d1b36
2017-06-13 08:16:43 -07:00
Andrew Imm 50b11aa09b Update remaining PropTypes references
Reviewed By: bvaughn

Differential Revision: D5231309

fbshipit-source-id: d54ee4f73dae63124f4462c138383447829a2551
2017-06-12 16:03:09 -07:00
James Burnett 3360999431 disable automock by default in as many places as possible @bypass-lint
Reviewed By: cpojer

Differential Revision: D5190858

fbshipit-source-id: d3125cf81427dbbe3362ef1f958413394a6dc51d
2017-06-08 07:45:54 -07:00
Pieter De Baets 79500f81a9 Fix Travis CI runs
Summary: Closes https://github.com/facebook/react-native/pull/14286

Differential Revision: D5164925

Pulled By: javache

fbshipit-source-id: 0ebe028ab58f37a9afc8b615fe346d7af9180040
2017-06-02 09:03:18 -07:00
Valentin Shergin 2e66ac8999 <ImageBackground> got `imageRef` and `imageStyle` props
Summary: It can be useful when you want to setup `tintColor` for the image or get a reference to call `setNativeProps` then.

Reviewed By: ericvicenti

Differential Revision: D5158908

fbshipit-source-id: 873c1cae9bd0af711a42016dcc548231e3cf89e7
2017-06-01 14:16:14 -07:00
Valentin Shergin 279f5f1c56 Using <Image> with nested content now causes warning (yellowbox)
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 #2: Yellow Box.

<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: D5139264

fbshipit-source-id: 99442107e10a321618fd34802c57a8c205ce66fb
2017-05-30 20:04:55 -07:00
Francisco Sales 457616fe5f Adding supported formats to Image component docs
Summary:
The lack of very clear docs on supported image formats is causing unnecessary issues (#13806).
This should mitigate and keep the issue list cleaner.

Its only a documentation change. No code changes made.
Closes https://github.com/facebook/react-native/pull/13807

Differential Revision: D5023002

Pulled By: javache

fbshipit-source-id: b1e3562ae7649cf71833b300e125966d6e832a69
2017-05-24 12:18:14 -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
Jean Regisser fc09c54324 Document image blurRadius is working on Android too
Summary:
Hi,

I saw blurRadius is now working on Android. Updated the doc to show it.

It is available since 0.44, see 0b348095b6

See RNTester screenshot on Android:
![blur-android](https://cloud.githubusercontent.com/assets/57791/26244353/97fa4f96-3c8f-11e7-8910-5c60f5ad93fc.png)

Also I noticed it's a bit different than on iOS:
![blur-ios](https://cloud.githubusercontent.com/assets/57791/26244396/bbaf9158-3c8f-11e7-96cc-534d8ee042fb.png)

Looking briefly at the code, it looks like it's caused by the fact that the Android version applies blur to the original image data in full size (and applies `PixelUtil.toPixelFromDIP(blurRadius)`), but the iOS version applies it to the resized version.
I'll open an issue for this.
Closes https://github.com/facebook/react-native/pull/14055

Differential Revision: D5103240

Pulled By: javache

fbshipit-source-id: 16d8c8755cd27a4f13c28e8831017733327ca491
2017-05-22 05:45:29 -07:00
Adam Perry ca2d57c744 Update examples in docs and address version lag of CRNA
Summary:
cc hramos

Pretty sure I've hit all of the places where AppRegistry is called in CRNA-pastable examples. Let me know whether you think we need to approach the version lag differently, I figure a caveat is as natural a place to call it out as any.

If you end up finding anything else that needs tweaking before cherry picking, I'm happy to push that up here too.
Closes https://github.com/facebook/react-native/pull/13744

Differential Revision: D5071038

Pulled By: hramos

fbshipit-source-id: 4a4a6f2a73079aca627f17d75a4e4b395ecbd4a8
2017-05-16 23:51:28 -07:00
Pieter De Baets 885856c6a1 More attempts to fix Travis CI runs
Summary:
* Add RCTBridge+Private to exported headers for unit tests
* Fix tvOS build
Closes https://github.com/facebook/react-native/pull/13840

Reviewed By: ericvicenti

Differential Revision: D5027887

Pulled By: javache

fbshipit-source-id: 7a17ee2f84eb1cb87e71373444ef25559959c24a
2017-05-10 04:32:54 -07:00
Brian Vaughn ef0bd5c71d Sync React 16 from alpha 6 to 12
Reviewed By: spicyj

Differential Revision: D4926070

fbshipit-source-id: c23c79ccd53eb594447d9b47fe3ac6e82499bd42
2017-05-03 17:16:48 -07:00
Eric Vicenti 3544b76c26 Cleanup Xcode project references to UIExplorer
Summary: The xcode project for these bundled libraries should not depend on UIExplorer

Reviewed By: yungsters

Differential Revision: D4979629

fbshipit-source-id: 440b225805e9ebaf0a02b39a35c3ab9c2a83ad05
2017-05-01 14:15:36 -07:00
Jean Lauliac 1f8d1002ef packager: buck library: expose asset content
Reviewed By: davidaurelio

Differential Revision: D4945778

fbshipit-source-id: ea132a3d284ed09c59c69afbdd7b707af9e521b9
2017-04-25 12:04:01 -07:00
Steffen Forkmann a9ad81a085 Update documentation to use newer version of fresco - fixes #13345
Summary:
Thanks for submitting a PR! Please read these instructions carefully:

React Native crashes hard on fresco 0.11.0 - see #13345

Repro case in #13345
Closes https://github.com/facebook/react-native/pull/13419

Differential Revision: D4913258

Pulled By: javache

fbshipit-source-id: 8beb55102e0f2d362c77698a35ea7d57fdcba48d
2017-04-19 05:02:09 -07:00
Brian Vaughn 6564edce5e Ran PropTypes -> prop-types codemod against Libraries/FBReactKit/js/react-native-github
Reviewed By: acdlite

Differential Revision: D4876709

fbshipit-source-id: 3a5e92bfc74287b7a9054546c438580bed0147af
2017-04-12 16:15:15 -07:00
Janic Duplessis c7387fefc8 Enable flow in react-native-implementation
Summary:
I noticed I didn't get type defs anymore for react-native. Looks like it is broken since we removed the .flow file in 3e153b2a5b. To fix it we can now enable flow in react-native-implementation since it now supports properties.

**Test plan**
Tested that I get type hints when using imports from react-native in a project.
Closes https://github.com/facebook/react-native/pull/12917

Differential Revision: D4704753

Pulled By: ericvicenti

fbshipit-source-id: cf882588d7f371931de8d7861a1a6d50f6c425dc
2017-04-05 10:17:49 -07:00
Brian Vaughn de8ce45258 Ran codemod to replace View.propTypes with ViewPropTypes
Reviewed By: yungsters

Differential Revision: D4764838

fbshipit-source-id: 0b47a0fdd6793dab9333bb73bb93053fccc27dae
2017-03-24 00:30:48 -07:00
Pieter De Baets 7c9173bc9e Enable -Wimplicit-retain-self en sync warning config for all projects
Summary:
This is enforced for all of our internal iOS code and a common cause of import failures.

cc janicduplessis
Closes https://github.com/facebook/react-native/pull/13124

Differential Revision: D4765016

fbshipit-source-id: 7c8248c98bca0fa6bad24d5a52b666243375e0db
2017-03-23 15:01:34 -07:00
Ashwin Bharambe f48b54bf62 Expose RCTImageLocalAssetURL as a utility
Reviewed By: javache

Differential Revision: D4696627

fbshipit-source-id: 56d3e59983f524dfd5021835734b9b34203e20f2
2017-03-17 17:02:06 -07:00
Mohammed 0150bc76eb Updating the documentation for getSize()
Summary:
Clearly state that the `getSize()` does not work for static image resources because it is assumed the developer knows their static image resource size (the reason I got from a comment on a github issue by a react native contributor).

This missing documentation cost me about 30 minutes to figure out why it didn't work for my static image resource and so I decided to update the documentation 💃
Closes https://github.com/facebook/react-native/pull/11645

Differential Revision: D4533463

Pulled By: lacker

fbshipit-source-id: 70e175ea30a5540c8a9f2a0c040585c711d82ac3
2017-03-08 06:45:22 -08:00
Eric Vicenti a8474c25fd Fix license headers
Reviewed By: hramos

Differential Revision: D4670890

fbshipit-source-id: e8429aa88a1d4f3cc80034dd087739410c0761f2
2017-03-08 00:52:17 -08:00
Jeff Morrison 59257d6976 fbobjc
Reviewed By: gabelevi

Differential Revision: D4652687

fbshipit-source-id: 6069c8bc24f0b88da3537ada877cdb7d1d4eccfd
2017-03-04 19:30:34 -08:00
Ludo Fardel 0b348095b6 blurRadius for Image
Summary:
This adds blurRadius support for <Image>, similar to iOS.
The heavy-lifting was done by lambdapioneer in the stack of diffs ending with
D3924013, we're just patching this in.
Two notes: we might need to apply two postprocessors going forward, will tackle
that in a separate diff, so we can ship this asap.
However, we need a new version of fresco to be released in order
to ship this.

Reviewed By: lexs

Differential Revision: D3936438

fbshipit-source-id: 353bf1f1120ebd5f4f8266c5a20188b41478a741
2017-03-02 07:47:21 -08:00
Mathieu Baudet 4a893ee071 remove unused includes in fbobjc/Libraries
Reviewed By: swolchok

Differential Revision: D4507573

fbshipit-source-id: 7fc6df52bc37c39698c7897be567758469417218
2017-02-19 18:33:49 -08:00
Martin Konicek 8c0e6ecfc0 Android: Support HTTP headers for source prop on <Image> components
Summary:
A copy of https://github.com/facebook/react-native/pull/7791 because of our very imperfect tools that mirror the changes from pull requests in the fb monorepo. The internal Phabricator revision for #7791 is in an 'abandoned' state (by foghina probably because of changing teams) and Phabricator doesn't allow me to claim that revision and merge it. Therefore I'm creating a new one.

(It's not foghina's fault, no one probably knew about this "abandoned Phabricator revision" edge case, don't remember we hit it before.)

Will try to keep attribution (git blame) to rigdern when merging.
Closes https://github.com/facebook/react-native/pull/12448

Differential Revision: D4584743

Pulled By: mkonicek

fbshipit-source-id: 66e5b88134fca1980adc4cd8a2ff17c42e10022c
2017-02-18 04:45:11 -08:00
Aaron Chiu 1fa95ed390 inline a bunch of NativeModule requires
Reviewed By: shergin

Differential Revision: D4578180

fbshipit-source-id: 3764ffd32eb7e4698e928740bc72bbad02876894
2017-02-17 16:49:38 -08:00
Charles Chen 274e7ba592 Make flow types update to date with proptypes with ImageSource
Summary:
As the task covered, we would like to update the ImageSource flow type.

Edit the flow types for ImageSource to map to the propTypes ImageSourcePropType.js

Reviewed By: mmmulani

Differential Revision: D4573836

fbshipit-source-id: ef3f5365e00b4926c75188f345811f5cfa4bfd3c
2017-02-16 15:18:43 -08:00
Tim Yung b053fd5bdd RN: Fix Type of `accessibilityLabel` in <Image>
Summary: Fixes the prop type of `accessibilityLabel` in `<Image>` so that it matches that of `<View>`.

Reviewed By: fkgozali

Differential Revision: D4499103

fbshipit-source-id: 66bf3dce60bd79857849e0c46c989e7866d83d81
2017-02-02 22:13:26 -08:00
Christoph Pojer a2c84d14ce Remove `react-packager` indirection.
Summary:
This moves the `src` directory one level up and removes the `react-packager` folder. Personally, I always disliked this indirection. I'm reorganizing some things in RNP, so this seems to make sense.

Not sure if I forgot to update any paths. Can anyone advice if there are more places that need change?

Reviewed By: jeanlauliac

Differential Revision: D4487867

fbshipit-source-id: d63f9c79d6238300df9632d2e6a4e6a4196d5ccb
2017-02-02 05:44:15 -08:00
Koen Punt 72bafefc31 fix type on => one
Summary:
Just fixed a typo
Closes https://github.com/facebook/react-native/pull/12001

Differential Revision: D4443718

Pulled By: hramos

fbshipit-source-id: 69d194da871491d7243c7cc0d07dff4dfb1db590
2017-01-23 15:13:32 -08:00
Peter Salanki 52d8851fc8 Cache policy control for image source
Summary:
In the context of an app an image exists in three resolutions on the server: `thumb` (30px) `feed` (300px) `full` (900px). When looking at an individual item a user can come either from the feed, via a permalink or from other parts of the app. This allows a situation where the `feed` image might or might not already be loaded somewhere in the app. In the detail view I want to render `thumb` with a blur (to quickly display something), then the `feed` image if it exists to have something decent to display until `full` loads. However it is quite a waste to load the `feed` image if it isn't already in cache, and will slow down the time until `full` is loaded. It is possible to track the navigation from feed->detail and that the `feed` image has actually completed loading by the feed component however as component hierarchies grow this turns into quite a lot of prop passing and bad separation of concerns.

NSURLRequests accepts a [Cache Policy](https://developer.apple.com/reference/fo
Closes https://github.com/facebook/react-native/pull/10844

Differential Revision: D4425959

Pulled By: lacker

fbshipit-source-id: 679835439c761a2fc894f56eb6d744c036cf0b49
2017-01-17 17:13:31 -08:00
Spencer Ahrens c7e3819cf4 Propagate prop type flow through StyleContext.createContainer
Reviewed By: blairvanderhoof

Differential Revision: D4394074

fbshipit-source-id: f9c7f71ba921d345e3313a3a2be16a7f85a2e0af
2017-01-13 19:28:28 -08:00
Drew Volz 5ba0bb287d Typo in imageResizeMode getSize
Summary:
Change "sucessfully" to "successfully"
Closes https://github.com/facebook/react-native/pull/11715

Differential Revision: D4380482

Pulled By: JoelMarcey

fbshipit-source-id: 2448d60b750cca0983d308945ad6ed9b46c73a97
2017-01-04 02:43:30 -08:00
Mehdi Mulani ac11eedfb0 Show yellowbox when we fail to load a local image
Reviewed By: achen1

Differential Revision: D4342295

fbshipit-source-id: 9411ffe9a376e1ed51fcadee718326d1d9443fff
2016-12-19 14:07:08 -08:00
Alan Norbauer 4aabf4b6b3 Replace jest.resetModuleRegistry() with jest.resetModules()
Reviewed By: cpojer

Differential Revision: D4344961

fbshipit-source-id: 45453ec7ee3211743946ab9156f51430322b5832
2016-12-18 17:13:38 -08:00
Pieter De Baets 59407f3660 Redo exported headers and include paths for opensource
Summary:
Xcode really sucks, per some discussion on e1577df1fd and https://developer.apple.com/library/content/technotes/tn2215/_index.html, if you use the headers phase, and mark headers in your static library as public, they will actually end up in the final package that's built and you can't submit to the app store! This changes our xcode setup to use a copy files phase instead.

I've also changed the header include path to be $(BUILT_PRODUCTS_DIR)/include, which is added to the include path by Xcode by default, so 3rd party libraries should not be impacted by these changes anymore.

Reviewed By: mkonicek

Differential Revision: D4291607

fbshipit-source-id: 969b9ebcbeb8161f85427f8c429e198d9d0fae30
2016-12-07 15:28:29 -08:00
Adam Comella 2aca021504 iOS: Fix dequeueTasks crash in image loader
Summary:
This fixes a crash occurring [on this line](f9f32eb426/Libraries/Image/RCTImageLoader.m (L253)). It was reported in a comment in #10433.

The problem is that `task` is deallocated at this point and is unsafe to use. Removing it from `_pendingTasks` dropped its ref count to 0. [The ARC docs](http://clang.llvm.org/docs/AutomaticReferenceCounting.html#fast-enumeration-iteration-variables) state that, by default, loop variables in fast enumeration loops are not retained. That's why `task`'s ref count is 0.

It's likely we ran into this bug because the code disobeyed the [reverseObjectEnumerator docs](https://developer.apple.com/reference/foundation/nsarray/1415734-reverseobjectenumerator) which state that "you must not modify the array during enumeration". The default retention policy for fast enumeration seems to assume you follow this.

To fix this bug and avoid other potential pitfalls, the code now follows the docs and `_pendingTa
Closes https://github.com/facebook/react-native/pull/11296

Differential Revision: D4277167

Pulled By: javache

fbshipit-source-id: 1211b32935bab7f4080dc00b88d85348786e859a
2016-12-05 10:13:29 -08:00
Adam Comella 23423774ba iOS: Fix an image loader crash
Summary:
Fixes #10433

The code didn't account for the fact that cancelLoad is set by two different threads. It gets set on the URL request queue when the request completes successfully and it gets set on the UI queue during cancelation. This oversight lead to a couple of different kinds of crashes.

1. Attempt to invoke a nil function -- We check that cancelLoad is non-nil and on the next line we call it. However, cancelLoad could have been set to nil by the other thread between the time it was verified to be non-nil and the time it was called. Consequently, the program will attempt to call nil and crash.

2. Block deallocated while it's executing -- Suppose cancelLoad points to a block, it is verified to be non-nil, and it is successfully invoked. In the middle of executing the block, cancelLoad, the last reference to the block, is set to nil. This causes the block to be deallocated and its captured values to be freed. However, the block continues executing and the next time it attempts to use a captured value
Closes https://github.com/facebook/react-native/pull/11145

Differential Revision: D4261499

Pulled By: javache

fbshipit-source-id: 46424c6dd8cfa085cef32d945308de07798040bc
2016-12-01 21:28:33 -08:00
Alex Kotliarskyi 1fe0f4d8ec Add `deprecated` flag for nativeImageSource
Summary:
Looks like the native Image implementation used to treat old `image!` images slightly differently. This diff restores that behavior for `nativeImageSource`.

{F65080365}

Reviewed By: mmmulani

Differential Revision: D4240506

fbshipit-source-id: d8d39216f86df32e0614d7cdc95df2148c85077a
2016-11-28 15:58:36 -08:00
Pieter De Baets 439092742a Fix imports in UIExplorerUnitTests
Reviewed By: bestander

Differential Revision: D4231271

fbshipit-source-id: 84f903f6b14256ed1958ad1800f128133590a3dc
2016-11-24 09:58:31 -08:00
David Aurelio ca58e0af82 BREAKING kill deprecated asset support
Summary:
This removes support for `require('image!…')`, which has been deprecated for a long time.

It is still possible to use images that are already bundled by the native app using the `nativeImageSource` module.
Check http://facebook.github.io/react-native/docs/images.html for detailed documentation.

Reviewed By: matryoshcow

Differential Revision: D4231208

fbshipit-source-id: 05ec4c1ca0fabdc3fbb652f8ad1acdf240a67955
2016-11-24 05:43:38 -08:00
Pieter De Baets e1577df1fd Move all header imports to "<React/..>"
Summary:
To make React Native play nicely with our internal build infrastructure we need to properly namespace all of our header includes.

Where previously you could do `#import "RCTBridge.h"`, you must now write this as `#import <React/RCTBridge.h>`. If your xcode project still has a custom header include path, both variants will likely continue to work, but for new projects, we're defaulting the header include path to `$(BUILT_PRODUCTS_DIR)/usr/local/include`, where the React and CSSLayout targets will copy a subset of headers too. To make Xcode copy headers phase work properly, you may need to add React as an explicit dependency to your app's scheme and disable "parallelize build".

Reviewed By: mmmulani

Differential Revision: D4213120

fbshipit-source-id: 84a32a4b250c27699e6795f43584f13d594a9a82
2016-11-23 07:58:39 -08:00
Pieter De Baets 7c91f894ba Fix CSSLayout import hack, update podspec
Summary: Correct header import paths, update podspec so we point at the copy in ReactCommon (and can eventually remove the copy under React)

Reviewed By: astreet

Differential Revision: D4204501

fbshipit-source-id: e979a010092f025b2cdc289e1e5f22fc7b65a8d1
2016-11-21 09:13:36 -08:00
Alex Kotliarskyi d117f550a5 Provide more info when image fails to load
Reviewed By: javache

Differential Revision: D4209311

fbshipit-source-id: 6ad8ea6b8e236ec5ad2a2313a69b8985f9a06c74
2016-11-21 04:58:30 -08:00
Tim Yung 23331df5a4 RN: Cleanup OSS JS & Flow Declarations
Reviewed By: vjeux

Differential Revision: D4210763

fbshipit-source-id: 5abaa547100b8badd13bcf311ceffc5b4098d252
2016-11-20 17:58:29 -08:00
Alex Kotliarskyi dcbcda75ec Introduce nativeImageSource API
Summary: The goal is to replace `require('image!...')` with an API that communicates better of what's going on under the hood.

Reviewed By: yungsters, fkgozali

Differential Revision: D4186241

fbshipit-source-id: b764588dbbd9494dd6905b2346e3274b575a9644
2016-11-20 12:28:28 -08:00
AgtLucas 84553ebf06 Improve doc code consistency
Summary:
For the sake of consistency. 😃
Closes https://github.com/facebook/react-native/pull/10978

Differential Revision: D4193554

Pulled By: JoelMarcey

fbshipit-source-id: c79de8192ecdd0a38c9693a996de84cf63cc89b1
2016-11-16 18:13:26 -08:00
Adam Comella fde7c35449 Make resolveAssetSource public
Summary:
When building a native component which takes an image reference as a prop, `resolveAssetSource` needs to be called on the image reference. If this isn't done, the native component may receive the opaque type returned by `require` (e.g. `require('./foo.png')`) which is useless to the native component. `resolveAssetSource` is used by builtin components that take image references such as `Image`, `WebView` and `MapView`.

This change makes `resolveAssetSource` public so that third-party native components can correctly handle image references.

**Test plan (required)**

Verified that `Image.resolveAssetSource` works in a test app. Also, my team is using this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/10904

Differential Revision: D4177803

Pulled By: ericvicenti

fbshipit-source-id: ffc511b9340325f7d1111002309cd8558ab8e6b0
2016-11-14 21:14:10 -08:00
Adam Comella e87e181998 Android: Expose Image's onError event to JavaScript
Summary:
iOS supports an Image onError event. Android was firing the event but it was never reaching JavaScript because Android didn't include this event in `getExportedCustomDirectEventTypeConstants`.

**Test plan (required)**

Verified that the `onError` event now fires in a test app.

My team uses this change in our app.

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/10902

Differential Revision: D4180149

Pulled By: ericvicenti

fbshipit-source-id: 4bf0b9aa7dc221d838d7b6b3e88bb47196dcadef
2016-11-14 19:43:58 -08:00
Fred Liu 6ed49341f3 Remove underline colour in Android text inputs
Summary: `require('something.jpg')` returns a `number` type.

Reviewed By: ejanzer

Differential Revision: D4132544

fbshipit-source-id: cf47baa377258195fe0155b3ea34208325d7c462
2016-11-04 14:58:46 -07:00
David Aurelio 3683beb88a RN: Update React (2/2)
Reviewed By: kentaromiura

Differential Revision: D4026114

fbshipit-source-id: 67808af91454d95941fea01eef58a4d9086f46e1
2016-11-04 05:43:44 -07:00
Cristian Carlesso 6a462fb085 Moving the jest configuration from jest-react-native to react native.
Reviewed By: cpojer

Differential Revision: D3923609

fbshipit-source-id: 62804df81b064871b499ae8c091e13dd1e0f229b
2016-10-17 08:44:05 -07:00
Tim Yung 7263c349c7 RN: Stop Deep Linking `ReactPropTypes`
Reviewed By: sebmarkbage

Differential Revision: D4025448

fbshipit-source-id: 4e9b6ee002a86f638fc57a4bbeb45bf35fabf74c
2016-10-14 18:59:10 -07:00
Pieter De Baets 26be005b0a Cancel network requests from the correct queue
Summary: Fix suggested by sooth-sayer (https://github.com/facebook/react-native/pull/10280)

Reviewed By: mmmulani

Differential Revision: D4001618

fbshipit-source-id: cc28d19d02a29b62d2bdbddcd30f94b1c1bcfd76
2016-10-11 12:43:40 -07:00
Douglas Lowder 8622998335 Apple TV support 2: Xcode projects and CI (scripts/objc-test.sh)
Summary:
* Motivation *

Second PR for Apple TV support.

* Test plan *

Apple TV tests have been added to scripts/objc-test.sh
Closes https://github.com/facebook/react-native/pull/10227

Differential Revision: D3974064

Pulled By: javache

fbshipit-source-id: 36dffb4517efa489e40fa713a30655d1d76ef646
2016-10-05 07:28:44 -07:00
Mattias Pfeiffer b2dac834fb Use strong reference in RCTImageLoader
Summary:
This PR is related to the multitude of crashes (#10016, #9751, #9882).

From my understanding, we should be using a strong reference when calling `decodeImageData` or we could be calling the method on a deallocated instance.

PR #9751 have mitigated this by adding a fail-safe, but I think the culprint is the weak reference, which this PR fixes.

Tested on iOS only, since it doesn't touch Android.
Closes https://github.com/facebook/react-native/pull/10147

Differential Revision: D3938763

fbshipit-source-id: 7389d4ae7a98926014401a1fe0cbbdcdd5ee6a01
2016-09-28 13:28:35 -07:00
Toby Cox 1a62b66c51 FIX #9751 - Cancelling offscreen image loads causing crashes
Summary:
This fixes https://github.com/facebook/react-native/issues/9751

We were seeing the same issues as the original reporter.

I'm not an expert on this code, so apologies if it's naive, but we haven't seen the crash since making this change.

From my understanding of it, it seems like the `cancelLoad` block was being released before the block returned by `_loadImageOrDataWithURLRequest:` was called.
This PR checks the `cancelled` flag before calling `cancelLoad()`.
Closes https://github.com/facebook/react-native/pull/10016

Differential Revision: D3902723

Pulled By: javache

fbshipit-source-id: 75cd115e28694105c6fc29469986998ca0d4cd09
2016-09-21 14:28:43 -07:00
Mehdi Mulani 820b1c0e46 Add partial image loading to RCTImageView
Reviewed By: javache

Differential Revision: D3856918

fbshipit-source-id: ca98f8604213e7e583a188ccc4c25ea9d7aa9aa2
2016-09-21 12:14:09 -07:00
leeight 3182b608fc Fix invalid package name and Remove unsupported prop in Image.android.js
Summary:
1. `textfrescosupport` -> `text.frescosupport`
2. `defaultImageSrc`, `imageTag` and `progressHandlerRegistered` looks like never exists in `ReactImageManager.java`
Closes https://github.com/facebook/react-native/pull/9885

Differential Revision: D3864980

fbshipit-source-id: 48a85563c60b6853c505177558520f5e48f4eb03
2016-09-14 13:43:48 -07:00
Adam Comella b6735f3391 Enable developers to force Fresco to resize an image
Summary:
Here's a little background. Resizing is inferior to scaling. See http://frescolib.org/docs/resizing-rotating.html#_

Currently, React Native has a heuristic to use resize when the image is likely to be from the device's camera. However, there may be other cases where a developer wants to use resize. For example, when the developer knows they'll be downloading a large image from a service but the image will be rendered at a small size on the device.

This change adds a `resizeMethod` prop to the `Image` component so developers can choose how Fresco resizes the image. The options are 'auto', 'resize', or 'scale'. When 'auto' is specified, a heuristic is used to choose between 'resize' and 'scale'. The default value is 'auto'.

**Test plan (required)**

In a small test app, verified that the `resizeMethod` prop properly influences the mechanism that is used to resize the image (e.g. resize or scale).

Adam Comella
Microsoft Corp.
Closes https://github.com/facebook/react-native/pull/9652

Differential Revision: D3841322

Pulled By: foghina

fbshipit-source-id: 6c78b5c75ea73053aa10386afd4cbff45f5b8ffe
2016-09-09 05:13:53 -07:00
Pieter De Baets 3efe95d989 Fix images not reloading after memory warning
Reviewed By: mmmulani

Differential Revision: D3816779

fbshipit-source-id: edccb41a38fff3b2c143ffb3cbe0a7001ee16331
2016-09-06 09:28:35 -07:00
Pieter De Baets 07553d0f1c Update React Native minimum OS version to iOS8
Reviewed By: majak

Differential Revision: D3723143

fbshipit-source-id: 482f9820370b752d937e6df7f74c33d53a0a2e7d
2016-09-01 19:43:47 -07:00
Pieter De Baets 46b54fd7a8 Support bundle argument for image loading
Reviewed By: mmmulani

Differential Revision: D3768798

fbshipit-source-id: 5b35f06957cebfe74aca90fe6a456f7f739509a9
2016-08-31 17:43:49 -07:00
Felix Oghina 69c889815e Expose image cache interrogation to JS
Summary: Add a static `Image.queryCache` function that can query multiple URLs at once. The result is a map where each URL that is in cache is mapped to the cache type (memory/disk). URLs that are not cached do not appear in the result.

Reviewed By: lexs

Differential Revision: D3791333

fbshipit-source-id: b183015d97423f0c095bf891f035dac2e23d8d11
2016-08-31 05:13:39 -07:00
Pieter De Baets 3fb76696bb Fix setImage clownyness
Reviewed By: mmmulani

Differential Revision: D3785608

fbshipit-source-id: eab547ae2724efde5aeb3855ab15610875d63dcd
2016-08-29 11:28:52 -07:00
Pieter De Baets 6f7898ee09 Avoid reloading images that are already the source size
Reviewed By: majak

Differential Revision: D3755114

fbshipit-source-id: 112fa6c8fe13d1070855d3e57f0009afe1b53038
2016-08-26 13:59:05 -07:00
Pieter De Baets 86fbf2386b Avoid sending out multiple requests for the same image
Reviewed By: majak

Differential Revision: D3755074

fbshipit-source-id: fea782fcb99e6b977fb52231d378aaab4685d480
2016-08-26 13:59:05 -07:00
Pieter De Baets bfa01f0d15 Rename RCTImageView source to imageSources
Reviewed By: majak

Differential Revision: D3754991

fbshipit-source-id: 9794af94b51b331df1209ae63d053dcef2cf4a97
2016-08-23 11:28:42 -07:00
Pieter De Baets 84f68c338a Send down image source to RCTImageView onLoad callback on iOS
Summary: This allows the onLoad callback to know which image has actually loaded. This is only for iOS at the moment - implementing this for Android will require quite a bit more work.

Reviewed By: majak

Differential Revision: D3738759

fbshipit-source-id: b1fc2bd0dc5de90096debeab02b8f795739a4547
2016-08-22 10:58:49 -07:00
Pieter De Baets 14188289fc Add some defensive cleanup of cancelBlock in RCTImageLoader
Reviewed By: mmmulani

Differential Revision: D3742177

fbshipit-source-id: 1cd16c2519052ec5811ecadf2530a5846b4ae1bc
2016-08-19 10:46:09 -07:00
Alon Schwarz 862b6570ee Add 'center' to the allowed values in Android Image.resizeMode proptype
Reviewed By: foghina

Differential Revision: D3703258

fbshipit-source-id: fc2546a8c2e595ec51416f3453a12d087cc68515
2016-08-16 04:15:03 -07:00
Alexander Jarvis 7cdd4c9a75 Fix image source prop change updating image
Summary:
fixes #7795
fixes #8500

Motivation: When having a simple button that changes the Image source when tapped, the image doesn't change (or at least sometimes, intermittently it works).

This was found to be an issue where the request was being sent to the native layer correctly but then being subsequently cancelled by the `reactSetFrame: method`  ...
Closes https://github.com/facebook/react-native/pull/9137

Differential Revision: D3702867

Pulled By: javache

fbshipit-source-id: c89ce6b841179394b6b23850b3128751ef9e0313
2016-08-11 03:28:40 -07:00
David Aurelio 94666f16c7 Auto-fix lint errors
Reviewed By: bestander

Differential Revision: D3683952

fbshipit-source-id: 9484d0b0e86859e8edaca0da1aa13a667f200905
2016-08-09 06:43:46 -07:00
Gant eba6c379c3 - Update remote image example
Summary:
I've seen quite a few newbs trip on this, so I'm fixing it.

First - you have to set the width/height on a remote image, otherwise nothing shows.  This is [even on stack overflow](http://stackoverflow.com/questions/30091398/unable-to-display-image-with-react-native-with-uri).

Second - with the addition of ATS in iOS most people who copy/paste this example will not be able to load an insecure image, so I changed it to the `https`.

**RESULT** this doc becomes copy/paste friendly again for beginners.
Closes https://github.com/facebook/react-native/pull/9235

Differential Revision: D3675478

Pulled By: JoelMarcey

fbshipit-source-id: 5b414caa40cda72dec4eace686278c26c251c4bb
2016-08-05 08:58:32 -07:00
Konstantin Raev 8419faa365 Fixed test CRMNowThumbnailCache-test.js
Reviewed By: matryoshcow

Differential Revision: D3662150

fbshipit-source-id: 29cb7ee52ba8dc67ecf2214ff92b2f97711debf0
2016-08-03 06:13:29 -07:00
Maria Mateescu 2a823bbc5c Add custom cache setter
Reviewed By: donyu

Differential Revision: D3622912

fbshipit-source-id: 675b3135212c73808cb18702c2cbf5684816df87
2016-08-01 22:13:27 -07:00
Jimmy Mayoukou f634a0fc23 Add missing resizeMode prop on Image Android
Summary:
It seems like the `resizeMode` propType was missing from `Image.android.js`, this PR adds it.
I caught by trying to use `Image.propTypes.resizeMode` on Android, and getting a warning because it was `undefined`.

It's not supposed to break anything, maybe pop a few warnings but not much more.

**Test Plan:**
- Launched UIExplorer
Closes https://github.com/facebook/react-native/pull/7355

Differential Revision: D3648559

fbshipit-source-id: a4397938d14c11ded909d6bf4652a4b0fcebed3b
2016-08-01 00:58:27 -07:00
Nicolas Charpentier 55bc825092 Add GIF and WebP support specification with Fresco 0.11
Summary:
Motivation #8455
Fixes #8501

With a bonus fix typo !

![screen shot 2016-07-25 at 14 16 01](https://cloud.githubusercontent.com/assets/7189823/17112118/9f06fe04-5272-11e6-83e9-ddf11573aa5e.png)
Closes https://github.com/facebook/react-native/pull/8951

Differential Revision: D3647816

Pulled By: mkonicek

fbshipit-source-id: e0349275045cae2922b4bb43bcb99af4c6ef1170
2016-07-31 08:13:27 -07:00
Maria Mateescu 3561dbb74d Unbreak compiling error - sorry
Reviewed By: bestander

Differential Revision: D3641418

fbshipit-source-id: fa131761b65a19ed0fc821dd52852480f2ed0c2d
2016-07-29 07:13:43 -07:00