瀏覽代碼

Merge back button only if it's defined explicitly

Guy Carmeli 6 年之前
父節點
當前提交
e5ce3151b0

+ 7
- 1
lib/android/app/src/main/java/com/reactnativenavigation/parse/BackButton.java 查看文件

@@ -15,6 +15,7 @@ public class BackButton extends Button {
15 15
         BackButton result = new BackButton();
16 16
         if (json == null) return result;
17 17
 
18
+        result.hasValue = true;
18 19
         result.visible = BoolParser.parse(json, "visible");
19 20
         if (json.has("icon")) result.icon = TextParser.parse(json.optJSONObject("icon"), "uri");
20 21
         result.id = json.optString("id", Constants.BACK_BUTTON_ID);
@@ -27,11 +28,16 @@ public class BackButton extends Button {
27 28
         return result;
28 29
     }
29 30
 
30
-    public BackButton() {
31
+    BackButton() {
31 32
         id = Constants.BACK_BUTTON_ID;
32 33
     }
33 34
 
34 35
     public Bool visible = new NullBool();
36
+    private boolean hasValue;
37
+
38
+    public boolean hasValue() {
39
+        return hasValue;
40
+    }
35 41
 
36 42
     public void mergeWith(BackButton other) {
37 43
         if (other.icon.hasValue()) icon = other.icon;

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/presentation/StackOptionsPresenter.java 查看文件

@@ -138,7 +138,7 @@ public class StackOptionsPresenter {
138 138
     private void mergeButtons(TopBarButtons buttons) {
139 139
         if (buttons.left != null) topBar.setLeftButtons(buttons.left);
140 140
         if (buttons.right != null) topBar.setRightButtons(buttons.right);
141
-        if (buttons.back != null) topBar.setBackButton(buttons.back);
141
+        if (buttons.back.hasValue()) topBar.setBackButton(buttons.back);
142 142
     }
143 143
 
144 144
     private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {