Commit Graph

3966 Commits

Author SHA1 Message Date
Eddie Dugan 22eb711c84 RN picker - implement background color
Summary:
add support to the android implementation of the Picker component for setting the background color.

Changelog: [Android] [Added] - Support item background color in Dialog Picker

Differential Revision: D20566131

fbshipit-source-id: d693b40803fa1051ec955c5728994c820fecd9e9
2020-03-23 08:37:16 -07:00
generatedunixname89002005287564 327fbd0509 Daily arc lint --take BUCKFORMAT
Reviewed By: zertosh

Differential Revision: D20593906

fbshipit-source-id: b056947c698508119dc9d4d1bba202295b8f0fda
2020-03-23 05:58:06 -07:00
Héctor Ramos 987b902dc0 Fix test_android: Remove references to fbsource cell (#28363)
Summary:
Fixes https://github.com/facebook/react-native/issues/28361.

## Changelog

[Internal] [CI] - Fix test_android
Pull Request resolved: https://github.com/facebook/react-native/pull/28363

Test Plan:
Prior to fix:

```
react-native $ ./scripts/circleci/buck_fetch.sh
Guessing 168a69309928ba16065cdb33b1775a4af9f924a6 as the last one used version.
Using additional configuration options from /Users/hramos/.buckconfig.d/experiments, /etc/buckconfig.d/fb_chef.ini, /etc/buckconfig.d/fb_chef_override.ini
Invalidating internal cached state: Watchman failed to start. This may cause slower builds.
Parsing buck files: finished in 1.5 sec
Buck wasn't able to parse /Users/hramos/git/react-native/ReactAndroid/src/main/java/com/facebook/fbreact/specs/BUCK:
IOError: [Errno 2] No such file or directory: '/Users/hramos/git/react-native/tools/build_defs/platform_defs.bzl'
Call stack:
  File "/Users/hramos/git/react-native/.buckd/resources/168a69309928ba16065cdb33b1775a4af9f924a6/buck_server/buck_parser/profiler.py", line 507, in wrapped
    return func(*args, **kwargs)
  File "/Users/hramos/git/react-native/ReactAndroid/src/main/java/com/facebook/fbreact/specs/BUCK", line 1
    load("//tools/build_defs:platform_defs.bzl", "ANDROID")
  File "/Users/hramos/git/react-native/.buckd/resources/168a69309928ba16065cdb33b1775a4af9f924a6/buck_server/buck_parser/profiler.py", line 507, in wrapped
    return func(*args, **kwargs)

This error happened while trying to get dependency '//ReactAndroid/src/main/java/com/facebook/fbreact/specs:FBReactNativeSpec' of target '//ReactAndroid/src/main/java/com/facebook/react/devsupport:devsupport'
```
After fix:

```
react-native $ ./scripts/circleci/buck_fetch.sh
+ buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
Guessing 168a69309928ba16065cdb33b1775a4af9f924a6 as the last one used version.
Using additional configuration options from /Users/hramos/.buckconfig.d/experiments, /etc/buckconfig.d/fb_chef.ini, /etc/buckconfig.d/fb_chef_override.ini
Invalidating internal cached state: Watchman failed to start. This may cause slower builds.
Parsing buck files: finished in 1.1 sec
Configuration 'ANDROID_SDK' points to an invalid directory '/opt/android_sdk'.
    When creating rule //ReactAndroid/src/main/java/com/facebook/hermes/instrumentation:instrumentation.
```

> Note: I don't have the Android SDK configured in this machine.

Verified on Circle CI. `test_android` is now green: https://circleci.com/gh/facebook/react-native/140682?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Reviewed By: cpojer

Differential Revision: D20564934

Pulled By: hramos

fbshipit-source-id: 5d843b8f113c4db5391ee39addc3ff259d962290
2020-03-20 15:36:54 -07:00
Joshua Gross b54257c628 Introduce early dispatch of ViewCommands in FabricUIManager
Summary:
Earlier this week I introduced a change in the old, non-Fabric renderer (D20378633 D20427803) that (gated behind a feature-flag) executes ViewCommands before all other types of commands, as a perf optimization and (I think) a potential fix for a category of race conditions.

I've added more details in comments here.

The Fabric renderer uses the same feature-flag that I introduced for the non-Fabric renderer.

Changelog: [Internal] Fabric

Reviewed By: mdvacca

Differential Revision: D20449186

fbshipit-source-id: bb3649f565f32c417a6247369902333989a043aa
2020-03-19 23:02:05 -07:00
Joshua Gross 0fe548aa2a Only retry ViewCommand mount items if exception is marked as "Retryable"
Summary:
Instead of just blindly retrying all ViewCommands if they fail - which could be dangerous, since it's arbitrary imperative commands we'd be executing twice, potentially with bad app state - we only retry if the ViewCommand throws a "RetryableMountingLayerException".

Changelog: [Internal] Optimization to ViewCommands

Reviewed By: mdvacca

Differential Revision: D20529985

fbshipit-source-id: 0217b43f4bf92442bcc7ca48c8ae2b9a9e543dc9
2020-03-19 23:02:04 -07:00
Joshua Gross 7561adac77 Consolidate "dispatchMountItems" reentrancy prevention code, and retry code, in one function
Summary:
Simplifying the dispatchMountItems reentrance and retry logic.

Motivation: cleanup so I can work on dispatching ViewCommands before anything else.

Importantly, this gives us the properties that:
1) Only one function is responsible for calling dispatchMountItems
2) Only one function is responsible for deciding if we shouldn't call dispatchMountItems due to reentrance
3) Only one function is responsible for all cleanup
4) Only one function maintains all of the relevant flags (except dispatchPreMountItems... two total now, instead of 4 before)

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20437035

