Преглед изворни кода

Remove get current leaf, better options resolving (#4700)

* Remove currentLeaf

* Fix resolve options

* Remove irrelevant test

* Remove RNNRootViewController clear background color

* Fix title with subtitle options
Yogev Ben David пре 5 година
родитељ
комит
7e15d59bbc
No account linked to committer's email address

+ 4
- 4
lib/ios/RNNBasePresenter.m Прегледај датотеку

@@ -1,18 +1,18 @@
1 1
 #import "RNNBasePresenter.h"
2 2
 #import "UIViewController+RNNOptions.h"
3 3
 #import "RNNTabBarItemCreator.h"
4
-#import "RNNReactComponentManager.h"
4
+#import "RNNReactComponentRegistry.h"
5 5
 
6 6
 @interface RNNBasePresenter ()
7
-@property (nonatomic, strong) RNNReactComponentManager* componentManager;
7
+@property (nonatomic, strong) RNNReactComponentRegistry* componentRegistry;
8 8
 @end
9 9
 
10 10
 
11 11
 @implementation RNNBasePresenter
12 12
 
13
-- (instancetype)initWithComponentManager:(RNNReactComponentManager *)componentManager {
13
+- (instancetype)initWithcomponentRegistry:(RNNReactComponentRegistry *)componentRegistry {
14 14
 	self = [super init];
15
-	self.componentManager = componentManager;
15
+	self.componentRegistry = componentRegistry;
16 16
 	return self;
17 17
 }
18 18
 

+ 5
- 5
lib/ios/RNNBridgeManager.m Прегледај датотеку

@@ -8,13 +8,13 @@
8 8
 #import "RNNBridgeModule.h"
9 9
 #import "RNNRootViewCreator.h"
10 10
 #import "RNNReactRootViewCreator.h"
11
-#import "RNNReactComponentManager.h"
11
+#import "RNNReactComponentRegistry.h"
12 12
 
13 13
 @interface RNNBridgeManager() <RCTBridgeDelegate>
14 14
 
15 15
 @property (nonatomic, strong, readwrite) RCTBridge *bridge;
16 16
 @property (nonatomic, strong, readwrite) RNNStore *store;
17
-@property (nonatomic, strong, readwrite) RNNReactComponentManager *componentManager;
17
+@property (nonatomic, strong, readwrite) RNNReactComponentRegistry *componentRegistry;
18 18
 
19 19
 @end
20 20
 
@@ -79,8 +79,8 @@
79 79
 	RNNEventEmitter *eventEmitter = [[RNNEventEmitter alloc] init];
80 80
 
81 81
 	id<RNNRootViewCreator> rootViewCreator = [[RNNReactRootViewCreator alloc] initWithBridge:bridge];
82
-	_componentManager = [[RNNReactComponentManager alloc] initWithCreator:rootViewCreator];
83
-	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator eventEmitter:eventEmitter store:_store componentManager:_componentManager andBridge:bridge];
82
+	_componentRegistry = [[RNNReactComponentRegistry alloc] initWithCreator:rootViewCreator];
83
+	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator eventEmitter:eventEmitter store:_store componentRegistry:_componentRegistry andBridge:bridge];
84 84
 	
85 85
 	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory eventEmitter:eventEmitter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:[RNNOverlayManager new] mainWindow:_mainWindow];
86 86
 	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
@@ -92,7 +92,7 @@
92 92
 
93 93
 - (void)onJavaScriptWillLoad {
94 94
 	[_store clean];
95
-	[_componentManager clean];
95
+	[_componentRegistry clean];
96 96
 }
97 97
 
98 98
 - (void)onJavaScriptLoaded {

+ 3
- 3
lib/ios/RNNCommandsHandler.m Прегледај датотеку

@@ -141,7 +141,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
141 141
 			});
142 142
 		}
143 143
 	} else {
144
-		id animationDelegate = (newVc.resolveOptions.animations.push.hasCustomAnimation || newVc.getCurrentLeaf.isCustomTransitioned) ? newVc : nil;
144
+		id animationDelegate = (newVc.resolveOptions.animations.push.hasCustomAnimation || newVc.resolveOptions.customTransition.animations) ? newVc : nil;
145 145
 		[newVc renderTreeAndWait:([newVc.resolveOptions.animations.push.waitForRender getWithDefaultValue:NO] || animationDelegate) perform:^{
146 146
 			[_stackManager push:newVc onTop:fromVC animated:[newVc.resolveOptions.animations.push.enable getWithDefaultValue:YES] animationDelegate:animationDelegate completion:^{
147 147
 				[_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
@@ -234,7 +234,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
234 234
 	
235 235
 	UIViewController<RNNParentProtocol> *newVc = [_controllerFactory createLayout:layout];
236 236
 	
237
-	[newVc renderTreeAndWait:[newVc.getCurrentLeaf.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
237
+	[newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
238 238
 		[_modalManager showModal:newVc animated:[newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
239 239
 			[_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
240 240
 			completion(componentId);
@@ -285,7 +285,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
285 285
 	[self assertReady];
286 286
 	
287 287
 	UIViewController<RNNParentProtocol>* overlayVC = [_controllerFactory createLayout:layout];
288
-	[overlayVC renderTreeAndWait:[overlayVC.options.animations.showOverlay.waitForRender getWithDefaultValue:NO] perform:^{
288
+	[overlayVC renderTreeAndWait:NO perform:^{
289 289
 		UIWindow* overlayWindow = [[RNNOverlayWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
290 290
 		overlayWindow.rootViewController = overlayVC;
291 291
 		[_overlayManager showOverlayWindow:overlayWindow];

+ 2
- 2
lib/ios/RNNControllerFactory.h Прегледај датотеку

@@ -5,14 +5,14 @@
5 5
 #import "RNNStore.h"
6 6
 #import "RNNEventEmitter.h"
7 7
 #import "RNNParentProtocol.h"
8
-#import "RNNReactComponentManager.h"
8
+#import "RNNReactComponentRegistry.h"
9 9
 
10 10
 @interface RNNControllerFactory : NSObject
11 11
 
12 12
 -(instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator
13 13
 						  eventEmitter:(RNNEventEmitter*)eventEmitter
14 14
 								 store:(RNNStore *)store
15
-					  componentManager:(RNNReactComponentManager *)componentManager
15
+					  componentRegistry:(RNNReactComponentRegistry *)componentRegistry
16 16
 							 andBridge:(RCTBridge*)bridge;
17 17
 
18 18
 - (UIViewController<RNNParentProtocol> *)createLayout:(NSDictionary*)layout;

+ 5
- 5
lib/ios/RNNControllerFactory.m Прегледај датотеку

@@ -20,7 +20,7 @@
20 20
 	id<RNNRootViewCreator> _creator;
21 21
 	RNNStore *_store;
22 22
 	RCTBridge *_bridge;
23
-	RNNReactComponentManager* _componentManager;
23
+	RNNReactComponentRegistry* _componentRegistry;
24 24
 }
25 25
 
26 26
 # pragma mark public
@@ -29,7 +29,7 @@
29 29
 - (instancetype)initWithRootViewCreator:(id <RNNRootViewCreator>)creator
30 30
 						   eventEmitter:(RNNEventEmitter*)eventEmitter
31 31
 								  store:(RNNStore *)store
32
-					   componentManager:(RNNReactComponentManager *)componentManager
32
+					   componentRegistry:(RNNReactComponentRegistry *)componentRegistry
33 33
 							  andBridge:(RCTBridge *)bridge {
34 34
 	
35 35
 	self = [super init];
@@ -38,7 +38,7 @@
38 38
 	_eventEmitter = eventEmitter;
39 39
 	_bridge = bridge;
40 40
 	_store = store;
41
-	_componentManager = componentManager;
41
+	_componentRegistry = componentRegistry;
42 42
 	
43 43
 	return self;
44 44
 }
@@ -115,7 +115,7 @@
115 115
 - (UIViewController<RNNParentProtocol> *)createComponent:(RNNLayoutNode*)node {
116 116
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] initWithNode:node];
117 117
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:node.data[@"options"]];;
118
-	RNNViewControllerPresenter* presenter = [[RNNViewControllerPresenter alloc] initWithComponentManager:_componentManager];
118
+	RNNViewControllerPresenter* presenter = [[RNNViewControllerPresenter alloc] initWithcomponentRegistry:_componentRegistry];
119 119
 	
120 120
 	RNNRootViewController* component = [[RNNRootViewController alloc] initWithLayoutInfo:layoutInfo rootViewCreator:_creator eventEmitter:_eventEmitter presenter:presenter options:options defaultOptions:_defaultOptions];
121 121
 	
@@ -137,7 +137,7 @@
137 137
 
138 138
 
139 139
 - (UIViewController<RNNParentProtocol> *)createStack:(RNNLayoutNode*)node {
140
-	RNNNavigationControllerPresenter* presenter = [[RNNNavigationControllerPresenter alloc] initWithComponentManager:_componentManager];
140
+	RNNNavigationControllerPresenter* presenter = [[RNNNavigationControllerPresenter alloc] initWithcomponentRegistry:_componentRegistry];
141 141
 	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] initWithNode:node];
142 142
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:node.data[@"options"]];;
143 143
 	

+ 0
- 2
lib/ios/RNNLayoutProtocol.h Прегледај датотеку

@@ -17,8 +17,6 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
17 17
 
18 18
 - (UIViewController<RNNLayoutProtocol> *)getCurrentChild;
19 19
 
20
-- (UIViewController<RNNLeafProtocol, RNNLayoutProtocol> *)getCurrentLeaf;
21
-
22 20
 - (void)mergeOptions:(RNNNavigationOptions *)options;
23 21
 
24 22
 - (RNNNavigationOptions *)resolveOptions;

+ 1
- 1
lib/ios/RNNModalManager.m Прегледај датотеку

@@ -60,7 +60,7 @@
60 60
 
61 61
 -(void)removePendingNextModalIfOnTop:(RNNTransitionCompletionBlock)completion {
62 62
 	UIViewController<RNNParentProtocol> *modalToDismiss = [_pendingModalIdsToDismiss lastObject];
63
-	RNNNavigationOptions* options = modalToDismiss.getCurrentChild.resolveOptions;
63
+	RNNNavigationOptions* options = modalToDismiss.resolveOptions;
64 64
 
65 65
 	if(!modalToDismiss) {
66 66
 		return;

+ 2
- 2
lib/ios/RNNNavigationButtons.h Прегледај датотеку

@@ -2,11 +2,11 @@
2 2
 #import <UIKit/UIKit.h>
3 3
 #import "RNNButtonOptions.h"
4 4
 #import "RNNRootViewCreator.h"
5
-#import "RNNReactComponentManager.h"
5
+#import "RNNReactComponentRegistry.h"
6 6
 
7 7
 @interface RNNNavigationButtons : NSObject
8 8
 
9
--(instancetype)initWithViewController:(UIViewController*)viewController componentManager:(RNNReactComponentManager *)componentManager;
9
+-(instancetype)initWithViewController:(UIViewController*)viewController componentRegistry:(RNNReactComponentRegistry *)componentRegistry;
10 10
 
11 11
 -(void)applyLeftButtons:(NSArray*)leftButtons rightButtons:(NSArray*)rightButtons defaultLeftButtonStyle:(RNNButtonOptions *)defaultLeftButtonStyle defaultRightButtonStyle:(RNNButtonOptions *)defaultRightButtonStyle;
12 12
 

+ 4
- 4
lib/ios/RNNNavigationButtons.m Прегледај датотеку

@@ -11,16 +11,16 @@
11 11
 @property (weak, nonatomic) UIViewController<RNNLayoutProtocol>* viewController;
12 12
 @property (strong, nonatomic) RNNButtonOptions* defaultLeftButtonStyle;
13 13
 @property (strong, nonatomic) RNNButtonOptions* defaultRightButtonStyle;
14
-@property (strong, nonatomic) RNNReactComponentManager* componentManager;
14
+@property (strong, nonatomic) RNNReactComponentRegistry* componentRegistry;
15 15
 @end
16 16
 
17 17
 @implementation RNNNavigationButtons
18 18
 
19
--(instancetype)initWithViewController:(UIViewController<RNNLayoutProtocol>*)viewController componentManager:(id)componentManager {
19
+-(instancetype)initWithViewController:(UIViewController<RNNLayoutProtocol>*)viewController componentRegistry:(id)componentRegistry {
20 20
 	self = [super init];
21 21
 	
22 22
 	self.viewController = viewController;
23
-	self.componentManager = componentManager;
23
+	self.componentRegistry = componentRegistry;
24 24
 	
25 25
 	return self;
26 26
 }
@@ -101,7 +101,7 @@
101 101
 		componentOptions.componentId = [[Text alloc] initWithValue:component[@"componentId"]];
102 102
 		componentOptions.name = [[Text alloc] initWithValue:component[@"name"]];
103 103
 		
104
-		RNNReactView *view = [_componentManager createComponentIfNotExists:componentOptions parentComponentId:self.viewController.layoutInfo.componentId reactViewReadyBlock:nil];
104
+		RNNReactView *view = [_componentRegistry createComponentIfNotExists:componentOptions parentComponentId:self.viewController.layoutInfo.componentId reactViewReadyBlock:nil];
105 105
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withCustomView:view];
106 106
 	} else if (iconImage) {
107 107
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withIcon:iconImage];

+ 1
- 5
lib/ios/RNNNavigationController.m Прегледај датотеку

@@ -42,7 +42,7 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
42 42
 }
43 43
 
44 44
 - (RNNNavigationOptions *)resolveOptions {
45
-	return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
45
+	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
46 46
 }
47 47
 
48 48
 - (void)mergeOptions:(RNNNavigationOptions *)options {
@@ -118,10 +118,6 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
118 118
 	return ((UIViewController<RNNParentProtocol>*)self.topViewController);
119 119
 }
120 120
 
121
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
122
-	return [[self getCurrentChild] getCurrentLeaf];
123
-}
124
-
125 121
 - (UIViewController *)childViewControllerForStatusBarStyle {
126 122
 	return self.topViewController;
127 123
 }

+ 2
- 2
lib/ios/RNNNavigationControllerPresenter.h Прегледај датотеку

@@ -1,10 +1,10 @@
1 1
 #import "RNNBasePresenter.h"
2 2
 #import "RNNRootViewCreator.h"
3
-#import "RNNReactComponentManager.h"
3
+#import "RNNReactComponentRegistry.h"
4 4
 
5 5
 @interface RNNNavigationControllerPresenter : RNNBasePresenter
6 6
 
7
-- (instancetype)initWithComponentManager:(RNNReactComponentManager *)componentManager;
7
+- (instancetype)initWithcomponentRegistry:(RNNReactComponentRegistry *)componentRegistry;
8 8
 
9 9
 - (void)applyOptionsBeforePopping:(RNNNavigationOptions *)options;
10 10
 

+ 6
- 6
lib/ios/RNNNavigationControllerPresenter.m Прегледај датотеку

@@ -5,7 +5,7 @@
5 5
 #import "RNNCustomTitleView.h"
6 6
 
7 7
 @interface RNNNavigationControllerPresenter() {
8
-	RNNReactComponentManager* _componentManager;
8
+	RNNReactComponentRegistry* _componentRegistry;
9 9
 	UIView* _customTopBar;
10 10
 	UIView* _customTopBarBackground;
11 11
 }
@@ -13,9 +13,9 @@
13 13
 @end
14 14
 @implementation RNNNavigationControllerPresenter
15 15
 
16
-- (instancetype)initWithComponentManager:(RNNReactComponentManager *)componentManager {
16
+- (instancetype)initWithcomponentRegistry:(RNNReactComponentRegistry *)componentRegistry {
17 17
 	self = [super init];
18
-	_componentManager = componentManager;
18
+	_componentRegistry = componentRegistry;
19 19
 	return self;
20 20
 }
21 21
 
@@ -174,7 +174,7 @@
174 174
 		readyBlock = nil;
175 175
 	}
176 176
 	if (options.topBar.component.name.hasValue) {
177
-		RCTRootView *reactView = [_componentManager createComponentIfNotExists:options.topBar.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
177
+		RCTRootView *reactView = [_componentRegistry createComponentIfNotExists:options.topBar.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
178 178
 		
179 179
 		_customTopBar = [[RNNCustomTitleView alloc] initWithFrame:navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
180 180
 		reactView.backgroundColor = UIColor.clearColor;
@@ -195,7 +195,7 @@
195 195
 		readyBlock = nil;
196 196
 	}
197 197
 	if (options.topBar.background.component.name.hasValue) {
198
-		RCTRootView *reactView = [_componentManager createComponentIfNotExists:options.topBar.background.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
198
+		RCTRootView *reactView = [_componentRegistry createComponentIfNotExists:options.topBar.background.component parentComponentId:navigationController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
199 199
 		
200 200
 		_customTopBarBackground = [[RNNCustomTitleView alloc] initWithFrame:navigationController.navigationBar.bounds subView:reactView alignment:@"fill"];
201 201
 		[navigationController.navigationBar insertSubview:_customTopBarBackground atIndex:1];
@@ -209,7 +209,7 @@
209 209
 
210 210
 - (void)dealloc {
211 211
 	RNNNavigationController* navigationController = self.bindedViewController;
212
-	[_componentManager removeComponent:navigationController.layoutInfo.componentId];
212
+	[_componentRegistry removeComponent:navigationController.layoutInfo.componentId];
213 213
 }
214 214
 
215 215
 @end

+ 1
- 0
lib/ios/RNNOptions.h Прегледај датотеку

@@ -15,6 +15,7 @@
15 15
 
16 16
 - (RNNOptions *)overrideOptions:(RNNOptions *)otherOptions;
17 17
 - (RNNOptions *)mergeOptions:(RNNOptions *)otherOptions;
18
+- (RNNOptions *)mergeInOptions:(RNNOptions *)otherOptions;
18 19
 
19 20
 - (RNNOptions *)withDefault:(RNNOptions *)defaultOptions;
20 21
 

+ 8
- 0
lib/ios/RNNOptions.m Прегледај датотеку

@@ -34,6 +34,14 @@
34 34
 	return [self mergeOptions:otherOptions overrideOptions:NO];
35 35
 }
36 36
 
37
+- (RNNOptions *)mergeInOptions:(RNNOptions *)otherOptions {
38
+	if (!otherOptions) {
39
+		return self;
40
+	}
41
+	
42
+	return [otherOptions mergeOptions:self overrideOptions:NO];
43
+}
44
+
37 45
 - (RNNOptions *)withDefault:(RNNOptions *)defaultOptions {
38 46
 	RNNOptions* newOptions = [[[self class] alloc] initWithDict:@{}];
39 47
 	[newOptions mergeOptions:defaultOptions overrideOptions:YES];

lib/ios/RNNReactComponentManager.h → lib/ios/RNNReactComponentRegistry.h Прегледај датотеку

@@ -4,7 +4,7 @@
4 4
 #import "RNNStore.h"
5 5
 #import "RNNRootViewCreator.h"
6 6
 
7
-@interface RNNReactComponentManager : NSObject
7
+@interface RNNReactComponentRegistry : NSObject
8 8
 
9 9
 - (instancetype)initWithCreator:(id<RNNRootViewCreator>)creator;
10 10
 

lib/ios/RNNReactComponentManager.m → lib/ios/RNNReactComponentRegistry.m Прегледај датотеку

@@ -1,13 +1,13 @@
1
-#import "RNNReactComponentManager.h"
1
+#import "RNNReactComponentRegistry.h"
2 2
 
3
-@interface RNNReactComponentManager () {
3
+@interface RNNReactComponentRegistry () {
4 4
 	id<RNNRootViewCreator> _creator;
5 5
 	NSMutableDictionary* _componentStore;
6 6
 }
7 7
 
8 8
 @end
9 9
 
10
-@implementation RNNReactComponentManager
10
+@implementation RNNReactComponentRegistry
11 11
 
12 12
 - (instancetype)initWithCreator:(id<RNNRootViewCreator>)creator {
13 13
 	self = [super init];

+ 1
- 5
lib/ios/RNNRootViewController.m Прегледај датотеку

@@ -105,7 +105,7 @@
105 105
 			}
106 106
 		}];
107 107
 	}];
108
-	reactView.backgroundColor = [UIColor clearColor];
108
+
109 109
 	self.view = reactView;
110 110
 	
111 111
 	if (!wait && readyBlock) {
@@ -118,10 +118,6 @@
118 118
 	return self;
119 119
 }
120 120
 
121
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
122
-	return self;
123
-}
124
-
125 121
 -(void)updateSearchResultsForSearchController:(UISearchController *)searchController {
126 122
 	[self.eventEmitter sendOnSearchBarUpdated:self.layoutInfo.componentId
127 123
 										 text:searchController.searchBar.text

+ 1
- 5
lib/ios/RNNSideMenuChildVC.m Прегледај датотеку

@@ -40,7 +40,7 @@
40 40
 }
41 41
 
42 42
 - (RNNNavigationOptions *)resolveOptions {
43
-	return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
43
+	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
44 44
 }
45 45
 
46 46
 - (void)mergeOptions:(RNNNavigationOptions *)options {
@@ -74,10 +74,6 @@
74 74
 	return self.child;
75 75
 }
76 76
 
77
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
78
-	return [[self getCurrentChild] getCurrentLeaf];
79
-}
80
-
81 77
 - (UIStatusBarStyle)preferredStatusBarStyle {
82 78
 	return self.child.preferredStatusBarStyle;
83 79
 }

+ 1
- 5
lib/ios/RNNSideMenuController.m Прегледај датотеку

@@ -48,7 +48,7 @@
48 48
 }
49 49
 
50 50
 - (RNNNavigationOptions *)resolveOptions {
51
-	return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
51
+	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
52 52
 }
53 53
 
54 54
 - (void)mergeOptions:(RNNNavigationOptions *)options {
@@ -181,8 +181,4 @@
181 181
 	return self.center;
182 182
 }
183 183
 
184
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
185
-	return [[self getCurrentChild] getCurrentLeaf];
186
-}
187
-
188 184
 @end

+ 1
- 6
lib/ios/RNNSplitViewController.m Прегледај датотеку

@@ -33,7 +33,7 @@
33 33
 }
34 34
 
35 35
 - (RNNNavigationOptions *)resolveOptions {
36
-	return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
36
+	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
37 37
 }
38 38
 
39 39
 - (void)mergeOptions:(RNNNavigationOptions *)options {
@@ -79,9 +79,4 @@
79 79
 	return self.viewControllers[0];
80 80
 }
81 81
 
82
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
83
-	return [[self getCurrentChild] getCurrentLeaf];
84
-}
85
-
86
-
87 82
 @end

+ 1
- 5
lib/ios/RNNTabBarController.m Прегледај датотеку

@@ -48,7 +48,7 @@
48 48
 }
49 49
 
50 50
 - (RNNNavigationOptions *)resolveOptions {
51
-	return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
51
+	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
52 52
 }
53 53
 
54 54
 - (void)mergeOptions:(RNNNavigationOptions *)options {
@@ -103,10 +103,6 @@
103 103
 	return self.selectedViewController;
104 104
 }
105 105
 
106
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
107
-	return [[self getCurrentChild] getCurrentLeaf];
108
-}
109
-
110 106
 - (UIStatusBarStyle)preferredStatusBarStyle {
111 107
 	return ((UIViewController<RNNParentProtocol>*)self.selectedViewController).preferredStatusBarStyle;
112 108
 }

+ 1
- 5
lib/ios/RNNTopTabsViewController.m Прегледај датотеку

@@ -46,7 +46,7 @@
46 46
 }
47 47
 
48 48
 - (RNNNavigationOptions *)resolveOptions {
49
-	return [(RNNNavigationOptions *)[self.getCurrentChild.resolveOptions.copy mergeOptions:self.options] withDefault:self.defaultOptions];
49
+	return [(RNNNavigationOptions *)[self.options mergeInOptions:self.getCurrentChild.resolveOptions.copy] withDefault:self.defaultOptions];
50 50
 }
51 51
 
52 52
 - (void)mergeOptions:(RNNNavigationOptions *)options {
@@ -132,8 +132,4 @@
132 132
 	return _currentViewController;
133 133
 }
134 134
 
135
-- (UIViewController<RNNLeafProtocol> *)getCurrentLeaf {
136
-	return [[self getCurrentChild] getCurrentLeaf];
137
-}
138
-
139 135
 @end

+ 0
- 1
lib/ios/RNNTransitionsOptions.h Прегледај датотеку

@@ -7,7 +7,6 @@
7 7
 @property (nonatomic, strong) RNNScreenTransition* push;
8 8
 @property (nonatomic, strong) RNNScreenTransition* pop;
9 9
 @property (nonatomic, strong) RNNScreenTransition* showModal;
10
-@property (nonatomic, strong) RNNScreenTransition* showOverlay;
11 10
 @property (nonatomic, strong) RNNScreenTransition* dismissModal;
12 11
 @property (nonatomic, strong) RNNScreenTransition* setStackRoot;
13 12
 @property (nonatomic, strong) RNNScreenTransition* setRoot;

+ 0
- 1
lib/ios/RNNTransitionsOptions.m Прегледај датотеку

@@ -8,7 +8,6 @@
8 8
 	self.push = [[RNNScreenTransition alloc] initWithDict:dict[@"push"]];
9 9
 	self.pop = [[RNNScreenTransition alloc] initWithDict:dict[@"pop"]];
10 10
 	self.showModal = [[RNNScreenTransition alloc] initWithDict:dict[@"showModal"]];
11
-	self.showOverlay = [[RNNScreenTransition alloc] initWithDict:dict[@"showOverlay"]];
12 11
 	self.dismissModal = [[RNNScreenTransition alloc] initWithDict:dict[@"dismissModal"]];
13 12
 	self.setStackRoot = [[RNNScreenTransition alloc] initWithDict:dict[@"setStackRoot"]];
14 13
 	self.setRoot = [[RNNScreenTransition alloc] initWithDict:dict[@"setRoot"]];

+ 2
- 2
lib/ios/RNNViewControllerPresenter.h Прегледај датотеку

@@ -1,10 +1,10 @@
1 1
 #import "RNNBasePresenter.h"
2 2
 #import "RNNNavigationButtons.h"
3
-#import "RNNReactComponentManager.h"
3
+#import "RNNReactComponentRegistry.h"
4 4
 
5 5
 @interface RNNViewControllerPresenter : RNNBasePresenter
6 6
 
7
-- (instancetype)initWithComponentManager:(RNNReactComponentManager *)componentManager;
7
+- (instancetype)initWithcomponentRegistry:(RNNReactComponentRegistry *)componentRegistry;
8 8
 
9 9
 - (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock;
10 10
 

+ 6
- 6
lib/ios/RNNViewControllerPresenter.m Прегледај датотеку

@@ -9,7 +9,7 @@
9 9
 @interface RNNViewControllerPresenter() {
10 10
 	RNNReactView* _customTitleView;
11 11
 	RNNTitleViewHelper* _titleViewHelper;
12
-	RNNReactComponentManager* _componentManager;
12
+	RNNReactComponentRegistry* _componentRegistry;
13 13
 }
14 14
 
15 15
 @end
@@ -26,15 +26,15 @@
26 26
 	return self;
27 27
 }
28 28
 
29
-- (instancetype)initWithComponentManager:(RNNReactComponentManager *)componentManager {
29
+- (instancetype)initWithcomponentRegistry:(RNNReactComponentRegistry *)componentRegistry {
30 30
 	self = [self init];
31
-	_componentManager = componentManager;
31
+	_componentRegistry = componentRegistry;
32 32
 	return self;
33 33
 }
34 34
 
35 35
 - (void)bindViewController:(UIViewController *)bindedViewController {
36 36
 	self.bindedViewController = bindedViewController;
37
-	_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:self.bindedViewController componentManager:_componentManager];
37
+	_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:self.bindedViewController componentRegistry:_componentRegistry];
38 38
 }
39 39
 
40 40
 - (void)applyOptions:(RNNNavigationOptions *)options {
@@ -154,7 +154,7 @@
154 154
 		rootView.passThroughTouches = !newOptions.overlay.interceptTouchOutside.get;
155 155
 	}
156 156
 	
157
-	[self setTitleViewWithSubtitle:newOptions];
157
+	[self setTitleViewWithSubtitle:(RNNNavigationOptions *)[[currentOptions overrideOptions:newOptions] mergeOptions:defaultOptions]];
158 158
 	
159 159
 	if (newOptions.topBar.title.component.name.hasValue) {
160 160
 		[self setCustomNavigationTitleView:newOptions perform:nil];
@@ -173,7 +173,7 @@
173 173
 	}
174 174
 	
175 175
 	if (options.topBar.title.component.name.hasValue) {
176
-		_customTitleView = (RNNReactView*)[_componentManager createComponentIfNotExists:options.topBar.title.component parentComponentId:viewController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
176
+		_customTitleView = (RNNReactView*)[_componentRegistry createComponentIfNotExists:options.topBar.title.component parentComponentId:viewController.layoutInfo.componentId reactViewReadyBlock:readyBlock];
177 177
 		_customTitleView.backgroundColor = UIColor.clearColor;
178 178
 		NSString* alignment = [options.topBar.title.component.alignment getWithDefaultValue:@""];
179 179
 		[_customTitleView setAlignment:alignment];

+ 8
- 8
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj Прегледај датотеку

@@ -166,8 +166,8 @@
166 166
 		504AFE751FFFF0540076E904 /* RNNTopTabsOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 504AFE731FFFF0540076E904 /* RNNTopTabsOptions.m */; };
167 167
 		504AFE761FFFF1E00076E904 /* RNNNavigationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E83BAD691F27362500A9F3DD /* RNNNavigationOptions.h */; };
168 168
 		504AFE771FFFF1E20076E904 /* RNNTopBarOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = A7626BFE1FC2FB6700492FB8 /* RNNTopBarOptions.h */; };
169
-		5050465421F8F4490035497A /* RNNReactComponentManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5050465221F8F4490035497A /* RNNReactComponentManager.h */; };
170
-		5050465521F8F4490035497A /* RNNReactComponentManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5050465321F8F4490035497A /* RNNReactComponentManager.m */; };
169
+		5050465421F8F4490035497A /* RNNReactComponentRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5050465221F8F4490035497A /* RNNReactComponentRegistry.h */; };
170
+		5050465521F8F4490035497A /* RNNReactComponentRegistry.m in Sources */ = {isa = PBXBuildFile; fileRef = 5050465321F8F4490035497A /* RNNReactComponentRegistry.m */; };
171 171
 		5053CE7F2175FB1900D0386B /* RNNDefaultOptionsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 5053CE7D2175FB1900D0386B /* RNNDefaultOptionsHelper.h */; };
172 172
 		5053CE802175FB1900D0386B /* RNNDefaultOptionsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 5053CE7E2175FB1900D0386B /* RNNDefaultOptionsHelper.m */; };
173 173
 		50570B262061473D006A1B5C /* RNNTitleOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50570B242061473D006A1B5C /* RNNTitleOptions.h */; };
