-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the iOS app template to move setups to a helper class
Summary: Changelog: [internal] Move initital setups in AppDelegate to util classes. This will make it easy to apply the new architecture changes in the future. Reviewed By: cortinico Differential Revision: D33051517 fbshipit-source-id: 16e326b7816fae83df65450c545e7dce1a93b9d0
- Loading branch information
1 parent
24e07bc
commit 73a04d1
Showing
4 changed files
with
70 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <React/RCTBridge.h> | ||
#import <React/RCTRootView.h> | ||
|
||
@interface RCTAppSetupUtils : NSObject | ||
+ (void)prepareApp:(UIApplication *_Nonnull)application; | ||
+ (RCTRootView *_Nonnull)defaultRootViewWithBridge:(RCTBridge *_Nonnull)bridge | ||
moduleName:(NSString *_Nonnull)moduleName | ||
initialProperties:(nullable NSDictionary *)initialProperties; | ||
@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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "RCTAppSetupUtils.h" | ||
|
||
#ifdef FB_SONARKIT_ENABLED | ||
#import <FlipperKit/FlipperClient.h> | ||
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h> | ||
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h> | ||
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h> | ||
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h> | ||
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h> | ||
|
||
static void InitializeFlipper(UIApplication *application) | ||
{ | ||
FlipperClient *client = [FlipperClient sharedClient]; | ||
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; | ||
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application | ||
withDescriptorMapper:layoutDescriptorMapper]]; | ||
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; | ||
[client addPlugin:[FlipperKitReactPlugin new]]; | ||
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; | ||
[client start]; | ||
} | ||
#endif | ||
|
||
@implementation RCTAppSetupUtils | ||
|
||
+ (void)prepareApp:(UIApplication *)application | ||
{ | ||
#ifdef FB_SONARKIT_ENABLED | ||
InitializeFlipper(application); | ||
#endif | ||
} | ||
|
||
+ (RCTRootView *)defaultRootViewWithBridge:(RCTBridge *)bridge | ||
moduleName:(NSString *)moduleName | ||
initialProperties:(NSDictionary *)initialProperties | ||
{ | ||
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; | ||
} | ||
|
||
@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