yogevbd 6 years ago
parent
commit
091e1befc5

+ 7
- 0
e2e/ScreenStyle.test.js View File

123
     await elementById(testIDs.PROVIDED_ID).tap();
123
     await elementById(testIDs.PROVIDED_ID).tap();
124
     await expect(elementByLabel('User provided id')).toBeVisible();
124
     await expect(elementByLabel('User provided id')).toBeVisible();
125
   });
125
   });
126
+
127
+  it('stack options should not override component options', async () => {
128
+    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
129
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
130
+    await elementById(testIDs.SECOND_TAB_BAR_BUTTON).tap();
131
+    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
132
+  });
126
 });
133
 });

+ 5
- 5
lib/ios/RNNControllerFactory.m View File

97
 
97
 
98
 - (UIViewController<RNNRootViewProtocol> *)createStack:(RNNLayoutNode*)node {
98
 - (UIViewController<RNNRootViewProtocol> *)createStack:(RNNLayoutNode*)node {
99
 	RNNNavigationController* vc = [[RNNNavigationController alloc] init];
99
 	RNNNavigationController* vc = [[RNNNavigationController alloc] init];
100
-	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:node.data[@"options"]];
100
+	NSDictionary* options = node.data[@"options"];
101
 	NSMutableArray* controllers = [NSMutableArray new];
101
 	NSMutableArray* controllers = [NSMutableArray new];
102
 	for (NSDictionary* child in node.children) {
102
 	for (NSDictionary* child in node.children) {
103
 		[controllers addObject:[self fromTree:child]];
103
 		[controllers addObject:[self fromTree:child]];
104
 	}
104
 	}
105
 	[vc setViewControllers:controllers];
105
 	[vc setViewControllers:controllers];
106
-	[vc setOptions:options];
106
+	[vc mergeOptions:options];
107
 	
107
 	
108
 	return vc;
108
 	return vc;
109
 }
109
 }
110
 
110
 
111
 -(UIViewController<RNNRootViewProtocol> *)createTabs:(RNNLayoutNode*)node {
111
 -(UIViewController<RNNRootViewProtocol> *)createTabs:(RNNLayoutNode*)node {
112
 	RNNTabBarController* vc = [[RNNTabBarController alloc] init];
112
 	RNNTabBarController* vc = [[RNNTabBarController alloc] init];
113
-	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:node.data[@"options"]];
114
-	
113
+	NSDictionary* options = node.data[@"options"];
114
+
115
 	NSMutableArray* controllers = [NSMutableArray new];
115
 	NSMutableArray* controllers = [NSMutableArray new];
116
 	for (NSDictionary *child in node.children) {
116
 	for (NSDictionary *child in node.children) {
117
 		UIViewController* childVc = (UIViewController*)[self fromTree:child];
117
 		UIViewController* childVc = (UIViewController*)[self fromTree:child];
121
 		[controllers addObject:childVc];
121
 		[controllers addObject:childVc];
122
 	}
122
 	}
123
 	[vc setViewControllers:controllers];
123
 	[vc setViewControllers:controllers];
124
-	[vc setOptions:options];
124
+	[vc mergeOptions:options];
125
 	
125
 	
126
 	return vc;
126
 	return vc;
127
 }
127
 }

+ 2
- 2
lib/ios/RNNNavigationController.m View File

16
 	return rootVC.isAnimated;
16
 	return rootVC.isAnimated;
17
 }
17
 }
18
 
18
 
19
-- (void)setOptions:(RNNNavigationOptions *)options {
20
-	((UIViewController<RNNRootViewProtocol>*)self.topViewController).options = options;
19
+- (void)mergeOptions:(NSDictionary *)options {
20
+	[((UIViewController<RNNRootViewProtocol>*)self.topViewController) mergeOptions:options];
21
 }
21
 }
22
 
22
 
23
 - (NSString *)componentId {
23
 - (NSString *)componentId {

+ 1
- 1
lib/ios/RNNNavigationOptions.m View File

44
 			[options mergeWith:[otherOptions objectForKey:key]];
44
 			[options mergeWith:[otherOptions objectForKey:key]];
45
 		} else {
45
 		} else {
46
 			[self setValue:[otherOptions objectForKey:key] forKey:key];
46
 			[self setValue:[otherOptions objectForKey:key] forKey:key];
47
-		}
47
+		} 
48
 	}
48
 	}
49
 }
49
 }
50
 
50
 

+ 4
- 0
lib/ios/RNNRootViewController.m View File

60
 	[super viewDidLoad];
60
 	[super viewDidLoad];
61
 }
61
 }
62
 
62
 
63
+- (void)mergeOptions:(NSDictionary *)options {
64
+	[self.options mergeWith:options];
65
+}
66
+
63
 - (void)setCustomNavigationTitleView {
67
 - (void)setCustomNavigationTitleView {
64
 	if (self.options.topBar.customTitleViewName) {
68
 	if (self.options.topBar.customTitleViewName) {
65
 		UIView *reactView = [_creator createRootView:self.options.topBar.customTitleViewName rootViewId:self.options.topBar.customTitleViewName];
69
 		UIView *reactView = [_creator createRootView:self.options.topBar.customTitleViewName rootViewId:self.options.topBar.customTitleViewName];

+ 1
- 1
lib/ios/RNNRootViewProtocol.h View File

3
 @protocol RNNRootViewProtocol <NSObject, UINavigationControllerDelegate>
3
 @protocol RNNRootViewProtocol <NSObject, UINavigationControllerDelegate>
4
 
4
 
5
 @optional
5
 @optional
6
-- (void)setOptions:(RNNNavigationOptions*)options;
6
+- (void)mergeOptions:(NSDictionary*)options;
7
 
7
 
8
 @required
8
 @required
9
 
9
 

+ 2
- 2
lib/ios/RNNTabBarController.m View File

41
 	return YES;
41
 	return YES;
42
 }
42
 }
43
 
43
 
44
-- (void)setOptions:(RNNNavigationOptions *)options {
45
-	[((UIViewController<RNNRootViewProtocol>*)self.selectedViewController) setOptions:options];
44
+- (void)mergeOptions:(NSDictionary *)options {
45
+	[((UIViewController<RNNRootViewProtocol>*)self.selectedViewController) mergeOptions:options];
46
 }
46
 }
47
 
47
 
48
 - (NSString *)componentId {
48
 - (NSString *)componentId {

+ 3
- 0
playground/src/screens/TextScreen.js View File

13
     return {
13
     return {
14
       bottomTabs: {
14
       bottomTabs: {
15
         testID: testIDs.BOTTOM_TABS_ELEMENT
15
         testID: testIDs.BOTTOM_TABS_ELEMENT
16
+      },
17
+      topBar: {
18
+        testID: testIDs.TOP_BAR_ELEMENT
16
       }
19
       }
17
     };
20
     };
18
   }
21
   }

+ 5
- 0
playground/src/screens/WelcomeScreen.js View File

61
                     passProps: {
61
                     passProps: {
62
                       text: 'This is tab 1',
62
                       text: 'This is tab 1',
63
                       myFunction: () => 'Hello from a function!'
63
                       myFunction: () => 'Hello from a function!'
64
+                    },
65
+                    options: {
66
+                      topBar: {
67
+                        visible: false
68
+                      }
64
                     }
69
                     }
65
                   }
70
                   }
66
                 }
71
                 }