@@ -498,8 +498,8 @@
498 498
 		504AFE631FFE53070076E904 /* RNNOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNOptions.m; sourceTree = "<group>"; };
499 499
 		504AFE721FFFF0540076E904 /* RNNTopTabsOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTopTabsOptions.h; sourceTree = "<group>"; };
500 500
 		504AFE731FFFF0540076E904 /* RNNTopTabsOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNTopTabsOptions.m; sourceTree = "<group>"; };
501
-		5050465221F8F4490035497A /* RNNReactComponentManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNReactComponentManager.h; sourceTree = "<group>"; };
502
-		5050465321F8F4490035497A /* RNNReactComponentManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNReactComponentManager.m; sourceTree = "<group>"; };
501
+		5050465221F8F4490035497A /* RNNReactComponentRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNReactComponentRegistry.h; sourceTree = "<group>"; };
502
+		5050465321F8F4490035497A /* RNNReactComponentRegistry.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNReactComponentRegistry.m; sourceTree = "<group>"; };
503 503
 		5053CE7D2175FB1900D0386B /* RNNDefaultOptionsHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNDefaultOptionsHelper.h; sourceTree = "<group>"; };
504 504
 		5053CE7E2175FB1900D0386B /* RNNDefaultOptionsHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNDefaultOptionsHelper.m; sourceTree = "<group>"; };
505 505
 		50570B242061473D006A1B5C /* RNNTitleOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNTitleOptions.h; sourceTree = "<group>"; };
@@ -984,8 +984,8 @@
984 984
 				261F0E691E6F028A00989DE2 /* RNNNavigationStackManager.m */,
985 985
 				50D031322005149000386B3D /* RNNOverlayManager.h */,
986 986
 				50D031332005149000386B3D /* RNNOverlayManager.m */,
987
-				5050465221F8F4490035497A /* RNNReactComponentManager.h */,
988
-				5050465321F8F4490035497A /* RNNReactComponentManager.m */,
987
+				5050465221F8F4490035497A /* RNNReactComponentRegistry.h */,
988
+				5050465321F8F4490035497A /* RNNReactComponentRegistry.m */,
989 989
 			);
990 990
 			name = Managers;
991 991
 			sourceTree = "<group>";
@@ -1292,7 +1292,7 @@
1292 1292
 				5012242221736883000F5F98 /* NullColor.h in Headers */,
1293 1293
 				50570B262061473D006A1B5C /* RNNTitleOptions.h in Headers */,
1294 1294
 				50395593217485B000B0A663 /* Double.h in Headers */,
1295
-				5050465421F8F4490035497A /* RNNReactComponentManager.h in Headers */,
1295
+				5050465421F8F4490035497A /* RNNReactComponentRegistry.h in Headers */,
1296 1296
 				504AFE741FFFF0540076E904 /* RNNTopTabsOptions.h in Headers */,
1297 1297
 				E8E5182E1F83A48B000467AC /* RNNTransitionStateHolder.h in Headers */,
