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

751 Коммитов

Автор SHA1 Сообщение Дата
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
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
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
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
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
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
Adlai Holler 4ac42d88ef Optimize font handling on iOS (#31764)
Summary:
Few issues I saw when profiling RNTester:
- Repeatedly calling `-lowercaseString` during `weightOfFont` causes a TON of extra memory traffic, for no reason.
- `NSCache` is thread-safe, so no need for a mutex.
- Using `stringWithFormat:` for the cache key is slow. Use `NSValue` to store the data directly instead.
- Calling `-fontDescriptor` in `isItalicFont` and `isCondensedFont` is overly expensive and unnecessary.
- `+fontNamesForFamilyName:` is insanely expensive. Wrap it in a cache.

Unscientific test on RNTester iPhone 11 Pro, memory & time. Before:
<img width="1656" alt="Screen Shot 2021-06-23 at 7 40 06 AM" src="https://user-images.githubusercontent.com/2466893/123092882-f4f55100-d3f8-11eb-906f-d25086049a18.png">
<img width="1656" alt="Screen Shot 2021-06-23 at 7 41 30 AM" src="https://user-images.githubusercontent.com/2466893/123092886-f6267e00-d3f8-11eb-89f6-cfd2cae9f7b6.png">

After:
<img width="1455" alt="Screen Shot 2021-06-23 at 9 02 54 AM" src="https://user-images.githubusercontent.com/2466893/123101899-7d2c2400-d402-11eb-97f8-2ee97ee69ec4.png">
<img width="1455" alt="Screen Shot 2021-06-23 at 8 59 44 AM" src="https://user-images.githubusercontent.com/2466893/123101892-7bfaf700-d402-11eb-9a10-def46b37b87f.png">

Changelog:
[iOS][Changed] - Optimized font handling

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

Reviewed By: appden

Differential Revision: D30241725

Pulled By: yungsters

fbshipit-source-id: 342e4f6e5492926acd2afc7d645e6878846369fc
2021-08-26 22:47:41 -07:00
Jimmy Zhang 1a42bd6e97 Add UIAccessibilityTraitUpdatesFrequently to progressBar role
Summary:
Changelog:
Add UIAccessibilityTraitUpdatesFrequently when the AccessibilityRole is set to progressBar. This trait tells the accessibility system where content may change with every percentage point, but without annoying the user with constant announcements.

Reviewed By: ikenwoo

Differential Revision: D30510587

fbshipit-source-id: e75690a2a56ce42476dc999383cf58c0811fcbdf
2021-08-25 05:10:27 -07:00
Jimmy Zhang 11f8d9c7cd Add support for the UIAccessibilityTraitsTabBar
Summary:
Changelog:
Add the capability to set tabbar accessibilityRole which maps to the iOS's UIAccessibilityTraitsTabBar

Reviewed By: yungsters

Differential Revision: D30490752

fbshipit-source-id: f7561a8932306e133d2f65a5ab40ba0be3899ec3
2021-08-24 02:31:17 -07:00
Nishan Bende c29ec46b0e fix#29319 - ios dismiss modal (#31500)
Summary:
This PR aims to resolve iOS can't dismiss Modal on swipe gesture.
https://github.com/facebook/react-native/issues/29319

When modal presentationStyle is pageSheet, iOS allows to dismiss the modal using swipe gesture. This PR adds support for that feature
## 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] [Added] - Support for onRequestClose for iOS Modal component.

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

Test Plan:
- If onRequestClose updates the visibility state, modal will be closed.

```
<Modal
    visible={visible}
    animationType="slide"
    presentationStyle="pageSheet"
    onRequestClose={dismiss}>
</Modal>
```

https://user-images.githubusercontent.com/23293248/117590263-36cd7f00-b14c-11eb-940c-86e700c0b8e7.mov

## Notes
- In this PR, only support for partial drag is added. i.e. user can't drag the modal up and down completely. I added full user dragging but reverted in this [commit](bb65b9a60d) to support controllable onRequestClose. If someone has any suggestion to have full draggable support + controllable onRequestClose, please let me know.

<!--

 the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->

Reviewed By: p-sun

Differential Revision: D30041625

Pulled By: sammy-SC

fbshipit-source-id: 9675da760bd5c070c4f0e1d30271c8af5c50b998
2021-08-16 11:25:57 -07:00
Jason Safaiyeh 48ba8df8f2 Resolve some XCode warnings (#31883)
Summary:
UIAccessibilityVoiceOverStatusChanged deprecated (iOS 11+) in favor for UIAccessibilityVoiceOverStatusDidChangeNotification ref: https://developer.apple.com/documentation/uikit/uiaccessibilityvoiceoverstatuschanged?language=objc

topLayoutGuide/bottomLayoutGuide deprecated (iOS 11+) in favor for safeAreaLayoutGuide ref: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621367-toplayoutguide

This block declaration is not a prototype warnings fixed by adding void to specify no parameters ref: https://stackoverflow.com/questions/47916585/objective-c-block-parameter-issue-this-block-declaration-is-not-a-prototype

## 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
-->

[Internal] [Fixed] - Resolved some deprecations

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

Test Plan: Tests should pass, no functionality should change.

Reviewed By: fkgozali

Differential Revision: D29822033

Pulled By: mdvacca

fbshipit-source-id: dec8d612885634aca090ac3372cd4c7bf8a197ee
2021-07-21 13:27:14 -07:00
Anas Khurshid 25a16123a6 Added Support for Entrance/exit from collection by Flatlist (#31630)
Summary:
Issue https://github.com/facebook/react-native/issues/30964 .When using a screen reader, flatlist does not announce entrance/ exit from the flat list.

## Changelog

[Android] [Changed] - Added support for accessibility role of "list" for flatlist and sectioned list

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

Test Plan: I have added accessibility role prop in flatlist and sectioned list in rntester app, that will announce entrance/ exit from flatlist and sectioned list.

Reviewed By: kacieb

Differential Revision: D29599351

Pulled By: blavalla

fbshipit-source-id: e16ec69a694780d12f15f88a1e6bb5d7d77ac15f
2021-07-09 19:25:36 -07:00
Luna Wei cddb97ad18 Remove Picker from OSS (#31772)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/31772

Changelog:[General][Removed] - Remove Picker iOS code

Reviewed By: p-sun

Differential Revision: D29124724

fbshipit-source-id: d3b3a409961cf04e2cd079a91986d30e3166dcda
2021-07-08 13:23:49 -07:00
Justin Huntington bc1e602e0c Add ScrollView.automaticallyAdjustsScrollIndicatorInsets prop (on iOS) (#29809)
Summary:
iOS 13 added a new property to `UIScrollView`: `automaticallyAdjustsScrollIndicatorInsets`, which is `YES` by default.  The property changes the meaning of the `scrollIndicatorInsets` property.  When `YES`, any such insets are **in addition to** whatever insets would be applied by the device's safe area.  When `NO`, the iOS <13 behavior is restored, which is for such insets to not account for safe area.

In other words, this effects ScrollViews that underlay the device's safe area (i.e. under the notch).  When `YES`, the OS "automatically" insets the scroll indicators, when `NO` it does not.

There are two problems with the default `YES` setting:

1. It means applying `scrollIndicatorInsets` to a `ScrollView` has a different effect on iOS 13 versus iOS 12.
2. It limits developers' control over `scrollIndicatorInsets`.  Since negative insets are not supported, if the insets the OS chooses are too large for your app, you cannot fix it.

Further explanation & sample code is available in issue https://github.com/facebook/react-native/issues/28140 .

This change sets the default for this property to `NO`, making the behavior consistent across iOS versions, and allowing developers full control.

## 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] - ScrollView scrollIndicatorInsets to not automatically add safe area on iOS13+

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

Test Plan:
Updated the RNTester example to explain what to expect. Also removed the `pageScreen` modal example for now as mentioned in my Github comment.

{F628636466}

Here are screenshots of the demo app (from the original bug) before (with safe area applied to insets) & after (without safe area applied to insets):

![before](https://user-images.githubusercontent.com/428831/91644197-ea03a700-ea07-11ea-9489-be27820930eb.png)

![after](https://user-images.githubusercontent.com/428831/91644200-eff98800-ea07-11ea-8788-daf1e783639d.png)

Reviewed By: p-sun

Differential Revision: D28229603

Pulled By: lunaleaps

fbshipit-source-id: 2e774ae150b1dc41680b8b7886c7ceac8808136a
2021-07-07 20:23:36 -07:00
Danilo Bürger c974cbff04 Allow PlatformColor to work with RCTView border colors (#29728)
Summary:
# See PR
https://github.com/facebook/react-native/pull/29728

# From PR Author
Using `PlatformColor` with border colors doesn't work currently when switching dark mode as the information is lost when converting to `CGColor`. This change keeps the border colors around as `UIColor` so switching to dark mode works.

```ts
<View
  style={{
    borderColor: DynamicColorIOS({ dark: "yellow", light: "red" }),
    borderWidth: 1,
  }}
>
...
</View>
```
This view will start with a red border (assuming light mode when started), but will not change to a yellow border when switching to dark mode. With this PR, the border color will be correctly set to yellow.

## Changelog

[iOS] [Fixed] - Allow PlatformColor to work with border colors

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

Test Plan:
1. Assign a `PlatformColor` or `DynamicColorIOS` to a view border color.
2. Toggle between dark / light mode. See the colors change.

Reviewed By: lunaleaps

Differential Revision: D29268376

Pulled By: p-sun

fbshipit-source-id: 586545b05be0beb0e6e5ace6e3f74b304620ad94
2021-06-23 13:37:22 -07:00
Samuel Susla 925af8ddea Add collapsable to RCTViewManager as property
Summary:
Changelog: [internal]

collapsable was not passed to Fabric because view configs are built using Paper' ViewManagers.

Reviewed By: p-sun

Differential Revision: D27944688

fbshipit-source-id: 73a5646e25b3dd7a1a9dfc1079406047ab483d88
2021-05-25 12:52:34 -07:00
Kevin Gozali ab45509d75 iOS: adding a few warning/enforcement for the new architecture
Summary:
In the full bridgeless, the following aren't allowed:
* using legacy view manager interop layer (won't support long term, but still needed today, so just warn)
* initializing any subclass of RCTViewManager (won't support long term, but still used by legacy interop layer)
* initializing RCTUIManager (fabric UIManager should be the only one used)

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D28111530

fbshipit-source-id: 4f5eab600c6c7896d51861545b7f878c25248e44
2021-05-03 21:31:19 -07:00
Kacie Bawiec da899c0cc4 Add support for Toggle Button accessibilityRole
Summary:
Changelog:
[General][Added] Add support for "togglebutton" accessibilityRole

# Context
The role for ToggleButton, which is needed on Android to implement toggle buttons correctly, is not currently supported.

# What does this diff do?
Adds support for accessibilityRole `"togglebutton"`.

On Android, this maps to class `"Android.widget.ToggleButton"`.

iOS does not have an equivalent trait for togglebutton, so I set it to be the same as setting `accessibilityRole="button"` for iOS.

# Caveats - checked vs selected
It seems to me like this role currently requires that you set `accessibilityState={{checked: true/false}}`. The behavior is strange when setting `selected` state, I think because on Android ToggleButtons are meant to use `checked` to indicate toggled on/off.

This is tricky because typically on iOS if you have a toggle button, you would use `selected` instead of `checked`, so RN users are likely to mess this up.

Possible solutions:
1. document that you should use `checked` state on Android for toggle buttons (and maybe throw a warning if someone passes in `selected`).
2. have RN ignore it if someone passes in accessibilityState `selected`, if this role is used.
3. Have RN convert passed in `selected` state to `checked` on the Android side.

Reviewed By: nadiia

Differential Revision: D27976046

fbshipit-source-id: 4ce202449cf2371f4bf83c4db2d53120369ee7b0
2021-05-03 11:50:02 -07:00
Paige Sun 7bf78eae5e iOS: 5/7 Use visible prop to dismiss Modal for Paper
Summary:
Changelog: [iOS] Use visible prop to dismiss Modal on old renderer.

Visible prop is used on Fabric so that onDismiss can be passed with the the bridgeless per-component event emitter, rather than the bridge global event emitter. The old renderer still uses the global event emitter.

I needed to use the visible prop for Paper too because in diff 6/7, Modal.js [no longer uses visible prop to return null](dc80b2dcb5/Libraries/Modal/Modal.js (L221-L222)), and Modal.js can't distinguish on whether it's a Fabric or Paper component.

Reviewed By: JoshuaGross

Differential Revision: D28137929

fbshipit-source-id: f6ede0019fbe498a10b822ff09fc135a9fff8ec0
2021-05-02 15:42:49 -07:00
Paige Sun 0932a0d775 iOS: 2/5 Remove use of bridge from Modal by dismissing with visible prop
Summary: Changelog: [Fabric][iOS][Fix] Remove use of bridge from Modal by dismissing Modal with visible prop

Reviewed By: sammy-SC

Differential Revision: D28074326

fbshipit-source-id: 0278bfb031db802b59429c553ac62d83838f4cc9
2021-05-02 15:42:49 -07:00
Paige Sun 3c17922c35 iOS: 1/7 Add missing onDismiss prop in Modal component
Summary:
Changelog: [Internal]

Static ViewConfigs are not yet available in Fabric. ViewConfigs are generated from Paper view managers.

For a prop to pass through from JS to iOS, props in [RCTModalHostViewNativeComponent.js](dc80b2dcb5/Libraries/Modal/RCTModalHostViewNativeComponent.js) need to match RCT_EXPORT_VIEW_PROPERTY in RCTModalHostViewManager.m.

Reviewed By: sammy-SC

Differential Revision: D27977574

fbshipit-source-id: 9790d93500890a04ffc0fb4d2bcd2de5187f1fc0
2021-05-02 00:19:53 -07:00
Samuel Susla 84d55868e8 Fix DatePicker sizing issue
Summary:
Changelog: Fix possible sizing issue with DatePicker

Changing `preferredDatePickerStyle` changes size of the component without triggering re-layout of the react native screen. The fix is to make sure the size stays the same after changing the style.

Reviewed By: mdvacca

Differential Revision: D28035226

fbshipit-source-id: 2dcb50fd5ebaa0c0d01d3289c4ffa77a053cfc4a
2021-04-28 13:48:28 -07:00
Andy Chou 266b21baf3 Update height for different UIDatePickerStyles
Summary:
Adding support for DatePickerStyles on iOS13.4+
Changelog:
[iOS][Added] - Expose UIDatePickerStyles as a prop for DatePickerIOS

Reviewed By: PeteTheHeat

Differential Revision: D27953279

fbshipit-source-id: a35adf245147467ecbacac3770b9c50836cea468
2021-04-22 22:27:22 -07:00
Andy Chou 2b62e19a78 iOS 14 Support new DatePicker styles
Summary:
Adding support for DatePickerStyles on iOS13.4+

Changelog:
[iOS][Added] - Expose UIDatePickerStyles as a prop for DatePickerIOS

Reviewed By: PeteTheHeat

Differential Revision: D27948608

fbshipit-source-id: fcc16c630148818d9db0c9eef8363f8592b13791
2021-04-22 22:27:22 -07:00
Peter Argany 679f38f1c5 Pass RCTEventDispatcher to RCTComponentData [6/n]
Summary:
Problem: `RCTComponentData` accesses event dispatcher via `_bridge.eventDispatcher` which won't work in bridgeless mode

Solution: Pass  `_eventDispatcher` through init

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27447532

fbshipit-source-id: 7e39b4f6a57d789df493590538248abb204036a3
2021-03-31 16:39:02 -07:00
Peter Argany 4efdf264d1 Introducing RCTWeakViewHolder [4/n]
Summary:
Problem: In paper, there is a handy API called `[uiManager viewForReactTag:]`. Fabric does not have this mapping. The Fabric interop layer still relies on this Paper mapping.

Solution: As a workaround, re-create this mapping in the Fabric interop layer. Therefore, whenever Fabric interop layer asks a paper view manager to create a view, store a weak reference to the view in a `NSMapTable`. NSMapTable allows us to customize the strong/weak relationship. I've added a comment explaining that `RCTWeakViewHolder` only needs to be used for this special circumstance.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27438899

fbshipit-source-id: 94663ef06479a8c863ce58b0f36d42109fa1c4f3
2021-03-31 16:39:02 -07:00
Peter Argany 491ca1d14e Create a bridgelessViewManager [2/n]
Summary:
Problem: In Paper rendering system, view managers are native modules that are created and retained by the bridge. Whenever rendering layer needs to create a view, it asks the bridge for the view manager. In bridgeless mode, these view managers are never created.

Solution: In bridgeless mode, let `RCTComponentData` create and retain a view manager. Having a 1:1 relationship of `RCTComponentData`:`ViewManager` is desirable, since their lifecycles should be similar. This implementation also maintains the lazy-instantiation behavior for bridgeless view managers.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D27375991

fbshipit-source-id: e76d966ba4b98972a49df1bc520b904fb2f4b3b5
2021-03-31 16:39:02 -07:00
Peter Argany daaa1b2c05 Remove code supporting legacy paper interop from Picker view manager
Summary:
Picker was migrated to Fabric in stack ending in D23663596 (8f45db3b9e). Therefore, Picker's paper view manager is never used in Fabric through LegacyInteropLayer. This diff deletes a codepath that was created to accommodate this interop layer.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D27245596

fbshipit-source-id: e574e4aedcfef0ae639cb2aa446e27d6db5e9b94
2021-03-23 10:59:32 -07:00
generatedunixname89002005325676 1c564c3a1f Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D27005870

fbshipit-source-id: 5d51d0e64ae3fb15d38f8a9f8479af1c86b18fa9
2021-03-12 04:00:19 -08:00
Stefan Wrobel 0afba0e90d Restore refresh spinner fix (#30978)
Summary:
Fixes https://github.com/facebook/react-native/issues/30912
Reverts https://github.com/facebook/react-native/issues/31024 which did not fix the issue

This fix was removed in https://github.com/facebook/react-native/issues/28236, however it caused bug https://github.com/facebook/react-native/issues/7976 to resurface, as reported in https://github.com/facebook/react-native/issues/30912

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

Test Plan:
This code had been present for quite some time before being removed in https://github.com/facebook/react-native/issues/28236

## Changelog

[Internal] [fixed] - regression with refresh control

Reviewed By: p-sun

Differential Revision: D26981600

Pulled By: PeteTheHeat

fbshipit-source-id: 2560e7dba1cfd6ed41d98f2c9ff4cd07a0e5fa24
2021-03-11 15:48:10 -08:00
David Biedenbach 310a6bcf4b Fix Issue 10718: Add iOS support for progressViewOffset (#30737)
Summary:
Fixes https://github.com/facebook/react-native/issues/10718, bringing `progressViewOffset` support to iOS.

Thanks to Taylor123 for the initial PR upon which this fix is based.

## Changelog

[iOS] [Fix] - `progressViewOffset` prop of `RefreshControl` and `VirtualizedList` now works on iOS

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

Test Plan:
Tested with quick-and-dirty sample app.

![progressViewOffset-iOS](https://user-images.githubusercontent.com/1563532/104526540-82fe1d80-55b7-11eb-9f99-e025bedf4874.gif)

## Documentation

The corresponding documentation update PR can be found [here](https://github.com/facebook/react-native-website/pull/2441).

Reviewed By: kacieb

Differential Revision: D26813977

Pulled By: sammy-SC

fbshipit-source-id: 45cc5a647d70e44a29c6391b7586cb41ca011bef
2021-03-11 10:27:25 -08:00
Samuel Susla 56e0309b78 Send onDismiss event when Modal is dismissed
Summary:
Changelog: [internal]

"onDismiss" event wasn't called in Fabric. This diff adds it.
Paper implementation of Modal uses `RCTEventEmitter` instead of callback to deliver the event. To align better with Paper, Fabric will follow this pattern.

Reviewed By: shergin

Differential Revision: D26911312

fbshipit-source-id: b0de619c5a02c3378d1f7ac3ce1b705bb5fb634d
2021-03-10 05:47:47 -08:00
Janic Duplessis e67811e7a6 Fix RefreshControl layout when removed from window (#31024)
Summary:
Since iOS 14 refresh control is sometimes visible when it shouldn't. It seems to happen when it is removed and added back to the window. This repros easily when using react-native-screens with react-navigation tabs. Inactive tabs are detached from the window to save resources.

Calling endRefreshing when refresh control is added to the window fixes the layout. It will also be called on first mount where it is not necessary, but should be a no-op and didn't cause any issues. I also decided to call it for all ios versions, although it is only needed on iOS 14+ to avoid forking behavior more.

## Changelog

[iOS] [Fixed] - Fix RefreshControl layout when removed from window

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

Test Plan:
Before:

https://user-images.githubusercontent.com/2677334/108666197-93ea5a80-74a4-11eb-839b-8a4916967bf8.mov

After:

https://user-images.githubusercontent.com/2677334/108666223-9ea4ef80-74a4-11eb-8489-4e5d257299c8.mov

Reviewed By: shergin

Differential Revision: D26590759

Pulled By: PeteTheHeat

fbshipit-source-id: b8c06068a24446b261cbeb88ff166289724031f1
2021-02-23 14:54:36 -08:00
Andres Suarez 0f4f917663 Apply clang-format update fixes
Reviewed By: igorsugak

Differential Revision: D25861683

fbshipit-source-id: 616afca13ae64c76421053ce49286035e0687e36
2021-01-09 22:11:00 -08:00
Mike a4526bcc3f fix: incorrect ScrollView offset on update (#30647)
Summary:
This pull request is to fix https://github.com/facebook/react-native/issues/30258.

After an investigation, I found out the scroll offset of the list seems to be calculated incorrectly due to a workaround in the source code.

Instead of fixing the `calculateOffsetForContentSize`, I chose to remove it, the reason why I do so is because this workaround is for fixing the offset when `contentSize` is set manually, but according to the source code, there is no interface for a react-native user to set the `contentSize` of ScrollView, it is just set to `GCSizeZero` and will never be changed ([ref](https://github.com/facebook/react-native/pull/30647/files#diff-cf6f991f585ebf4cfdd555fe474e1f9ce40c2e4f823fc3f42b549414639c8c30L304)).

Also I changed the function name from `updateContentOffsetIfNeeded` to  `updateContentSizeIfNeeded` according what the function is actually doing.

## 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] - Incorrect ScrollView offset on update

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

Test Plan:
1. Create a fresh new project named `testapp` using npx create-react-native-app
2. Apply example code to `testapp` from https://snack.expo.io/lokomass/flatlist
3. Run `testapp` on iOS emulator and reproduce the bug
4. Make changes to files in `testapp/node_modules/react-native/`
5. Rebuild `testapp` and run on iOS emulator again, the bug is no more exist
6. Apply changes from step 4 to react-native, make a pull request.

#### Screenshots

Before: The scroll offset is incorrect after children of FlatList has changed

https://user-images.githubusercontent.com/48589760/103155130-b54a0580-47d7-11eb-97af-bdfd3e728714.mov

After: No more incorrect scroll offset if children of FlatList has changed

https://user-images.githubusercontent.com/48589760/103155091-6ef4a680-47d7-11eb-89fa-6f708bfef1c9.mov

Reviewed By: sammy-SC

Differential Revision: D25732958

Pulled By: shergin

fbshipit-source-id: dac6eff15ac3bbfec502452ac14b3d49fee76c29
2021-01-05 11:06:30 -08:00
Koichi Nagaoka d85d5d2e19 Fix cannot working Modal's onDismiss. (#29882)
Summary:
Fixes: https://github.com/facebook/react-native/issues/29455

Modal's onDismiss is not called on iOS.
This issue occurred the commit bd2b7d6c03 and was fixed the commit 27a3248a3b.
However, the master and stable-0.63 branches do not have this modified commit applied to them.

## 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] - Modal's onDismiss prop will now be called successfully.

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

Test Plan:
Tested on iOS with this change:

1. Set function Modal's onDismiss prop.
1. Set Modal's visible props is true. (show Modal)
1. Set Modal's visible props is false. (close Modal)
1. The set function in onDismiss is called.

Reviewed By: shergin

Differential Revision: D24648412

Pulled By: hramos

fbshipit-source-id: acf28fef21420117c845d3aed97e47b5dd4e9390
2020-11-13 23:56:09 -08:00
Lulu Wu ea93151f21 Make RCTEventDispatcher TurboModule-compatible
Summary:
This diff ended up being a bit more complicated than I anticipated, since the source files in `ReactInternal` were depending on `RCTEventDispatcher`. I made the following changes:
1. Make `RCTEventDispatcher` a `protocol`, keep it in `ReactInternal`.
2. Rename the `RCTEventDispatcher` NativeModule to `RCTEventDispatcherModule`, make it conform to the `RCTEventEmitter` `protocol`, and move it to `CoreModules`.
3. Where necessary, replace categories of `RCTEventDispatcher` with functions.

Changelog:
[iOS][Added] - Make RCTEventDispatcher TurboModule-comaptible

Reviewed By: fkgozali

Differential Revision: D18439488

fbshipit-source-id: b3da15c29459fddf884519f33b0c3b8c036b5539
2020-10-14 02:40:10 -07:00
Samuel Susla 9a2a4ba579 Remove handling of view commands for Fabric
Summary:
Changelog: [internal]

This code was put in when we didn't have view commands implementation in Fabric. Now we do so let's get rid of it.

Reviewed By: JoshuaGross

Differential Revision: D24046269

fbshipit-source-id: d0f203bc09bf22f5307cb1844d14b295fe3550dd
2020-10-01 12:25:59 -07:00
generatedunixname89002005325676 da8b50cd33 Daily `arc lint --take CLANGFORMAT`
Reviewed By: zertosh

Differential Revision: D23986055

fbshipit-source-id: 7bfe9f06f236f8866e812db060edf3d089fe253c
2020-09-29 04:14:33 -07:00
simek 2160377574 remove most of tvOS remnants from the code (#29407)
Summary:
Refs: [0.62 release](https://reactnative.dev/blog/#moving-apple-tv-to-react-native-tvos), https://github.com/facebook/react-native/issues/28706, https://github.com/facebook/react-native/issues/28743, https://github.com/facebook/react-native/issues/29018

This PR removes most of the tvOS remnants in the code. Most of the changes are related to the tvOS platform removal from `.podspec` files, tvOS specific conditionals removal (Obj-C + JS) or tvOS CI/testing pipeline related code.

In addition to the changes listed above I have removed the deprecated `Platform.isTVOS` method. I'm not sure how `Platform.isTV` method is correlated with Android TV devices support which is technically not deprecated in the core so I left this method untouched for now.

## 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
-->

* **[Internal] [Removed]** - remove most of tvOS remnants from the code:
  * `TVEventHandler`, `TVTouchable`, `RCTTVView`, `RCTTVRemoteHandler` and `RCTTVNavigationEventEmitter`
* **[Internal] [Removed]** - remove `TARGET_TV_OS` flag and all the usages
* **[iOS] [Removed]** - remove deprecated `Platform.isTVOS` method
* **[iOS] [Removed]** - remove deprecated and TV related props from View:
  * `isTVSelectable`, `hasTVPreferredFocus` and `tvParallaxProperties`
* **[iOS] [Removed]** - remove `BackHandler` utility implementation

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

Test Plan: Local tests (and iOS CI run) do not yield any errors, but I'm not sure how the CI pipeline would react to those changes. That is the reason why this PR is being posted as Draft. Some tweaks and code adjustment could be required.

Reviewed By: PeteTheHeat

Differential Revision: D22619441

Pulled By: shergin

fbshipit-source-id: 9aaf3840c5e8bd469c2cfcfa7c5b441ef71b30b6
2020-09-28 21:26:41 -07:00
Martin Ortega 0a0d2c990d Make the Instagram app compile again
Summary:
Wrap iOS 14 SDK code in a `#if/#endif` so that the Instagram app compiles again

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23948336

fbshipit-source-id: 67e6ee48d1951ae405c12b4ad39cf8c9817df627
2020-09-28 12:36:04 -07:00
Peter Argany c015f485c2 Workaround for Date Picker in iOS14
Summary:
iOS14 has introduced new styles for date picker. The default new calendar style breaks the old spinner type style.

This is a workaround to keep the spinner style as a default, until the calendar style is properly supported. According to [this github comment](https://github.com/react-native-community/datetimepicker/issues/285) it works well.

This will fix DatePicker for both Fabric and Paper, since Fabric uses the interop layer to render it.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23935328

fbshipit-source-id: 1a7fadba274e0537f0ac4ced60e23e7c809d57dc
2020-09-25 11:43:49 -07:00
Jayme Deffenbaugh cb719a16cc Fix Xcode warnings in React-Core pod (#29622)
Summary:
With the upgrade to React Native 0.63, we started running into nullability warnings that were breaking our build. This PR fixes those nullability warnings as well as a few other warnings in React-Core.

## Changelog

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

[iOS] [Fixed] - Fix xcodebuild warnings in React-Core

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

Test Plan:
- Nullability annotations should only affect compilation, but even though RNTester compiles, I'm not fully convinced that this won't break projects downstream. It would be good to get another opinion on this.
- The change in `RCTAllocateRootViewTag` is the only real logic change in this PR. We throw an exception if the root view tag is not in the correct format, so this change seems safe after some basic manual testing in RNTester.

Reviewed By: shergin

Differential Revision: D23386678

Pulled By: appden

fbshipit-source-id: a74875195a4614c3248e8f968aa98602e3ee2de0
2020-09-09 12:48:09 -07:00
Mi-ZAZ 8933724d7d Update RCTModalHostViewManager.m (#29745)
Summary:
Fix a issue that RCTModalHostView can't be dismissed while being presented

Steps To Reproduce
A native modal presented view controller is being dismissed before the first screen shows.
A RCTModalHostView is presented when the first screen shows.
The RCTModalHostView will be dismissed after an asynchronous callback.
If the callback was called before the completion of the presenting animation, the RCTModalHostView will not be dismissed.

## Changelog

[iOS] [Fixed] - Fix that RCTModalHostView can't be dismissed while being presented

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

Reviewed By: shergin

Differential Revision: D23566487

Pulled By: sammy-SC

fbshipit-source-id: bd95f200b79fa75e2387e402091d58c0f538759c
2020-09-09 06:41:06 -07:00
Samuel Susla 00563575ba Fix native command dispatch from RCTLegacyViewManagerInteropComponentView
Summary:
Changelog: [Internal]

# Problem

In D22274782 (fb2b49d298) I removed integration between Paper and Fabric. However this integration was still used by `RCTLegacyViewManagerInteropComponentView` for view commands dispatch.

Fix is to use `[RCTUIManager viewForReactTag:viewTag]` instead of viewRegistry.

Reviewed By: shergin

Differential Revision: D23291567

fbshipit-source-id: 35c50716fd8b86ae25b1534e4d8aa688c8e6e129
2020-08-24 10:33:56 -07:00
Peter Argany fcb667059d Fix refresh control redbox
Summary: Changelog:[Internal]

Reviewed By: Vince0613

Differential Revision: D22989945

fbshipit-source-id: 735da1cf103b2465663ecb6abfd49e512aff9a1e
2020-08-06 17:31:47 -07:00
Yogev Ben David 1b0fb9bead iOS: Fix refreshControl layouting (#28236)
Summary:
In `react-native-navigation` we allow the usage of native iOS navigationBar **largeTitle** which cause the title to "jump" when pulling to refresh.
We found that the layout calculations of the refreshControl element mess up the system behaviour.

## Changelog

[iOS] [Fixed] - Fix refreshControl messes up navigationBar largeTitles

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

Test Plan:
### Before the fix:
![before](https://user-images.githubusercontent.com/10794586/75991307-f7c7ec00-5efe-11ea-8cd9-ab8c3fbe1dc1.gif)

### And after:
![after](https://user-images.githubusercontent.com/10794586/75990618-d9152580-5efd-11ea-8c72-5deb6d83a840.gif)

### How it looks like with react-native init app after the fix:
![ezgif com-video-to-gif (4)](https://user-images.githubusercontent.com/10794586/77253369-54970680-6c62-11ea-9ad6-3265e23044e6.gif)

Reviewed By: sammy-SC

Differential Revision: D22782680

Pulled By: PeteTheHeat

fbshipit-source-id: f86ccd0a6ad492312029a69b392cd525450fe594
2020-08-05 11:51:30 -07:00