yogevbd 6 years ago
parent
commit
091e1befc5

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

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

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

@@ -16,8 +16,8 @@
16 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 23
 - (NSString *)componentId {

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

@@ -44,7 +44,7 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
44 44
 			[options mergeWith:[otherOptions objectForKey:key]];
45 45
 		} else {
46 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,6 +60,10 @@
60 60
 	[super viewDidLoad];
61 61
 }
62 62
 
63
+- (void)mergeOptions:(NSDictionary *)options {
64
+	[self.options mergeWith:options];
65
+}
66
+
63 67
 - (void)setCustomNavigationTitleView {
64 68
 	if (self.options.topBar.customTitleViewName) {
65 69
 		UIView *reactView = [_creator createRootView:self.options.topBar.customTitleViewName rootViewId:self.options.topBar.customTitleViewName];

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

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

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

@@ -41,8 +41,8 @@
41 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 48
 - (NSString *)componentId {

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

@@ -13,6 +13,9 @@ class TextScreen extends Component {
13 13
     return {
14 14
       bottomTabs: {
15 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,6 +61,11 @@ class WelcomeScreen extends Component {
61 61
                     passProps: {
62 62
                       text: 'This is tab 1',
63 63
                       myFunction: () => 'Hello from a function!'
64
+                    },
65
+                    options: {
66
+                      topBar: {
67
+                        visible: false
68
+                      }
64 69
                     }
65 70
                   }
66 71
                 }