Browse Source

Add font size support on title bar for android (#1493)

* Add font family support on bottom tabs

* import missing classes

* import missing class

* update document

* Support customize icon for left nav button in android

* Add navBar navBarTextFontSize support for android
Jing Tai Piao 7 years ago
parent
commit
cff9e145a6

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java View File

93
     public Color titleBarButtonColor;
93
     public Color titleBarButtonColor;
94
     public Color titleBarDisabledButtonColor;
94
     public Color titleBarDisabledButtonColor;
95
     public Font titleBarTitleFont;
95
     public Font titleBarTitleFont;
96
+    public int titleBarTitleFontSize;
96
     public boolean titleBarTitleTextCentered;
97
     public boolean titleBarTitleTextCentered;
97
     public boolean backButtonHidden;
98
     public boolean backButtonHidden;
98
 
99
 

+ 5
- 0
android/app/src/main/java/com/reactnativenavigation/params/parsers/StyleParamsParser.java View File

49
         result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
49
         result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
50
         result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
50
         result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
51
         result.titleBarTitleFont = getFont("titleBarTitleFontFamily", getDefaultTitleTextFontFamily());
51
         result.titleBarTitleFont = getFont("titleBarTitleFontFamily", getDefaultTitleTextFontFamily());
52
+        result.titleBarTitleFontSize = getInt("titleBarTitleFontSize", getDefaultTitleTextFontSize());
52
         result.titleBarTitleTextCentered = getBoolean("titleBarTitleTextCentered", getDefaultTitleBarTextCentered());
53
         result.titleBarTitleTextCentered = getBoolean("titleBarTitleTextCentered", getDefaultTitleBarTextCentered());
53
         result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
54
         result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
54
         result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
55
         result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
243
         return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarTitleFont;
244
         return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarTitleFont;
244
     }
245
     }
245
 
246
 
247
+    private int getDefaultTitleTextFontSize() {
248
+        return AppStyle.appStyle == null ? -1 : AppStyle.appStyle.titleBarTitleFontSize;
249
+    }
250
+
246
     private boolean getDefaultTitleBarTextCentered() {
251
     private boolean getDefaultTitleBarTextCentered() {
247
         return AppStyle.appStyle != null && AppStyle.appStyle.titleBarTitleTextCentered;
252
         return AppStyle.appStyle != null && AppStyle.appStyle.titleBarTitleTextCentered;
248
     }
253
     }

+ 11
- 0
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java View File

75
         setVisibility(params.titleBarHidden);
75
         setVisibility(params.titleBarHidden);
76
         setTitleTextColor(params);
76
         setTitleTextColor(params);
77
         setTitleTextFont(params);
77
         setTitleTextFont(params);
78
+        setTitleTextFontSize(params);
78
         setSubtitleTextColor(params);
79
         setSubtitleTextColor(params);
79
         colorOverflowButton(params);
80
         colorOverflowButton(params);
80
         setBackground(params);
81
         setBackground(params);
149
         }
150
         }
150
     }
151
     }
151
 
152
 
153
+    protected void setTitleTextFontSize(StyleParams params) {
154
+        if (params.titleBarTitleFontSize == -1) {
155
+            return;
156
+        }
157
+        View titleView = getTitleView();
158
+        if (titleView instanceof TextView) {
159
+            ((TextView) titleView).setTextSize(((float) params.titleBarTitleFontSize));
160
+        }
161
+    }
162
+
152
     protected void setSubtitleTextColor(StyleParams params) {
163
     protected void setSubtitleTextColor(StyleParams params) {
153
         if (params.titleBarSubtitleColor.hasColor()) {
164
         if (params.titleBarSubtitleColor.hasColor()) {
154
             setSubtitleTextColor(params.titleBarSubtitleColor.getColor());
165
             setSubtitleTextColor(params.titleBarSubtitleColor.getColor());

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

155
     titleBarButtonColor: processColor(originalStyleObject.navBarButtonColor),
155
     titleBarButtonColor: processColor(originalStyleObject.navBarButtonColor),
156
     titleBarDisabledButtonColor: processColor(originalStyleObject.titleBarDisabledButtonColor),
156
     titleBarDisabledButtonColor: processColor(originalStyleObject.titleBarDisabledButtonColor),
157
     titleBarTitleFontFamily: originalStyleObject.navBarTextFontFamily,
157
     titleBarTitleFontFamily: originalStyleObject.navBarTextFontFamily,
158
+    titleBarTitleFontSize: originalStyleObject.navBarTextFontSize,
158
     titleBarTitleTextCentered: originalStyleObject.navBarTitleTextCentered,
159
     titleBarTitleTextCentered: originalStyleObject.navBarTitleTextCentered,
159
     backButtonHidden: originalStyleObject.backButtonHidden,
160
     backButtonHidden: originalStyleObject.backButtonHidden,
160
     topTabsHidden: originalStyleObject.topTabsHidden,
161
     topTabsHidden: originalStyleObject.topTabsHidden,