Browse Source

Fixes button react component props

yogevbd 6 years ago
parent
commit
caff3b8801

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

115
     await expect(elementByLabel(`Two`)).toExist();
115
     await expect(elementByLabel(`Two`)).toExist();
116
   });
116
   });
117
 
117
 
118
+  test(':ios: pass props to custom button component should exist after screen rerender', async () => {
119
+    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
120
+    await expect(elementByLabel(`Two`)).toExist();
121
+    await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
122
+    await elementById(testIDs.POP_BUTTON).tap();
123
+    await expect(elementByLabel(`Two`)).toExist();
124
+  });
125
+
118
   test('tab bar items visibility', async () => {
126
   test('tab bar items visibility', async () => {
119
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
127
     await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
120
     await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();
128
     await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();

+ 7
- 0
lib/ios/RNNTopBarOptions.m View File

153
 		_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:(RNNRootViewController*)viewController];
153
 		_navigationButtons = [[RNNNavigationButtons alloc] initWithViewController:(RNNRootViewController*)viewController];
154
 		[_navigationButtons applyLeftButtons:self.leftButtons rightButtons:self.rightButtons defaultLeftButtonStyle:self.leftButtonStyle defaultRightButtonStyle:self.rightButtonStyle];
154
 		[_navigationButtons applyLeftButtons:self.leftButtons rightButtons:self.rightButtons defaultLeftButtonStyle:self.leftButtonStyle defaultRightButtonStyle:self.rightButtonStyle];
155
 	}
155
 	}
156
+	
157
+	self.rightButtons = nil;
158
+	self.leftButtons = nil;
156
 }
159
 }
157
 
160
 
158
 - (void)setRightButtonColor:(NSNumber *)rightButtonColor {
161
 - (void)setRightButtonColor:(NSNumber *)rightButtonColor {
184
 		} else {
187
 		} else {
185
 			[_rightButtonStyle mergeWith:rightButtons];
188
 			[_rightButtonStyle mergeWith:rightButtons];
186
 		}
189
 		}
190
+	} else {
191
+		_rightButtons = rightButtons;
187
 	}
192
 	}
188
 }
193
 }
189
 
194
 
196
 		} else {
201
 		} else {
197
 			[_leftButtonStyle mergeWith:leftButtons];
202
 			[_leftButtonStyle mergeWith:leftButtons];
198
 		}
203
 		}
204
+	} else {
205
+		_leftButtons = leftButtons;
199
 	}
206
 	}
200
 }
207
 }
201
 
208
 

+ 6
- 0
playground/src/screens/ScrollViewScreen.js View File

37
       topBarHideOnScroll: false
37
       topBarHideOnScroll: false
38
     };
38
     };
39
     this.onClickToggleTopBarHideOnScroll = this.onClickToggleTopBarHideOnScroll.bind(this);
39
     this.onClickToggleTopBarHideOnScroll = this.onClickToggleTopBarHideOnScroll.bind(this);
40
+    this.onClickPop = this.onClickPop.bind(this);
40
   }
41
   }
41
 
42
 
42
   render() {
43
   render() {
45
         <ScrollView testID={testIDs.SCROLLVIEW_ELEMENT} contentContainerStyle={styles.contentContainer}>
46
         <ScrollView testID={testIDs.SCROLLVIEW_ELEMENT} contentContainerStyle={styles.contentContainer}>
46
           <View>
47
           <View>
47
             <Button title='Toggle Top Bar Hide On Scroll' testID={testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL} onPress={this.onClickToggleTopBarHideOnScroll} />
48
             <Button title='Toggle Top Bar Hide On Scroll' testID={testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL} onPress={this.onClickToggleTopBarHideOnScroll} />
49
+            <Button title='Pop screen' testID={testIDs.POP_BUTTON} onPress={this.onClickPop} />
48
           </View>
50
           </View>
49
         </ScrollView>
51
         </ScrollView>
50
       </View>
52
       </View>
57
     });
59
     });
58
   }
60
   }
59
 
61
 
62
+  onClickPop() {
63
+    Navigation.pop(this.props.componentId);
64
+  }
65
+
60
   componentDidUpdate() {
66
   componentDidUpdate() {
61
     Navigation.mergeOptions(this.props.componentId, {
67
     Navigation.mergeOptions(this.props.componentId, {
62
       topBar: {
68
       topBar: {