From 1fd7315c3b31b4378d1ee18ed98a1d941a0feecf Mon Sep 17 00:00:00 2001 From: Dan Zimmerman Date: Wed, 27 Dec 2017 12:51:08 -0800 Subject: [PATCH 1/8] Remove unnecessary include Reviewed By: mzlee Differential Revision: D6638538 fbshipit-source-id: 4b11b8f4f88aa533ac0467348df36e5780bfbb70 --- ReactCommon/yoga/BUCK | 2 -- 1 file changed, 2 deletions(-) diff --git a/ReactCommon/yoga/BUCK b/ReactCommon/yoga/BUCK index bd4dddd12aa5..65bfdf418530 100644 --- a/ReactCommon/yoga/BUCK +++ b/ReactCommon/yoga/BUCK @@ -1,5 +1,3 @@ -include_defs("//ReactAndroid/DEFS") - fb_xplat_cxx_library( name = "yoga", srcs = glob(["yoga/*.cpp"]), From 0ec1017660602d6b3ae84b4d7a444cbd49ba0d53 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 27 Dec 2017 17:38:21 -0800 Subject: [PATCH 2/8] Fixed double initial prop applying for newly created views Summary: This is a leftover from recent changes in D6595780 where a prop application step was moved out to separare mount block. Differential Revision: D6640736 fbshipit-source-id: 70de0f55f992a7912e222ec4bf9ade1c9bad99f2 --- React/Modules/RCTUIManager.m | 1 - 1 file changed, 1 deletion(-) diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index ef1c571f3aea..27fa1556fe7a 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -974,7 +974,6 @@ - (void)_manageChildren:(NSNumber *)containerTag } UIView *view = [componentData createViewWithTag:reactTag]; if (view) { - [componentData setProps:props forView:view]; uiManager->_viewRegistry[reactTag] = view; } }); From f9e742aadfacbde5f2b6010a56821fa7009003be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Thu, 28 Dec 2017 08:30:16 -0800 Subject: [PATCH 3/8] Fix buck failure Summary: Buck is failing due to missing args: https://circleci.com/gh/facebook/react-native/29268 Closes https://github.com/facebook/react-native/pull/17346 Differential Revision: D6642181 Pulled By: hramos fbshipit-source-id: 399d3c5f197ae0de9748a592def945c14ac1d348 --- ReactAndroid/DEFS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/DEFS b/ReactAndroid/DEFS index 0b5843026b38..a594df919940 100644 --- a/ReactAndroid/DEFS +++ b/ReactAndroid/DEFS @@ -110,4 +110,4 @@ def rn_robolectric_test(name, srcs, vm_args = None, *args, **kwargs): def fb_xplat_cxx_library(allow_jni_merging=None, **kwargs): - cxx_library(*args, **kwargs) + cxx_library(**kwargs) From 4d33080f0fa7b2eb7b0e9ff7bbd50c222f461786 Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Thu, 28 Dec 2017 08:47:25 -0800 Subject: [PATCH 4/8] better Keyabord event utils Reviewed By: shergin Differential Revision: D6639418 fbshipit-source-id: ef973cfebb94325579525bdcd3990737fe576ef8 --- Libraries/Components/Keyboard/Keyboard.js | 43 +++++++++++++++++------ 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index 9b3c7973062e..d85801c9d871 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -11,6 +11,7 @@ */ 'use strict'; +const LayoutAnimation = require('LayoutAnimation'); const invariant = require('fbjs/lib/invariant'); const NativeEventEmitter = require('NativeEventEmitter'); const KeyboardObserver = require('NativeModules').KeyboardObserver; @@ -25,16 +26,18 @@ type KeyboardEventName = | 'keyboardWillChangeFrame' | 'keyboardDidChangeFrame'; -type KeyboardEventData = { - endCoordinates: { - width: number, - height: number, - screenX: number, - screenY: number, - }, -}; +export type KeyboardEvent = {| + +duration?: number, + +easing?: string, + +endCoordinates: {| + +width: number, + +height: number, + +screenX: number, + +screenY: number, + |}, +|}; -type KeyboardEventListener = (e: KeyboardEventData) => void; +type KeyboardEventListener = (e: KeyboardEvent) => void; // The following object exists for documentation purposes // Actual work happens in @@ -134,11 +137,31 @@ let Keyboard = { */ dismiss() { invariant(false, 'Dummy method used for documentation'); - } + }, + + /** + * Useful for syncing TextInput (or other keyboard accessory view) size of + * position changes with keyboard movements. + */ + scheduleLayoutAnimation(event: KeyboardEvent) { + invariant(false, 'Dummy method used for documentation'); + }, }; // Throw away the dummy object and reassign it to original module Keyboard = KeyboardEventEmitter; Keyboard.dismiss = dismissKeyboard; +Keyboard.scheduleLayoutAnimation = function(event: KeyboardEvent) { + const {duration, easing} = event; + if (duration) { + LayoutAnimation.configureNext({ + duration: duration, + update: { + duration: duration, + type: (easing && LayoutAnimation.Types[easing]) || 'keyboard', + }, + }); + } +}; module.exports = Keyboard; From d3b41e0da37c08ab0637d9f70d612e50b6f5e63c Mon Sep 17 00:00:00 2001 From: Michael Schneider Date: Thu, 28 Dec 2017 10:24:25 -0800 Subject: [PATCH 5/8] Set minHeight instead of minWidth for calculating the layout in RCTSurfaceRootShadowView Summary: Fix calculating layout in `RCTSurfaceRootShadowView` as the `minWidth` is set doubled in `calculateLayoutWithMinimumSize:maximumSize:`. cc shergin Closes https://github.com/facebook/react-native/pull/17203 Differential Revision: D6642437 Pulled By: shergin fbshipit-source-id: 3483c952c9ecf0132182a156b7b916eb1e975424 --- React/Base/Surface/RCTSurfaceRootShadowView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Base/Surface/RCTSurfaceRootShadowView.m b/React/Base/Surface/RCTSurfaceRootShadowView.m index f076c9daeea1..9ffe7364cb32 100644 --- a/React/Base/Surface/RCTSurfaceRootShadowView.m +++ b/React/Base/Surface/RCTSurfaceRootShadowView.m @@ -50,7 +50,7 @@ - (void)calculateLayoutWithMinimumSize:(CGSize)minimumSize maximumSize:(CGSize)m float availableHeight = isinf(maximimSize.height) ? YGUndefined : maximimSize.height; self.minWidth = (YGValue){isinf(minimumSize.width) ? YGUndefined : minimumSize.width, YGUnitPoint}; - self.minWidth = (YGValue){isinf(minimumSize.height) ? YGUndefined : minimumSize.height, YGUnitPoint}; + self.minHeight = (YGValue){isinf(minimumSize.height) ? YGUndefined : minimumSize.height, YGUnitPoint}; YGNodeCalculateLayout(self.yogaNode, availableWidth, availableHeight, _baseDirection); } From 52f350a9cbe914f7fbdbb008a4cb40cb25b4a638 Mon Sep 17 00:00:00 2001 From: Mark Amery Date: Thu, 28 Dec 2017 11:30:33 -0800 Subject: [PATCH 6/8] Add proptypes for scrollview drag start & end handlers Summary: `ScrollView` has a bunch of `onFoo` handlers for scrolling-related events, most of which have a proptype defined and are documented. However, `onScrollBeginDrag` and `onScrollEndDrag` do not currently have a proptype and are not currently documented (as noted at https://stackoverflow.com/a/41793747/1709587). It seems reasonable to bring consistency and to provide documentation of these otherwise hard-to-discover props. I haven't added or run any tests, and don't plan to do so (beyond waiting and seeing that no existing checks fail in CircleCI). I have also created a PR to update the documentation at https://github.com/facebook/react-native-website/pull/99 *(None needed; this isn't a functionality change.)* Closes https://github.com/facebook/react-native/pull/17368 Differential Revision: D6642695 Pulled By: TheSavior fbshipit-source-id: fa40ed2ae6d5947a161b816a47441d8f5d4d9c4d --- Libraries/Components/ScrollView/ScrollView.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 74026c7e6496..1f6c55aff668 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -256,6 +256,15 @@ const ScrollView = createReactClass({ * events can be controlled using the `scrollEventThrottle` prop. */ onScroll: PropTypes.func, + /** + * Called when the user begins to drag the scroll view. + */ + onScrollBeginDrag: PropTypes.func, + /** + * Called when the user stops dragging the scroll view and it either stops + * or begins to glide. + */ + onScrollEndDrag: PropTypes.func, /** * Called when scrollable content view of the ScrollView changes. * From fa574c60920588e29d7b642e547e240ac8655e66 Mon Sep 17 00:00:00 2001 From: Jhen-Jie Hong Date: Fri, 29 Dec 2017 07:44:42 -0800 Subject: [PATCH 7/8] Set host of development server for setupDevtools Summary: Related to #15126, and this would be useful for use React DevTools on real device without modify `setupDevtools.js`. In Android emulator, the host of `SourceCode.scriptURL` is same with `PlatformConstants.ServerHost` so we can just replace it. * Tested on iOS device with [react-devtools](https://github.com/facebook/react-devtools/tree/master/packages/react-devtools) package. * Tested on Android emulator, the `getDevServer` module got the correctly hostname so that don't need `adb reverse`. [ENHANCEMENT] [setupDevtools] Set host of development server for setupDevtools Closes https://github.com/facebook/react-native/pull/15547 Differential Revision: D6544980 Pulled By: javache fbshipit-source-id: a286874bcef0501c5d2e0be2251d58c236a5534a --- Libraries/Core/Devtools/setupDevtools.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Libraries/Core/Devtools/setupDevtools.js b/Libraries/Core/Devtools/setupDevtools.js index 869eb7ccda40..b1c32960abf5 100644 --- a/Libraries/Core/Devtools/setupDevtools.js +++ b/Libraries/Core/Devtools/setupDevtools.js @@ -28,11 +28,11 @@ let register = function () { if (__DEV__) { const AppState = require('AppState'); const WebSocket = require('WebSocket'); - const {PlatformConstants} = require('NativeModules'); /* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an * error found when Flow v0.54 was deployed. To see the error delete this * comment and run Flow. */ const reactDevTools = require('react-devtools-core'); + const getDevServer = require('getDevServer'); // Initialize dev tools only if the native module for WebSocket is available if (WebSocket.isAvailable) { @@ -42,10 +42,11 @@ if (__DEV__) { // or the code will throw for bundles that don't have it. const isAppActive = () => AppState.currentState !== 'background'; - // Special case: Genymotion is running on a different host. - const host = PlatformConstants && PlatformConstants.ServerHost ? - PlatformConstants.ServerHost.split(':')[0] : - 'localhost'; + // Get hostname from development server (packager) + const devServer = getDevServer(); + const host = devServer.bundleLoadedFromServer + ? devServer.url.replace(/https?:\/\//, '').split(':')[0] + : 'localhost'; reactDevTools.connectToDevTools({ isAppActive, From a8391bde7d757d01521a6d12170fb9090c17a6a0 Mon Sep 17 00:00:00 2001 From: Matt Sessions Date: Fri, 29 Dec 2017 14:04:34 -0800 Subject: [PATCH 8/8] SectionList renderItem should be optional Summary: `renderItem` on `SectionList` is within the `OptionalProps` group of props but it is not actually marked as optional. Which means that doing things such as in the example where each section has its own `renderItem` and no `renderItem` prop is passed into `SectionList` will fail flow. Create a `SectionList` where each section has it's own `renderItem` and do not pass in a `renderItem` into `SectionList`. Run flow, it should error. [GENERAL] [MINOR] [SectionList] -Makes `renderItem` prop on `SectionList` optional for flow. Closes https://github.com/facebook/react-native/pull/17262 Differential Revision: D6645672 Pulled By: hramos fbshipit-source-id: 1096e8c4998c14003cf42f29ea559505082047c1 --- Libraries/Lists/SectionList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Lists/SectionList.js b/Libraries/Lists/SectionList.js index 775685131d6e..f547066f129b 100644 --- a/Libraries/Lists/SectionList.js +++ b/Libraries/Lists/SectionList.js @@ -71,7 +71,7 @@ type OptionalProps> = { /** * Default renderer for every item in every section. Can be over-ridden on a per-section basis. */ - renderItem: (info: { + renderItem?: (info: { item: Item, index: number, section: SectionT,