forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wip] add module maps to some RN modules to allow for swift c++ imports feat: implement RCTReactController and RCTSwiftUIAppDelegate feat: introduce new method to RCTAppDelegate
- Loading branch information
1 parent
474980e
commit 2e08709
Showing
13 changed files
with
213 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/react-native/Libraries/AppDelegate/RCTReactViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import <React/RCTBridgeDelegate.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface RCTReactViewController : UIViewController | ||
|
||
@property (nonatomic, strong) NSString *_Nonnull moduleName; | ||
@property (nonatomic, strong) NSDictionary *_Nullable initialProps; | ||
|
||
- (instancetype _Nonnull)initWithModuleName:(NSString *_Nonnull)moduleName | ||
initProps:(NSDictionary *_Nullable)initProps; | ||
|
||
@end |
28 changes: 28 additions & 0 deletions
28
packages/react-native/Libraries/AppDelegate/RCTReactViewController.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#import "RCTReactViewController.h" | ||
#import <React/RCTUtils.h> | ||
|
||
#import "RCTAppDelegate.h" | ||
|
||
@implementation RCTReactViewController | ||
|
||
- (instancetype)initWithModuleName:(NSString *)moduleName initProps:(NSDictionary *)initProps { | ||
if (self = [super init]) { | ||
_moduleName = moduleName; | ||
_initialProps = initProps; | ||
} | ||
return self; | ||
} | ||
|
||
// TODO: Temporary solution for creating RCTRootView. This should be done through factory pattern, here: https://github.com/facebook/react-native/pull/42263 | ||
- (void)loadView { | ||
id<UIApplicationDelegate> appDelegate = RCTSharedApplication().delegate; | ||
if ([appDelegate respondsToSelector:@selector(viewWithModuleName:initialProperties:launchOptions:)]) { | ||
RCTAppDelegate *delegate = (RCTAppDelegate *)appDelegate; | ||
self.view = [delegate viewWithModuleName:_moduleName initialProperties:_initialProps launchOptions:@{}]; | ||
} else { | ||
[NSException raise:@"UIApplicationDelegate:viewWithModuleName:initialProperties:launchOptions: not implemented" | ||
format:@"Make sure you subclass RCTAppDelegate"]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.