|
@@ -31,6 +31,7 @@ class PushedScreen extends Component {
|
31
|
31
|
|
32
|
32
|
constructor(props) {
|
33
|
33
|
super(props);
|
|
34
|
+ Navigation.events().bindComponent(this);
|
34
|
35
|
if (this.props.simulateLongRunningTask) {
|
35
|
36
|
this.simulateLongRunningTask();
|
36
|
37
|
}
|
|
@@ -49,6 +50,12 @@ class PushedScreen extends Component {
|
49
|
50
|
for (let i = 0; i < Math.pow(2, 25); i++);
|
50
|
51
|
}
|
51
|
52
|
|
|
53
|
+ navigationButtonPressed({buttonId}) {
|
|
54
|
+ if (buttonId === 'backPress') {
|
|
55
|
+ alert('back button clicked')
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+
|
52
|
59
|
listeners = [];
|
53
|
60
|
|
54
|
61
|
componentDidMount() {
|
|
@@ -89,6 +96,7 @@ class PushedScreen extends Component {
|
89
|
96
|
<Button title='Pop To Root' testID={testIDs.POP_TO_ROOT} onPress={this.onClickPopToRoot} />
|
90
|
97
|
<Button title='Set Stack Root' testID={testIDs.SET_STACK_ROOT_BUTTON} onPress={this.onClickSetStackRoot} />
|
91
|
98
|
<Button title='Push and Wait for Render' testID={testIDs.PUSH_BUTTON_WAIT_FOR_RENDER} onPress={this.onClickPushWaitForRender} />
|
|
99
|
+ <Button title='Push custom back button' testID={testIDs.PUSH_CUSTOM_BACK_BUTTON} onPress={this.onClickPushCustomBackButton} />
|
92
|
100
|
{stackPosition > 2 && <Button title='Pop To Stack Position 1' testID={testIDs.POP_STACK_POSITION_ONE_BUTTON} onPress={this.onClickPopToFirstPosition} />}
|
93
|
101
|
<Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
|
94
|
102
|
</View>
|
|
@@ -242,6 +250,29 @@ class PushedScreen extends Component {
|
242
|
250
|
});
|
243
|
251
|
}
|
244
|
252
|
|
|
253
|
+ onClickPushCustomBackButton = async () => {
|
|
254
|
+ Navigation.push(this.props.componentId, {
|
|
255
|
+ component: {
|
|
256
|
+ name: 'navigation.playground.PushedScreen',
|
|
257
|
+ passProps: {
|
|
258
|
+ stackPosition: this.getStackPosition() + 1,
|
|
259
|
+ previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId),
|
|
260
|
+ },
|
|
261
|
+ options: {
|
|
262
|
+ topBar: {
|
|
263
|
+ backButton: {
|
|
264
|
+ id: 'backPress',
|
|
265
|
+ icon: require('../../img/navicon_add.png'),
|
|
266
|
+ visible: true,
|
|
267
|
+ color: 'black',
|
|
268
|
+ testID: testIDs.CUSTOM_BACK_BUTTON
|
|
269
|
+ }
|
|
270
|
+ }
|
|
271
|
+ }
|
|
272
|
+ }
|
|
273
|
+ });
|
|
274
|
+ }
|
|
275
|
+
|
245
|
276
|
async onClickPushBottomTabs() {
|
246
|
277
|
await Navigation.push(this.props.componentId, {
|
247
|
278
|
bottomTabs: {
|