fbshipit-source-id: 5370366790eb25f653bee6c1950e747458374a61
2020-03-19 23:02:04 -07:00
Ramanpreet Nara 950826f6b5 Back out "Track animations and flush them"
Summary:
Original commit changeset: b594d0e6e9b6

D20319824 introduced a problem in LayoutAnimations, which makes surfaced as the problem in T63911344. This diff reverts D20319824.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D20541918

fbshipit-source-id: ff72b839f57d39051122920a38b2632cbb5ec362
2020-03-19 20:49:36 -07:00
Joshua Gross bb7f4dc818 Early ViewCommand dispatch: retry exactly once, log soft errors in one place
Summary:
As a followup to T63997094, I think it is better to attempt to execute early once, and then to execute the ViewCommand after the current batch of mount instructions if that fails. If both fail, then log a soft exception.

This is to support the use-case here, when ScrollView.scrollToEnd is called during the render pass, before any Views are mounted on the screen: https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/xplat/js/RKJSModules/Apps/Profile/ProfileEdit/ui/featured_highlights_migration/ProfileEditFeaturedHighlightsMigrationProfilePreview.js?commit=75f66a9077abb81b7797079b567df759dd023a79&lines=221-229

Changelog: [Internal] Fix for dispatching ViewCommands early

Reviewed By: mdvacca

Differential Revision: D20478681

fbshipit-source-id: 052b3ecf4913a0096f590637faf0f68a072e2427
2020-03-16 19:41:47 -07:00
Joshua Gross 5296a740a7 Dispatching ViewCommands to a non-existent tag should log SoftException, but not crash
Summary:
Patch for T63997094.

Will still crash in debug mode, and log soft errors, so as not to entirely hide errors.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20473855

fbshipit-source-id: 8b052b1ae3c886f83d6a7922feb158172cdcd33d
2020-03-16 13:28:08 -07:00
Jack Wang 45d7df6cf7 Adding interface callback for dynamic color scheme
Summary:
Changelog: [Android] [Added]

Adding:
- OverrideColorScheme interface to AppearanceModule
- setOverrideColorScheme method to AppearanceModule

This allows RN surfaces's color scheme to be overriden by custom theme from the app.
When set, AppearanceModule will use the value from OverrideColorScheme instead of system theme (light/dark)

Reviewed By: JoshuaGross

Differential Revision: D20405810

fbshipit-source-id: 8e562148a75231781649b615fdaf3368beeb477d
2020-03-13 22:06:04 -07:00
Héctor Ramos 07def55396 fbshipit-source-id: da15f69185e724eaf7d4bc78dbc61fcdcb3074d5 2020-03-13 21:46:45 -07:00
Joshua Gross f3a53fd338 TextInput: keep less stateful data on the View
Summary:
Allow JS to keep track of mostRecentEventCount and pass it into each event or prop update. We really don't want to separately keep track of that data.

In non-Fabric, the ShadowNode will keep track of the mostRecentEventCount associated to prop updates. In Fabric, that happens on the C++ ShadowNode.

Changelog: [Internal] Simplification to TextInput native state

Reviewed By: mdvacca

Differential Revision: D20374573

