124 Commits

Author SHA1 Message Date
Tadeu Zagallo
4fc15dbf17 [ReactNative] Implement proper event coalescing 2015-05-27 20:41:20 -08:00
Nick Lockwood
8d992262ed Fixed loading flicker on RCTRootView 2015-05-27 02:51:32 -08:00
Alex Kotliarskyi
cfa4b13472 [ReactNative] Element Inspector
Summary:
This adds new development feature to React Native that provides information
about selected element (see the demo in Test Plan).

This is how it works:

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

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

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

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

@public

Test Plan:
https://www.facebook.com/pxlcld/mn5k
Works nicely with scrollviews
2015-05-26 11:19:49 -08:00
Nick Lockwood
b7c669aa73 Fixed root view background color propagation 2015-05-26 04:18:55 -08:00
Tadeu Zagallo
9062bda79b [ReactNative] Add RCTAssertThread and restrict -[UIManager addUIBlock:] to _shadowQueue
Summary:
@public

Add `RCTAssertThread` to `RCTAssert.h` for convenience when checking the current/queue,
it accepts either a `NSString *`, `NSThread *` or `dispatch_queue_t` as the object to be checked

Also add a check to `-[RCTUIManager addUIBlock:]` - There was a discussion on github (https://github.com/facebook/react-native/issues/1365)
due to the weird behavior caused by calling it from a different thread/queue (it might be added after `batchDidComplete` has been called
and will just be dispatched on the next call from JS to objc)

Test Plan:
Change `-[RCTAnimationExperimentalManager methodQueue]` to return `dispatch_get_main_queue()` and run the 2048 example,
it should dispatch with a helpful message (screenshot on the comments)
2015-05-25 05:23:27 -08:00
Nick Lockwood
fe4b4c2d83 Optimised blending for translucent images with opaque background color + fixed cropping for images in cover/contain mode.
Summary:
@public

Our background color propagation mechanism is designed to make rendering of translucent content more efficient by pre-blending against an opaque background. Currently this only works for text however, because images are not composited into their background even if the background color is opaque.

This diff precomposites network images with their background color when the background is opaque, allowing them to take advantage of this performance optimization.

I've also added some logic to correctly crop the downloaded image when the resizeMode is "cover" or "contain" - previously it was only correct for "stretch".

Before:{F22437859}
After:{F22437862}

Test Plan: Run the UIExplorer "<ListView> - Paging" example with "color blended layers" enabled and observe that the images appear in green now, instead of red as they did before.
2015-05-22 07:19:06 -08:00
Tadeu Zagallo
08844e3ddc [ReactNative] Add fps monitor
Summary:
@public

Add basic JS and UI thread FPS monitor

Test Plan: Launch the UIExplorer, open the Dev Menu with cmd+D, and select `Show FPS Monitor`
2015-05-20 18:26:36 -08:00
Georgiy Kassabli
6ef7eaf663 Added accessibility traits support to View class 2015-05-18 07:30:29 -08:00
Tadeu Zagallo
a4e89d71a3 [ReactNative] Fix RCTBatchedBridge main thread invalidation
Summary:
D2052669 introduced a block for objects that had to be invalidated on the main
thread, but after the JS thread objects, but the block was being dispatched on
the JS thread.

@public

Test Plan:
I added `RCTAssertMainThread()` to the `mainThreadInvalidate` block, it was
crashing on reload, but now it should work as expected.
2015-05-17 18:27:20 -08:00
Christopher Chedeau
723e988416 [ReactNative] Redbox if JSC syntax errors 2015-05-15 15:33:17 -08:00
James Ide
2497c02e38 [RCTBridge] Have RCTBridge.loading return RCTBatchedBridge.loading
Summary:
The parent RCTBridge no longer tracks the JS loading since that has been handed off to the RCTBatchedBridge. To make the `loading` property accurate again, just expose the batch bridge's loading property from the parent bridge (note: I didn't make it KVO-compliant).

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

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-14 16:00:18 -08:00
Harrison Harnisch
babdc21614 WebSocket polyfill
Summary:
- Added as a library in /Libraries/WebSocket
- Drag and drop to add to project (similar to adding Geolocation polyfill)
- Exposed as `window.WebSocket` which conforms with https://developer.mozilla.org/en-US/docs/Web/API/WebSocket specs
Closes https://github.com/facebook/react-native/pull/890
Github Author: Harrison Harnisch <hharnisc@gmail.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-14 09:37:02 -08:00
James Ide
f40a7b4609 [Bridge] Make RCTJavaScriptDidFailToLoadNotification match DidLoad notif
Summary:
Add the RCTBatchedBridge object to the notification's userInfo for consistency with RCTJavaScriptDidLoadNotification, and set the target object to `_parentBridge`.

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

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-13 13:24:37 -07:00
James Ide
ba9ef00ab9 [RCTBridge] Clean up reload notification observer
Summary:
After the RCTBatchedBridge refactor, the `-[NSNotificationCenter addObserver]` and `[removeObserver]` calls got divided between RCTBridge and RCTBatchedBridge. This diff does two things:

 - Moved `removeObserver` out of RTCBatchedBridge and into `-[RCTBridge invalidate]`
 - Moved `addObserver` from `bindKeys` to `setUp`. This is so that `-[RCTBridge reload]` will re-add the observer after invalidating and removing the observer

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

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-05-13 13:24:37 -07:00
Tadeu Zagallo
d230629e61 [ReactNative] Add test to check RootContentView and BatchedBridge are deallocated 2015-05-13 13:24:36 -07:00
Tadeu Zagallo
92d7324f15 [ReactNative] Fix RootContentView release when the top-level bridge is held
Summary:
The RCTRootView creates a underlying RCTRootContentView that was deallocated when
the bridge modules were deallocated. That doesn't work when the bridge is held.