1298 1298
 				5049594A216F5FE6006D2B81 /* NullText.h in Headers */,
@@ -1476,7 +1476,7 @@
1476 1476
 				5012242721737278000F5F98 /* NullImage.m in Sources */,
1477 1477
 				7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */,
1478 1478
 				A7626BFD1FC2FB2C00492FB8 /* RNNTopBarOptions.m in Sources */,
1479
-				5050465521F8F4490035497A /* RNNReactComponentManager.m in Sources */,
1479
+				5050465521F8F4490035497A /* RNNReactComponentRegistry.m in Sources */,
1480 1480
 				263905CB1E4C6F440023D7D3 /* SidebarLuvocracyAnimation.m in Sources */,
1481 1481
 				50570BEB2063E09B006A1B5C /* RNNTitleViewHelper.m in Sources */,
1482 1482
 				263905E71E4CAC950023D7D3 /* RNNSideMenuChildVC.m in Sources */,

+ 1
- 1
lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m Прегледај датотеку

@@ -62,7 +62,7 @@
62 62
 	self.store = [OCMockObject partialMockForObject:[[RNNStore alloc] init]];
63 63
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
64 64
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
65
-	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:self.store componentManager:nil andBridge:nil]];
65
+	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:self.store componentRegistry:nil andBridge:nil]];
66 66
 	self.uut = [[RNNCommandsHandler alloc] initWithStore:self.store controllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:_mainWindow];
