Browse Source

Get color from screen when adding TitleBar buttons

Guy Carmeli 8 years ago
parent
commit
84bce86fb2

+ 13
- 5
android/app/src/main/java/com/reactnativenavigation/screens/Screen.java View File

@@ -48,9 +48,17 @@ public abstract class Screen extends RelativeLayout {
48 48
     protected abstract void createContent();
49 49
 
50 50
     private void createTitleBar() {
51
+        addTitleBarButtons();
52
+        topBar.setTitle(screenParams.title);
53
+    }
54
+
55
+    private void addTitleBarButtons() {
56
+        setButtonColorFromScreen(screenParams.rightButtons);
57
+        if (screenParams.leftButton != null) {
58
+            screenParams.leftButton.setColorFromScreenStyle(screenParams.styleParams.titleBarButtonColor);
59
+        }
51 60
         topBar.addTitleBarAndSetButtons(screenParams.rightButtons, screenParams.leftButton,
52 61
                 titleBarBackButtonListener, screenParams.navigatorEventId);
53
-        topBar.setTitle(screenParams.title);
54 62
     }
55 63
 
56 64
     private void createTopBar() {
@@ -117,7 +125,7 @@ public abstract class Screen extends RelativeLayout {
117 125
     }
118 126
 
119 127
     public void setTopBarVisible(boolean visible, boolean animate) {
120
-//        topBarVisibilityAnimator.setVisible(visible, animate); TODO
128
+        //        topBarVisibilityAnimator.setVisible(visible, animate); TODO
121 129
     }
122 130
 
123 131
     public void setTitleBarTitle(String title) {
@@ -138,9 +146,9 @@ public abstract class Screen extends RelativeLayout {
138 146
         return screenParams.styleParams;
139 147
     }
140 148
 
141
-    private void setButtonColorFromScreen(List<TitleBarButtonParams> titleBarButtonParamses) {
142
-        for (TitleBarButtonParams titleBarButtonParamse : titleBarButtonParamses) {
143
-            titleBarButtonParamse.setColorFromScreenStyle(screenParams.styleParams.titleBarButtonColor);
149
+    private void setButtonColorFromScreen(List<TitleBarButtonParams> titleBarButtonParams) {
150
+        for (TitleBarButtonParams titleBarButtonParam : titleBarButtonParams) {
151
+            titleBarButtonParam.setColorFromScreenStyle(screenParams.styleParams.titleBarButtonColor);
144 152
         }
145 153
     }
146 154
 }