Граф коммитов

578 Коммитов

Автор SHA1 Сообщение Дата
Peter Argany f229d67498 Make RCTAccessibilityManger a TurboModule
Summary:
Move RCTAccessibilityManager to CoreModules (since that's the only dir that supports TM).

Fixup some variable names to match spec.

Reviewed By: RSNara

Differential Revision: D16861739

fbshipit-source-id: a0a53b221dcc172979d1f2c83851ab92e23f2333
2019-08-23 12:01:52 -07:00
Anatolii Shevchenko d8e335df0e Remove ; from method implementation definition
Summary: Removing excessive semicolon ";" symbol from method implementation definition.

Reviewed By: adamjernst

Differential Revision: D16912006

fbshipit-source-id: 9c3e778a107e8fd0055f40a95ea9ca58d461e1c5
2019-08-21 15:49:16 -07:00
Peter Argany 685c15a955 Make RCTDeviceInfo a TurboModule
Summary: Follow pattern laid out by Kevin in D16001262 to convert a Core OSS native module to use TM generated spec.

Reviewed By: RSNara

Differential Revision: D16016391

fbshipit-source-id: f517777be44c68367d786f04c50cf12f240eed00
2019-08-21 14:31:02 -07:00
Peter Argany 6991e28653 Move RCTExceptionsManager to CoreModules and make it conform to spec
Summary:
`NativeExceptionsManager.js` contains the JS spec for this native module. This diff moves the objc code to CoreModules (since it's the only directory that supports TM at the moment) and makes it conform to the spec.

NOTE: I will update podfiles after this diff is reviewed, before I land. Adding those generated changes makes it really hard to review.

Reviewed By: RSNara

Differential Revision: D16812212

fbshipit-source-id: 38b6e9a20ce15e7e9995df34493b37ed7adb2911
2019-08-15 20:25:23 -07:00
Kevin Gozali d2e18a1c5c iOS: Revert RCT->RN prefix renaming to avoid confusion
Summary: The previous rename from RCT->RN prefix ended up causing some confusions on which prefix to use for which files and under what circumstances. To avoid further confusion before we're done with the re-architecture project, let's keep them as RCT.

Reviewed By: mdvacca

Differential Revision: D16705566

fbshipit-source-id: 395bff771c84e5ded6b2261a84c7549df1e6c5e5
2019-08-08 07:21:25 -07:00
Kevin Gozali 9420de6860 iOS: codemod react-native-github: RCT->RN prefix for Fabric
Summary: Fabric ObjC(++) files will be prefixed by RN* for the time being, this codemod is a simple rename. This includes `interface` and `protocol` definition

Reviewed By: PeteTheHeat, yungsters

Differential Revision: D16611524

fbshipit-source-id: 868d2571ea2414dde4cbb3b75b1334b779b5d832
2019-08-01 20:06:04 -07:00
Adam Ernst 0e8d571298 Remove duplicate category implementation
Summary:
Duplicate category method implementations cause undefined behavior in Objective-C; one is chosen essentially at random. The linker also issues a noisy warning about this (which is how I noticed this case).

It didn't matter in this particular case since both implementations do the same thing, but we should clean this up so people don't get desensitized to these linker warnings. There is no need to have two implementations.

Reviewed By: fkgozali

Differential Revision: D16587219

fbshipit-source-id: 56dc3493735443c476484092f4a7eacfcddee8cb
2019-07-31 16:42:25 -07:00
zhongwuzw c5ea18f738 Don't call sharedApplication in App Extension (#25769)
Summary:
Fixes https://github.com/facebook/react-native/issues/25767 .

## Changelog

[iOS] [Fixed] - Don't call sharedApplication in App Extension
Pull Request resolved: https://github.com/facebook/react-native/pull/25769

Test Plan: RN works in App Extension.

Reviewed By: cpojer

Differential Revision: D16516104

Pulled By: sammy-SC

fbshipit-source-id: 446fd1d88724b783b2afb2369783b9a85b5cc178
2019-07-26 06:17:34 -07:00
David Vacca e42009b784 Deprecate UIManager.measureLayoutRelativeToParent
Summary:
UIManager.measureLayoutRelativeToParent will not be supported as part of fabric.
This diff deprecates this method in the current version or React Native.

Reviewed By: fkgozali

Differential Revision: D16471845

fbshipit-source-id: acfda9bfb2dd8553ff8e359ea2c8d7d88a14c6d2
2019-07-25 01:00:06 -07:00
Dan Abramov 17f8e5810f Enable by default
Summary:
This enables Fast Refresh by default.

More concretely:

* For clean installs, it's enabled by default. (You can opt out at any time via the dev menu.)

* For updated DEV apps (on device or simulator), it flips from disabled to enabled **but only if you never touched the setting before**.

* If you previously explicitly enabled and/or later disabled it, we keep your previous setting.

Reviewed By: yungsters

Differential Revision: D16442656

fbshipit-source-id: 1bfe0bf4bcf2830284f9c757fbfacc10db92acb4
2019-07-24 13:08:56 -07:00
Min ho Kim 84f5ebe4f9 Fix typos (#25770)
Summary:
Fix typos mostly in comments and some string literals.

## Changelog

[General] [Fixed] - Fix typos
Pull Request resolved: https://github.com/facebook/react-native/pull/25770

Differential Revision: D16437857

Pulled By: cpojer

fbshipit-source-id: ffeb4d6b175e341381352091134f7c97d78c679f
2019-07-23 03:23:11 -07:00
David Vacca 2992518b2e Deprecate UIManagerModule.removeSubviewsFromContainerWithID
Summary:
The method UIManagerModule.removeSubviewsFromContainerWithID will not be part of fabric. This diff deprecates it to avoid future usage before the migration.
This can not be removed, as it is currently used from React-VR

Reviewed By: shergin

Differential Revision: D16420687

fbshipit-source-id: a06810cabb434e35e5a371444114db2633a35a29
2019-07-22 15:39:01 -07:00
David Vacca a863949413 Deprecate UIManagerModule.replaceExistingNonRootView
Summary:
The method UIManagerModule.replaceExistingNonRootView will not be part of fabric. This diff deprecates it to avoid future usage before the migration.
This can not be removed, as it is currently used from React-VR

Reviewed By: shergin

Differential Revision: D16420685

fbshipit-source-id: c534e2ee6371698638751f1482bb619db1569733
2019-07-22 15:39:00 -07:00
David Vacca 458c06b8e7 Back out "[RN][iOS] Remove definition of viewIsDescendantOf method in RN iOS code"
Summary:
Adding viewIsDescendantOf back again, more context 9ae7f0c7da
This method might no not be implemented in Fabric

Reviewed By: fkgozali

Differential Revision: D16186406

fbshipit-source-id: 9cd4c9e20c01713d4e8608a54c6f54082067e27f
2019-07-10 20:56:39 -07:00
Radosław Pietruszewski 3724810d21 Initial UIKitForMac support (#25427)
Summary:
This PR adds initial support for Project Catalyst a.k.a. UIKitForMac. This is not yet meant for production, but this is enough for RNTester to successfully compile and mostly work :)

Some APIs are not supported on the Mac -- e.g. telephony, and deprecated APIs are removed on Mac ���-- those had to be ifdef'd out via platform checks.

The biggest limitation right now is that I couldn't get Web Socket code to successfully compile, and so there are a lot of temporary platform checks  for that , and the RCTWebSocket.xcodeproj is marked as not supporting UIKitForMac. Again -- temporary, until someone with more knowledge knows how to fix this.

https://github.com/react-native-community/discussions-and-proposals/issues/131

## Changelog

[iOS] [Added] - Fixed compilation for macOS (Project Catalyst) -- not meant for production use yet
Pull Request resolved: https://github.com/facebook/react-native/pull/25427

Test Plan:
- Open RNTester/RNTester.xcodeproj with Xcode 10.2, run it like a normal iOS app -- make sure it compiles and runs correctly (no regression)
- Open the same project with Xcode 11 beta 2 (or higher) on macOS Catalina beta, select "My Mac" as device target, and run -- see that it actually compiles and runs. **Note** there are unfortunately some required steps:
   - change build configuration to Release (because packager doesn't work correctly yet)
   - change development team to yours if Xcode tells you to
   - go to RNTester project → Build phases → Link binary with libraries, and change `platforms` for `libRCTWebSocket.a` to `iOS` (without Mac compatibility). I can't commit that change because it breaks compatibility with earlier Xcode versions

The two extra steps for successful compile will disappear once web socket compilation for Catalyst is fixed

Reviewed By: mmmulani

Differential Revision: D16088263

Pulled By: sammy-SC

fbshipit-source-id: 9c0b932b048e50a8e0f336eaa0612851b1909cae
2019-07-04 10:30:33 -07:00
David Vacca 9ae7f0c7da Remove definition of viewIsDescendantOf method in RN iOS code
Summary: The viewIsDescendantOf method is not required anymore, deleting code in RN iOS

Reviewed By: JoshuaGross

Differential Revision: D16014665

fbshipit-source-id: fab63973cfa4340f4f8d91d8bce41defc81486e6
2019-06-26 18:47:13 -07:00
Eli White 0a34fb78ab RN iOS: Support View Manager Commands that are strings
Summary:
Right now JS triggers a view manager command with the following code:

```
UIManager.dispatchViewManagerCommand(
  nullthrows(this.scrollResponderGetScrollableNode()),
  UIManager.getViewManagerConfig('RCTScrollView').Commands.scrollTo,
  [x || 0, y || 0, animated !== false],
);
```

As we want to get rid of calls to UIManager, we need to stop looking for the integer defined in native from JavaScript. We will be changing methods like this to be:

```
UIManager.dispatchViewManagerCommand(
  nullthrows(this.scrollResponderGetScrollableNode()),
  'scrollTo',
  [x || 0, y || 0, animated !== false],
);
```

We need to support ints and Strings to be backwards compatible, but ints will be deprecated.

This is the same change as made for Android here: 3cae6fa950

Reviewed By: PeteTheHeat

Differential Revision: D15983041

fbshipit-source-id: 6cb0f3001553d1f9d26e7e8fb5481e16fbca6847
2019-06-26 10:05:33 -07:00
Dan Abramov a52e6d1dbb Unify "Hot Reloading" and "Reload-on-Save" into "Fast Refresh"
Summary:
We have too many options in the Dev Menu, and they're really hard to pick from. They're also somewhat conflicting. This replaces two menu choices that have a similar purpose (faster iteration cycle) with one.

"Fast Refresh" tries to only update the affected modules, but falls back to doing a full reload if the update can't be handled by the React components.

If for some reason you prefer the "Reload-on-Save" behavior, please:

- Reach out to me so I can learn more about your use case.
- As a workaround, you can add `if (__DEV__) require.Refresh.forceFullRefresh = true` to your app's entry point to always do a full refresh.

Also note that I only removed the user-facing part of "Reload-on-Save". So if you have automation depending on it, that's gonna keep working.

I moved it above Systrace since it's a more generic feature.

As a total aside nit, I renamed "Enable Inspector" and "Disable Inspector" to "Show Inspector" and "Hide Inspector" because... that's what those options do, really.

Reviewed By: rickhanlonii

Differential Revision: D15958697

fbshipit-source-id: 20e856d56f661fe4d39b5ab47d8c44754bf70f67
2019-06-24 13:54:39 -07:00
Dan Abramov 1f04ff580d Make "Enable Hot Reloading" Instant
Summary:
As we saw in D15947985, and later traced down to D5623623, the `hot` option isn't used by Metro anymore. The relevant transforms _always_ run in DEV regardless of the option.

Given that, it doesn't make sense that enabling or disabling Hot Reloading forces a full refresh. This significantly raises the usage barrier because **currently, you might have to wait ~20 seconds (on a large app) to just start using Hot Reloading when you're already in the middle of some screen.** So you just end up not using it.

This diff changes enabling/disabling Hot Reloading to be _instant_.

Here's how it works:

1. Now we always send the necessary info to the client via the new `HMRClient.setup()` function. It creates a Metro HMR client instance, but only actually sets up the socket if Hot Reloading is on.

2. The "Enable Hot Reloading" menu no longer forces a reload. Instead, it calls `HMRClient.enable()` which lazily sets up a socket (at most once).

3. The "Disable Hot Reloading" menu also doesn't trigger a refresh now. Instead, it calls `HMRClient.disable()`. We don't actually tear down the socket here because it's a pain to deal with race conditions and such. Instead, we keep the connection — but we _ignore the updates_ that come in while we're disabled.

4. As a result, it is possible to enable and disable it many times during a single session. (Updates while disabled would be ignored — which has a risk of making your running app inconsistent — but I'd argue it's expected and is worth it. You can always save a particular file to force it to update once the mode is on.)

5. In order to support "ignoring" updates, Metro's `HMRClient` (not to be confused with RN's module) now supports a `shouldApplyUpdates` field. The RN module uses it to disable handling updates when the mode is off.

6. In case there is an error that makes hot reloading unavailable (such as the server disconnecting), we surface the error only if the mode is on. If the mode is off, we stash the error message in the `_hmrUnavailableReason` variable, and display it next time you try to enable Hot Reloading.

Reviewed By: rickhanlonii

Differential Revision: D15958160

fbshipit-source-id: 8256fc4d5c2c3f653a78edf13b8515a5671953e4
2019-06-24 09:48:56 -07:00
Alex Cohen 5c2459996e name background tasks
Summary: [iOS] [Changed] - background tasks need names in order to track them.

Reviewed By: aditya7fb

Differential Revision: D15604435

fbshipit-source-id: 098e28620b75860c0e39166639399bbbcd42ff2b
2019-06-03 10:59:02 -07:00
zhongwuzw 338298417f Timing: Fixes timer when app get into background (#24649)
Summary:
Related #23674, in that PR, we imported background timer support, but it's not sufficient, I think the reason that works is because it enable the `Background Modes` and do some background tasks, for the users who don't enable it, timer would pause immediately before goes into background.

To fix it, we can mark a background task when goes into background, it can keep app active for minutes, try best to support timing when in background.

cc. cpojer .

## Changelog

[iOS] [Fixed] - Timing: Fixes timer when app get into background
Pull Request resolved: https://github.com/facebook/react-native/pull/24649

Differential Revision: D15554451

Pulled By: cpojer

fbshipit-source-id: a33f7afe6b63d1a4fefcb7098459aee0c09145da
2019-05-30 02:03:14 -07:00
Valentin Shergin 94dfc153a4 Fabric: Temporary workaround to enable commands in Fabric
Summary: This is a temporary workaround that we need only temporary and will get rid of soon.

Reviewed By: mdvacca

Differential Revision: D15501203

fbshipit-source-id: cec4891b6a185ea9e39f50bfedf9e1dae8993b66
2019-05-24 19:16:31 -07:00
Michał Pierzchała 49d26eb0c4 cleanup RedBox message and stack output (#24662)
Summary:
Cleanup RedBox messages and stack traces. This PR consists of 2 changes (I'm good with splitting them up if you'd like):

- [general] filter out some of the internal callsites from the symbolicated stack (I thought about using monospace font for title with code frame, but it looks weird)
- [ios][android] strip ANSI characters (coming from colored Babel code frame) from the error message

I think it's ok to strip it inside native handlers so we can still have a colorful code frame in the terminal output.

**JS Code frame:**

|before|after|
|--|--|
|<img width="400" alt="Screenshot 2019-04-30 at 12 32 05" src="https://user-images.githubusercontent.com/5106466/56956590-ef678d80-6b44-11e9-9019-6801f050ab0d.png">|<img width="400" alt="Screenshot 2019-04-30 at 12 52 43" src="https://user-images.githubusercontent.com/5106466/56957302-f42d4100-6b46-11e9-869b-ea9c7ce5b90f.png">|

|before|after|
|--|--|
|![image](https://user-images.githubusercontent.com/5106466/56959472-c8618980-6b4d-11e9-84be-6261d8375f4a.png)|![image](https://user-images.githubusercontent.com/5106466/56959463-bc75c780-6b4d-11e9-9d8b-25ffe46c87cf.png)|

**Filtered stack traces:**

|before|after|
|--|--|
|<img width="50%" alt="Screenshot 2019-04-30 at 12 27 21" src="https://user-images.githubusercontent.com/5106466/56956641-0908d500-6b45-11e9-8cdc-8c2a34a071e5.png"><img width="50%" alt="Screenshot 2019-04-30 at 12 27 28" src="https://user-images.githubusercontent.com/5106466/56956642-0908d500-6b45-11e9-921c-fabfb8515cc0.png">|<img width="100%" alt="Screenshot 2019-04-30 at 12 26 55" src="https://user-images.githubusercontent.com/5106466/56956650-0efeb600-6b45-11e9-9f5f-f10dd69580d1.png">|

There's still a lot of places that are hard to read, but I think this is a good start towards more readable errors.

cc cpojer

[General][Changed] - Cleanup RedBox message and stack output
Pull Request resolved: https://github.com/facebook/react-native/pull/24662

Differential Revision: D15147571

Pulled By: cpojer

fbshipit-source-id: 1de4e521af988fa7fc709b6accd0ddd984388e72
2019-04-30 07:35:14 -07:00
James Treanor 31850df116 Fix nullability warnings in RCTExceptionsManager (#24467)
Summary:
There are a number of nullability warnings in `RCTExceptionsManager` when building React Native for iOS with Xcode 10.2. This resolves them without changing the existing behavior.

See the warnings here:

![image](https://user-images.githubusercontent.com/1773641/56201323-89551380-6038-11e9-9998-b6a8d3d28f36.png)

[iOS] [Fixed] - Fix nullability warnings in RCTExceptionsManager
Pull Request resolved: https://github.com/facebook/react-native/pull/24467

Differential Revision: D14973485

Pulled By: cpojer

fbshipit-source-id: 2fac9f067ac9418397c3913760a2403f9a2cc147
2019-04-17 08:36:14 -07:00
Spencer Ahrens b1f1c5375c avoid startup deadlock with dispatch_async's
Summary:
There are cases where native modules will try to reference other native modules during startup, which can causes a deadlock on `RCTModuleData::_instanceLock`.

My system was in a state where the deadlock would repro 100% so I could actually debug it a bit, but really this whole system is very fragile and needs to die in a fire.

I tried a recursive lock and it was not sufficient - there are definitely issues with multiple threads invoking at the same time and then calling `RCTUnsafeExecuteOnMainQueueSync`...

Reviewed By: fkgozali

Differential Revision: D14863583

fbshipit-source-id: 8c0d062353595a4ed3871aa9135950bc57983907
2019-04-12 12:25:10 -07:00
Ryan Donnelly 33b55cccca Calculate Correct Window Dimensions for iOS (#19932)
Summary:
Fixes: #16152

[iOS] [Fixed] - Pass back correct dimensions for application window in Dimensions module
Pull Request resolved: https://github.com/facebook/react-native/pull/19932

Reviewed By: cpojer

Differential Revision: D14312906

Pulled By: PeteTheHeat

fbshipit-source-id: aacb729c89862267465eefc3534c48d9d4b5d746
2019-04-10 14:25:14 -07:00
cojo 97c414ec8d Fire timers in the background via NSTimer (#23674)
Summary:
This PR is a follow-up to #21211 by request of hramos to incorporate some additional crash fixes / synchronization edge cases found in our production testing.  What follows is largely a copy of the original PR description from #21211 - see that PR for original discussion thread as well as context on why this replacement PR was needed.

This PR is a minimalistic change to RCTTiming that causes it to switch exclusively to NSTimer (i.e., the 'sleep timer') in order to continue triggering timers when the app has moved to the background.

Many people have expressed a desire for background timer support on iOS. (See #1282, #167, and #16493). In our app — a podcast/audio player — we use background timers to ensure that we never lose track of the user's playback position, should the app crash or be terminated by the OS.

The RCTTimer module uses a RN-managed CADisplayLink if the next requested timer is less than a second away; otherwise, it switches to an NSTimer (which is refers to as a 'sleep timer' in source). The RN-managed CADisplayLink is always disabled when the app goes to the background (and thus cannot be used); however, the NSTimer will still issue its callbacks in the background.

This PR adds a flag to track whether the app is in the background, and if so, all timers are routed through NSTimer until the app returns to the foreground. vishnevskiy at Discord opened a similar PR (#16493) that implements a drop-in for CADisplayLink which falls back to NSTimer, but I decided to incorporate the background-NSTimer logic directly into RCTTimer, since NSTimer is already in use.

It's worth noting that the background NSTimer may not fire as often as requested — it may give the appearance of lagging depending upon your app's priority in the background. For our audio app, NSTimer fires exactly on schedule if there's an open AVAudioSession and audio is playing; if audio is not playing, it fires about half as often as requested, which is still adequate for networking polling and other tasks.

It's worth noting that background timers only function as long as an app is actually running in the background. Apple offers a variety of Background Modes (which can be toggled in the Capabilities section of the target inspector in Xcode), and the app will need to be legitimately using one of these modes in order for this change to provide any value — otherwise it will be terminated within a couple of seconds of moving to the background.

The good thing about this change is that for apps that do perform essential computation in support of their Background Mode, they can now use `setTimeout` and `setInterval` without problem — whereas in the past, neither would ever trigger their callback until the app returns to the foreground.
Pull Request resolved: https://github.com/facebook/react-native/pull/23674

Differential Revision: D14621326

Pulled By: shergin

fbshipit-source-id: c76e060ad2c662c140d7d2f4fb5aaa7094032515
2019-03-26 12:24:37 -07:00
Estevão Lucas 40de0495b9 - add more iOS flags into AccessibilityInfo (#23913)
Summary:
As a follow-up to this other PR #23839, it adds support for other, iOS only, flags into `AccessibilityInfo`.

It adds these other 4 methods:
* `isBoldTextEnabled()`
* `isGrayscaleEnabled()`
* `isInvertColorsEnabled()`
* `isReduceTransparencyEnabled()`

P.S: Android implementation for those methods just return `false` (with `Promise.resolve(false)`)

And the corresponding event listeners:
* `boldTextChanged`
* `grayscaleChanged`,
* `invertColorsChanged`,
* `reduceTransparencyChanged`
Pull Request resolved: https://github.com/facebook/react-native/pull/23913

Differential Revision: D14482214

Pulled By: cpojer

fbshipit-source-id: b97725fd12706957d4dad880a97e6b0993738272
2019-03-15 11:34:20 -07:00
zhongwuzw af7efff955 Move Bridge RCTSurfacePresenterStub category implementation to .m file (#23888)
Summary:
Move implementation out from header file. Because it may have potential linker issue.
CC. sahrens

<img width="716" alt="image" src="https://user-images.githubusercontent.com/5061845/54267283-ea11ac00-45b3-11e9-8d0e-9ff20db98b01.png">

[iOS] [Fixed] - Move Bridge RCTSurfacePresenterStub category implementation to .m file
Pull Request resolved: https://github.com/facebook/react-native/pull/23888

Differential Revision: D14477611

Pulled By: cpojer

fbshipit-source-id: 660f3c27806252fc8f47430582818d37d42fd365
2019-03-15 11:22:53 -07:00
Peter Argany d0d8c8b651 Fix a race condition in UIManager NativeID which cause snapshot tests to crash
Summary:
D14323747 broke SSTs. This PR optimized implementation of nativeID. Instead of searching entire tree to find a view, it uses a map to cache views which have nativeID set. The map uses keys with format <nativeID-rootViewTag>. Finding the rootViewTag causes a race condition, due to [this syncing code](https://fburl.com/93vqzlbg). The SST runner attempts to read the map to find a [SST view](https://fburl.com/8zadz024) before that view is added to the map.

My fix is to change the key format to simply <nativeID>. Product code should not duplicate nativeID since it is used to uniquely identify react managed views from native. I'll comment on PR with this fix.

Reviewed By: shergin, mmmulani

Differential Revision: D14416262

fbshipit-source-id: 3b707f2ff4049ac83ac8861e3cda435224d973d8
2019-03-14 22:08:33 -07:00
ericlewis fc94ade11c Move RCTTest & takeSnapshot to RNTester (#23721)
Summary:
Part of: #23313.

This moves the `RCTTest` lib from `Libraries/RCTTest` to `RNTester/RCTTest`. This also removes `takeSnapshot` from React Native, and implements it as a standalone module in RNTester called `ScreenshotManager`.

[General] [Removed] - RCTTest & ReactNative.takeSnapshot
Pull Request resolved: https://github.com/facebook/react-native/pull/23721

Differential Revision: D14434796

Pulled By: PeteTheHeat

fbshipit-source-id: d6e103a0ea0b6702701cdb5ce8449163ca4628ce
2019-03-14 11:24:21 -07:00
Estevão Lucas 0090ab32c2 - Add support for "reduce motion" into AccessibilityInfo (#23839)
Summary:
This PR adds `isReduceMotionEnabled()` to `AccessibilityInfo` in other to add support for "reduce motion", exposing the Operational System's settings option. Additionally, it adds a new event, `reduceMotionChanged`, in order to listen for this flag's update.

With this feature, developers will be able to disable or reduce animations, _**something that will be required as soon as WCAG 2.1 draft got approved**._ See [WCAG 2.1 — 2.3.3 Animations from Interaction criteria](https://knowbility.org/blog/2018/WCAG21-233Animations/)

It's exposed by [`UIAccessibility`' isReduceMotionEnabled ](https://developer.apple.com/documentation/uikit/uiaccessibility/1615133-isreducemotionenabled
) on iOS and [Settings.Global.TRANSITION_ANIMATION_SCALE](https://developer.android.com/reference/android/provider/Settings.Global#TRANSITION_ANIMATION_SCALE) on Android.

Up until now, `AccessibilityInfo` only exposes screen reader flag. By adding this second accessibility option, it's a good opportunity to rename `fetch` method to an appropriate name, `isScreenReaderEnabled`, as well as rename `change` event to `screenReaderChanged`, which will make it clearer and more specific.

(In case it's approved, a follow-up PR could exposes [more iOS acessibility flags](https://developer.apple.com/documentation/uikit/uiaccessibility), such as `isShakeToUndoEnabled`, `isReduceTransparencyEnabled`, `isGrayscaleEnabled`, `isInvertColorsEnabled`)

(iOS code inspired by [phonegap-mobile-accessibility](https://github.com/phonegap/phonegap-mobile-accessibility). And Android by [Flutter](https://github.com/flutter/engine/blob/master/shell/platform/android/io/flutter/view/AccessibilityBridge.java
))
Pull Request resolved: https://github.com/facebook/react-native/pull/23839

Differential Revision: D14406227

Pulled By: hramos

fbshipit-source-id: adf43be84c488522bf1e29d862681220ad193883
2019-03-12 20:28:21 -07:00
Spencer Ahrens 544d9fb10b Use surface observer for Animated
Summary:
Right now we rely on the Paper UIManager to update animated node graphs - this hooks us into `RCTSurfacePresenter` in the same way so we are no longer reliant on Paper. Should also help with complex ordering corner cases with pre vs. post operations and restoring defaults when nodes are removed. More info:

https://github.com/facebook/react-native/pull/11819/files

Note that we don't have a way to differentiate animation nodes related to fabric views vs. paper views, so if paper and fabric are both rendering updates simultaneously it's possible they could get processed by the wrong callback. That should be very rare, rarely cause problems even if it does happen, and won't be a problem at all in a post-Paper world.

Reviewed By: shergin

Differential Revision: D14336760

fbshipit-source-id: 1c6a72fa67d5fedbaefb21cd4d7e5d75484f4fae
2019-03-07 17:39:00 -08:00
zhongwuzw b7b8836a7f Implement the nativeID functionality in a more efficient way (#23662)
Summary:
Implement TODO, implement the nativeID functionality in a more efficient way instead of searching the whole view tree.

[iOS] [Fixed] - Implement the nativeID functionality in a more efficient way
Pull Request resolved: https://github.com/facebook/react-native/pull/23662

Differential Revision: D14323747

Pulled By: shergin

fbshipit-source-id: 3d45dbf53ad2b6adb79b4331600d53b51ede76d4
2019-03-05 09:41:19 -08:00
Kevin Gozali 75f2da23c5 TM iOS: disable remote debugging toggle when TurboModule is active
Summary: TurboModule needs sync calls from JS to native, and that's not supported with the current Chrome debugger. Until we have proper solution, disable it to avoid confusion.

Reviewed By: PeteTheHeat

Differential Revision: D14286383

fbshipit-source-id: e93903bf8fdfc714960d0d58e3f3eb0442c811bd
2019-03-01 14:30:35 -08:00
zhongwuzw d2ac9a0698 Fixed deprecated declarations warning (#23625)
Summary:
Fixed deprecated declarations warning.
cc cpojer .

[iOS] [Fixed] - Fixed deprecated declarations warning
Pull Request resolved: https://github.com/facebook/react-native/pull/23625

Differential Revision: D14205929

Pulled By: cpojer

fbshipit-source-id: 5e46f7f598ab1080b93923dcc25c98e1cd4362cd
2019-02-24 19:38:58 -08:00
Eric Lewis 468ae234a6 Fix xcode warnings (#23565)
Summary:
As part of #22609, this fixes yet more warnings.
- Adding more __unused to params.
- Refactors `isPackagerRunning` to use NSURLSession.
- Turns off suspicious comma warnings

[iOS] [Fixed] - Xcode Warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23565

Differential Revision: D14161151

Pulled By: cpojer

fbshipit-source-id: 339874711eca718fc6151e84737ccc975225d736
2019-02-20 18:46:23 -08:00
Eric Lewis 19866aee3d Fix 50 xcode warnings (#23553)
Summary:
This PR reduces the number of warnings in React from 68 to 18. Mostly by marking unused variables. RNTester's warnings are more than halved.

[iOS] [Fixed] - Xcode warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/23553

Differential Revision: D14151339

Pulled By: hramos

fbshipit-source-id: 8255330bf910a69a4c03051d91d7b0de3fadf2d1
2019-02-20 10:17:26 -08:00
zhongwuzw f95876ba8c Remove android initialAppState fallback check (#23487)
Summary:
1. We expose the `initialAppState` for Android in #19935, so we can remove the fallback check for Android.
2. Rename `RCTCurrentAppBackgroundState` to `RCTCurrentAppState`, it's a private file function, so it's safe to rename, `RCTCurrentAppState` is more suitable because we actually get app state, not app background state.

[Android] [Enhancement] - Remove android `initialAppState` fallback check.
Pull Request resolved: https://github.com/facebook/react-native/pull/23487

Differential Revision: D14121293

Pulled By: cpojer

fbshipit-source-id: fec196cef2969fe6f6f1571f4ebcafcec26266a1
2019-02-17 15:32:13 -08:00
Kevin Gozali 24894ac795 FBiOS TM: make sure to lazily load view managers
Summary: The hacks we added for lazy viewmanagers don't really apply to TurboModule lookup system, so let's enable lazy lookup as needed only if TurboModule is enabled.

Reviewed By: PeteTheHeat

Differential Revision: D14116548

fbshipit-source-id: 701e963ef0593cd890198725f8cb6d0d29434cd9
2019-02-15 20:14:59 -08:00
zhongwuzw cbf65f2cf4 Enable edge antialiasing only for transforms with perspective (#19360)
Summary:
Enable edge antialiasing only for transforms with perspective

[iOS] [Added] - RCTViewManager: Enable edge antialiasing only for transforms with perspective.

Pull Request resolved: https://github.com/facebook/react-native/pull/19360

Reviewed By: cpojer

Differential Revision: D14088290

Pulled By: hramos

fbshipit-source-id: 2113c7a29efce5ca9990e2a79c69fc70bdf8a041
2019-02-15 10:09:07 -08:00
Ramanpreet Nara f37093319b Start using getConstants
Summary:
TurboModules depend on a getConstants method. Existing ObjectiveC modules do not have this method. Therefore, I moved the contents of `constantsToExport` to `getConstants` and then had `constantsToExports` call `getConstants`.

facebook
Since all NativeModules will eventually need to be migrated to the TurboModule system, I didn't restrict this to just the NativeModules in Marketplace.

```
const fs = require('fs');

if (process.argv.length < 3) {
    throw new Error('Expected a file containing a list of native modules as the third param');
}

function read(filename) {
    return fs.readFileSync(filename, 'utf8');
}

const nativeModuleFilenames = read(process.argv[2]).split('\n').filter(Boolean);

nativeModuleFilenames.forEach((fileName) => {
    if (fileName.endsWith('.h')) {
        return;
    }

    const absPath = `${process.env.HOME}/${fileName}`;
    const fileSource = read(absPath);

    if (/(\n|^)-\s*\((.+)\)getConstants/.test(fileSource)) {
        return;
    }

    const constantsToExportRegex = /(\n|^)-\s*\((.+)\)constantsToExport/;
    const result = constantsToExportRegex.exec(fileSource);

    if (result == null) {
        throw new Error(`Didn't find a constantsToExport function inside NativeModule ${fileName}`);
    }

    const returnType = result[2];

    const newFileSource = fileSource.replace(
        constantsToExportRegex,
        '$1- ($2)constantsToExport\n' +
        '{\n' +
        `  return ${returnType.includes('ModuleConstants') ? '($2)' : ''}[self getConstants];\n` +
        '}\n' +
        '\n' +
        '- ($2)getConstants'
    );

    fs.writeFileSync(absPath, newFileSource);
});
```

```
> xbgs -l ')constantsToExport'
```

Reviewed By: fkgozali

Differential Revision: D13951197

fbshipit-source-id: 394a319d42aff466c56a3d748e17c335307a8f47
2019-02-04 17:46:56 -08:00
nossbigg 05f35c296d Expose isLocalUserInfoKey to keyboard event notifications (#23245)
Summary:
Given two apps loaded side-by-side and when a `Keyboard` event is triggered, there is no way to ascertain which app triggered the keyboard event. This ambiguity can arise in slide over/split view scenarios.

This pull request exposes the `isLocalUserInfoKey` property of the native `UIKeyboard` iOS events to the `Keyboard` event listener; this property will return `true` for the app that triggered the keyboard event.

(Also, I threw in a couple of Keyboard.js tests just for fun 😅)

[iOS][Added] - Expose isLocalUserInfoKey to keyboard event notifications

1. Load two apps side-by-side, with the app on the left side subscribing to the keyboard events (and logging out the events as they happen)
1. Trigger a keyboard to appear with the left app. The logged keyboard event will contain the `isEventFromThisApp` property which will be true.
1. Dismiss the keyboard
1. Trigger a keyboard to appear with the right app. The left app will still log the keyboard event, but the event's `isEventFromThisApp` property will be false (because the left app didn't trigger the keyboard event)
Pull Request resolved: https://github.com/facebook/react-native/pull/23245

Differential Revision: D13928612

Pulled By: hramos

fbshipit-source-id: 6d74d2565e2af62328485fd9da86f15f9e2ccfab
2019-02-01 14:32:19 -08:00
zhongwuzw e4364faa3c Fixes alert view block first responder (#23240)
Summary:
Fixes #23076 , the reason is `blur()` is managed by `UIManager`, `UIManager` maintains all operations and execute them each `batchDidComplete`, which means every time `JS` finish callback native , but `Alert` module would call directly, this mess up the order of method call, for example like below, even `this.$input.blur()` is called before `Alert.alert()`, but in native side, `Alert.alert()` is called before `this.$input.blur()`.

```
        <TextInput style={{ borderWidth: 1 }} ref={$input => this.$input = $input} />
        <Button title="Show Alert" onPress={() => {
          // // `blur` works if using without `Alert`
          this.$input && this.$input.blur()
          // // `blur` is not working
          Alert.alert('show alert', 'desc', [
            { text: 'cancel', style: 'cancel' },
            { text: 'show', onPress: () => {
            }},
          ])
        }} />
```

[iOS] [Fixed] - Fixes alert view block first responder

After fix, example like below, `blur` can works.
```
import * as React from 'react';
import { TextInput, View, Alert, Button } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center' }}>
        <TextInput style={{ borderWidth: 1 }} ref={$input => this.$input = $input} />
        <Button title="Show Alert" onPress={() => {
          this.$input && this.$input.blur()
          Alert.alert('show alert', 'desc', [
            { text: 'cancel', style: 'cancel' },
            { text: 'show', onPress: () => {
            }},
          ])
        }} />
      </View>
    );
  }
}
```
Pull Request resolved: https://github.com/facebook/react-native/pull/23240

Differential Revision: D13915920

Pulled By: cpojer

fbshipit-source-id: fe1916fcb5913e2b8128d045a6364c5e3d39c516
2019-02-01 03:51:24 -08:00
Elliott Sprehn 27b4d21564 Always write the manifest in multiRemove (#18613)
Summary:
RCTAsyncLocalStorage did not write the manifest after removing a value that was larger than RCTInlineValueThreshold. This meant that the values would still be on disk as null in the manifest.json, and if the app didn't do anything to make the manifest get written out again the null values would persist in the AsyncStorage and be returned by getAllKeys. We need to always write out the manifest.json even if the value is in the overflow storage files.

Thank you for sending the PR! We appreciate you spending the time to work on these changes.
Help us understand your motivation by explaining why you decided to make this change.

Fixes #9196.

Not sure where the tests are for this?

none.

[IOS] [BUGFIX] [AsyncStorage] - Correctly remove keys of large values from AsyncStorage.

tadeuzagallo nicklockwood dannycochran
Pull Request resolved: https://github.com/facebook/react-native/pull/18613

Differential Revision: D13860820

Pulled By: cpojer

fbshipit-source-id: ced1cd40273140335cd9b1f29fc1c1881ab8cebd
2019-01-29 09:15:30 -08:00
Teddy Martin 7b8235a95a Expose AsyncLocalStorage get/set methods (#18454)
Summary:
Currently, if an app uses AsyncStorage on the JS side, there is no public interface to access stored data from the native side.

In our app, written in Swift, I have written a [helper](https://gist.github.com/ejmartin504/d501abe55c28450a0e52ac39aee7b0e6) that pulls out the data. I accomplished this by reverse-engineering the code in RCTAsyncLocalStorage.m. It would have been far easier had this code been exposed to native.

I made this change locally and tested out getting the data from Swift code. This worked like a charm:

```swift
let storage = RCTAsyncLocalStorage()
let cacheKey = "test"
storage.methodQueue?.async {
    self.storage.multiGet([cacheKey]) { values in
        print(values)
    }
}
```

[IOS ][ENHANCEMENT ][RCTAsyncLocalStorage.h] - Expose AsyncLocalStorage get/set methods to native code.

<!--
  **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

    CATEGORY
  [----------]      TYPE
  [ CLI      ] [-------------]    LOCATION
  [ DOCS     ] [ BREAKING    ] [-------------]
  [ GENERAL  ] [ BUGFIX      ] [ {Component} ]
  [ INTERNAL ] [ ENHANCEMENT ] [ {Filename}  ]
  [ IOS      ] [ FEATURE     ] [ {Directory} ]   |-----------|
  [ ANDROID  ] [ MINOR       ] [ {Framework} ] - | {Message} |
  [----------] [-------------] [-------------]   |-----------|

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Pull Request resolved: https://github.com/facebook/react-native/pull/18454

Differential Revision: D13860333

Pulled By: cpojer

fbshipit-source-id: b33ee5bf1ec65c8291bfcb76b0d6f0df39376a7e
2019-01-29 08:54:16 -08:00
Monte Thakkar 7fbccdea22 Updated RedBox screen (#22242)
Summary:
[Re: RedBox screen is a bit scary - Discussions and Proposals](https://github.com/react-native-community/discussions-and-proposals/issues/42)

Per hramos:
> The RedScreen was inspired by Ruby on Rails's error screen

> I do see the RedBox screen could be made less jarring while still successfully displaying all the information we need.

Hence jamonholmgren came up with the idea that only the header & footer of the RedBox screen could be red. This makes the content a bit more readable as well as makes the screen a little less intimidating.

Also frantic made the suggestion that since the bottom buttons are not as important, they don't need to stand out. Hence only the header of the RedBox screen which displays the error is made red.

Screenshots:
----------

<div style="flex-direction: row">
<img width="325" alt="orginal" src="https://user-images.githubusercontent.com/7840686/48322916-b4958b80-e5de-11e8-9276-33378d1b41c5.png">
<img width="320" alt="redbox_v2_ios" src="https://user-images.githubusercontent.com/7840686/48665300-cce32b80-ea60-11e8-8e8f-88f74bad30ca.png">

</div>

<div style="flex-direction: row">
<img width="300" alt="original_android" src="https://user-images.githubusercontent.com/7840686/48322958-d5f67780-e5de-11e8-891c-1b20bd00e67b.png">
<img width="300" alt="redbox_v2_android" src="https://user-images.githubusercontent.com/7840686/48665312-f13f0800-ea60-11e8-9fb6-47e03c809789.png">

</div>
Pull Request resolved: https://github.com/facebook/react-native/pull/22242

Reviewed By: hramos

Differential Revision: D13564287

Pulled By: cpojer

fbshipit-source-id: fcb6ba5e20d863f4b957d20f3787f5b7a365bfdb
2019-01-15 06:29:49 -08:00
Adam Comella 70826dbafc iOS: Support inline view truncation (#21456)
Summary:
If text is truncated and an inline view appears after the truncation point, the user should not see the inline view. Instead, we have a bug such that the inline view is always visible at the end of the visible text.

This commit fixes this by marking the inline view as hidden if it appears after the truncation point.

This appears to be a regression. React Native used to have logic similar to what this commit is adding: 1e2a924ba6/Libraries/Text/RCTShadowText.m (L186-L192)

**Before fix**

Inline view (blue square) is visible even though it appears after the truncation point:

![image](https://user-images.githubusercontent.com/199935/46382038-d3a71200-c65d-11e8-8179-2ce4aad8d010.png)

The full text being rendered was:

```
<Text numberOfLines={1}>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
  sed do eiusmod tempor incididunt ut labore et dolore magna
  <View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
</Text>
```

**After fix**

Inline view is properly truncated:

![image](https://user-images.githubusercontent.com/199935/46382067-fdf8cf80-c65d-11e8-84ea-e2b71c229dae.png)

**Test Plan**

Tested that the inline view is hidden if it appears after the truncation point when `numberOfLines` is 1 and 2. Similarly, verified that the inline view is visible if it appears before the truncation point.

**Release Notes**

[IOS] [BUGFIX] [Text] - Fix case where inline view is visible even though it should have been truncated

Adam Comella
Microsoft Corp.
Pull Request resolved: https://github.com/facebook/react-native/pull/21456

Differential Revision: D10182991

Pulled By: shergin

fbshipit-source-id: a5bddddb1bb8672b61d4feaa04013a92c8224155
2018-11-20 00:11:56 -08:00
Mehdi Mulani d7865ebde8 Add another guard to lazilyLoadView
Summary:
it's possible that moduleForName won't return anything, so we should return.

Created from Diffusion's 'Open in Editor' feature.

Reviewed By: spredolac

Differential Revision: D12963342

fbshipit-source-id: c059595a68bfcaa38221e05fb62d70cc29887ca7
2018-11-09 11:25:13 -08:00
Valentin Shergin d6236796b2 `Removing UIManager.measureViewsInRect()`
Summary:
It does not supported on Android and nobody uses it.
I could find only one use cases: Very old versin of `SectionList` library (4 years ago).

Reviewed By: sahrens

Differential Revision: D12972361

fbshipit-source-id: a5dfef5e877e996adec2d4941417b4a2e727cfb7
2018-11-08 22:22:46 -08:00