fbshipit-source-id: 385fba6ec69a071c78832a686b397699a6c55d67
2020-03-11 12:32:40 -07:00
Joshua Gross 8b61578076 Maintain a separate queue for ViewCommands and execute before everything else
Summary:
ViewCommands are sort of like setNativeProps updates, in that they're direct manipulations of Views on-screen that don't go through the normal
commit/diff process that other UI updates do. This is an MVP that shows how we can do this in non-Fabric RN.

Changelog: [Internal] experiment, allow ViewCommands to be executed before other types of UIOperations

Reviewed By: axe-fb, mdvacca

Differential Revision: D20378633

fbshipit-source-id: 5f3c54d3c84b4e4f7cb060a9505b20b0e5b7afed
2020-03-10 20:26:44 -07:00
generatedunixname89002005287564 837c3db49e Daily arc lint --take GOOGLEJAVAFORMAT
Reviewed By: zertosh

Differential Revision: D20360867

fbshipit-source-id: 737748733ff6826b2f20760fcb301988ff46e278
2020-03-10 05:41:35 -07:00
Joshua Gross 2f45961beb Protect against View context not being a ThemedReactContext in AndroidTextInput in Android 4
Summary:
See D19204032. In some cases the View might not have a ThemedReactContext, it may be wrapped, so we use a previously-created helper to get the correct context from the View or we throw a soft exception.

Changelog: [Internal] Fabric change

Reviewed By: mdvacca

Differential Revision: D20355126

fbshipit-source-id: 469a3b7f8f2d3b98236f3170dd62c4a6e7e1e46f
2020-03-09 20:45:01 -07:00
Joshua Gross 3cc69d2e2b Work around crash when default colors are null
Summary:
Work around crash in Android TextInput when default colors are null.

This likely indicates that the Context is corrupted in some way, so this is not a permanent solution.

Changelog: [Internal] Raise soft exception is default platform text color isn't defined

Reviewed By: mdvacca

Differential Revision: D20351080

fbshipit-source-id: d912c9348272c2f3a3b8d571d465d482060efe5a
2020-03-09 20:45:01 -07:00
Luna Wei c938c0afbf Adjust Layout Animation with pending deletion set
Summary:
Changelog: [Internal]
This solves the problem of viewToAdd indices being invalid if the deletes are asynchronous within the scope of one `manageChildren` call.

Since deletions are performed first, we keep a set of tags being deleted.
During view insertion, we iterate through and filter those tags out of our count.

Reviewed By: JoshuaGross

Differential Revision: D20324643

fbshipit-source-id: 150230428fcd65b8c43cc1f2331e9ce02d31fff9
2020-03-09 18:33:53 -07:00
Luna Wei dedf9372ca Track animations and flush them
Summary:
Changelog: [Internal]

Track delete animations and when `manageChildren` is called on a certain view tag, finish all pending deletion animations before manipulating children

Reviewed By: JoshuaGross

Differential Revision: D20319824

fbshipit-source-id: b594d0e6e9b6fecc5eca2938f284be631494e55c
2020-03-09 15:56:38 -07:00
Luna Wei d3b93f7578 Remove all layout index adjustments
Summary:
Changelog: [Internal]

# Context Timeline

* ~March 2019 landed D14529038 (I'll be referring to this as "index adjustment fix")
which attempted to fix a reproducible issue with layout animations: P127130177, see Spencer's diff for more context: D14245985

* May 2019 I realized that "index adjustment fix" has a bug in it and attempted to fix with D15485132, but was eventually reverted because of other crashes

* Just recently have been getting tasks related to crashes that are attempting to either remove or add a view that is out of bounds which is caused by invalid index because of the "index adjustment fix".

# What is this diff doing?
I'm removing the "index adjustment fix" because I found that the original layout animation repro, P127130177, no longer repros on  latest master with the "index adjustment fix" reverted.

Additionally, I've found a consistent crash in (RN bookmark > Sample Integration App > Relay Sample Friends) of a bad view deletion because of the "index adjustment fix"

Removing the index adjustment fix may have effects elsewhere but it seems better to remove this and go back to what layout animations was doing a year ago than to continue on in this half-baked state.

Reviewed By: JoshuaGross

Differential Revision: D20323928

fbshipit-source-id: ba4a222915add00e98a9936ba2a8efc4006fb8e3
2020-03-09 15:56:37 -07:00
Jesse Katsumata 42c1957aff chore: fix typo in comments (#28269)
Summary:
Fixed some typos in the comment.

## Changelog

[Internal] [Fixed] - Fixed typo in the comments
Pull Request resolved: https://github.com/facebook/react-native/pull/28269

Test Plan: Changes are only made in the comments, so test is not necessary.

Reviewed By: cpojer

Differential Revision: D20342637

Pulled By: shergin

fbshipit-source-id: f6e7dd538ee54c43e1570c35e1f8c4502054e328
2020-03-09 15:37:33 -07:00
David Vacca c3d0729550 Fix rendering of TextInput in Catalyst App
Summary:
This diff fixes the rendering of the TextInput RNTester examples in catalyst app.
The root cause of the bug is that we were parsing the props of the text using the TextAttributeProps class, this is incorrect because TextAttributeProps is a holder of the C++ TextAttributes and not TextProps, but the name is confusing.
As a consecuence there was some mistmaches of types during parsing and that was throwing an exception in some examples.

I created the task T63643819 to refactor these classes to make this cleaner.
I'll be working on T63643819 next week, now I want to unblock this bug.

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20320969

fbshipit-source-id: 7b47546ba4f34df2a7fa151ab200823ea2eeb696
2020-03-06 23:07:32 -08:00
David Vacca acbf9e18ea Deprecate method UIManagerModule.resolveRootTagFromReactTag
Summary:
In this diff I'm doing the following:
- Deprecating the method UIManagerModule.resolveRootTagFromReactTag
- Removing the callsites to the method UIManagerModule.resolveRootTagFromReactTag
- Refactoring the callsites in order to keep the same behavior for rootTags
- Throwing an exception if this method was being called with a non rootTag
- Controlling this change of behavior with a MC

This is possible because long time ago we refactored all the callsites to this method to ensure we only use rootTag. I'm making extra steps to make sure this deprecation is safe and we don't break production if this method was being called with a non Root Tag.

changelog: [Android][Deprecated] We are deprecating the method UIManagerModule.resolveRootTagFromReactTag, this will not be supported in the next version of RN

Reviewed By: fkgozali

Differential Revision: D20309166

fbshipit-source-id: 8b89ba889313ae03ed543f402b68f1bb4064ca68
2020-03-06 13:29:01 -08:00
Logan Daniels b85cb0cf7a Back out "Moving towards UIWindowScene support"
Summary:
Original commit changeset: ae2a4478e2e7

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D20289851

fbshipit-source-id: 1167ce8f5135411b80630b523c91c10e2b7eece1
2020-03-05 15:58:44 -08:00
Joshua Gross 782e06a059 LogBox: do less work in production when LogBox shouldn't even be running
Summary:
Do we need this? Is it possible for any of these codepaths to execute in production? If so, it would be nice to avoid NPEs or even scheduling work on the UI thread.

Maybe we want to add soft exception logging for if these paths are called?

Changelog: [Internal] make sure LogBox does even less work when it's not hooked up

Reviewed By: rickhanlonii

Differential Revision: D20156812

fbshipit-source-id: ba9faedcb3b0951e6913724ca99549dc2d16237e
2020-03-04 19:38:24 -08:00
Michael Yoon (LAX) 0a17a4fe56 fix android TextInput transitions
Summary:
On Android, when changing the props on TextInput component, there are cases where behavior is incorrect.

ex: there were two other PR requests to fix the following issues:
1) TextInput doesnt respect the autoCapitalize prop when keyboardType is set to "default"
2) Password visibility is broken

But those PRs ended up breaking a transition from phone-pad to default

Root cause
- The issue is that the bits that Android defines to store the InputType flags are reused.
- For example, the previous issue: TYPE_TEXT_FLAG_CAP_WORDS and TYPE_NUMBER_FLAG_DECIMAL are both using 0x00002000 bit. So when switching input types from phone-pad to default (text), it is not known if this bit should be cleared. It could have been set for capitalize or for indicating the num pad should be generic.

the solution is to always unset the TYPE_CLASS flags before setting the keyboardType so the user has the correct keyboard.

Changelog: [Fixed] TextInput transition from phone-pad to default

Reviewed By: JoshuaGross

Differential Revision: D20263334

fbshipit-source-id: 0b283fbd6314bf10b90f760917447d2439aaa147
2020-03-04 17:41:50 -08:00
Ramanpreet Nara 7ec9af0fcf Temporarily add logs in TM initialization
Summary:
Marketplace eagerly initializes a few NativeModules. These NativeModules are TurboModule compatible, and the device/user is in the TurboModule test. So these NativeModuels should be returned from the TurboModule system. However, for some reason, we end up doing a lookup on the `NativeModuleRegistry` for these NativeModules.

This means that either:
1. The TurboModuleManager isn't attached to the CatalystInstance
2. The TurboModuleManager returned null from getModule.

These logs will help us get to the bottom of what's going on.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D20260150

fbshipit-source-id: bb554ead412ad3b0fa7502b77f575365608ebc98
2020-03-04 15:06:55 -08:00
radex b58e176af0 Moving towards UIWindowScene support (#28058)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/28058

I'm taking the first step towards supporting iOS 13 UIScene APIs and modernizing React Native not to assume an app only has a single window. See discussion here: https://github.com/facebook/react-native/issues/25181#issuecomment-505612941

The approach I'm taking is to take advantage of `RootTagContext` and passing it to NativeModules so that they can identify correctly which window they refer to. Here I'm just laying groundwork.

- [x] `Alert` and `ActionSheetIOS` take an optional `rootTag` argument that will cause them to appear on the correct window
- [x] `StatusBar` methods also have `rootTag` argument added, but it's not fully hooked up on the native side — this turns out to require some more work, see: https://github.com/facebook/react-native/issues/25181#issuecomment-506690818
- [x] `setNetworkActivityIndicatorVisible` is deprecated in iOS 13
- [x] `RCTPerfMonitor`, `RCTProfile` no longer assume `UIApplicationDelegate` has a `window` property (no longer the best practice) — they now just render on the key window

Next steps: Add VC-based status bar management (if I get the OK on https://github.com/facebook/react-native/issues/25181#issuecomment-506690818 ), add multiple window demo to RNTester, deprecate Dimensions in favor of a layout context, consider adding hook-based APIs for native modules such as Alert that automatically know which rootTag to pass

## Changelog

[Internal] [Changed] - Modernize Modal to use RootTagContext
[iOS] [Changed] - `Alert`, `ActionSheetIOS`, `StatusBar` methods now take an optional `surface` argument (for future iPadOS 13 support)
[iOS] [Changed] - RCTPresentedViewController now takes a nullable `window` arg
[Internal] [Changed] - Do not assume `UIApplicationDelegate` has a `window` property
Pull Request resolved: https://github.com/facebook/react-native/pull/25425

Test Plan:
- Open RNTester and:
- go to Modal and check if it still works
- Alert → see if works
- ACtionSheetIOS → see if it works
- StatusBar → see if it works
- Share → see if it works

Reviewed By: PeteTheHeat

Differential Revision: D16957751

Pulled By: hramos

fbshipit-source-id: ae2a4478e2e7f8d2be3022c9c4861561ec244a26
2020-03-04 14:25:12 -08:00
Samuel Susla fcec815368 Fix what updateState in ScrollView when called from reactSmoothScrollTo
Summary:
Changelog: [Internal]

# Problem

Fabric didn't know about content offset, even though `reactSmoothScrollTo` calls `updateStateOnScroll`, the value of content offset is {0, 0}.

# Fix

Call `updateStateOnScroll` from `reactSmoothScrollTo` with where the scroll view is going to be rather than where it is.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D20248959

fbshipit-source-id: b1da645576dd5e8dce29e7e1d90ab232e0df9fd5
2020-03-04 14:20:05 -08:00
Samuel Susla 4f908a569a Fix HorizontalScrollView not reporting its contentOffset
Summary:
# Problem

HorizontalScrollView was not reporting its `contentOffset` to Fabric, therefore `measure`  was returning wrong value.

# Solution

Copy over implementation of `updateState` from scrollView. I noticed that there is a lot of duplication between the two classes, that's why I decided to duplicate `updateState` as well.

Changelog: [Internal]

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D20247552

fbshipit-source-id: 48b1eb0c11198a32531effe55301f8d554e92130
2020-03-04 14:11:06 -08:00
Joshua Gross d892bb889b Add more specific error messages for different lifecycle problems
Summary:
Currently the error messages lead users to assume that all problems are because we're trying to use the ReactContext too early; it could be because we're using it too late, after it's been destroyed. Because of D17944723, it could be because we're accessing too late, after teardown.

Changelog: [Internal] making some error messages more specific and helpful

Reviewed By: mdvacca

Differential Revision: D20251909

fbshipit-source-id: e236d57e4d7d9c778d41de95160c242bcd69b3c9
2020-03-04 12:44:18 -08:00
generatedunixname89002005287564 6aa7030ce8 Daily arc lint --take CLANGFORMAT
Reviewed By: zertosh

Differential Revision: D20245569

fbshipit-source-id: 2fede4cfd7e0291aa6718d510bfe14ee175134df
2020-03-04 06:08:57 -08:00
David Vacca 8b0ccd2bdb Fix RN Android codegen to support null values for Color typed props
Summary:
This diff fixes the RN Android codegen to support null values for Color typed props.
This was already supported but it recently changed as part of D20169335, when we added the new prop type "color".

changelog: [internal]

Reviewed By: TheSavior

Differential Revision: D20213689

fbshipit-source-id: 42d624de3d1296582f4dcc9c7decd0c02aacca98
2020-03-03 00:55:05 -08:00
Joshua Gross c2de99662e Prevent reentrant dispatchMountItems calls
Summary:
Turns out that dispatchMountItems was reentrant, meaning that something (in particular, updateState) could cause mount items to be queued up which would then be executed synchronously, out-of-order, in the middle of the previous dispatchMountItems call.

We will continue to monitor this and see how often we're reentering: T63181639 and via any soft exceptions that are logged.

For context, there are currently three ways dispatchMountItems gets called: 1) On every UI Tick in the UI thread, in a loop; 2) via animations, via synchronouslyUpdateViewOnUIThread, which happens to fail a *lot* currently; 3) when there is a commit on the UI thread, like with a Java->C++ state update. We must account for reentrance and failure in all three cases and make sure the `mInDispatch` flag is reset after success or failure in all of those situations.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20170160

