yogevbd 6 jaren geleden
bovenliggende
commit
105624d9ca

+ 5
- 0
e2e/ScreenStyle.test.js Bestand weergeven

@@ -102,6 +102,11 @@ describe('screen style', () => {
102 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 110
   test('tab bar items visibility', async () => {
106 111
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
107 112
     await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();

+ 2
- 2
lib/ios/RNNNavigationButtons.m Bestand weergeven

@@ -54,7 +54,7 @@
54 54
 -(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary {
55 55
 	NSString* buttonId = dictionary[@"id"];
56 56
 	NSString* title = dictionary[@"title"];
57
-	NSString* component = dictionary[@"component"][@"name"];
57
+	NSDictionary* component = dictionary[@"component"];
58 58
 	
59 59
 	if (!buttonId) {
60 60
 		@throw [NSException exceptionWithName:@"NSInvalidArgumentException" reason:[@"button id is not specified " stringByAppendingString:title] userInfo:nil];
@@ -68,7 +68,7 @@
68 68
 	
69 69
 	RNNUIBarButtonItem *barButtonItem;
70 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 72
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withCustomView:view];
73 73
 	} else if (iconImage) {
74 74
 		barButtonItem = [[RNNUIBarButtonItem alloc] init:buttonId withIcon:iconImage];

+ 1
- 1
playground/src/screens/CustomRoundedButton.js Bestand weergeven

@@ -37,7 +37,7 @@ class CustomRoundedButton extends Component {
37 37
       <View style={styles.container} key={'guyguy'}>
38 38
         <View style={styles.button}>
39 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 41
           </TouchableOpacity>
42 42
         </View>
43 43
       </View>

+ 4
- 1
playground/src/screens/OptionsScreen.js Bestand weergeven

@@ -66,7 +66,10 @@ class OptionsScreen extends Component {
66 66
             id: CUSTOM_BUTTON2,
67 67
             testID: CUSTOM_BUTTON2,
68 68
             component: {
69
-              name: 'CustomRoundedButton'
69
+              name: 'CustomRoundedButton',
70
+              passProps: {
71
+                title: "Two"
72
+              }
70 73
             }
71 74
           },
72 75
           {