Guy Carmeli 7 years ago
parent
commit
09fdf9a7e4

+ 3
- 4
android/app/src/main/java/com/reactnativenavigation/params/TitleBarLeftButtonParams.java View File

6
 
6
 
7
 public class TitleBarLeftButtonParams extends TitleBarButtonParams {
7
 public class TitleBarLeftButtonParams extends TitleBarButtonParams {
8
     @Nullable public MaterialMenuDrawable.IconState iconState;
8
     @Nullable public MaterialMenuDrawable.IconState iconState;
9
-    public boolean overrideBackPressInJs;
10
 
9
 
11
     public TitleBarLeftButtonParams(TitleBarButtonParams params) {
10
     public TitleBarLeftButtonParams(TitleBarButtonParams params) {
12
         icon = params.icon;
11
         icon = params.icon;
19
         return eventId.equals("back");
18
         return eventId.equals("back");
20
     }
19
     }
21
 
20
 
22
-    public boolean hasIcon() {
21
+    public boolean hasDefaultIcon() {
23
         return iconState != null;
22
         return iconState != null;
24
     }
23
     }
25
 
24
 
26
-    public void setOverrideBackPressInJs(boolean overrideBackPressInJs) {
27
-        this.overrideBackPressInJs = overrideBackPressInJs;
25
+    public boolean hasCustomIcon() {
26
+        return icon != null;
28
     }
27
     }
29
 }
28
 }

+ 15
- 3
android/app/src/main/java/com/reactnativenavigation/views/LeftButton.java View File

8
 import com.reactnativenavigation.NavigationApplication;
8
 import com.reactnativenavigation.NavigationApplication;
9
 import com.reactnativenavigation.params.TitleBarButtonParams;
9
 import com.reactnativenavigation.params.TitleBarButtonParams;
10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
10
 import com.reactnativenavigation.params.TitleBarLeftButtonParams;
11
+import com.reactnativenavigation.utils.ViewUtils;
11
 
12
 
12
 class LeftButton extends MaterialMenuDrawable implements View.OnClickListener {
13
 class LeftButton extends MaterialMenuDrawable implements View.OnClickListener {
13
 
14
 
64
 
65
 
65
     private void setInitialState() {
66
     private void setInitialState() {
66
         if (params != null) {
67
         if (params != null) {
67
-            setIconState(params.iconState);
68
+            if (params.iconState != null) {
69
+                setIconState(params.iconState);
70
+            }
68
         } else {
71
         } else {
69
             setVisible(false);
72
             setVisible(false);
70
         }
73
         }
71
     }
74
     }
72
 
75
 
76
+    @Override
77
+    public void setColor(int color) {
78
+        if (params.hasDefaultIcon()) {
79
+            super.setColor(color);
80
+        } else {
81
+            ViewUtils.tintDrawable(params.icon, color, true );
82
+        }
83
+    }
84
+
73
     private boolean isBackButton() {
85
     private boolean isBackButton() {
74
-        return getIconState() == IconState.ARROW;
86
+        return params.hasDefaultIcon() && getIconState() == IconState.ARROW;
75
     }
87
     }
76
 
88
 
77
     private boolean isSideMenuButton() {
89
     private boolean isSideMenuButton() {
78
-        return getIconState() == IconState.BURGER;
90
+        return params.hasDefaultIcon() && getIconState() == IconState.BURGER;
79
     }
91
     }
80
 
92
 
81
     private void sendClickEvent() {
93
     private void sendClickEvent() {

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java View File

61
         if (shouldSetLeftButton(leftButtonParams)) {
61
         if (shouldSetLeftButton(leftButtonParams)) {
62
             createAndSetLeftButton(leftButtonParams, leftButtonOnClickListener, navigatorEventId, overrideBackPressInJs);
62
             createAndSetLeftButton(leftButtonParams, leftButtonOnClickListener, navigatorEventId, overrideBackPressInJs);
63
         } else if (hasLeftButton()) {
63
         } else if (hasLeftButton()) {
64
-            if (leftButtonParams.hasIcon()) {
64
+            if (leftButtonParams.hasDefaultIcon()) {
65
                 updateLeftButton(leftButtonParams);
65
                 updateLeftButton(leftButtonParams);
66
             } else {
66
             } else {
67
                 removeLeftButton();
67
                 removeLeftButton();
164
     }
164
     }
165
 
165
 
166
     private boolean shouldSetLeftButton(TitleBarLeftButtonParams leftButtonParams) {
166
     private boolean shouldSetLeftButton(TitleBarLeftButtonParams leftButtonParams) {
167
-        return leftButton == null && leftButtonParams != null && leftButtonParams.iconState != null;
167
+        return leftButton == null && leftButtonParams != null && (leftButtonParams.hasDefaultIcon() || leftButtonParams.hasCustomIcon());
168
     }
168
     }
169
 
169
 
170
     private void createAndSetLeftButton(TitleBarLeftButtonParams leftButtonParams,
170
     private void createAndSetLeftButton(TitleBarLeftButtonParams leftButtonParams,