-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop manually manage viewControllers store, Iterate layout instead (#…
…4991) * Stop manually manage viewControllers store, Iterate layout instead * Update RNNCommandsHandlerTest.m
- Loading branch information
Showing
28 changed files
with
311 additions
and
433 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#import "ReactNativeNavigation.h" | ||
#import "RNNLayoutInfo.h" | ||
|
||
@interface RNNExternalComponentStore : NSObject | ||
|
||
- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback; | ||
- (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge; | ||
|
||
@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,26 @@ | ||
#import "RNNExternalComponentStore.h" | ||
|
||
@interface RNNExternalComponentStore () | ||
|
||
@end | ||
|
||
@implementation RNNExternalComponentStore { | ||
NSMutableDictionary* _externalComponentCreators; | ||
} | ||
|
||
-(instancetype)init { | ||
self = [super init]; | ||
_externalComponentCreators = [NSMutableDictionary new]; | ||
return self; | ||
} | ||
|
||
- (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback { | ||
[_externalComponentCreators setObject:[callback copy] forKey:name]; | ||
} | ||
|
||
- (UIViewController *)getExternalComponent:(RNNLayoutInfo *)layoutInfo bridge:(RCTBridge *)bridge { | ||
RNNExternalViewCreator creator = [_externalComponentCreators objectForKey:layoutInfo.name]; | ||
return creator(layoutInfo.props, bridge); | ||
} | ||
|
||
@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,9 @@ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface RNNLayoutManager : NSObject | ||
|
||
+ (UIViewController *)findComponentForId:(NSString *)componentId; | ||
|
||
@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 @@ | ||
|
||
#import "RNNLayoutManager.h" | ||
#import "RNNLayoutProtocol.h" | ||
#import "UIViewController+LayoutProtocol.h" | ||
|
||
@implementation RNNLayoutManager | ||
|
||
+ (UIViewController *)findComponentForId:(NSString *)componentId { | ||
for (UIWindow* window in UIApplication.sharedApplication.windows) { | ||
UIViewController* result = [self findChildComponentForParent:window.rootViewController ForId:componentId]; | ||
if (result) { | ||
return result; | ||
} | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
+ (UIViewController *)findChildComponentForParent:(UIViewController *)parentViewController ForId:(NSString *)componentId { | ||
if ([parentViewController.layoutInfo.componentId isEqualToString:componentId]) { | ||
return parentViewController; | ||
} | ||
|
||
if (parentViewController.presentedViewController) { | ||
if ([parentViewController.presentedViewController.layoutInfo.componentId isEqualToString:componentId]) { | ||
return parentViewController.presentedViewController; | ||
} | ||
|
||
UIViewController* modalResult = [self findChildComponentForParent:parentViewController.presentedViewController ForId:componentId]; | ||
if (modalResult) { | ||
return modalResult; | ||
} | ||
|
||
} | ||
|
||
for (UIViewController* childVC in parentViewController.childViewControllers) { | ||
UIViewController* result = [self findChildComponentForParent:childVC ForId:componentId]; | ||
if (result) { | ||
return result; | ||
} | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
|
||
@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
Oops, something went wrong.