|
@@ -8,6 +8,7 @@ import com.reactnativenavigation.params.ScreenParams;
|
8
|
8
|
import com.reactnativenavigation.params.TitleBarButtonParams;
|
9
|
9
|
import com.reactnativenavigation.params.TitleBarLeftButtonParams;
|
10
|
10
|
import com.reactnativenavigation.screens.ScreenStack;
|
|
11
|
+import com.reactnativenavigation.views.TitleBarBackButtonListener;
|
11
|
12
|
|
12
|
13
|
import java.util.List;
|
13
|
14
|
|
|
@@ -18,6 +19,12 @@ public class SingleScreenLayout extends FrameLayout implements Layout {
|
18
|
19
|
private final AppCompatActivity activity;
|
19
|
20
|
private final ScreenParams screenParams;
|
20
|
21
|
private ScreenStack stack;
|
|
22
|
+ private TitleBarBackButtonListener titleBarBackButtonListener;
|
|
23
|
+
|
|
24
|
+ public SingleScreenLayout(AppCompatActivity activity, ScreenParams screenParams, TitleBarBackButtonListener titleBarBackButtonListener) {
|
|
25
|
+ this(activity, screenParams);
|
|
26
|
+ this.titleBarBackButtonListener = titleBarBackButtonListener;
|
|
27
|
+ }
|
21
|
28
|
|
22
|
29
|
public SingleScreenLayout(AppCompatActivity activity, ScreenParams screenParams) {
|
23
|
30
|
super(activity);
|
|
@@ -48,6 +55,7 @@ public class SingleScreenLayout extends FrameLayout implements Layout {
|
48
|
55
|
@Override
|
49
|
56
|
public void destroy() {
|
50
|
57
|
stack.destroy();
|
|
58
|
+ removeView(stack);
|
51
|
59
|
}
|
52
|
60
|
|
53
|
61
|
@Override
|
|
@@ -97,9 +105,11 @@ public class SingleScreenLayout extends FrameLayout implements Layout {
|
97
|
105
|
}
|
98
|
106
|
|
99
|
107
|
@Override
|
100
|
|
- public void onTitleBarBackPress() {
|
101
|
|
- if (stack.canPop()) {
|
102
|
|
- stack.pop();
|
|
108
|
+ public boolean onTitleBarBackPress() {
|
|
109
|
+ if (titleBarBackButtonListener != null) {
|
|
110
|
+ return titleBarBackButtonListener.onTitleBarBackPress();
|
103
|
111
|
}
|
|
112
|
+
|
|
113
|
+ return onBackPressed();
|
104
|
114
|
}
|
105
|
115
|
}
|