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

3518 Коммитов

Автор SHA1 Сообщение Дата
Samuel Susla 1989ad3955 Attempt to fix a crash in Scheduler::uiManagerDidCloneShadowNode
Summary:
changelog: [internal]

Attempt at fixing a crash in `Scheduler::uiManagerDidCloneShadowNode` by setting delegate to nullptr explicitly.

I don't think this will make a difference because `scheduler_` is released at the end of `dealloc` but it is worth a shot. Maybe some complex interaction between Obj-C and C++ comes into play here.

In this diff I also removed `_animationDriver = nullptr` because dealloc will do that automatically.

Reviewed By: philIip

Differential Revision: D32720901

fbshipit-source-id: 227ced2331384c47e8d15a323ee8a621bbb3d179
2021-12-01 03:09:47 -08:00
Sota Ogo 0ff02f9a41 Add log function binding to Facebook App
Summary:
Adding the RCTLog binding to Facebook app. More context is in D30271863 (c317a709d5)

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D31299188

fbshipit-source-id: 5234242e2f82262f9d2538e6c689f4a3738f37bb
2021-11-29 14:42:10 -08:00
Samuel Susla 3ba237b663 Remove gating for subview clipping
Summary:
changelog: [internal]

Remove gating for subview clipping

Reviewed By: philIip

Differential Revision: D32594194

fbshipit-source-id: e35e698cc3303f289cdd44a7f34274ea046dfd81
2021-11-25 08:08:56 -08:00
Christoph Purrer 3fff164dfa RCTDisplayLink.m > Use autoreleasepool from CFRunLoopPerformBlock
Summary:
Changelog:
[iOS][Fixed] This is a quick speculative fix since we know `CFRunLoopPerformBlock` does not push/pop an autorelease pool.

Reviewed By: appden

Differential Revision: D32657298

fbshipit-source-id: 4641ad89baf7889ba4bf80e6e64e26de02818cb8
2021-11-24 16:57:43 -08:00
Phillip Pan b8f0e975b7 use NSInteger for NS_ENUM instead of NSUInteger
Summary:
as title

in practice, this doesn't make any difference, but this is to follow the apple recommendation and for us to have a more consistent codebase.

https://developer.apple.com/library/content/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html

>The NS_ENUM macro helps define both the name and type of the enumeration, in this case named UITableViewCellStyle of type NSInteger. The type for enumerations should be NSInteger.
>Like enumerations, the NS_OPTIONS macro defines both a name and a type. However, the type for options should usually be NSUInteger.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32641990

fbshipit-source-id: 56e4cd44cdefe54f61c90844665a685ee2d6ffad
2021-11-24 15:45:23 -08:00
Phillip Pan d4c1c5f686 clean up RCTBundleURLProvider
Summary:
a lot of unused code here, cleaning it up

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32640185

fbshipit-source-id: 2917b4e3ea9c08ccb520250de509f0253d5dae61
2021-11-24 15:35:28 -08:00
CodemodService FBSourceClangFormatLinterBot 52b78a0bb7 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D32638856

fbshipit-source-id: a362894018de2a2ce144e90363a7978d8e4da25b
2021-11-24 04:45:45 -08:00
Phillip Pan 749a9207b6 introduce RCTMockDef
Summary:
here's a way we can mock C apis - however i am not sure if the flag i'm using is correct

used in D31949237

Changelog:
[General][Added] - add macros to be able to stub C functions in tests

Reviewed By: RSNara

Differential Revision: D31949238