67 67
 	self.vc1 = [RNNRootViewController new];
68 68
 	self.vc2 = [RNNRootViewController new];

+ 1
- 1
lib/ios/ReactNativeNavigationTests/RNNControllerFactoryTest.m Прегледај датотеку

@@ -23,7 +23,7 @@
23 23
 	[super setUp];
24 24
 	self.creator = nil;
25 25
 	self.store = [RNNStore new];
26
-	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator eventEmitter:nil store:self.store componentManager:nil andBridge:nil];
26
+	self.factory = [[RNNControllerFactory alloc] initWithRootViewCreator:self.creator eventEmitter:nil store:self.store componentRegistry:nil andBridge:nil];
27 27
 }
28 28
 
29 29
 - (void)tearDown {

+ 0
- 6
lib/ios/ReactNativeNavigationTests/RNNNavigationControllerTest.m Прегледај датотеку

@@ -47,12 +47,6 @@
47 47
 	XCTAssertTrue(self.uut.getCurrentChild == self.uut.topViewController);
48 48
 }
49 49
 
50
-- (void)testCurrentLeaf_shouldReturnCurrentChildLeaf {
51
-	[[_vc2Mock expect] getCurrentLeaf];
52
-	[self.uut getCurrentLeaf];
53
-	[_vc2Mock verify];
54
-}
55
-
56 50
 - (void)testGetLeafViewController_shouldReturnTopViewController {
57 51
 	XCTAssertTrue(self.uut.getCurrentChild == self.uut.topViewController);
58 52
 }

