Browse Source

Add ability to set button colors individually on Android

Guy Carmeli 7 years ago
parent
commit
11c27401ac

+ 6
- 1
android/app/src/main/java/com/reactnativenavigation/params/BaseTitleBarButtonParams.java View File

34
     }
34
     }
35
 
35
 
36
     private void setColorFromScreenStyle(StyleParams.Color titleBarButtonColor) {
36
     private void setColorFromScreenStyle(StyleParams.Color titleBarButtonColor) {
37
-        if (titleBarButtonColor.hasColor()) {
37
+        if (titleBarButtonColor.hasColor() && shouldOverrideColorFromScreenStyle()) {
38
             color = titleBarButtonColor;
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
     public StyleParams.Color getColor() {
47
     public StyleParams.Color getColor() {
43
         if (enabled) {
48
         if (enabled) {
44
             return color;
49
             return color;

+ 12
- 0
src/deprecated/platformSpecificDeprecated.android.js View File

319
           button.icon = icon.uri;
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
   let leftButton = getLeftButton(params);
327
   let leftButton = getLeftButton(params);
329
         leftButton.icon = icon.uri;
332
         leftButton.icon = icon.uri;
330
       }
333
       }
331
     }
334
     }
335
+    if (leftButton.buttonColor) {
336
+      leftButton.color = processColor(leftButton.buttonColor);
337
+    }
332
   } else if (shouldRemoveLeftButton(params)) {
338
   } else if (shouldRemoveLeftButton(params)) {
333
     leftButton = {};
339
     leftButton = {};
334
   }
340
   }
514
           button.icon = icon.uri;
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
         leftButton.icon = icon.uri;
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
   const fab = getFab(screen);
542
   const fab = getFab(screen);