Skip to content

Commit 2d547a3

Browse files
vonovakfacebook-github-bot
authored andcommitted
feat: RCTConvert to support UIModalPresentationStyle (facebook#43297)
Summary: Currently, the ability to convert JS values to `UIModalPresentationStyle` is not present directly on `RCTConvert`. In the RN code base itself, there's not a lot of need to do this type of conversion, but in community modules, presenting ViewControllers can be a fairly common scenario and it'd be nice to be able to use this conversion directly from `RCTConvert`, rather than from `RCTModalHostViewManager`, as it'd improve its "discoverability" and consistency. If someone relied on this, then it's technically speaking a breaking change but I'd say it's for the better, and searching `#import <React/RCTModalHostViewManager.h>` on github doesn't reveal a lot of results. ## Changelog: [IOS] [ADDED] - RCTConvert to support UIModalPresentationStyle For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: facebook#43297 Test Plan: Tested using RN Tester https://github.com/facebook/react-native/assets/1566403/6e62df86-dde3-47b0-b2e9-bb6b483cadf6 Reviewed By: fkgozali Differential Revision: D54635896 Pulled By: dmytrorykun fbshipit-source-id: c6747857830762cd0333c31c287954f3f10d4954
1 parent 9b1c486 commit 2d547a3

File tree

4 files changed

+12
-21
lines changed

4 files changed

+12
-21
lines changed

packages/react-native/React/Base/RCTConvert.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef NSURL RCTFileURL;
8080
+ (UIReturnKeyType)UIReturnKeyType:(id)json;
8181
+ (UIUserInterfaceStyle)UIUserInterfaceStyle:(id)json API_AVAILABLE(ios(12));
8282
+ (UIInterfaceOrientationMask)UIInterfaceOrientationMask:(NSString *)orientation;
83+
+ (UIModalPresentationStyle)UIModalPresentationStyle:(id)json;
8384

8485
#if !TARGET_OS_TV
8586
+ (UIDataDetectorTypes)UIDataDetectorTypes:(id)json;

packages/react-native/React/Base/RCTConvert.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,17 @@ + (UIKeyboardType)UIKeyboardType:(id)json RCT_DYNAMIC
510510
NSNotFound,
511511
unsignedIntegerValue)
512512

513+
RCT_ENUM_CONVERTER(
514+
UIModalPresentationStyle,
515+
(@{
516+
@"fullScreen" : @(UIModalPresentationFullScreen),
517+
@"pageSheet" : @(UIModalPresentationPageSheet),
518+
@"formSheet" : @(UIModalPresentationFormSheet),
519+
@"overFullScreen" : @(UIModalPresentationOverFullScreen),
520+
}),
521+
UIModalPresentationFullScreen,
522+
integerValue)
523+
513524
RCT_ENUM_CONVERTER(
514525
UIViewContentMode,
515526
(@{

packages/react-native/React/Views/RCTModalHostViewManager.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
#import <React/RCTInvalidating.h>
1010
#import <React/RCTViewManager.h>
1111

12-
@interface RCTConvert (RCTModalHostView)
13-
14-
+ (UIModalPresentationStyle)UIModalPresentationStyle:(id)json;
15-
16-
@end
17-
1812
typedef void (^RCTModalViewInteractionBlock)(
1913
UIViewController *reactViewController,
2014
UIViewController *viewController,

packages/react-native/React/Views/RCTModalHostViewManager.m

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@
1414
#import "RCTShadowView.h"
1515
#import "RCTUtils.h"
1616

17-
@implementation RCTConvert (RCTModalHostView)
18-
19-
RCT_ENUM_CONVERTER(
20-
UIModalPresentationStyle,
21-
(@{
22-
@"fullScreen" : @(UIModalPresentationFullScreen),
23-
@"pageSheet" : @(UIModalPresentationPageSheet),
24-
@"formSheet" : @(UIModalPresentationFormSheet),
25-
@"overFullScreen" : @(UIModalPresentationOverFullScreen),
26-
}),
27-
UIModalPresentationFullScreen,
28-
integerValue)
29-
30-
@end
31-
3217
@interface RCTModalHostShadowView : RCTShadowView
3318

3419
@end

0 commit comments

Comments
 (0)