fbshipit-source-id: 0f18a65f810f1b855dbc844f11f5a304c1e5ecea
2021-11-23 22:33:54 -08:00
Paige Sun 160807d112 Add ReactMarker::LogTaggedMarkerBridgeless, to replace LogTaggedMarkerWithInstanceKey
Summary:
# Issue in iOS
Before this diff, [Venice would override](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/fbobjc/Apps/Internal/Venice/Core/RCTPerformanceLoggerUtils.mm?lines=52%2C57) the static function ReactMarker::LogTaggedMarker [created in CxxBridge](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/xplat/js/react-native-github/React/CxxBridge/RCTCxxBridge.mm?lines=179%2C183). This means that in mixed mode they would share the Bridgeless instance of RCTPerformanceLogger [owned by Venice-only RCTInstance](https://www.internalfb.com/code/fbsource/[08e6e7a37f9ac1d33e14fc14ed763c0f8716f73a]/fbobjc/Apps/Internal/Venice/Core/RCTInstance.mm?lines=65%2C73).

This is wrong because Bridge is supposed to use the instance of RCTPerformanceLogger [owned by RCTBridge](https://www.internalfb.com/code/fbsource/[73ab70b2d9e28569171b62f60e9f25744461d4d9]/xplat/js/react-native-github/React/Base/RCTBridge.m?lines=353).

# Fix iOS and refactor Android

1) Add LogTaggedMarkerBridgeless to use the bridgeless RCTPerformanceLogger.

2) Use LogTaggedMarkerBridgeless to replace logTaggedMarkerWithInstanceKey.
- Remove logTaggedMarkerWithInstanceKey because it always clear from the code that instanceKey is 0 for Bridge, and 1 for Bridgeless,
- iOS doesn't use instanceKey and keeps separate instances of FBReactBridgeStartupLogger, FBReactWildePerfLogger, and RCTPerformanceLogger instead. This is better than using instanceKey because they are all [deallocated when Bridgeless is invalidated](https://www.internalfb.com/code/fbsource/[ea436e5ea6ae4ebc5e206197c4900022be867135]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=1160%2C1167%2C1170).
- logTaggedMarkerWithInstanceKey is only called from Venice's ReactInstance.cpp so it's easy to remove.

Reviewed By: sshic

Differential Revision: D32588327

fbshipit-source-id: 3151a44c9796da88fef4459b9b56946861514435
2021-11-23 12:55:56 -08:00
Phillip Pan 31b64c2615 kill RCTFabricSurfaceHostingView
Summary:
after D32591685, no one is using this. delete

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D32591686

fbshipit-source-id: 11ffb8cbf0fef605b7aefa47347db3ccc6e7d7fe
2021-11-23 02:29:25 -08:00
Phillip Pan 437b06f397 hook up onScroll event to RCTTextInputComponentView
Summary:
fixing oncall issue: https://fb.workplace.com/groups/rn.support/permalink/7241260632589156/

in this diff, we hook up the event emitter onScroll event to the native text input view

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D32523146

fbshipit-source-id: d8035deacc8a511577a6fb892ac55c9e07b14392
2021-11-19 11:41:26 -08:00
Sota Ogo 85ce4ef4b6 use the third party provider in OSS
Summary:
This diff actually adds the usage of ThirdPartyFabricComponentsProvider. We cannot land this until we start using generate-artifacts.js at pod install time.

Changelog: [internal]

Reviewed By: hramos

Differential Revision: D32128889

fbshipit-source-id: 9af39d73c8b5fe3ff9d70190fd83f679914bfd27
2021-11-17 14:49:34 -08:00
Saad Najmi 70ddf46c8a Revert "Fix Deadlock in RCTi18nUtil (iOS) (#31032)" (#32574)
Summary:
This reverts commit fcead14b0e.

This should close https://github.com/facebook/react-native/issues/32509 . There was a bug where il8nManager.forceRTL() wouldn't work on app launch, and required an app restart. That was caused by an earlier change (https://github.com/facebook/react-native/pull/31032) which should not be necessary (the deadlock it was attempting to fix was actually caused by separate code).

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Fixed bug where forceRTL did not work on app launch

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

Test Plan: Simple revert back to previously working code.

Reviewed By: RSNara

Differential Revision: D32315034

Pulled By: GijsWeterings

fbshipit-source-id: dae6c1f0a2481e53f2f1e80f1ac083947681ef99
2021-11-15 08:08:11 -08:00
Nick Fujita 614e6025ab Fix RCTAlertController import when embed in existing iOS projects (#32457)
Summary:
Fixes a build error relating to RCTAlertController import when embedding react-native into existing iOS app. This PR resolves the issue detailed in https://github.com/facebook/react-native/issues/32356

## Changelog

Adjusts the import syntax which was added in:
f319ff321c (diff-56beca6ee071cdd162c269ce765ab12d5af8c8c0ca840bca1e9d1f59e9fab790)

Existing:
#import "RCTAlertController.h"

New:
#import <React/RCTAlertController.h>

[iOS] [Fix] - Fix RCTAlertController import build error when embedded in existing iOS projects

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

Test Plan:
Build this branch in existing iOS project using swift, and should not have the build error described in the issue above.

Would also like to have this fix cherry-pick'd to release 0.63 after merging.

Reviewed By: RSNara

Differential Revision: D31861814

Pulled By: charlesbdudley

fbshipit-source-id: e60f80c8ea982e400cbf6d9375037d4197bbb8a3
2021-11-11 15:30:50 -08:00
Sota Ogo 751708d779 Use dummy file for FBReactNativeSpecs.podspec so that it doesn't include any files even there are old files.
Summary:
FBReactNativeSpecs.podspec is currently only acting as a config for codegen. It should not include any sources. This would fix unintended build error related to FBReactNativeSpecs-generated file.

Changelog: [internal]

Reviewed By: philIip

Differential Revision: D32267102

fbshipit-source-id: 27b510198666dc26a890cd7a6f873a04a9df66ca
2021-11-11 14:15:57 -08:00
Liron Yahdav f249d21da0 Native changes for TextInput.setSelection method
Summary:
Native changes in preparation for adding a `setSelection` imperative method to `TextInput`.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D31590771

fbshipit-source-id: eed40d1c2803fec713f2008ab8053a2812249715
2021-11-11 13:35:46 -08:00
Phillip Pan f10741a946 replace contentInsetsForView: with RCTContentInsets()
Summary:
as title

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31949240

fbshipit-source-id: 2660a4b44fd2aad5cda52ec61e741e7b4e9eb442
2021-11-10 13:56:52 -08:00
Phillip Pan 83fab36b93 clean up unneeded imports in RCTView
Summary:
just cleaning up some unused stuff

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31949239

fbshipit-source-id: f6542a01a879cd9ee10903d99de32e6537aa573b
2021-11-10 12:01:07 -08:00
Phillip Pan 9fc3fc83ac introduce RCTViewUtils
Summary:
Changelog: [Internal]

in this diff, i convert the following method to a C function.
https://www.internalfb.com/code/fbsource/[c58818169205f1e0fa816968efdb4c3fac8333e9]/xplat/js/react-native-github/React/Views/RCTView.h?lines=43

besides for testing demonstration purposes later in the stack, C functions are a superior choice to static class methods because they incur less binary size cost (see section 4.3 of https://swolchok.github.io/objcperf/ if you're curious, and https://fb.workplace.com/groups/aexpixfn/posts/1909150855887748 for the impact of a conversion)

Reviewed By: RSNara

Differential Revision: D31949241

fbshipit-source-id: dd40871d48f1de168d360168c4dd60015145d7e3
2021-11-09 20:42:13 -08:00
Ken Tominaga 9b059b6709 Remove iOS 11 availability check (#32488)
Summary:
This pull request aims to remove iOS 11 availability check which is no longer needed.

The minimum iOS deployment target for React Native is iOS 11 but we still have iOS 11 version check like below.

```
if (available(iOS 11.0, *)) {
```

This is a continuation pull request of https://github.com/facebook/react-native/pull/32151

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Changed] - Remove iOS 11 availability check

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

Reviewed By: yungsters

Differential Revision: D32006312

Pulled By: ryancat

fbshipit-source-id: 0ee6579e433a15d3d220a52d2ccd6931b0513971
2021-11-03 09:06:06 -07:00
Sota Ogo f7e4c07c84 Move codegen output out of node_modules
Summary:
In this diff, it moves the codegen output location out of node_modules and to build/generated/ios folder.

A temp pod spec will be created so that those files will be included in the Xcode project.

Changelog: [Internal]

Reviewed By: hramos, cortinico

Differential Revision: D31809012

fbshipit-source-id: ba1c884c8024306ba0fd2102837b7dbebc6e18ac
2021-10-25 20:48:24 -07:00
CodemodService FBSourceClangFormatLinterBot 64711b0d98 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31891742

fbshipit-source-id: f6f6ad019e972de5acc8d04f0e8c8d9c9a2e3324
2021-10-25 04:08:21 -07:00
Andrew Rahn 72ea0e111f Hide the logbox window explicitly. New behavior in iOS SDK appears to… (#32435)
Summary:
Fixes  https://github.com/facebook/react-native/issues/32434: RCTLogBox window is orphaned, covering entire screen.

After this change, the logbox window once again is removed from the screen.

## Changelog

Some third-party SDKs may hold references to created UIWindow, UIViewController, or UIView objects. Doing so means that the current code's `hide` method that releases the reference to the UIWindow in LogBox will not cause the window to be dealloc'd, and thus instead it will remain on the screen. This change explicitly hides the LogBox window when the reference is released, so that even if some other SDK holds onto the window it will still be taken off the screen.

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - 32434

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

Test Plan:
1.     Use console.warn to generate a yellow warning message in log box.  Also install a third-party SDK that holds onto a reference to UIWindow -- for example the Facebook SDK, the Data Dog SDK, or any number of other SDKs that use `swizzling` to intercept calls like `viewDidAppear:`.
2.     click the log
3.     tap "dismiss"
4.     try to tap anywhere
5. Use Xcode view debugger to inspect the UI state

## Expected

The app still responds to the touch.
In Xcode, there is not an extra UIWindow covering the screen

Reviewed By: philIip

Differential Revision: D31794242

Pulled By: sshic

fbshipit-source-id: 28aa247b3ed3fd60b8e7c2ed7d0606cbf5c42408
2021-10-24 13:52:40 -07:00
Phillip Pan def7dd857d use new instead of alloc init
Summary:
i saw this a lot in the codebase, it's not optimal bc we're using two selectors when we only need one.

  fastmod --extensions m,mm '\[\[(.*) alloc] init]' '[${1} new]' --dir xplat/js/react-native-github/*

i manually updated the callsites that this codemod couldn't handle (e.g., where there were more than one of these instances in a single line)

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D31776561

fbshipit-source-id: 1b16da240e8a79b54da67383d548921b82b05a9f
2021-10-20 22:18:38 -07:00
Phillip Pan 6acb18ca5d do not return BOOL for start and stop methods
Summary:
Changelog: [Internal]

these are returning bools for some reason even though no one is using the returned value. changing them to return void

Reviewed By: RSNara

Differential Revision: D31594241

fbshipit-source-id: 04c115b573b74996eaf2fef631eedb12c6734ea8
2021-10-20 15:42:22 -07:00
Phillip Pan f1aabc5164 remove unnecessary public methods on RCTFabricSurface
Summary:
Changelog: [Internal]

`start` and `stop` are already part of `RCTSurfaceProtocol` which is a public protocol conformance, we don't need to add these to this header, it's just extra work for the compiler

Reviewed By: RSNara

Differential Revision: D31776005

fbshipit-source-id: d89ad4dbe35e1b67cfa750c6414c40f9b4fc7f24
2021-10-20 15:42:22 -07:00
Phillip Pan f3eb675d23 clean up RCTFabricSurface imports
Summary:
Changelog: [Internal]

making these imports a little more optimal & clean

Reviewed By: javache

Differential Revision: D31594240

fbshipit-source-id: 076610454a6f3c35ac58e97bd9f887b05b86f5bb
2021-10-15 16:15:37 -07:00
Xin Chen 55392f65a6 Fix issue with setting shadow node state data after scrolling programmatically
Summary:
This issue is found when investigating T101563978 with IOS platform. When animation is off, the x position measurement is off after `scrollToItem` is called.

The android fix is checked in at D31492685 (1a9e2d5d55). For IOS, the correct state data is updated only for animated cases, but not for instant scroll cases. This diff unified them.

Changelog
[IOS][Fixed] Fixed an edge case when scroll to item/index is called without animation, the offset position is not updated. This caused the measurement of the position to be wrong.

Reviewed By: sammy-SC

Differential Revision: D31564169

fbshipit-source-id: 89f47d8054afb03c2ace1d595163b160e5bb2036
2021-10-12 17:43:26 -07:00
Neil Dhar aae93553d0 Remove libstdc++ dependency (#32247)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32247

I don't think we need both libc++ and libstdc++.

allow-large-files

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30950943

fbshipit-source-id: d0669815ff59c3e9ac45954a4a11930d1bc3959f
2021-10-08 14:16:54 -07:00
Samuel Susla c99a0212a0 Fix failing assert in EventTarget
Summary:
changelog: [internal]

calling `setEnabled(true)` needs to have a matching `setEnabled(false)` in order for `eventTarget_` to be deallocated correctly.

Also, retaining `eventTarget_` longer, does not mean instanceHandle will be available later on.

Reviewed By: p-sun

Differential Revision: D31503119

fbshipit-source-id: 324e16fe0f6ad937ab2c38be9a536bdf14851172
2021-10-08 13:44:37 -07:00
Lulu Wu c901c43d11 Remove shared responsibility between LogBox and ExceptionsManager native module
Summary:
## Context
Right now we are using both LogBox and ExceptionsManager native module to report JS errors in ExceptionsManager.js, from below code we can tell they have some overlapping - when ```__DEV__ === true``` both could report the error.

https://www.internalfb.com/code/fbsource/[5fb44bc926de87e62e6e538082496f22017698eb]/xplat/js/react-native-github/Libraries/Core/ExceptionsManager.js?lines=109-141

## Changes
In this diff overlapping is removed: in ```ExceptionsManager.js``` LogBox will be responsible for showing the error with dialog when ```__DEV__ === true```, when it's prod we'll use ExceptionsManager native module to report the error. As a result LogBox and ExceptionsManager native module don't share responsibilities any more.

Changelog:
[General][Changed] - Remove shared responsibility between LogBox and ExceptionsManager native module

Reviewed By: philIip

Differential Revision: D30942433

fbshipit-source-id: 8fceaaa431e5a460c0ccd151fe9831dcccbcf237
2021-10-08 11:08:43 -07:00
Brent Kelly 25a2c608f7 Addressing various issues with the Appearance API (#28823) (#29106)
Summary:
This PR fixes a few issues with the Appearance API (as noted here https://github.com/facebook/react-native/issues/28823).

1. For the Appearance API to work correctly on Android you need to call `AppearanceModule.onConfigurationChanged` when the current Activity goes through a configuration change. This was being called in the RNTester app but not in `ReactActivity` so it meant the Appearance API wouldn't work for Android in newly generated RN projects (or ones upgraded to the latest version of RN).

2. The Appearance API wasn't working correctly for brownfield scenarios on Android. It's possible to force an app light or dark natively on Android by calling `AppCompatDelegate.setDefaultNightMode()`. The Appearance API wasn't picking up changes from this function because it was using the Application context instead of the current Activity context.

3. The Appearance API wasn't working correctly for brownfield scenarios on iOS. Just like on Android its possible to force an app light or dark natively by setting `window.overrideUserInterfaceStyle`. The Appearance API didn't work with this override because we were overwriting `_currentColorScheme` back to default as soon as we set it.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

### Fixed

https://github.com/facebook/react-native/issues/28823

* [Android] [Fixed] - Appearance API now works on Android
* [Android] [Fixed] - Appearance API now works correctly when calling `AppCompatDelegate.setDefaultNightMode()`
* [iOS] [Fixed] - Appearance API now works correctly when setting `window.overrideUserInterfaceStyle`

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

Test Plan: Ran RNTester on iOS and Android and verified the Appearance examples still worked [correctly.](url)

Reviewed By: hramos

Differential Revision: D31284331

Pulled By: sota000

fbshipit-source-id: 45bbe33983e506eb177d596d33ddf15f846708fd
2021-10-05 20:23:48 -07:00
CodemodService FBSourceClangFormatLinterBot 2372e7a008 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31362458

fbshipit-source-id: e26b6b5e1c99dd6adbd661240d6979160633c10b
2021-10-02 08:33:02 -07:00
Phillip Pan d8931e2f94 provide public hook to programatically turn on voiceover
Summary:
Changelog: [Internal]

https://fb.workplace.com/groups/rn.support/posts/6677051292343429

ax team is building a tool to extract information about the views for design reviewers, and RN has some AX information that is not working atm because of dependency on whether voiceover is on or not. so, this will give them the ability to programmatically set that field and hopefully be able to get accurate ax info

Reviewed By: ikenwoo

Differential Revision: D31010566

fbshipit-source-id: 4c8a33fce40266b270dd5994442c8472ca88f5dd
2021-10-01 21:17:07 -07:00
Sota Ogo 8595f3f22c Back out "Feature: ScrollView `automaticallyAdjustKeyboardInsets`"
Summary:
Original commit changeset: 9ccfb4b6d477 / D30015799 (6e903b07fa)

The diff caused a redbox/error in some products. Reverting now and will try it again.

Changelog: Backing out PR: 31402

Differential Revision: D31238961

fbshipit-source-id: b2ccd3d3ab9d7e764e41fb54d8a7e60882d1405f
2021-09-28 14:05:00 -07:00
Samuel Susla 8d0a2e7921 Stop subview clipping recursion at RCTScrollViewComponentView component
Summary:
changelog: [internal]

Prevent `RCTScrollViewComponentView`'s children from being clipped by stopping clipping recursion.

Reviewed By: fkgozali

Differential Revision: D31196948

fbshipit-source-id: 09548ade9cf993730784f544b565b9fde77a6ee4
2021-09-26 12:15:38 -07:00
Marc Rousavy 6e903b07fa Feature: ScrollView `automaticallyAdjustKeyboardInsets` (#31402)
Summary:
Currently, ScrollViews provide the prop `keyboardDismissMode` which lets you choose `"interactive"`. However when the keyboard is shown, it will be rendered above the ScrollView, potentially blocking content.

With the `automaticallyAdjustKeyboardInsets` prop the ScrollView will automatically adjust it's `contentInset`, `scrollIndicatorInsets` and `contentOffset` (scroll Y) props to push the content up so nothing gets blocked.

* The animation curve and duration of the Keyboard is exactly matched.
* The absolute position of the ScrollView is respected, so if the Keyboard only overlaps 10 pixels of the ScrollView, it will only get inset by 10 pixels.
* By respecting the absolute position on screen, this automatically makes it fully compatible with phones with notches (custom safe areas)
* By using the keyboard frame, this also works for different sized keyboards and even `<InputAccessoryView>`s
* This also supports `maintainVisibleContentPosition` and `autoscrollToTopThreshold`.
* I also fixed an issue with the `maintainVisibleContentPosition` (`autoscrollToTopThreshold`) prop(s), so they behave more reliably when `contentInset`s are applied. (This makes automatically scrolling to new items fully compatible with `automaticallyAdjustKeyboardInsets`)

## Changelog

* [iOS] [Added] - ScrollView: `automaticallyAdjustKeyboardInsets` prop: Automatically animate `contentInset`, `scrollIndicatorInsets` and `contentOffset` (scroll Y) to avoid the Keyboard. (respecting absolute position on screen and safe-areas)
* [iOS] [Fixed] - ScrollView: Respect `contentInset` when animating new items with `autoscrollToTopThreshold`, make `automaticallyAdjustKeyboardInsets` work with `autoscrollToTopThreshold` (includes vertical, vertical-inverted, horizontal and horizontal-inverted ScrollViews)

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

Test Plan:
<table>
<tr>
<th>Before</th>
<th>After</th>
</tr>
<tr>
<td>

https://user-images.githubusercontent.com/15199031/115708680-9700aa80-a370-11eb-8016-e75d81a92cd7.MP4

</td>

<td>

https://user-images.githubusercontent.com/15199031/115708699-9b2cc800-a370-11eb-976f-c4010cd96d55.MP4

</td>
</table>

### "Why not just use `<KeyboardAvoidingView>`?"

<table>
<tr>
<th>Before (with <code>&lt;KeyboardAvoidingView&gt;</code>)</th>
<th>After (with <code>automaticallyAdjustKeyboardInsets</code>)</th>
</tr>
<tr>
<td>

https://user-images.githubusercontent.com/15199031/115708749-abdd3e00-a370-11eb-8e09-a27ffaef12b8.MP4

</td>

<td>

https://user-images.githubusercontent.com/15199031/115708777-b3044c00-a370-11eb-9b7a-e040ccb3ef8c.MP4

</td>
</table>

> Also notice how the `<KeyboardAvoidingView>` does not match the animation curve of the Keyboard

### Usage

```jsx
export const ChatPage = ({
  flatListProps,
  textInputProps
}: Props): React.ReactElement => (
  <>
    <FlatList
      {...flatListProps}
      keyboardDismissMode="interactive"
      automaticallyAdjustContentInsets={false}
      contentInsetAdjustmentBehavior="never"
      maintainVisibleContentPosition={{ minIndexForVisible: 0, autoscrollToTopThreshold: 100 }}
      automaticallyAdjustKeyboardInsets={true}
    />
    <InputAccessoryView backgroundColor={colors.white}>
      <ChatInput {...textInputProps} />
    </InputAccessoryView>
  </>
);
```

## Related Issues

* Fixes https://github.com/facebook/react-native/issues/31394
* Fixes https://github.com/facebook/react-native/issues/13073

Reviewed By: yungsters

Differential Revision: D30015799

Pulled By: sota000

fbshipit-source-id: 9ccfb4b6d477da192a96db4cfa07c31a2d2cefcb
2021-09-24 18:46:00 -07:00
Joshua Gross 10fe09c456 Back out "Send unix timestamp for touch events instead of systemUptime"
Summary:
Original commit changeset: 2acd52ae5873

This original change was made in D26705430 (b08362ade5) and D26705429 (69feed518d). The intention was to change the timestamp definition to make touch telemetry easier, but this is (1) unnecessary and (2) causes other issues.

Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D31183734

fbshipit-source-id: 6af669bb5696896b43fa4508af1171446d62c6d6
2021-09-24 18:11:33 -07:00
Phillip Pan 99f706e5df introduce RCTComputeScreenScale
Summary:
Changelog: [Internal]

in this diff, we add a function that allows us to retrieve screen scale. enforcing thread safety will be dependent on the consumer to make sure it's used on main thread.

i'd like for this to be a more temporary solution, i think we should have a more scalable screen solution for consumers to handle the gambit of uiscreen use cases.

Reviewed By: sammy-SC

Differential Revision: D31163909

fbshipit-source-id: 78104e9ef982b47c60697461141afb4b06eede72
2021-09-24 16:59:29 -07:00
Phillip Pan c744528da1 fix inaccurate comment for RCTScreenSize()
Summary:
Changelog:
[iOS][changed] - fixed inaccurate comment

while looking around, i saw this comment for RCTScreenSize that says it's called on app start - i looked around and also put a breakpoint here, and this assumption doesn't seem accurate anymore. just updating the comment for clarity.

Reviewed By: sammy-SC

Differential Revision: D31136182

fbshipit-source-id: 5f02a1a9fd95e16495bb79b3645b5f4e3bc1d9c9
2021-09-24 16:59:29 -07:00
CodemodService FBSourceClangFormatLinterBot 1a1c3a6405 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D31138547

fbshipit-source-id: ba134ae7f057c918eaefdc6310f7663e187e9749
2021-09-23 07:54:31 -07:00
Muhammad Numan 01856633a1 feat: add cancelButtonTintColor props in ActionSheetIOS for change cancel button tint color (#31972)
Summary:
we need to change the text color of the cancel button in `ActionSheetIOS` but `tintColor` changes the all button text color except `destructiveButtonIndex`

so I have added `cancelButtonTintColor` prop to change only the text color of the cancel button

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Changed] - added `cancelButtonTintColor` prop for `ActionSheetIOS` to change only the text color of the cancel button

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

Test Plan:
With this PR you can change the cancel text button of `ActionSheetIOS` by this `cancelButtonTintColor` prop

| <img src="https://user-images.githubusercontent.com/36044436/128414537-c4454786-a5cf-49d2-8225-1ff26c9c5058.png"  /> | <img src="https://user-images.githubusercontent.com/36044436/128414549-74a21509-711e-48e0-baf1-3718beae1598.png"  /> | <img src="https://user-images.githubusercontent.com/36044436/128414559-4bee9d1a-ac9f-4cd2-b158-5c4c441158ec.png"  /> |
|-|-|-|

Reviewed By: lunaleaps

Differential Revision: D30878022

Pulled By: yungsters

fbshipit-source-id: c70204f9f2510c75d8e9bed4e0fba79f1c941a1f
2021-09-22 10:44:17 -07:00
Kudo Chien e2b5b6504c Propose to connect metro server programmatically (#31828)
Summary:
nowadays, we could only specify metro server by either dev settings or building time ip.txt.
this pr adds a new way to specify metro server programmatically which makes rn launcher or testing more feasible.

## Changelog

[Internal] [iOS] [Added] - Propose to connect metro server programmatically

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

Test Plan:
just exposing a public interface for RCTPackagerConnection without much code change.
test to call this interface success locally.

Reviewed By: sammy-SC

Differential Revision: D30878774

Pulled By: yungsters

fbshipit-source-id: 5f1d6a4835a983abde7e095d20153e4ba2146a61
2021-09-22 10:40:06 -07:00
Ken Tominaga 398595e074 Remove iOS 11 version check (#32151)
Summary:
This pull request aims to remove iOS 11 version check which is no longer needed.

The minimum iOS deployment target for React Native is `iOS 11` but we still have iOS 11 version check like below.

```
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
        if (available(iOS 11.0, *)) {
```

> React Native apps may target iOS 11.0 and Android 5.0 (API 21) or newer.

ref: https://github.com/facebook/react-native#-requirements

------

If there is a team motivation to remove the deprecated methods and classes before iOS 10, I can continue the work in this pull request or in the continuing pull requests.

We have deprecated warnings for these in the project.

- `UIUserNotificationSettings`
- `UILocalNotification`
- `topLayoutGuide` and `bottomLayoutGuide`
- `automaticallyAdjustsScrollViewInsets`

## Changelog

[iOS] [Changed] - Remove iOS 11 version check

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

Reviewed By: sammy-SC

Differential Revision: D30877917

Pulled By: yungsters

fbshipit-source-id: d903ea5d557beeb65ef87bfce572e4db3532b3c5
2021-09-22 10:37:09 -07:00
Samuel Susla 3d83ca0331 Ship initial max size on iOS
Summary:
changelog: [internal]

Ship initial max size on iOS

Reviewed By: fkgozali

Differential Revision: D30990650

fbshipit-source-id: cf8f202ee862145a6fa9f173c2073096f86015e3
2021-09-21 08:23:08 -07:00
Pieter De Baets 6025611bd0 Use real propsParserContext in LayoutAnimation
Summary: Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D31053819

fbshipit-source-id: 8ec21012500f3bfc7e8aea018b5ca72323da2d9e
2021-09-21 04:24:28 -07:00
Radek Pietruszewski c0e04460f5 Time out packager liveness check after 10s (#31367)
Summary:
`isPackagerRunning` check on iOS makes a http request to packager's /status endpoint to check if it's alive... The problem is if the packager can't be reached, but doesn't error out immediately. This can happen, for example, if running the app on device, and host computer's firewall doesn't allow a :8081 connection. In that case, the request will never succeed or fail until default timeout of 60s. It makes debugging the underlying issue quite unbearable. It's hard for me to imagine a legitimate packager connection that wouldn't respond in less than a second, so I propose a conservative timeout of 10s

## Changelog

[iOS] [Fixed] - Don't hang app for 60s if packager can't be reached

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

Test Plan: Checked my app in dev mode to see if packager connects properly.

Reviewed By: sammy-SC

Differential Revision: D30912047

Pulled By: charlesbdudley

fbshipit-source-id: 110743dc45b9cc7d30e49f79ce3b0d5986f7aebd
2021-09-20 13:29:27 -07:00
Ramanpreet Nara 564b944e56 Ensure RCTJSThread is initialized in Bridgeless mode
Summary:
## Context
When Venice is enabled app-wide, we won't be creating/initializing the bridge. This means that RCTBridge +(void)initialize; won't execute:

https://www.internalfb.com/code/fbsource/[d8b25a1907ee55baa21e02a69ecab0f7a9442b8e]/xplat/js/react-native-github/React/Base/RCTBridge.m?lines=167%2C171-180

## Problem
When RCTBridge initialize isn't executed, we won't initialize RCTJSThread to kCFNull. RCTJSThread will be nil.

NativeModules like RCTEventDispatcher use RCTJSThread to indicate that their methods must be executed on the JavaScript thread:

https://www.internalfb.com/code/fbsource/[44976912ae618619a394f063c4c942ef020b86e8]/xplat/js/react-native-github/React/CoreModules/RCTEventDispatcher.mm?lines=198-201

If RCTJSThread is nil, these NativeModules will fail to initialize w/ the TurboModule system:

https://www.internalfb.com/code/fbsource/[f6a04f529ac1354b2973bd3553d12aef28ff24f2][blame]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.mm?lines=584-589%2C595%2C599%2C610-618

How:
1. The TurboModuleManager will see that each of these NativeModules has a methodQueue getter (line 587 above).
2. It'll invoke that getter (line 588), and get a nil methodQueue out, when **that methodQueue should be kCFNull**.
3. Because the TurboModuleManager gets a nil method queue from the getter, !methodQueue will pass (line 595).
4. So, TurboModuleManager try to create and assign a method queue to these modules (line 611), which'll raise an error (line 613), because none of these modules synthesize the methodQueue (b/c they expose a getter to methodQueue instead).

## Changes
We need to initialize RCTJSThread to kCFNull in all cases, to prevent this breakage. So, I moved RCTJSThread into its own header: RCTJSThread.h. RCTJSThread.h exports a function that initializes the RCTJSThread constant: _RCTInitializeJSThreadConstantInternal. This function gets invoked inside RCTHost initialize, and RCTBridge initialize.

Created from CodeHub with https://fburl.com/edit-in-codehub

Changelog: [Internal]

Reviewed By: p-sun, mdvacca

Differential Revision: D30910515

fbshipit-source-id: 2dd9b0cfcda92c497bb497f12f9fb847da563f47
2021-09-19 16:23:53 -07:00
Samuel Susla 6c66cef8ec Show warning if TTRC flag may clipped
Summary: changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D31016886

fbshipit-source-id: 26b5b97382936141ae7ef69fb1701d9822df5e8c
2021-09-17 14:23:54 -07:00
Tim Yung 5683932862 RN: Fix NSInvalidArgumentException for Invalid Font Family Name
Summary:
We observed that in certain production scenarios, `[UIFont fontNamesForFamilyName:familyName]` returns `nil`.

This is problematic because we cannot insert `nil` (which is not an object type) into `NSCache`. Currently, this is causing `NSInvalidArgumentException` to be thrown.

This fix works around the problem by guarding against `nil`.

Changelog:
[iOS][Fixed] - Fix NSInvalidArgumentException for invalid font family names.

Reviewed By: fkgozali

Differential Revision: D31011394

fbshipit-source-id: a9eb9ce69efd832acca65787c665fcbb7b42a795
2021-09-16 23:23:33 -07:00