Browse Source

Fix back button color not getting set in ContextualMenu

Guy Carmeli 8 years ago
parent
commit
c9a71d8d0e

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/params/ContextualMenuParams.java View File

9
 
9
 
10
     public void setButtonsColor(StyleParams.Color buttonColor) {
10
     public void setButtonsColor(StyleParams.Color buttonColor) {
11
         for (ContextualMenuButtonParams button : buttons) {
11
         for (ContextualMenuButtonParams button : buttons) {
12
-            button.setColorFromScreenStyle(buttonColor);
12
+            button.color = buttonColor;
13
         }
13
         }
14
-        leftButton.setColorFromScreenStyle(buttonColor);
14
+        leftButton.color = buttonColor;
15
     }
15
     }
16
 }
16
 }

+ 1
- 2
android/app/src/main/java/com/reactnativenavigation/screens/Screen.java View File

214
     }
214
     }
215
 
215
 
216
     public void showContextualMenu(ContextualMenuParams params, Callback onButtonClicked) {
216
     public void showContextualMenu(ContextualMenuParams params, Callback onButtonClicked) {
217
-        params.setButtonsColor(styleParams.contextualMenuButtonsColor);
218
-        topBar.showContextualMenu(params, styleParams.contextualMenuBackgroundColor, onButtonClicked);
217
+        topBar.showContextualMenu(params, styleParams, onButtonClicked);
219
         setStatusBarColor(styleParams.contextualMenuStatusBarColor);
218
         setStatusBarColor(styleParams.contextualMenuStatusBarColor);
220
     }
219
     }
221
 
220
 

+ 12
- 9
android/app/src/main/java/com/reactnativenavigation/views/ContextualMenu.java View File

15
 import java.util.List;
15
 import java.util.List;
16
 
16
 
17
 public class ContextualMenu extends TitleBar implements LeftButtonOnClickListener, ContextualMenuButton.ContextualButtonClickListener {
17
 public class ContextualMenu extends TitleBar implements LeftButtonOnClickListener, ContextualMenuButton.ContextualButtonClickListener {
18
+    private ContextualMenuParams params;
18
     private Callback onButtonClicked;
19
     private Callback onButtonClicked;
19
     private final String navigatorEventId;
20
     private final String navigatorEventId;
20
 
21
 
21
-    public ContextualMenu(Context context, ContextualMenuParams params, StyleParams.Color contextualMenuBackgroundColor, Callback onButtonClicked) {
22
+    public ContextualMenu(Context context, ContextualMenuParams params, StyleParams styleParams, Callback onButtonClicked) {
22
         super(context);
23
         super(context);
24
+        this.params = params;
23
         this.onButtonClicked = onButtonClicked;
25
         this.onButtonClicked = onButtonClicked;
24
         navigatorEventId = params.navigationParams.navigatorEventId;
26
         navigatorEventId = params.navigationParams.navigatorEventId;
25
-        setStyle(contextualMenuBackgroundColor);
26
-        setButtons(params.buttons, params.leftButton);
27
+        setStyle(styleParams);
28
+        setButtons();
27
     }
29
     }
28
 
30
 
29
-    public void setStyle(StyleParams.Color contextualMenuBackgroundColor) {
30
-        if (contextualMenuBackgroundColor.hasColor()) {
31
-            setBackgroundColor(contextualMenuBackgroundColor.getColor());
31
+    public void setStyle(StyleParams styleParams) {
32
+        params.setButtonsColor(styleParams.contextualMenuButtonsColor);
33
+        if (styleParams.contextualMenuBackgroundColor.hasColor()) {
34
+            setBackgroundColor(styleParams.contextualMenuBackgroundColor.getColor());
32
         }
35
         }
33
     }
36
     }
34
 
37
 
35
-    public void setButtons(List<ContextualMenuButtonParams> buttons, TitleBarLeftButtonParams leftButton) {
36
-        addButtonsToContextualMenu(buttons, getMenu());
37
-        setBackButton(leftButton);
38
+    public void setButtons() {
39
+        addButtonsToContextualMenu(params.buttons, getMenu());
40
+        setBackButton(params.leftButton);
38
     }
41
     }
39
 
42
 
40
     private void setBackButton(TitleBarLeftButtonParams leftButton) {
43
     private void setBackButton(TitleBarLeftButtonParams leftButton) {

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

103
         topTabs.setSelectedTabIndicatorStyle(style);
103
         topTabs.setSelectedTabIndicatorStyle(style);
104
     }
104
     }
105
 
105
 
106
-    public void showContextualMenu(final ContextualMenuParams params, StyleParams.Color contextualMenuBackgroundColor, Callback onButtonClicked) {
107
-        contextualMenu = new ContextualMenu(getContext(), params, contextualMenuBackgroundColor, onButtonClicked);
106
+    public void showContextualMenu(final ContextualMenuParams params, StyleParams styleParams, Callback onButtonClicked) {
107
+        contextualMenu = new ContextualMenu(getContext(), params, styleParams, onButtonClicked);
108
         titleBarAndContextualMenuContainer.addView(contextualMenu, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
108
         titleBarAndContextualMenuContainer.addView(contextualMenu, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
109
         ViewUtils.runOnPreDraw(contextualMenu, new Runnable() {
109
         ViewUtils.runOnPreDraw(contextualMenu, new Runnable() {
110
             @Override
110
             @Override