Browse Source

Added ability to specify font size for tab bar labels on Android (#2754)

* Added bottomTabFontSize and bottomTabSelectedFontSize properties for android tab bar

* Added tabFontSize and selectedTabFontSize properties to the doc

* Fix default values of bottomTabFontSize and bottomTabSelectedFontSize properties.
Alexey 6 years ago
parent
commit
993992daf7

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

152
     public Color bottomTabBadgeTextColor;
152
     public Color bottomTabBadgeTextColor;
153
     public Color bottomTabBadgeBackgroundColor;
153
     public Color bottomTabBadgeBackgroundColor;
154
     public Font bottomTabFontFamily;
154
     public Font bottomTabFontFamily;
155
+    public Integer bottomTabFontSize;
156
+    public Integer bottomTabSelectedFontSize;
155
 
157
 
156
     public Color navigationBarColor;
158
     public Color navigationBarColor;
157
 
159
 

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

102
         result.forceTitlesDisplay = getBoolean("forceTitlesDisplay", getDefaultForceTitlesDisplay());
102
         result.forceTitlesDisplay = getBoolean("forceTitlesDisplay", getDefaultForceTitlesDisplay());
103
 
103
 
104
         result.bottomTabFontFamily = getFont("bottomTabFontFamily", getDefaultBottomTabsFontFamily());
104
         result.bottomTabFontFamily = getFont("bottomTabFontFamily", getDefaultBottomTabsFontFamily());
105
+        result.bottomTabFontSize = getIntegerOrNull("bottomTabFontSize");
106
+        result.bottomTabSelectedFontSize = getIntegerOrNull("bottomTabSelectedFontSize");
105
 
107
 
106
         return result;
108
         return result;
107
     }
109
     }
125
         result.titleBarHideOnScroll = false;
127
         result.titleBarHideOnScroll = false;
126
         result.orientation = Orientation.auto;
128
         result.orientation = Orientation.auto;
127
         result.bottomTabFontFamily = new StyleParams.Font();
129
         result.bottomTabFontFamily = new StyleParams.Font();
130
+        result.bottomTabFontSize = 10;
131
+        result.bottomTabSelectedFontSize = 10;
128
         result.titleBarTitleFont = new StyleParams.Font();
132
         result.titleBarTitleFont = new StyleParams.Font();
129
         result.titleBarSubtitleFontFamily = new StyleParams.Font();
133
         result.titleBarSubtitleFontFamily = new StyleParams.Font();
130
         result.titleBarButtonFontFamily = new StyleParams.Font();
134
         result.titleBarButtonFontFamily = new StyleParams.Font();
361
         return params.containsKey(key) ? params.getInt(key) : defaultValue;
365
         return params.containsKey(key) ? params.getInt(key) : defaultValue;
362
     }
366
     }
363
 
367
 
368
+    private Integer getIntegerOrNull(String key) {
369
+        return params.containsKey(key) ? params.getInt(key) : null;
370
+    }
371
+
364
     private Bundle getBundle(String key) {
372
     private Bundle getBundle(String key) {
365
         return params.containsKey(key) ? params.getBundle(key) : Bundle.EMPTY;
373
         return params.containsKey(key) ? params.getBundle(key) : Bundle.EMPTY;
366
     }
374
     }

+ 7
- 0
android/app/src/main/java/com/reactnativenavigation/views/BottomTabs.java View File

26
         createVisibilityAnimator();
26
         createVisibilityAnimator();
27
         setStyle();
27
         setStyle();
28
         setFontFamily();
28
         setFontFamily();
29
+        setFontSize();
29
     }
30
     }
30
 
31
 
31
     public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
32
     public void addTabs(List<ScreenParams> params, OnTabSelectedListener onTabSelectedListener) {
156
             setTitleTypeface(AppStyle.appStyle.bottomTabFontFamily.get());
157
             setTitleTypeface(AppStyle.appStyle.bottomTabFontFamily.get());
157
         }
158
         }
158
     }
159
     }
160
+
161
+    private void setFontSize() {
162
+        if(AppStyle.appStyle.bottomTabSelectedFontSize != null &&  AppStyle.appStyle.bottomTabFontSize != null) {
163
+            setTitleTextSizeInSp(AppStyle.appStyle.bottomTabSelectedFontSize, AppStyle.appStyle.bottomTabFontSize);
164
+        }
165
+    }
159
 }
166
 }

+ 2
- 2
android/gradle/wrapper/gradle-wrapper.properties View File

1
-#Mon Sep 12 16:05:44 IDT 2016
1
+#Mon Feb 19 11:46:35 EET 2018
2
 distributionBase=GRADLE_USER_HOME
2
 distributionBase=GRADLE_USER_HOME
3
 distributionPath=wrapper/dists
3
 distributionPath=wrapper/dists
4
 zipStoreBase=GRADLE_USER_HOME
4
 zipStoreBase=GRADLE_USER_HOME
5
 zipStorePath=wrapper/dists
5
 zipStorePath=wrapper/dists
6
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
6
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

+ 3
- 1
docs/styling-the-tab-bar.md View File

38
     tabBarButtonColor: '#ffffff',
38
     tabBarButtonColor: '#ffffff',
39
     tabBarSelectedButtonColor: '#63d7cc',
39
     tabBarSelectedButtonColor: '#63d7cc',
40
     tabBarTranslucent: false,
40
     tabBarTranslucent: false,
41
-    tabFontFamily: 'Avenir-Medium'  // existing font family name or asset file without extension which can be '.ttf' or '.otf' (searched only if '.ttf' asset not found)
41
+    tabFontFamily: 'Avenir-Medium',  // existing font family name or asset file without extension which can be '.ttf' or '.otf' (searched only if '.ttf' asset not found)
42
+    tabFontSize: 10,
43
+    selectedTabFontSize: 12,
42
   },
44
   },
43
 ...
45
 ...
44
 }
46
 }

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

227
     bottomTabBadgeTextColor: processColor(originalStyleObject.bottomTabBadgeTextColor),
227
     bottomTabBadgeTextColor: processColor(originalStyleObject.bottomTabBadgeTextColor),
228
     bottomTabBadgeBackgroundColor: processColor(originalStyleObject.bottomTabBadgeBackgroundColor),
228
     bottomTabBadgeBackgroundColor: processColor(originalStyleObject.bottomTabBadgeBackgroundColor),
229
     bottomTabFontFamily: originalStyleObject.tabFontFamily,
229
     bottomTabFontFamily: originalStyleObject.tabFontFamily,
230
+    bottomTabFontSize: originalStyleObject.tabFontSize,
231
+    bottomTabSelectedFontSize: originalStyleObject.selectedTabFontSize,
230
 
232
 
231
     navigationBarColor: processColor(originalStyleObject.navigationBarColor)
233
     navigationBarColor: processColor(originalStyleObject.navigationBarColor)
232
   };
234
   };