@public

Test Plan:
Launch Groups, put a breakpoint on `-[RCTRootContentView dealloc]`, enter and
leave a group page. It should be called now.
2015-05-13 13:24:36 -07:00
Ben Alpert
f8b36491d7 [react-native] Fix spelling of "cancelled"
Summary:
Apparently British spelling is "cancelled", American is "canceled"? Picking "cancelled" for consistency with UIKit.

@public

Test Plan: landcastle
2015-05-13 13:24:36 -07:00
Krzysztof Magiera
ff00e1496c [ReactNative] Rename ReactIOS JS module (and relatives) to ReactNative. 2015-05-13 13:24:35 -07:00
Alex Kotliarskyi
320208f4f7 Updates from Fri 8 May 2015-05-08 10:29:59 -07:00
Tadeu Zagallo
ec9015d005 [ReactNative] Disable event deduping 2015-05-07 19:49:03 -08:00
Tadeu Zagallo
6b38fad219 [ReactNative] Fix ref to eventDispatcher on RCTBridge 2015-05-07 09:05:29 -08:00
James Ide
b8bf4d0957 [Loader] Post a notification when the JS fails to load
Summary:
This provides a way to get notified when a bridge fails to load JS, allowing apps to handle the error.

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

Test Plan: run the UIExplorer app with the packager server not running, and verify that the notification is posted.
2015-05-07 04:26:24 -08:00
Nick Lockwood
205c22b915 Fixed dev menu loop 2015-05-07 03:55:43 -08:00
Nick Lockwood
47164baaec Fixed redbox error loop when camera access is disabled 2015-05-06 17:21:10 -08:00
Alex Kotliarskyi
cad5cdef42 Updates from Wed 6 May 2015-05-06 16:08:10 -07:00
Nick Lockwood
790cee6e26 Fixed broken listview header alignment 2015-05-06 10:48:24 -08:00
Tadeu Zagallo
ea470408e2 [ReactNative] Allow JSON fragments on RCTJSONStringify 2015-05-06 05:44:40 -08:00
Nick Lockwood
88a83084e4 Fixed UIExplorer in Catalyst shell 2015-05-06 00:08:08 -08:00
Nick Lockwood
54974d6333 +[RCTConvert UIFont:] tests 2015-05-05 17:37:59 -08:00
Alex Kotliarskyi
5df5602f1a Updates from Tue 5 May 2015-05-05 14:15:51 -07:00
Tadeu Zagallo
3ab4d32538 [ReactNative] Fix DevMenu crash when launching the app with WebView executor 2015-05-05 07:30:55 -08:00
Alex Akers
08246b77df [React Native] Fix immediate animation crash 2015-05-05 07:21:43 -08:00
Nick Lockwood
acafa7e921 [ReactNative] Properly transition RCTTouchHandler state
Summary:
When touches end or cancel, update self.state in
RCTTouchHandler to let iOS know that we are in an ended/canceled state.
This way we won't eat other touches because it still thinks we're in a
began/changed state.

@public

Test Plan:
Scrolling in the back swipe area no longer busts gesture
recognition in Wilde.
2015-05-05 06:21:55 -08:00
Alex Akers
5eca2e1d3c [React Native] Added RCTSettings 2015-05-05 05:46:52 -08:00
Tadeu Zagallo
65a3da3003 [ReactNative] Fix chrome debugger 2015-05-05 05:36:05 -08:00
Tadeu Zagallo
d713a711c4 [ReactNative] Fix packager assets 2015-05-05 02:54:51 -08:00
Tadeu Zagallo
132a9170f1 [ReactNative] Create private underlying bridge to prevent retain cycles 2015-05-04 10:36:20 -08:00
Nick Lockwood
c5a6ec5b53 Disable React Native dev menu in release mode 2015-05-03 15:57:26 -08:00
Nick Lockwood
d29a0c6768 Fix for nil array crash 2015-05-02 18:40:04 -08:00
Tadeu Zagallo
09460cf21b [ReactNative] Use explicit doubles on RCTLocationOptions to avoid NSInvocation bug 2015-05-02 14:19:56 -08:00
Tadeu Zagallo
17262db5a9 [ReactNative] Fix JS calls being lost 2015-05-02 13:14:19 -08:00
Nick Lockwood
ba501a1bf5 Upgraded dev menu 2015-05-01 06:36:49 -08:00
Kevin Gozali
b6646d1c4c [ReactNative] Honor fontWeight once again 2015-04-30 11:33:36 -08:00
Nick Lockwood
eb0476074f Improved debug and fixed macros 2015-04-30 09:59:16 -08:00
Ben Alpert
d8ab648fce Updates from Wed 29 Apr 2015-04-29 18:55:07 -07:00
Tadeu Zagallo
483077d4da [ReactNative] Don't log invalid utf8 strings 2015-04-29 12:24:52 -08:00
Brent Vatne
c09bdebcd5 Add support for multiline TextInput via UITextView
Summary:
@nicklockwood - Could I get a review of this?

Just took `RCTTextField` and ported it from `UITextField` to `UITextView` as you mentioned in another discussion, and removed any `UITextField` specific attributes.

- How do you think this should behave when there are subviews?
- Do you know how we can respond to the `UIControlEventEditingDidEndOnExit` event to respond to submit? Because `UITextView` isn't a `UIControl` we can't just use `addTarget` with `UIControlEventEditingDidEndOnExit`.
- Any other feedback?

Still going to look over the `UITextView` docs in more detail and make sure we expose all important options, and add it to the UIExplorer example, just putting this out here for feedback.

![multiline](https://cloud.githubusercontent.com/assets/90494/7310854/32174d6a-e9e8-11e4-919e-71e54cf3c739.gif)

Closes https://github.com/facebook/react-native/pull/991
Github Author: Brent Vatne <brent.vatne@madriska.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-04-29 01:33:58 -08:00
Tadeu Zagallo
2f4430cf51 [ReactNative] Fix bridge event dedupe 2015-04-28 07:58:35 -08:00
Nick Lockwood
bc24be8584 Fixed nil object insertion crash due to incorrectly encoded HTTP response body data 2015-04-28 04:48:32 -08:00
Ben Alpert
dd56ccb9c7 [react-native] Fix capitalization of "REact" 2015-04-27 13:52:57 -08:00