Procházet zdrojové kódy

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 před 7 roky
rodič
revize
cff9e145a6

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java Zobrazit soubor

@@ -93,6 +93,7 @@ public class StyleParams {
93 93
     public Color titleBarButtonColor;
94 94
     public Color titleBarDisabledButtonColor;
95 95
     public Font titleBarTitleFont;
96
+    public int titleBarTitleFontSize;
96 97
     public boolean titleBarTitleTextCentered;
97 98
     public boolean backButtonHidden;
98 99
 

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

@@ -49,6 +49,7 @@ public class StyleParamsParser {
49 49
         result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
50 50
         result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
51 51
         result.titleBarTitleFont = getFont("titleBarTitleFontFamily", getDefaultTitleTextFontFamily());
52
+        result.titleBarTitleFontSize = getInt("titleBarTitleFontSize", getDefaultTitleTextFontSize());
52 53
         result.titleBarTitleTextCentered = getBoolean("titleBarTitleTextCentered", getDefaultTitleBarTextCentered());
53 54
         result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
54 55
         result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
@@ -243,6 +244,10 @@ public class StyleParamsParser {
243 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 251
     private boolean getDefaultTitleBarTextCentered() {
247 252
         return AppStyle.appStyle != null && AppStyle.appStyle.titleBarTitleTextCentered;
248 253
     }

+ 11
- 0
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Zobrazit soubor

@@ -75,6 +75,7 @@ public class TitleBar extends Toolbar {
75 75
         setVisibility(params.titleBarHidden);
76 76
         setTitleTextColor(params);
77 77
         setTitleTextFont(params);
78
+        setTitleTextFontSize(params);
78 79
         setSubtitleTextColor(params);
79 80
         colorOverflowButton(params);
80 81
         setBackground(params);
@@ -149,6 +150,16 @@ public class TitleBar extends Toolbar {
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 163
     protected void setSubtitleTextColor(StyleParams params) {
153 164
         if (params.titleBarSubtitleColor.hasColor()) {
154 165
             setSubtitleTextColor(params.titleBarSubtitleColor.getColor());

+ 1
- 0
src/deprecated/platformSpecificDeprecated.android.js Zobrazit soubor

@@ -155,6 +155,7 @@ function convertStyleParams(originalStyleObject) {
155 155
     titleBarButtonColor: processColor(originalStyleObject.navBarButtonColor),
156 156
     titleBarDisabledButtonColor: processColor(originalStyleObject.titleBarDisabledButtonColor),
157 157
     titleBarTitleFontFamily: originalStyleObject.navBarTextFontFamily,
158
+    titleBarTitleFontSize: originalStyleObject.navBarTextFontSize,
158 159
     titleBarTitleTextCentered: originalStyleObject.navBarTitleTextCentered,
159 160
     backButtonHidden: originalStyleObject.backButtonHidden,
160 161
     topTabsHidden: originalStyleObject.topTabsHidden,