+ 0
- 12
lib/ios/ReactNativeNavigationTests/RNNTabBarControllerTest.m Прегледај датотеку

@@ -77,12 +77,6 @@
77 77
 	XCTAssertTrue(uut.delegate == uut);
78 78
 }
79 79
 
80
-- (void)testWillMoveToParent_invokePresenterApplyOptionsOnWillMoveToParent {
81
-	[[self.mockTabBarPresenter expect] applyOptionsOnWillMoveToParentViewController:[(RNNTabBarController *)self.mockUut resolveOptions]];
82
-	[self.mockUut willMoveToParentViewController:[UIViewController new]];
83
-	[self.mockTabBarPresenter verify];
84
-}
85
-
86 80
 - (void)testWillMoveToParent_shouldNotInvokePresenterApplyOptionsOnWillMoveToNilParent {
87 81
 	[[self.mockTabBarPresenter reject] applyOptionsOnWillMoveToParentViewController:[(RNNTabBarController *)self.mockUut options]];
88 82
 	[self.mockUut willMoveToParentViewController:nil];
@@ -123,12 +117,6 @@
123 117
 	[parentMock verify];
124 118
 }
125 119
 
126
-- (void)testGetCurrentLeaf_shouldInvokeSelectedViewControllerGetCurrentLeaf {
127
-	[[self.mockChildViewController expect] getCurrentLeaf];
128
-	[self.mockUut getCurrentLeaf];
129
-	[self.mockChildViewController verify];
130
-}
131
-
132 120
 - (void)testGetCurrentChild_shouldReturnSelectedViewController {
133 121
 	XCTAssertEqual([self.mockUut getCurrentChild], [(RNNTabBarController *)self.mockUut selectedViewController]);
134 122
 }