Skip to content

feat(iOS, ContainedModal): add ContainedModal and ContainedModalProvider related files on JS side#4171

Open
sgaczol wants to merge 17 commits into
mainfrom
@sgaczol/contained-modal-codegen
Open

feat(iOS, ContainedModal): add ContainedModal and ContainedModalProvider related files on JS side#4171
sgaczol wants to merge 17 commits into
mainfrom
@sgaczol/contained-modal-codegen

Conversation

@sgaczol

@sgaczol sgaczol commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR adds ContainedModal and ContainedModalProvider related files on JS side.

Closes https://github.com/software-mansion/react-native-screens-labs/issues/1358

Changes

  • added codegen files
  • added component and types - related files
  • update package.json

Before & after - visual documentation

N/A

Test plan

N/A

Checklist

  • Included code example that can be used to test this change.
  • For visual changes, included screenshots / GIFs / recordings documenting the change.
  • For API changes, updated relevant public types.
  • Ensured that CI passes

sgaczol added 5 commits June 8, 2026 12:28
such approach is temporary - implementing a custom shadow node will be handled in a separate pr
- ContainedModal.tsx
- ContainedModal.types.ts
- ContainedModalProvider.tsx
- ContainedModalProvider.types.ts
- index.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the JS/Fabric surface for a new Gamma iOS modal primitive (ContainedModal) and its hosting context (ContainedModalProvider) so it can be consumed from React code and registered for RN Codegen.

Changes:

  • Added two Fabric codegen native component definitions for RNSContainedModal and RNSContainedModalProvider (iOS-only).
  • Added JS components, props types, and a barrel export for the new contained-modal module.
  • Registered the new component view names in the package.json codegen components map.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/fabric/gamma/modals/contained-modal/ContainedModalProviderNativeComponent.ts Adds codegen binding for the provider native view (excluded on Android).
src/fabric/gamma/modals/contained-modal/ContainedModalNativeComponent.ts Adds codegen binding for the modal native view (excluded on Android) with isOpen.
src/components/gamma/modals/contained-modal/index.ts Exposes public exports for the new modal/provider module.
src/components/gamma/modals/contained-modal/ContainedModalProvider.types.ts Defines provider props as ViewProps.
src/components/gamma/modals/contained-modal/ContainedModalProvider.tsx JS wrapper around the provider native component.
src/components/gamma/modals/contained-modal/ContainedModal.types.ts Defines modal props, including required isOpen.
src/components/gamma/modals/contained-modal/ContainedModal.tsx JS wrapper around the modal native component + host styling.
package.json Registers RNSContainedModal* component view class names for codegen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
import React from 'react';
import ContainedModalProviderNativeComponent from '../../../../fabric/gamma/modals/contained-modal/ContainedModalProviderNativeComponent';
import { ContainedModalProviderProps } from './ContainedModalProvider.types';
Comment thread package.json Outdated
Comment on lines 239 to 244
"RNSContainedModal": {
"className": "RNSContainedModalComponentView"
},
"RNSContainedModalProvider": {
"className": "RNSContainedModalProviderComponentView"
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Comment thread src/fabric/gamma/modals/contained-modal/ContainedModalHostNativeComponent.ts Outdated
Comment on lines +8 to +13
export default codegenNativeComponent<NativeProps>(
'RNSContainedModalProvider',
{
excludedPlatforms: ['android'],
},
);
Comment thread src/components/gamma/modals/contained-modal/ContainedModal.tsx
Comment on lines +1 to +3
import React from 'react';
import ContainedModalProviderHostNativeComponent from '../../../../fabric/gamma/modals/contained-modal/ContainedModalProviderHostNativeComponent';
import type { ContainedModalProviderProps } from './ContainedModalProvider.types';

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread package.json
Comment on lines +239 to +241
"RNSContainedModalHost": {
"className": "RNSContainedModalHostComponentView"
},

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be handled in a separate PR

Comment thread package.json Outdated
Comment on lines 242 to 244
"RNSContainedModalHostProvider": {
"className": "RNSContainedModalProviderHostComponentView"
}
Comment thread src/components/gamma/modals/contained-modal/ContainedModal.types.ts Outdated

@t0maboro t0maboro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments, but overall looks good

Comment thread src/components/gamma/modals/contained-modal/ContainedModal.tsx
Comment on lines +19 to +20
width: 0,
height: 0,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just leaving note: dimensions might not be needed to define here in the future, maybe we can handle the logic similarly as in FormSheet with hitTest override + dedicated touch handler: https://github.com/software-mansion/react-native-screens/blob/main/ios/gamma/modals/form-sheet/RNSFormSheetHostComponentView.mm#L343-L348 - sth to keep in mind in a further development

Comment thread src/components/gamma/modals/contained-modal/ContainedModal.tsx
Comment thread src/components/gamma/modals/contained-modal/ContainedModal.types.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

@t0maboro t0maboro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last remark regarding the naming, rest is looking good

*
* @platform ios
*/
providerKey: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using providerKey on both sides. From a semantic perspective, using providerKey here feels a bit ambiguous. What do you think about being more explicit about roles of components by using containerId (or containerKey) on the Provider level, and targetContainerId/Key on the Modal level?

Having it defined this way should make the relationship much clearer. The Modal "points to" a specific destination.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay: 3628223


export interface NativeProps extends ViewProps {
isOpen?: CT.WithDefault<boolean, false>;
providerKey?: CT.WithDefault<string, ''>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same request as for public API types

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done: 3628223

@t0maboro

t0maboro commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Before merging, please ensure that this doesn't cause any runtime crashes, because native components haven't been defined yet.
If it might crash, this PR should be coordinated with PRs adding native implementation/stubs

@kkafar kkafar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed the code, only looked at the scope of this PR and I'm seconding @t0maboro here. Let's avoid landing this PR until we have at least mock, but complete implementation of the native component.

I don't require the native code to be added in this particular PR, but let's see it in stacked PR & then merge both PRs together in quick succession. Let's not introduce intermediate states onto the main. The idea behind a commit / PR is that is should be always self-contained.

@sgaczol sgaczol changed the title feat(iOS): add ContainedModal and ContainedModalProvider related files on JS side feat(iOS, ContainedModal): add ContainedModal and ContainedModalProvider related files on JS side Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants