Commit Graph

23 Commits

Author SHA1 Message Date
Oskar Kwaśniewski 28986a7599 fix(iOS): allow to interactively swipe down the modal (#51483)
Summary:
This PR allows to interactively close the modal using the swipe down gesture.

It fixes 5 year old issue: https://github.com/facebook/react-native/issues/29319

In short it removes `modalInPresentation` which according to the documentation causes: "UIKit ignores events outside the view controller’s bounds and **prevents the interactive dismissal of the view controller while it is onscreen.**".

It also adds another delegate event to call onRequestClose whenever modal is closed by gesture.

https://github.com/user-attachments/assets/8849ecba-f762-47ec-a28b-b41c1991a882

## Changelog:

[IOS] [ADDED] - Allow to interactively swipe down the modal.
Add allowSwipeDismissal prop.

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

Test Plan: Test if swiping down the modal calls onRequestClose

Reviewed By: rshest

Differential Revision: D75125438

Pulled By: javache

fbshipit-source-id: d4f2c8b59447680f405b725d0809573a937f97cf
2025-06-18 07:18:40 -07:00
Panos Vekris 50ca7e5730 manual annotations in preparation of natural inference rollout in react-native, tools, etc.
Summary:
The Flow team is improving the way Flow infers type for primitive literals. This diff prepares the codebase for the new behavior by adding type annotations, or annotations of the form `'abc' as const`.

Changelog: [internal]

Reviewed By: marcoww6

Differential Revision: D75188179

fbshipit-source-id: be50990f23f79cf2d8dae7576af5190218adcafe
2025-05-21 20:06:46 -07:00
Dawid Małecki ddcab831b1 Migrate already root exported deep imports in rn-tester. (#50958)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50958

In rn-tester package there are many react-native deep imports which will be deprecated in the future. It is a starter for migrating rn-tester to using root imports instead. Only deep imports that are already root exported are changed. This diff avoids using `CodegenTypes` as it causes build errors and will be resolved in next stages.

Besides import changes, `PointerEvent` type is now also exported from the root.

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D73656526

fbshipit-source-id: 5814a3d9c6a04b1236581dbbe291cd109e2c71c0
2025-04-28 07:24:46 -07:00
Samuel Susla 9f7b8457ec expose ref to <Modal />'s native component (#49859)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49859

changelog: [internal]

this will be used for testing purposes in Fantom.

This diff also cleans up `ModalInjection.js` which is unused.

Reviewed By: rubennorte

Differential Revision: D69883384

fbshipit-source-id: 4ff278ef174c95fd5a93f70519f14c5190a5ada5
2025-03-08 05:50:14 -08:00
Dawid Małecki 3f9e474d23 Align Flow to TS types in Modal (#49521)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/49521

Changelog:
[Internal] - Aligned types of the Modal between Flow and iOS

Reviewed By: huntie

Differential Revision: D69786560

fbshipit-source-id: 3bf0999db5ad57a1b9b9dd95f2b77c994fe3af6e
2025-02-19 09:12:45 -08:00
Mathieu Acthernoene 7a6c7a462a feat(android): Edge-to-edge Modal (navigationBarTranslucent prop) (#47254)
Summary:
The future of Android is [edge-to-edge](https://github.com/react-native-community/discussions-and-proposals/discussions/827) and to make the React Native developer experience seamless in this regard, the ecosystem needs to transition from “opaque system bars by default” to “edge-to-edge by default.”

Currently, there's no easy way to have edge-to-edge modals, as they are implemented using `Dialog` instances (a separate `Window`) and only provide a `statusBarTranslucent` prop.

I tried to implement it in [`react-native-edge-to-edge`](https://github.com/zoontek/react-native-edge-to-edge) by listening to the `topShow` `UIManager` event. But if it works well when there's a defined animation, we can see a quick jump when there's none, because there's too much delay before the event, and edge-to-edge cannot be applied quick enough to the dialog window.

### react-native-edge-to-edge implem with animation (no jump)

https://github.com/user-attachments/assets/4933a102-87a5-40e4-98d9-47f8c0817592

### react-native-edge-to-edge implem without animation (jump)

https://github.com/user-attachments/assets/e4675589-08fe-44fe-b9d8-0a6b3552b461

 ---

For this reason, and because listening to event feels a bit hacky, I think it will be better to go for a new prop directly on RN Modal component: `navigationBarTranslucent`

> [!NOTE]
> `navigationBarTranslucent` cannot be used without `statusBarTranslucent`, as setting both enable edge-to-edge, like [AndroidX would do](https://github.com/androidx/androidx/blob/androidx-main/activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt) and it would requires extra (and unecessary, given the direction Android is taking) work to find a way to keep the status bar opaque but the navigation bar transparent that work on Android 6 to 15+

### Additional infos

- Colors used for the buttons navigation bar in the PR are the default Android ones ([light](https://github.com/androidx/androidx/blob/androidx-main/activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt#L37) and [dark](https://github.com/androidx/androidx/blob/androidx-main/activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt#L42))
- Compared to the Google implementation, the light scrim is applied from `O_MR1` to `Q` (and not `O` to `Q`) as the [`android:windowLightNavigationBar`](https://developer.android.com/reference/android/R.attr#windowLightNavigationBar) style attribute is not available on `O` (it can only be applied programmatically on API 26).

## Changelog:

[ANDROID] [ADDED] - Add navigationBarTranslucent prop to Modal component

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

Test Plan:
Run the tester app, toggle `navigationBarTranslucent`:

https://github.com/user-attachments/assets/286d173b-35a5-4951-9105-f9f7562d6764

-----
did some additional testing with RNTester using different justification

|flex-start|flex-end|
|https://pxl.cl/5Rd20|https://pxl.cl/5Rd21|

Reviewed By: javache

Differential Revision: D65103501

Pulled By: alanleedev

fbshipit-source-id: ef6473ecd785976d3e26c77bbc212222ec96c9f2
2024-11-06 21:09:36 -08:00
Tim Yung c9ea05552f RN: Fix lint/sort-imports Errors (#47109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47109

Fixes the `lint/sort-imports` errors that are now surfaced after fixing the lint configuration.

For a couple files, I added lint suppressions instead because the unsorted import ordering is important due to interleaved calls with side effects.

Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D64569485

fbshipit-source-id: 26415d792e2b9efe08c05d1436f723faae549882
2024-10-18 04:07:02 -07:00
Peter Abbondanzo 09682b5109 Fix dark mode text (#46898)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46898

Replaces *many* `Text` component usages with `RNTesterText`: a thin wrapper around `Text` that applies color based on the color scheme chosen by the user. It makes text legible for dark mode across 41 different example files. This changes intentionally do not touch a few larger component sites that expand beyond RNTester, like `Animated` and `NewAppScreen`

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D64053464

fbshipit-source-id: 9516fef2afe1b364eb38e85e3a2dbb5c434e44db
2024-10-10 11:02:18 -07:00
Pieter De Baets a9551641b4 Cleanup Modal test code (#46603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46603

Was debugging this test for the mounting instruction changes, and found some opportunities to clean this up.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D63258342

fbshipit-source-id: f7e6be58474f112993232ce5859ccb160f050ae8
2024-09-24 05:34:01 -07:00
Alan Lee 7aeff18970 rename overlayColor to backdropColor in Modal (#46523)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46523

the name change [commit](https://github.com/facebook/react-native/pull/46322/commits/64ee5712f7aa9a3df84589146d00f81bac6d945c) was not properly imported from last diff for https://github.com/facebook/react-native/pull/46322/

redoing the name change: overlayColor -> backdropColor

Changelog:
[general][Fixed] - rename overlayColor prop in Modal to backdropColor

Reviewed By: christophpurrer

Differential Revision: D62760028

fbshipit-source-id: 92d6e8f002c92f4e13136542dce946434516988e
2024-09-16 16:11:55 -07:00
shubhamguptadream11 4e1d7015c1 feat: add overlayColor prop to modal component for customisable background overlay (#46322)
Summary:
Solves these issues:
- https://github.com/facebook/react-native/issues/18398
- https://github.com/facebook/react-native/issues/12478

Solves this proposal: https://github.com/react-native-community/discussions-and-proposals/discussions/774

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [ADDED] - added overlayColor prop to modal component for customisable background overlay

**Motivation:**
Currently, the React Native Modal component only allows the background to be set to either `transparent` or `white`. This limits the ability to dim the background or apply custom colors, which is essential for creating a more polished and user-friendly interface.

**Change Log:**

Modal Component Enhancements:

- Introduced a new optional prop `overlayColor` to the Modal component.
- Updated the background color logic to prioritize `overlayColor` when transparent is `false`.
- Ensured backward compatibility by defaulting to `white` when `overlayColor` is not provided.

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

Test Plan:
- Test the changes on both iOS and Android devices/emulators to ensure consistent behavior.
- Added example in **rn-tester** app

**Sample screenshot with custom overlayColor passed as 'red'.**

![simulator_screenshot_4F112217-7AD5-4030-8A18-6260AD32988A](https://github.com/user-attachments/assets/52f16ef2-874b-487c-908b-1aa2a1b8fafb)

Reviewed By: cipolleschi

Differential Revision: D62201559

Pulled By: alanleedev

fbshipit-source-id: e990d7f18f5edf61f0107026ea899c5f22d47bfd
2024-09-16 09:29:00 -07:00
Erica Klein a58ec074b6 Back out "Send Modal onDismiss event on iOS (Fabric) and Android" @bypass-github-export-checks
Summary:
~~Original commit changeset: f419164032c3

Original Phabricator Diff: D52445670

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D52932743

fbshipit-source-id: ea37270998213de0ae732477e0fb99b47aae7cd5
2024-01-20 05:57:48 -08:00
Bernhard Owen Josephus 314cfa8c91 Send Modal onDismiss event on iOS (Fabric) and Android (#42014)
Summary:
1. Modal onDismiss is not working on iOS (Fabric).
2. Modal onDismiss is currently only available on iOS. On Android, we don't have a way to know when exactly a modal is dismissed.

Currently, the onDismiss is emitted using a device event as a workaround to the RCTModalHostView unable to receive the component event as it's already unmounted when visible is false.

This PR removes the workaround and keeps RCTModalHostView mounted until the onDismiss event is emitted from the host and sends the onDismiss event on Android.

bypass-github-export-checks

## Changelog:
[ANDROID] [ADDED] - Added support for Modal onDismiss prop
[IOS] [FIXED] - Fix onDismiss is not working on Fabric
[General][Breaking] - The public API of Modal has changed. We don't have anymore a NativeModalManger turbomodule; RCTModalHostViewNtiveComponent's Prop does not require to pass an identifier anymore.

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

Test Plan:
1. Run rn-tester
2. Open the Modal example
3. The second example shows the counter for the show and dismiss count
4. Show and dismiss the modal and verify the count is incremented correctly

https://github.com/facebook/react-native/assets/50919443/108bfb26-c8f6-43b2-ac40-f0b46e48771b

Reviewed By: javache, sammy-SC

Differential Revision: D52445670

Pulled By: cipolleschi

fbshipit-source-id: f419164032c3bef67387200778b274299bf0659f
2024-01-16 09:31:34 -08:00
Moti Zilberman d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
Elżbieta Berger aa2a0c1115 New RNtester e2e tests (#39117)
Summary:
The motivation was to create more e2e tests that test other components in the RNTester app.
The list of components that have been tested is below:

| Component|Test is added|Platform|
| :---        |    :----:   |---: |
|DrawerLayoutAndroid|NO|Android|
|ActivityIndicator|YES|iOS & Android|
|Button|YES|iOS & Android|
|FlatList|YES|iOS & Android|
|Image|NO|iOS & Android|
|JSResponderHandler|YES|iOS & Android|
|InputAccessoryView|NO|iOS|
|KeyboardAvoidingView|YES|iOS & Android|
|Modal|YES|iOS & Android|
|New App Screen|YES|iOS & Android|
|Pressable|YES|iOS & Android|
|RefreshControl|YES|iOS & Android|
|ScrollView|NO|iOS & Android|
|ScrollViewSimpleExample|YES|iOS & Android|
|SafeAreaView|NO|iOS|
|ScrollViewAnimated|NO|iOS & Android|
|ScrollViewIndicatorInsets|NO|iOS|
|SectionList|NO|iOS & Android|
|StatusBar|NO|iOS & Android|
|SwipeableCard|NO|iOS & Android|
|Switch|NO|iOS & Android|
|Text|NO|iOS & Android|
|TextInput|NO|iOS & Android|
|Touchable* and onPress|NO|iOS & Android|
|TextInputs with key prop|NO|Android|
|TransparentHitTestExample|NO|iOS|
|View|NO|iOS & Android|
|New Architecture Examples|NO|iOS & Android|
|Performance Comparison Examples|NO|iOS & Android|

## Changelog:

[General] [Added] - Added next component tests for RNTester

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

Test Plan:
Follow Readme file.

## Test Result:

For iOS platform:<br>
![Screenshot 2023-08-22 at 18 08 28](https://github.com/facebook/react-native/assets/19895261/c9d0ef78-ae31-487f-aa53-4c299fefef6a)

For Android platform:<br>
![Screenshot 2023-08-22 at 18 13 47](https://github.com/facebook/react-native/assets/19895261/db661c95-1cf9-4e1a-b02f-4a6141313719)

Reviewed By: yungsters

Differential Revision: D48828525

Pulled By: cipolleschi

fbshipit-source-id: dfe7cc9871666a6b5c0704a207ca1eeb65f50114
2023-09-01 03:24:30 -07:00
Evan Charlton 04fb0122b2 feat(rn-tester): Improve the Modal tester (#38977)
Summary:
## Summary:

The modal tester in the sandbox was lacking a bit of functionality that the Modal component exposes -- especially on Android. This change revamps the Modal page to more-closely resemble the API documentation by exposing all of the options, and annotating which ones are reserved for the different platforms.

Additionally, this change puts the modal controls into the created modal itself. This allows the user to more-easily test what happens if the props change during the lifespan of the modal (related PR: https://github.com/facebook/react-native/issues/38947).

 ## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests -->

[INTERNAL] [CHANGED] - Revamp Modal tester in rn-tester

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

Test Plan:
| Control page | Modal (with `transparent=true` on Android) |
|:--:|:--:|
| ![image](https://github.com/facebook/react-native/assets/418560/ef49cb94-14d8-4ebe-ade5-699b8e67ba5c) | ![image](https://github.com/facebook/react-native/assets/418560/d4bb6ef5-7d8c-4d5f-b4d8-37b8d736b19a) |

Reviewed By: yungsters

Differential Revision: D48414351

Pulled By: NickGerleman

fbshipit-source-id: 54bece639f4c64132dfb21c54c91d46972f5a335
2023-08-17 23:58:28 -07:00
Pieter Vanderwerff 66c6a75650 Suppress missing annotations in xplat/js
Summary: Add annotations to function parameters required for Flow's Local Type Inference project. This codemod prepares the codebase to match Flow's new typechecking algorithm. The new algorithm will make Flow more reliable and predictable.

Reviewed By: bradzacher

Differential Revision: D37388949

fbshipit-source-id: cdcbc98035ce9b6994842005ea46df42de54f9b8
2022-06-23 16:54:29 -07:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Tim Yung 148c98ec80 RN: Resolve Outstanding ESLint Warnings
Summary:
Resolves outstanding ESLint warnings in React Native.

Changelog:
[Internal]

Reviewed By: lunaleaps

Differential Revision: D32291912

fbshipit-source-id: 61337d5a5a0e6ed55f732675e029f4b76d850af9
2021-11-09 21:46:21 -08:00
Tim Yung 77ecc7ede1 JS: Format with Prettier v2.4.1 [3/n]
Summary:
Changelog:
[General][Internal]

Reviewed By: zertosh

Differential Revision: D31883447

fbshipit-source-id: cbbf85e4bf935096d242336f41bf0cc5d6f92359
2021-11-02 22:14:16 -07:00
Paige Sun d3345f5720 JS: Fix "Modal | Basic" Test's Layout
Summary:
Fix the CSS on the main Modal test

Move the warning message for the "Transparent" switch to below the switch, since warnings messages are usually under the field they're warning.

Move Presentation Style to be before Transparent, since Transparent is a modifier of "overFullScreen" Presentation Style.

Reviewed By: lunaleaps

Differential Revision: D30323087

fbshipit-source-id: b13d6c958145096da95c9888181ff457b093fb49
2021-08-17 13:41:21 -07:00
Luna Wei fa3243ad33 Rename things in RNTester
Summary:
Changelog:
[Internal] - Rename some types and components in RNTester to support work for tertiary levels of navigation.

module = component | api
moduleExample = an example of a certain feature a module

Reviewed By: kacieb

Differential Revision: D29381875

fbshipit-source-id: c348bcbb73aaf95e85928bb14080a097e685cc78
2021-07-01 14:35:30 -07:00
Luna Wei b22a6d6e9d Remove Picker from Modal example
Summary: Changelog: [Internal] - Remove picker from Modal example in RNTester in prep for deprecating Picker from RN

Reviewed By: kacieb

Differential Revision: D29082452

fbshipit-source-id: 01ee5ae2d0978721f7229d824f23cfbccfaf2813
2021-06-14 21:54:16 -07:00