Преглед на файлове

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

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/presentation/StackOptionsPresenter.java Целия файл

138
     private void mergeButtons(TopBarButtons buttons) {
138
     private void mergeButtons(TopBarButtons buttons) {
139
         if (buttons.left != null) topBar.setLeftButtons(buttons.left);
139
         if (buttons.left != null) topBar.setLeftButtons(buttons.left);
140
         if (buttons.right != null) topBar.setRightButtons(buttons.right);
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
     private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {
144
     private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {