Commit Graph

1494 Commits

Author SHA1 Message Date
Emil Sjolander 31f848a5fa Expose alignContent to react native
Summary:
This diff adds alignContent (https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) support to React Native. This enables aligning the lines of multi-line content. See below playground for example usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white', flexWrap: 'wrap', alignContent: 'space-between'}}>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 10, marginTop: 10, backgroundColor: 'red'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611803

fbshipit-source-id: ae7f6b4b7e9f4bc78d2502da948214294aad4dd2
2017-03-01 09:16:05 -08:00
Emil Sjolander cc275557be Add margin auto support to react native
Summary:
This diff adds margin:auto (https://drafts.csswg.org/css-flexbox-1/#auto-margins) support to React Native. This enables layout not previously supported without inserting empty 'spacer' views. See below Playground for usage.

```
class Playground extends React.Component {
  render() {
    return (
      <View style={{width: '100%', height: '100%', flexDirection: 'row', backgroundColor: 'white'}}>
        <View style={{width: 100, height: 100, backgroundColor: 'red'}}/>
        <View style={{width: 100, height: 100, marginLeft: 'auto', backgroundColor: 'blue'}}/>
      </View>
    );
  }
}
```

Reviewed By: astreet

Differential Revision: D4611753

fbshipit-source-id: e78335565c193f7fb263129a638b444715ba5ab0
2017-03-01 09:16:05 -08:00
Emil Sjolander 23f2f5f239 default root node to size of parent contraints
Reviewed By: dshahidehpour

Differential Revision: D4634616

fbshipit-source-id: 089eb4313c5bb810a6ff56f158cd19cec71808ec
2017-03-01 07:15:23 -08:00
Marc Horowitz 611661e5fe TODO is done
Reviewed By: AaaChiuuu

Differential Revision: D4614454

fbshipit-source-id: 48d66b26371834e35c43731a22abc015fc234650
2017-02-28 14:15:57 -08:00
Emil Sjolander 702564fb60 Pass the parent size to YGNodeCalculateLayout instead of the node size
Reviewed By: astreet

Differential Revision: D4611417

fbshipit-source-id: 2fb0eedffa17f0ec89b601722a1717a72e216b9e
2017-02-28 08:14:51 -08:00
Valentin Shergin b00c1fa3b6 `accessibilityViewIsModal` property was exposed for any view (iOS only)
Reviewed By: mmmulani

Differential Revision: D4582786

fbshipit-source-id: 0902b8cc762042e772798ea7eaa350bc9d737cfb
2017-02-27 23:46:14 -08:00
Eloy Durán 19caaba1d5 Fixes current CI failures and allows tree shaking of native dev support code.
Summary:
* The dev support code moved into a `DevSupport` subspec, meaning that only if the subspec is specified in the user’s Podfile will the packager client, dev menu, etc be included. This is mainly done through checks for header availability.

  It also improves the weird situation where you had to specify the `RCTWebSocket` subspec if you wanted to be able to use the packager client during development.

* I removed hardcoding the release version in the podspec on release, because the podspec still relies on `package.json` when evaluating, so there’s no real point in not also getting the version number from there. This should remove any requirement to perform maintenance of the OSS release script regarding the podspec.
Closes https://github.com/facebook/react-native/pull/12602

Differential Revision: D4621021

Pulled By: ericvicenti

fbshipit-source-id: 6c208371fc40ea607809a6ab05dd3714ed9980cf
2017-02-27 14:04:58 -08:00
Valentin Shergin e7cc1bcbba RCTRootView's `intrinsicSize` property was deprecated in favour of `intrinsicContentSize`
Summary:
Nothing actually changed except the deprecation.
Existed `intrinsicSize` was already implemented as `intrinsicContentSize` and this change only removes redundancy.
Moreover, we do not need `rootViewDidChangeIntrinsicSize` delegate method anymore; this is now mentioned in its description.

Depends on D4577890

Reviewed By: mmmulani

Differential Revision: D4589344

fbshipit-source-id: 16ed62cbf6bf72678bd7f7c11d4812c5aa36c743
2017-02-27 14:04:58 -08:00
Valentin Shergin 9dccff0eda Better support of UIKit layout stuff for RCTRootView an co.
Summary:
Now RCTRootView is much more reliable citizen of UIKit, it got:
 * Implemented `sizeThatFits:`;
 * Implemented `instrinsicContentSize`;
 * Notifying superview via `setNeedsLayout` about changed size.

All it make possible painless integration of ReactNative-powered widgets inside existing native apps.

Reviewed By: javache

Differential Revision: D4577890

fbshipit-source-id: 9897cb002c9d658a97fd436240c2ac947ba2084b
2017-02-27 14:04:58 -08:00
dlowder-salesforce 7f6f964e18 Add missing websocket headers to React-tvOS target
Summary:
Fix Apple TV breakage.  This should allow scripts/objc-test-tvos.sh to run normally.
Closes https://github.com/facebook/react-native/pull/12565

Differential Revision: D4612182

Pulled By: hramos

fbshipit-source-id: 77fd3eeabc6757b23e4f5efbd46e9948b61b1ab6
2017-02-24 09:45:38 -08:00
Lukas Piatkowski 0707361b00 Add a RCTPackagerClientMethod handler for pokeSamplingProfiler in DevMenu
Reviewed By: javache

Differential Revision: D4579600

fbshipit-source-id: dfdf2b6ca0690988015873add58c43faa96ab0a6
2017-02-24 08:30:50 -08:00
Ben Roth 6a14f0b449 Add RCTDevSettings module
Summary:
This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings.

**Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet.

It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else.

The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.**

The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though
some methods are now deprecated.

In order to ensure that RCTDevSettings
Closes https://github.com/facebook/react-native/pull/11613

Reviewed By: mmmulani

Differential Revision: D4571773

Pulled By: javache

fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
2017-02-24 07:00:16 -08:00
Lukas Piatkowski ccc525c5ca Refactor iOS packager webSocket handling to resemble Android's packagerconnection
Reviewed By: javache

Differential Revision: D4572607

fbshipit-source-id: b588d6216f7b84aef5a63454d2d8978783412c7b
2017-02-23 10:03:54 -08:00
Pieter De Baets dba133a291 Merge AndroidConstants and IOSConstants into PlatformConstants
Reviewed By: AaaChiuuu

Differential Revision: D4597790

fbshipit-source-id: 0a54598d6e9cadb75efff4ac17c13899d6785f9b
2017-02-22 15:01:11 -08:00
Benoit VALLON ca2741609a Fix badgeColor for previous iOS 10 versions
Summary:
The actual badgeColor prop causes the following error when run on device with a version inferior to iOS 10 like iPad 2 and iPad mini 1.

`*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITabBarItem setBadgeColor:]: unrecognized selector sent to instance 0x7968be80'`

This PR fixes it by checking at runtime if the selector is available for the current running version.

It also makes the color available at start by using the variable `self.barItem`. Currently, the color appears only after a reload.
Closes https://github.com/facebook/react-native/pull/12354

Differential Revision: D4598036

Pulled By: shergin

fbshipit-source-id: 9f104fc27db51213a54273e33c5a22f1b350c55e
2017-02-22 12:04:10 -08:00
Adam Comella 6fbc2c9972 iOS: Remove leading space from accessibilityLabel
Summary:
In some cases, the accessibilityLabel contains a leading space. This is because `RCTRecursiveAccessibilityLabel` adds a space before every iteration of the loop including the first.

After this change, the contract is that:
  - `RCTRecursiveAccessibilityLabel` always returns a string with a leading space.
  - `accessibilityLabel` never returns a string with a leading space.

**Test plan**

I created a test app with the following code:

```
<View style={{height: 100, width: 100, backgroundColor: 'steelblue'}} accessible={true}>
  <View style={{height: 20, width: 20, backgroundColor: 'red'}} accessibilityLabel='One' />
  <View style={{height: 20, width: 20, backgroundColor: 'yellow'}} accessibilityLabel='Two' />
  <View style={{height: 20, width: 20, backgroundColor: 'green'}} accessibilityLabel='Three' />
</View>
```

Before this change, the accessibilityLabel of the outermost View was " One Two Three" (notice the leading space).

After this change, it is "One Two Three" as desired.

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

Reviewed By: javache

Differential Revision: D4596761

Pulled By: shergin

fbshipit-source-id: 7d5ff704e858d9f277d1547339a2831ffa90f592
2017-02-22 11:16:13 -08:00
Valentin Shergin e361ce8673 `RCTShadowViews`'s `cssNode` property was renamed to `yogaNode`
Reviewed By: javache

Differential Revision: D4590104

fbshipit-source-id: 7767aaa62bcbdce2746c3a26543052dd46be63e0
2017-02-21 08:45:05 -08:00
Pieter De Baets bdd27f4696 Break apart -[RCTComponentData propBlockForKey:inDictionary:]
Reviewed By: shergin

Differential Revision: D4578549

fbshipit-source-id: 726773fdf8c97cdcc3b0540b32278e36c00b19b5
2017-02-20 05:15:25 -08:00
Pieter De Baets ebe3355de7 Create NSDataBigString
Reviewed By: bnham

Differential Revision: D4559734

fbshipit-source-id: 6766093524ae79ed2a41285d33eb2207993a7d0e
2017-02-20 05:00:58 -08:00
Ashok Menon 1635c02e92 Simplifying Struct definition.
Summary:
Since we are reading from a file, we should make sure this struct is packed, just in case we change it down the line and the compiler decides it might want to introduce padding, we're now protected against that.

There was also a discussion about the fact that people might use `ptr += sizeof(BundleHeader)` as an idiom in their code, which would currently be incorrect, if padding was introduced at the end of the file. Actually, it remains incorrect to do that now, because a RAM bundle header is a different size to a BC Bundle header. If people are properly testing their code, they should spot this pretty quickly, because it will always be an incorrect thing to do with a RAM bundle, so this isn't as bad as previously thought: where the code only succeeds when the compiler deigns to not pad the struct at the end.

This diff also cleans up how headers are initialised. `BundleHeader` has a constructor that explicitly zero-initialises it so we can rely on the default initializer to do the right thing now.

Reviewed By: mhorowitz

Differential Revision: D4572032

fbshipit-source-id: 7dc50cfa9438dfdfb9f842dc39d8f15334813c63
2017-02-20 04:30:19 -08:00
Valentin Shergin c02c78a681 Splitting `RCTRootView.m`, decoupling RCTRootContentView
Reviewed By: javache

Differential Revision: D4570067

fbshipit-source-id: 91305d0c175af135ce2f22d7992bee68c13da80e
2017-02-19 23:19:47 -08:00
Valentin Shergin ba170ec78c Simplifying mess with RCTRootViewSizeFlexibility
Summary:
Now things look much more clear, I hope.
This diff:
 * Introduces new property of `RCTRootShadowView` `availableSize` which represents exactly what we transmit to layout engine;
 * Illuminates conflict between logical `availableSize` and explicitly specified size of DOM node (current `size`);
 * Splits overcomplicated `setSize:forView:` method into two unrelated ones;
 * Changes actual values of `RCTRootViewSizeFlexibility` enum constants for simpler usage;
 * Completely removes `sizeFlexibility` concept from `RCTRootShadowView` (in favor of special values of `availableSize`);
 * Makes the code clearer finally.

This is beginning of big effort to improve `RCTRootView` and co.

Reviewed By: mmmulani

Differential Revision: D4562834

fbshipit-source-id: f5baaf2859ea430d44645a6b5d35f222f15a668e
2017-02-19 23:19:47 -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
Mehdi Mulani 93a263d874 Make RCTRefreshControl not dependent on order of setting properties
Summary: With the Cxx bridge, properties are not guaranteed to be set it any order (and furthermore, they should not be). RCTRefreshControl previously had its title set first, and would crash otherwise. This fixes that.

Reviewed By: mhorowitz

Differential Revision: D4580253

fbshipit-source-id: 39baecceb8b67c6a851c08ba9cabbf4dc99359cb
2017-02-17 15:16:01 -08:00
Ashok Menon 3148cc09ae Fix CI runs
Summary: I broke Circle CI builds by moving a file, so I am updating the OSS build setup with details of the move. Whilst I was testing the change, I noticed that the UI Explorer build was also already broken, so this diff also changes some of its configuration to make it build again.

Reviewed By: javache

Differential Revision: D4579137

fbshipit-source-id: 4cbb1ef148075280b991cbc5bb47bf96ec3d543a
2017-02-17 09:17:19 -08:00
Pieter De Baets 591de3e278 Move tryBytecode to bundle specifier
Reviewed By: amnn

Differential Revision: D4559898

fbshipit-source-id: 917bef5a1d753b52e9e967f3029eb158935feee6
2017-02-17 06:00:55 -08:00
Alexey Lang ba029becbe Support QuickPerformanceLogger.js in CxxBridge
Reviewed By: javache

Differential Revision: D4573567

fbshipit-source-id: 3ef9da38fb178cf4c1400b4a991a9e85f3ec3755
2017-02-17 06:00:54 -08:00
Pieter De Baets 0c8e925a18 Move initializedExecutorWithContextProvider API
Reviewed By: dcaspi

Differential Revision: D4558591

fbshipit-source-id: 821d6a6d4e42d1c67559fde102a0558eb623733b
2017-02-17 02:30:45 -08:00
Pieter De Baets c529a06cb8 Remove unused RCTMessageQueue
Reviewed By: mhorowitz

Differential Revision: D4564975

fbshipit-source-id: 62cb686fe5fefb4ec4a8f5db44898a95496420be
2017-02-16 15:18:43 -08:00
Pieter De Baets 11e59e3ff4 Move some utilities to RCTCxxUtils
Reviewed By: mhorowitz

Differential Revision: D4551173

fbshipit-source-id: db01d3205ec1feb54c815c0f0fc688fc7a4823d0
2017-02-16 14:02:03 -08:00
Alexey Lang 7c97008fa8 Support QuickPerformanceLogger.js in the old bridge
Reviewed By: javache

Differential Revision: D4566647

fbshipit-source-id: 1a6448b89b14f4ce9f2192e9f7b4e28b8dcb52b7
2017-02-16 11:33:48 -08:00
Emil Sjolander 1b5eb36e2f Fix up some small issues with YGUnitAuto
Reviewed By: wwjholmes

Differential Revision: D4567045

fbshipit-source-id: ace5fd89bd534a6bb5ec7dba0c3afbf13d62d7c9
2017-02-16 06:59:33 -08:00
Pieter De Baets 53b387638e Move JSBigString to its own header
Reviewed By: mhorowitz

Differential Revision: D4551162

fbshipit-source-id: 2374e05e60942211e50af86ed42eb194e5e82bbe
2017-02-16 06:59:30 -08:00
Pieter De Baets 5d4ff693b4 Move RCTFollyConvert to the correct namespace
Reviewed By: mhorowitz

Differential Revision: D4551124

fbshipit-source-id: 40a0a8ca818710a7529798b8244d9c133eb5c22d
2017-02-16 06:59:27 -08:00
Lukas Piatkowski a2addbd932 BREAKING: Change the js1 - packager - RN App protocol to version 2
Reviewed By: cwdick

Differential Revision: D4551991

fbshipit-source-id: 395c38ee5c71ddc24d8743e7ec90cc89de087503
2017-02-16 04:30:00 -08:00
Pieter De Baets 8987d86718 Fix error handling for nested exceptions
Reviewed By: mhorowitz

Differential Revision: D4551110

fbshipit-source-id: e593c1ef0dea27e95a387bcde6250aeb22d2e9cc
2017-02-15 06:15:11 -08:00
Pieter De Baets bbe0c45c19 Prevent deadlock after bridge reload
Reviewed By: dcaspi

Differential Revision: D4551097

fbshipit-source-id: 33b43b2691d4e595d3c09c9a5b101ce458c4d6d7
2017-02-15 06:15:11 -08:00
Pieter De Baets a2000d1200 Replace valueForKey with subscript access in RCTJavascriptLoader
Reviewed By: shergin

Differential Revision: D4559391

fbshipit-source-id: 44cb4900f93f2ac60dae3a461ed5344e1af08f3b
2017-02-15 03:45:55 -08:00
Kevin Gozali a512f6dcf6 ios: exposed 'RCTConvert UITabBarSystemItem:' in the header file
Summary: This method was defined in the .m file already, so we can just expose it to the header for other usages.

Reviewed By: mmmulani, shergin

Differential Revision: D4557942

fbshipit-source-id: a1be8af8e31b88a152cabfab6d4cf82316088572
2017-02-15 02:17:17 -08:00
Valentin Shergin 5263699f90 Introducing RCTRootShadowView.baseDirection property
Reviewed By: dshahidehpour

Differential Revision: D4555904

fbshipit-source-id: 8f0a2a9a38af42334188bc1cc5e0f6dded8592ae
2017-02-14 15:33:15 -08:00
David Hart 67f6b32409 Rename YGUnitPixel to YGPoint...
Summary:
...to reflect the modern world we live in with dynamic DPI platforms :)
Closes https://github.com/facebook/yoga/pull/375

