Browse Source

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 years ago
parent
commit
b347104dba

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

36
     private static final String KEY_TOOL_BAR_COLOR = "toolBarColor";
36
     private static final String KEY_TOOL_BAR_COLOR = "toolBarColor";
37
     private static final String KEY_TOOL_BAR_HIDDEN = "navBarHidden";
37
     private static final String KEY_TOOL_BAR_HIDDEN = "navBarHidden";
38
     private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
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
     private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
41
     private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
42
     private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
42
     private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
43
     private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
43
     private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
58
     @Nullable public Boolean toolBarHidden;
58
     @Nullable public Boolean toolBarHidden;
59
     @Nullable @ColorInt public Integer statusBarColor;
59
     @Nullable @ColorInt public Integer statusBarColor;
60
     @Nullable @ColorInt public Integer navigationBarColor;
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
     @Nullable @ColorInt public Integer tabNormalTextColor;
63
     @Nullable @ColorInt public Integer tabNormalTextColor;
64
     @Nullable @ColorInt public Integer tabSelectedTextColor;
64
     @Nullable @ColorInt public Integer tabSelectedTextColor;
65
     @Nullable @ColorInt public Integer tabIndicatorColor;
65
     @Nullable @ColorInt public Integer tabIndicatorColor;
110
             toolBarHidden = getBoolean(style, KEY_TOOL_BAR_HIDDEN);
110
             toolBarHidden = getBoolean(style, KEY_TOOL_BAR_HIDDEN);
111
             statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
111
             statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
112
             navigationBarColor = getColor(style, KEY_NAVIGATION_BAR_COLOR);
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
             tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
115
             tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
116
             tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
116
             tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
117
             tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);
117
             tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);

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

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

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

16
     statusBarColor: '#303F9F',
16
     statusBarColor: '#303F9F',
17
     toolBarColor: '#3F51B5',
17
     toolBarColor: '#3F51B5',
18
     navigationBarColor: '#303F9F',
18
     navigationBarColor: '#303F9F',
19
-    buttonsTint: '#FFFFFF',
20
-    titleColor: '#FFFFFF',
21
     tabSelectedTextColor: '#FFA000',
19
     tabSelectedTextColor: '#FFA000',
22
     tabNormalTextColor: '#FFC107',
20
     tabNormalTextColor: '#FFC107',
23
     tabIndicatorColor: '#FFA000'
21
     tabIndicatorColor: '#FFA000'

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

16
     statusBarColor: '#303F9F',
16
     statusBarColor: '#303F9F',
17
     toolBarColor: '#3F51B5',
17
     toolBarColor: '#3F51B5',
18
     navigationBarColor: '#303F9F',
18
     navigationBarColor: '#303F9F',
19
-    buttonsTint: '#FFFFFF',
20
-    titleColor: '#FFFFFF',
21
     tabSelectedTextColor: '#FFA000',
19
     tabSelectedTextColor: '#FFA000',
22
     tabNormalTextColor: '#FFC107',
20
     tabNormalTextColor: '#FFC107',
23
     tabIndicatorColor: '#FF4081'
21
     tabIndicatorColor: '#FF4081'