fbshipit-source-id: 834f1d9b65000caa7f2eea4849e5e7951d2b6be6
2020-03-02 22:28:21 -08:00
Valentin Shergin 11948bb4b6 Fabric: Removing TimeUtils.h
Summary:
We don't use it anymore (we switched to `std::chrono`).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D20201214

fbshipit-source-id: 0c464223822b78c99ed7ff60d926e84a675f2612
2020-03-02 20:11:29 -08:00
Eli White ce0edca620 Update ReactPropertyProcessor to handle new color objects
Summary:
D19837753 updated the native platforms to support complex color objects however the diff failed to build when going through this code path (as we do at Facebook).

This updates the automatic PropSetter classes to go through the new Color handler.

Changelog:
[Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: mdvacca

Differential Revision: D20169335

fbshipit-source-id: 8eb9c8b48b1840832b3aec9ffcb83c3cf614ce0e
2020-03-02 15:12:10 -08:00
Eli White 8643b5560e Update OSS generated Android component delegates
Summary:
$title

Now that the codegen handles the new PlatformColors, regenerating the checked in native component files.

Changelog:
[Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: mdvacca

Differential Revision: D20175914

fbshipit-source-id: fa7b8e5139dcfe06f49582d7810fae12e1e1fb4b
2020-03-02 15:12:10 -08:00
Tom Underhill f4de45800f PlatformColor implementations for iOS and Android (#27908)
Summary:
This Pull Request implements the PlatformColor proposal discussed at https://github.com/react-native-community/discussions-and-proposals/issues/126.   The changes include implementations for iOS and Android as well as a PlatformColorExample page in RNTester.

Every native platform has the concept of system defined colors. Instead of specifying a concrete color value the app developer can choose a system color that varies in appearance depending on a system theme settings such Light or Dark mode, accessibility settings such as a High Contrast mode, and even its context within the app such as the traits of a containing view or window.

The proposal is to add true platform color support to react-native by extending the Flow type `ColorValue` with platform specific color type information for each platform and to provide a convenience function, `PlatformColor()`, for instantiating platform specific ColorValue objects.

`PlatformColor(name [, name ...])` where `name` is a system color name on a given platform.  If `name` does not resolve to a color for any reason, the next `name` in the argument list will be resolved and so on.   If none of the names resolve, a RedBox error occurs.  This allows a latest platform color to be used, but if running on an older platform it will fallback to a previous version.
 The function returns a `ColorValue`.

On iOS the values of `name` is one of the iOS [UI Element](https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors) or [Standard Color](https://developer.apple.com/documentation/uikit/uicolor/standard_colors) names such as `labelColor` or `systemFillColor`.

On Android the `name` values are the same [app resource](https://developer.android.com/guide/topics/resources/providing-resources) path strings that can be expressed in XML:
XML Resource:
`@ [<package_name>:]<resource_type>/<resource_name>`
Style reference from current theme:
`?[<package_name>:][<resource_type>/]<resource_name>`
For example:
- `?android:colorError`
- `?android:attr/colorError`
- `?attr/colorPrimary`
- `?colorPrimaryDark`
- `android:color/holo_purple`
- `color/catalyst_redbox_background`

On iOS another type of system dynamic color can be created using the `IOSDynamicColor({dark: <color>, light:<color>})` method.   The arguments are a tuple containing custom colors for light and dark themes. Such dynamic colors are useful for branding colors or other app specific colors that still respond automatically to system setting changes.

Example: `<View style={{ backgroundColor: IOSDynamicColor({light: 'black', dark: 'white'}) }}/>`

Other platforms could create platform specific functions similar to `IOSDynamicColor` per the needs of those platforms.   For example, macOS has a similar dynamic color type that could be implemented via a `MacDynamicColor`.   On Windows custom brushes that tint or otherwise modify a system brush could be created using a platform specific method.

## Changelog

[General] [Added] - Added PlatformColor implementations for iOS and Android
Pull Request resolved: https://github.com/facebook/react-native/pull/27908

Test Plan:
The changes have been tested using the RNTester test app for iOS and Android.   On iOS a set of XCTestCase's were added to the Unit Tests.

<img width="924" alt="PlatformColor-ios-android" src="https://user-images.githubusercontent.com/30053638/73472497-ff183a80-433f-11ea-90d8-2b04338bbe79.png">

In addition `PlatformColor` support has been added to other out-of-tree platforms such as macOS and Windows has been implemented using these changes:

react-native for macOS branch: https://github.com/microsoft/react-native/compare/master...tom-un:tomun/platformcolors

react-native for Windows branch: https://github.com/microsoft/react-native-windows/compare/master...tom-un:tomun/platformcolors

iOS
|Light|Dark|
|{F229354502}|{F229354515}|

Android
|Light|Dark|
|{F230114392}|{F230114490}|

{F230122700}

Reviewed By: hramos

Differential Revision: D19837753

Pulled By: TheSavior

fbshipit-source-id: 82ca70d40802f3b24591bfd4b94b61f3c38ba829
2020-03-02 15:12:09 -08:00
Will Holen 5166856d04 Don't try to create tracing runtimes in OSS RN
Summary:
Tracing isn't supported in OSS builds, so use `hermes/hermes.h` instead
of `hermes_tracing.h` to avoid pulling in any unnecessary dependencies.

Changelog: [Internal]

Reviewed By: dulinriley

Differential Revision: D20201826

fbshipit-source-id: 4c2977db191bb9a1a82310888a435b761629169b
2020-03-02 15:07:21 -08:00
Will Holen 3508017fb3 Remove unconditional assert from addNativeTracingHooks. Do nothing instead.
Summary:
This line was and apparently has always been triggered from the
HermesExecutorFactory. We just didn't notice because we didn't build with
assertions.

Changelog: [Internal] Don't crash on load when assertions and Hermes are enabled

Reviewed By: dulinriley

Differential Revision: D20163138

fbshipit-source-id: af672bb51eeb1833f3e27ad9a00921731c345fc5
2020-03-02 14:51:34 -08:00
David Vacca 17a62b72b7 Serialize and de-serialize text attachments for Android
Summary:
This diff implements serialization and deserialization of text attachments as part of the calculation of layout of text components
changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20087251

fbshipit-source-id: dbcbd22f856aadace14343205548154ea80c8464
2020-02-28 22:43:14 -08:00
David Vacca 58d683a688 Delete TODO to support inlinew Views in Fabric + venice
Summary:
ez diff to remove TODO to support inlinew Views in Fabric + venice

changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D20088698

fbshipit-source-id: bd7cbbd76a8c13edf94d4eecac0dd670ccd0d209
2020-02-28 22:43:14 -08:00
Will Holen b8621f5d30 Try the debug executor before the release executor
Summary:
We are currently unintentionally including both libhermes-executor-release.so
and libhermes-executor-debug.so in all OSS RN builds.

RN tries both in turn, but since they both exist and the release executor is compatible
with the debug build, we always get the release executor without debug functionality.

While we sort this out, switch the load order. Since the debug executor is not compatible
with the release build, so it'll fail to load and try the next one.

ChangeLog: [Android] Fix Hermes debugger being disabled by default

Reviewed By: mhorowitz

Differential Revision: D20163828

fbshipit-source-id: ee4d87f40e42a7c8eedfdb7e1fc17eb3e5966ba5
2020-02-28 15:08:50 -08:00
Kevin Gozali 30822e3923 make RN infra labels public
Summary:
Internal build target labeling.

Changelog: [Internal]

Reviewed By: zlern2k

Differential Revision: D20152676

fbshipit-source-id: 89615a0b3a6f3994b18f2c07b86d0ae93e052327
2020-02-28 12:46:49 -08:00
Ramanpreet Nara 6a9a76e420 Make RCTDevLoadingView TurboModule-compatible
Summary:
This is a redo of D16969764, with a few extensions.

## Changes
1. Move `RCTDevLoadingView.{h,m}` to `CoreModuels/RCTDevLoadingView.{h,mm}`
2. Extract ObjC API of `RCTDevLodingView` into `RCTDevLoadingViewProtocol` in `ReactInternal`.
3. Create API `RCTDevLoadingViewSetEnabled.h` in `ReactInternal` to enable/disable `RCTDevLoadingView`

Changelog:
[iOS][Added] - Make RCTDevLoadingView TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18642554

fbshipit-source-id: 6b62e27e128d98254b7a6d018399ec1c06e274fc
2020-02-27 17:06:13 -08:00
Emily Janzer 5ff9ae4a46 Refactor reloadJSFromServer to use a callback internally
Summary:
This is step 3 in creating a new DevSupportManager with a better async API for loading the JS bundle from Metro.

Right now DevSupportManagerImpl calls a method on its ReactInstanceManagerDevHelper delegate when the JS bundle is done being downloaded from the server. However, I want to move to a callback-based method for bridgeless mode (similar to packager status). In this diff, I'm adding a protected method that uses a callback, and then calling that from `reloadJSFromServer` with a callback that calls the delegate, to preserve existing behavior.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D19871102

fbshipit-source-id: 2dbb6b91c5b927df86c3db42aa11e080d57ea78e
2020-02-27 12:36:30 -08:00
Emily Janzer 506e3a208e Create AsyncDevSupportManager + associated classes
Summary:
This is the second step in creating a new DevSupportManager impl with more async-friendly APIs for bundle loading, which I'll use in bridgeless mode. This diff creates a new interface, AsyncDevSupportManager, and two implementations, mirroring what we currently have.

This new interface doesn't define any methods yet.

Changelog: [Android][Changed] Specify DevSupportManager.setPackagerLocationCustomizer in DevSupportManager impls

Reviewed By: mdvacca

Differential Revision: D19870812

fbshipit-source-id: 042a43e1a3055aba6d7325f948060300b5bf17f3
2020-02-27 12:36:30 -08:00
Emily Janzer 3f13c9abe6 Split DevSupportManagerImpl into DevSupportManagerBase + Impl
Summary:
This is the first step for adding my own async APIs for DevSupportManager to use in bridgeless mode.

To avoid having to add these APIs to the DevSupportManager interface + both of its implementations, I'm instead splitting DevSupportManager into a base class + final impl so I can more easily share logic with the new impl I'll create.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D19846619

fbshipit-source-id: c67b0231f4e6581fb484f9a4899ed0b7f08fb684
2020-02-27 12:36:29 -08:00
Ram N 3498b3b96b Check null values in shouldAnimate
Summary:
Looks like there could be cases when the NativeHirearchyManager may be asking if it should animate on a view that has been removed. Adding a null check

Changelog:
[General] [Fixed] - Check null values in shouldAnimate

Reviewed By: makovkastar

Differential Revision: D20063054

fbshipit-source-id: 5b3b1c27b9aba57a592bd8d4e27a970cf0912b5d
2020-02-27 09:22:13 -08:00
Héctor Ramos 8ae3174873 Run clang-format and apply patches
Summary:
Run clang-format and add .clang-tidy with `clang-diagnostic-*` to several more directories in order to catch any problems.

Changelog:
[Internal]

Reviewed By: shergin

Differential Revision: D19860169

fbshipit-source-id: 7785aab010c8e6945cc6b5c9b68cb8ee0cdbb7fa
2020-02-27 08:29:30 -08:00
Joshua Gross 6beee039a2 Don't crash in dev if ViewCommand is sent to nonexistent tag
Summary:
We were already doing this for ViewCommands sent with integer IDs; we should do the same for now with String commands. Otherwise, screens with TextInputs are unusable during development because these exceptions are thrown very often around reload and navigation.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20127446

fbshipit-source-id: a5d65ff6ae5b520fd0efffa5c325b5cca3bd53a0
2020-02-26 23:32:24 -08:00