yogevbd 6 years ago
parent
commit
105624d9ca

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

102
     await expect(elementById('buttonLeft')).toBeVisible();
102
     await expect(elementById('buttonLeft')).toBeVisible();
103
   });
103
   });
104
 
104
 
105
+  test('pass props to custom button component', async () => {
106
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
107
+    await expect(elementByLabel(`Two`)).toExist();
108
+  });
109
+
105
   test('tab bar items visibility', async () => {
110
   test('tab bar items visibility', async () => {
106
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
111
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
107
     await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();
112
     await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();

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

54
 -(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary {
54
 -(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary {
55
 	NSString* buttonId = dictionary[@"id"];
55
 	NSString* buttonId = dictionary[@"id"];
56
 	NSString* title = dictionary[@"title"];
56
 	NSString* title = dictionary[@"title"];
57
-	NSString* component = dictionary[@"component"][@"name"];
57
+	NSDictionary* component = dictionary[@"component"];
58
 	
58
 	
59
 	if (!buttonId) {
59
 	if (!buttonId) {
60
 		@throw [NSException exceptionWithName:@"NSInvalidArgumentException" reason:[@"button id is not specified " stringByAppendingString:title] userInfo:nil];
60
 		@throw [NSException exceptionWithName:@"NSInvalidArgumentException" reason:[@"button id is not specified " stringByAppendingString:title] userInfo:nil];
68
 	
68
 	
69
 	RNNUIBarButtonItem *barButtonItem;
69
 	RNNUIBarButtonItem *barButtonItem;
70
 	if (component) {
70
 	if (component) {
71
-		RCTRootView *view = (RCTRootView*)[self.viewController.creator createRootView:component rootViewId:buttonId];
71
+		RCTRootView *view = (RCTRootView*)[self.viewController.creator createRootView:component[@"name"] rootViewId:component[@"componentId"]];
72
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withCustomView:view];
72
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withCustomView:view];
73
 	} else if (iconImage) {
73
 	} else if (iconImage) {
74
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withIcon:iconImage];
74
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withIcon:iconImage];

+ 1
- 1
playground/src/screens/CustomRoundedButton.js View File

37
       <View style={styles.container} key={'guyguy'}>
37
       <View style={styles.container} key={'guyguy'}>
38
         <View style={styles.button}>
38
         <View style={styles.button}>
39
           <TouchableOpacity onPress={() => Alert.alert(this.props.title, 'Thanks for that :)')}>
39
           <TouchableOpacity onPress={() => Alert.alert(this.props.title, 'Thanks for that :)')}>
40
-            <Text style={styles.text}>Hi:)</Text>
40
+            <Text style={styles.text}>{this.props.title}</Text>
41
           </TouchableOpacity>
41
           </TouchableOpacity>
42
         </View>
42
         </View>
43
       </View>
43
       </View>

+ 4
- 1
playground/src/screens/OptionsScreen.js View File

66
             id: CUSTOM_BUTTON2,
66
             id: CUSTOM_BUTTON2,
67
             testID: CUSTOM_BUTTON2,
67
             testID: CUSTOM_BUTTON2,
68
             component: {
68
             component: {
69
-              name: 'CustomRoundedButton'
69
+              name: 'CustomRoundedButton',
70
+              passProps: {
71
+                title: "Two"
72
+              }
70
             }
73
             }
71
           },
74
           },
72
           {
75
           {