Procházet zdrojové kódy

Fix back button color not getting set in ContextualMenu

Guy Carmeli před 8 roky
rodič
revize
c9a71d8d0e

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/params/ContextualMenuParams.java Zobrazit soubor

@@ -9,8 +9,8 @@ public class ContextualMenuParams {
9 9
 
10 10
     public void setButtonsColor(StyleParams.Color buttonColor) {
11 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 Zobrazit soubor

@@ -214,8 +214,7 @@ public abstract class Screen extends RelativeLayout implements Subscriber {
214 214
     }
215 215
 
216 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 218
         setStatusBarColor(styleParams.contextualMenuStatusBarColor);
220 219
     }
221 220
 

+ 12
- 9
android/app/src/main/java/com/reactnativenavigation/views/ContextualMenu.java Zobrazit soubor

@@ -15,26 +15,29 @@ import com.reactnativenavigation.params.TitleBarLeftButtonParams;
15 15
 import java.util.List;
16 16
 
17 17
 public class ContextualMenu extends TitleBar implements LeftButtonOnClickListener, ContextualMenuButton.ContextualButtonClickListener {
18
+    private ContextualMenuParams params;
18 19
     private Callback onButtonClicked;
19 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 23
         super(context);
24
+        this.params = params;
23 25
         this.onButtonClicked = onButtonClicked;
24 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 43
     private void setBackButton(TitleBarLeftButtonParams leftButton) {

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/TopBar.java Zobrazit soubor

@@ -103,8 +103,8 @@ public class TopBar extends AppBarLayout {
103 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 108
         titleBarAndContextualMenuContainer.addView(contextualMenu, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
109 109
         ViewUtils.runOnPreDraw(contextualMenu, new Runnable() {
110 110
             @Override