Sfoglia il codice sorgente

Use iOS properties when styling Toolbar on Android

* Use navBarButtonColor to tint Toolbar instead of buttonsTint

* Use navBarTextColor to tint Toolbar instead of titleColor
Guy Carmeli 8 anni fa
parent
commit
b347104dba

+ 6
- 6
android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java Vedi File

@@ -36,8 +36,8 @@ public class Screen extends JsonObject implements Serializable {
36 36
     private static final String KEY_TOOL_BAR_COLOR = "toolBarColor";
37 37
     private static final String KEY_TOOL_BAR_HIDDEN = "navBarHidden";
38 38
     private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
39
-    private static final String KEY_BUTTONS_TINT_COLOR = "buttonsTint";
40
-    private static final String KEY_TITLE_COLOR = "titleColor";
39
+    private static final String KEY_NAV_BAR_BUTTON_COLOR = "navBarButtonColor";
40
+    private static final String KEY_NAV_BAR_TEXT_COLOR = "navBarTextColor";
41 41
     private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
42 42
     private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
43 43
     private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
@@ -58,8 +58,8 @@ public class Screen extends JsonObject implements Serializable {
58 58
     @Nullable public Boolean toolBarHidden;
59 59
     @Nullable @ColorInt public Integer statusBarColor;
60 60
     @Nullable @ColorInt public Integer navigationBarColor;
61
-    @Nullable @ColorInt public Integer buttonsTintColor;
62
-    @Nullable @ColorInt public Integer titleColor;
61
+    @Nullable @ColorInt public Integer navBarButtonColor;
62
+    @Nullable @ColorInt public Integer navBarTextColor;
63 63
     @Nullable @ColorInt public Integer tabNormalTextColor;
64 64
     @Nullable @ColorInt public Integer tabSelectedTextColor;
65 65
     @Nullable @ColorInt public Integer tabIndicatorColor;
@@ -110,8 +110,8 @@ public class Screen extends JsonObject implements Serializable {
110 110
             toolBarHidden = getBoolean(style, KEY_TOOL_BAR_HIDDEN);
111 111
             statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
112 112
             navigationBarColor = getColor(style, KEY_NAVIGATION_BAR_COLOR);
113
-            buttonsTintColor = getColor(style, KEY_BUTTONS_TINT_COLOR);
114
-            titleColor = getColor(style, KEY_TITLE_COLOR);
113
+            navBarButtonColor = getColor(style, KEY_NAV_BAR_BUTTON_COLOR);
114
+            navBarTextColor = getColor(style, KEY_NAV_BAR_TEXT_COLOR);
115 115
             tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
116 116
             tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
117 117
             tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);

+ 5
- 5
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java Vedi File

@@ -75,8 +75,8 @@ public class RnnToolBar extends Toolbar {
75 75
             resetBackground();
76 76
         }
77 77
 
78
-        if (screen.titleColor != null) {
79
-            setTitleTextColor(screen.titleColor);
78
+        if (screen.navBarTextColor != null) {
79
+            setTitleTextColor(screen.navBarTextColor);
80 80
         } else {
81 81
             resetTitleTextColor();
82 82
         }
@@ -138,11 +138,11 @@ public class RnnToolBar extends Toolbar {
138 138
     private Drawable setupBackButton(Screen screen) {
139 139
         Resources resources = getResources();
140 140
         final Drawable backButton;
141
-        if (screen.buttonsTintColor != null) {
141
+        if (screen.navBarButtonColor != null) {
142 142
             backButton = ResourcesCompat.getDrawable(resources,
143 143
                     R.drawable.abc_ic_ab_back_mtrl_am_alpha,
144 144
                     null);
145
-            ImageUtils.tint(backButton, screen.buttonsTintColor);
145
+            ImageUtils.tint(backButton, screen.navBarButtonColor);
146 146
         } else {
147 147
             backButton = ResourcesCompat.getDrawable(resources,
148 148
                     R.drawable.abc_ic_ab_back_mtrl_am_alpha,
@@ -184,7 +184,7 @@ public class RnnToolBar extends Toolbar {
184 184
             mToolbarWR = new WeakReference<>(toolBar);
185 185
             mOldButtons = oldScreen == null ? null : oldScreen.getButtons();
186 186
             mNewButtons = newScreen.getButtons();
187
-            mTintColor = newScreen.buttonsTintColor;
187
+            mTintColor = newScreen.navBarButtonColor;
188 188
             mIconDimensions = (int) (toolBar.getHeight() * 0.4f);
189 189
         }
190 190
 

+ 0
- 2
example-redux/src/screens/FirstTabScreen.js Vedi File

@@ -16,8 +16,6 @@ class FirstTabScreen extends Component {
16 16
     statusBarColor: '#303F9F',
17 17
     toolBarColor: '#3F51B5',
18 18
     navigationBarColor: '#303F9F',
19
-    buttonsTint: '#FFFFFF',
20
-    titleColor: '#FFFFFF',
21 19
     tabSelectedTextColor: '#FFA000',
22 20
     tabNormalTextColor: '#FFC107',
23 21
     tabIndicatorColor: '#FFA000'

+ 0
- 2
example-redux/src/screens/PushedScreen.js Vedi File

@@ -16,8 +16,6 @@ class PushedScreen extends Component {
16 16
     statusBarColor: '#303F9F',
17 17
     toolBarColor: '#3F51B5',
18 18
     navigationBarColor: '#303F9F',
19
-    buttonsTint: '#FFFFFF',
20
-    titleColor: '#FFFFFF',
21 19
     tabSelectedTextColor: '#FFA000',
22 20
     tabNormalTextColor: '#FFC107',
23 21
     tabIndicatorColor: '#FF4081'