|
@@ -1,3 +1,4 @@
|
|
1
|
+import _ from 'lodash';
|
1
|
2
|
import React, { Component } from 'react';
|
2
|
3
|
import {
|
3
|
4
|
StyleSheet,
|
|
@@ -13,6 +14,7 @@ class PushedScreen extends Component {
|
13
|
14
|
super(props);
|
14
|
15
|
this.onClickPush = this.onClickPush.bind(this);
|
15
|
16
|
this.onClickPop = this.onClickPop.bind(this);
|
|
17
|
+ this.onClickPopPrevious = this.onClickPopPrevious.bind(this);
|
16
|
18
|
}
|
17
|
19
|
render() {
|
18
|
20
|
return (
|
|
@@ -21,24 +23,30 @@ class PushedScreen extends Component {
|
21
|
23
|
<Text style={styles.h2}>{`Stack Position: ${this.getStackPosition()}`}</Text>
|
22
|
24
|
<Button title="Push" onPress={this.onClickPush} />
|
23
|
25
|
<Button title="Pop" onPress={this.onClickPop} />
|
|
26
|
+ <Button title="Pop Previous" onPress={this.onClickPopPrevious} />
|
24
|
27
|
<Text style={styles.footer}>{`this.props.id = ${this.props.id}`}</Text>
|
25
|
28
|
</View>
|
26
|
29
|
);
|
27
|
30
|
}
|
28
|
|
-
|
|
31
|
+
|
29
|
32
|
onClickPush() {
|
30
|
33
|
Navigation.on(this.props.id).push({
|
31
|
34
|
name: 'navigation.playground.PushedScreen',
|
32
|
35
|
passProps: {
|
33
|
|
- stackPosition: this.getStackPosition() + 1
|
|
36
|
+ stackPosition: this.getStackPosition() + 1,
|
|
37
|
+ previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.id)
|
34
|
38
|
}
|
35
|
39
|
});
|
36
|
40
|
}
|
37
|
|
-
|
|
41
|
+
|
38
|
42
|
onClickPop() {
|
39
|
43
|
Navigation.on(this.props.id).pop();
|
40
|
44
|
}
|
41
|
|
-
|
|
45
|
+
|
|
46
|
+ onClickPopPrevious() {
|
|
47
|
+ Navigation.on(_.last(this.props.previousScreenIds)).pop();
|
|
48
|
+ }
|
|
49
|
+
|
42
|
50
|
getStackPosition() {
|
43
|
51
|
return this.props.stackPosition || 1;
|
44
|
52
|
}
|