Quellcode durchsuchen

Add ability to set button colors individually on Android

Guy Carmeli vor 7 Jahren
Ursprung
Commit
11c27401ac

+ 6
- 1
android/app/src/main/java/com/reactnativenavigation/params/BaseTitleBarButtonParams.java Datei anzeigen

@@ -34,11 +34,16 @@ public class BaseTitleBarButtonParams {
34 34
     }
35 35
 
36 36
     private void setColorFromScreenStyle(StyleParams.Color titleBarButtonColor) {
37
-        if (titleBarButtonColor.hasColor()) {
37
+        if (titleBarButtonColor.hasColor() && shouldOverrideColorFromScreenStyle()) {
38 38
             color = titleBarButtonColor;
39 39
         }
40 40
     }
41 41
 
42
+    private boolean shouldOverrideColorFromScreenStyle() {
43
+        // Override color if no color is defined, or if the defined color was set by AppStyle
44
+        return !color.hasColor() || color == AppStyle.appStyle.titleBarButtonColor;
45
+    }
46
+
42 47
     public StyleParams.Color getColor() {
43 48
         if (enabled) {
44 49
             return color;

+ 12
- 0
src/deprecated/platformSpecificDeprecated.android.js Datei anzeigen

@@ -319,6 +319,9 @@ function navigatorSetButtons(navigator, navigatorEventID, _params) {
319 319
           button.icon = icon.uri;
320 320
         }
321 321
       }
322
+      if (button.buttonColor) {
323
+        button.color = processColor(button.buttonColor);
324
+      }
322 325
     });
323 326
   }
324 327
   let leftButton = getLeftButton(params);
@@ -329,6 +332,9 @@ function navigatorSetButtons(navigator, navigatorEventID, _params) {
329 332
         leftButton.icon = icon.uri;
330 333
       }
331 334
     }
335
+    if (leftButton.buttonColor) {
336
+      leftButton.color = processColor(leftButton.buttonColor);
337
+    }
332 338
   } else if (shouldRemoveLeftButton(params)) {
333 339
     leftButton = {};
334 340
   }
@@ -514,6 +520,9 @@ function addNavigatorButtons(screen, sideMenuParams) {
514 520
           button.icon = icon.uri;
515 521
         }
516 522
       }
523
+      if (button.buttonColor) {
524
+        button.color = processColor(button.buttonColor);
525
+      }
517 526
     });
518 527
   }
519 528
 
@@ -525,6 +534,9 @@ function addNavigatorButtons(screen, sideMenuParams) {
525 534
         leftButton.icon = icon.uri;
526 535
       }
527 536
     }
537
+    if (leftButton.buttonColor) {
538
+      leftButton.color = processColor(leftButton.buttonColor);
539
+    }
528 540
   }
529 541
 
530 542
   const fab = getFab(screen);