Reviewed By: dshahidehpour

Differential Revision: D4528518

Pulled By: emilsjolander

fbshipit-source-id: e422bd4ae148e02c598a7b484a6adfa8c0e1e0c9
2017-02-14 14:31:31 -08:00
Lukas Wöhrl dbaa687518 Feature auto margin
Summary:
Even so I know there are some opinions against ```margin: 0 auto``` it's still part of the spec: https://www.w3.org/TR/css-flexbox-1/#auto-margins and pretty usefull if you have to position via ```justify-content```.

This PR adds an implementation for that.

It adds an additonal ```YGUnitAuto``` and margins got ```YGNodeStyleSetMarginAuto``` functions as well.
Closes https://github.com/facebook/yoga/pull/357

Reviewed By: astreet

Differential Revision: D4501142

Pulled By: emilsjolander

fbshipit-source-id: 86519f8632496f46e78a7c9dbc5b21e212e3e0c7
2017-02-14 14:31:31 -08:00
Pieter De Baets 4695508826 Remove iOS7 API check
Reviewed By: shergin

Differential Revision: D4551186

fbshipit-source-id: ab5ec3c01bbfe0faca833960431a9739cbc1ea44
2017-02-13 12:17:01 -08:00
Valentin Shergin 7686274e13 Removed RTL workaround in RCTShadowText
Reviewed By: fkgozali

Differential Revision: D4511274

fbshipit-source-id: f658afb4e1c943cc9ecab2dd2a91f251edd3fa36
2017-02-13 12:00:57 -08:00
Ciprian Pãtru dcf7f631f4 Enable perf monitor for CxxBridge
Reviewed By: javache

Differential Revision: D4510939

fbshipit-source-id: f90dc5c97b98ce68cb2c21e5f283790880b032a4
2017-02-09 12:47:04 -08:00
Valentin Shergin d8748233ca Removing `transformMatrix` and `decomposedMatrix` properties
Summary: We deprecated `transformMatrix` and `decomposedMatrix` in D3239960 10 months ago. This revision finally removes remains of this functionality from native code.

Reviewed By: mmmulani

Differential Revision: D4515760

fbshipit-source-id: b4d5b7e834ac4a775f4992b28270b4ff961889a6
2017-02-07 14:02:20 -08:00
Valentin Shergin ec673d0771 Added support of `direction` style property
Summary: Now layout direction (LTR or LTR) can be specified not only for whole app but also for view subtree via `direction` style property.

Reviewed By: mmmulani

Differential Revision: D4510206

fbshipit-source-id: 4e56c5886b6e42f2343165eb76be897e681c5ba4
2017-02-06 21:00:16 -08:00
Valentin Shergin 233015c93e `[-RCTUIManager setFrame:forView:]` was replaced with `[-RCTUIManager setSize:forView:]`
Reviewed By: fkgozali

Differential Revision: D4511712

fbshipit-source-id: 5c51d573bf638cb9b55d5f03b9f1882dc6129510
2017-02-06 11:01:11 -08:00
Valentin Shergin e38679fbc7 Added missing files to React.xcodeproj
Reviewed By: mmmulani

Differential Revision: D4513525

fbshipit-source-id: 40700db4cc8fd8eae1f7b98855a461489adaf86a
2017-02-05 11:43:32 -08:00
Valentin Shergin 54d3e83bbf Fixed crash in RCTScrollView on iOS 8
Reviewed By: javache

Differential Revision: D4508906

fbshipit-source-id: 08955f338879f708d35f4784e858a92b542e8661
2017-02-03 15:28:34 -08:00