Browse Source

Support fontSize and selectedFontSize options on Android

Guy Carmeli 6 years ago
parent
commit
3fd183a51b

+ 3
- 1
docs/docs/styling.md View File

224
   },
224
   },
225
   bottomTabs: {
225
   bottomTabs: {
226
     titleDisplayMode: 'alwaysShow' | 'showWhenActive' | 'alwaysHide' // Sets the title state for each tab.
226
     titleDisplayMode: 'alwaysShow' | 'showWhenActive' | 'alwaysHide' // Sets the title state for each tab.
227
-  }
227
+  },
228
+  bottomTab: {
229
+    selectedFontSize: 19 // Selected tab font size in sp
228
 }
230
 }
229
 ```
231
 ```
230
 
232
 

+ 1
- 1
lib/android/app/build.gradle View File

72
     implementation 'com.android.support:design:26.1.0'
72
     implementation 'com.android.support:design:26.1.0'
73
     implementation 'com.android.support:appcompat-v7:26.1.0'
73
     implementation 'com.android.support:appcompat-v7:26.1.0'
74
     implementation 'com.android.support:support-v4:26.1.0'
74
     implementation 'com.android.support:support-v4:26.1.0'
75
-    implementation 'com.github.wix-playground:ahbottomnavigation:2.4.3'
75
+    implementation 'com.github.wix-playground:ahbottomnavigation:2.4.5'
76
 
76
 
77
     implementation 'com.github.clans:fab:1.6.4'
77
     implementation 'com.github.clans:fab:1.6.4'
78
 
78
 

+ 11
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabOptions.java View File

5
 
5
 
6
 import com.reactnativenavigation.parse.params.Color;
6
 import com.reactnativenavigation.parse.params.Color;
7
 import com.reactnativenavigation.parse.params.NullColor;
7
 import com.reactnativenavigation.parse.params.NullColor;
8
+import com.reactnativenavigation.parse.params.NullNumber;
8
 import com.reactnativenavigation.parse.params.NullText;
9
 import com.reactnativenavigation.parse.params.NullText;
10
+import com.reactnativenavigation.parse.params.Number;
9
 import com.reactnativenavigation.parse.params.Text;
11
 import com.reactnativenavigation.parse.params.Text;
10
 import com.reactnativenavigation.parse.parsers.ColorParser;
12
 import com.reactnativenavigation.parse.parsers.ColorParser;
13
+import com.reactnativenavigation.parse.parsers.NumberParser;
11
 import com.reactnativenavigation.parse.parsers.TextParser;
14
 import com.reactnativenavigation.parse.parsers.TextParser;
12
 import com.reactnativenavigation.utils.TypefaceLoader;
15
 import com.reactnativenavigation.utils.TypefaceLoader;
13
 
16
 
28
         options.badge = TextParser.parse(json, "badge");
31
         options.badge = TextParser.parse(json, "badge");
29
         options.testId = TextParser.parse(json, "testID");
32
         options.testId = TextParser.parse(json, "testID");
30
         options.fontFamily = typefaceManager.getTypeFace(json.optString("fontFamily", ""));
33
         options.fontFamily = typefaceManager.getTypeFace(json.optString("fontFamily", ""));
34
+        options.fontSize = NumberParser.parse(json, "fontSize");
35
+        options.selectedFontSize = NumberParser.parse(json, "selectedFontSize");
31
         return options;
36
         return options;
32
     }
37
     }
33
 
38
 
39
     public Color selectedIconColor = new NullColor();
44
     public Color selectedIconColor = new NullColor();
40
     public Text testId = new NullText();
45
     public Text testId = new NullText();
41
     public Text badge = new NullText();
46
     public Text badge = new NullText();
47
+    public Number fontSize = new NullNumber();
48
+    public Number selectedFontSize = new NullNumber();
42
     @Nullable public Typeface fontFamily;
49
     @Nullable public Typeface fontFamily;
43
 
50
 
44
 
51
 
51
         if (other.selectedIconColor.hasValue()) selectedIconColor = other.selectedIconColor;
58
         if (other.selectedIconColor.hasValue()) selectedIconColor = other.selectedIconColor;
52
         if (other.badge.hasValue()) badge = other.badge;
59
         if (other.badge.hasValue()) badge = other.badge;
53
         if (other.testId.hasValue()) testId = other.testId;
60
         if (other.testId.hasValue()) testId = other.testId;
61
+        if (other.fontSize.hasValue()) fontSize = other.fontSize;
62
+        if (other.selectedFontSize.hasValue()) selectedFontSize = other.selectedFontSize;
54
         if (other.fontFamily != null) fontFamily = other.fontFamily;
63
         if (other.fontFamily != null) fontFamily = other.fontFamily;
55
     }
64
     }
56
 
65
 
62
         if (!iconColor.hasValue()) iconColor = defaultOptions.iconColor;
71
         if (!iconColor.hasValue()) iconColor = defaultOptions.iconColor;
63
         if (!selectedIconColor.hasValue()) selectedIconColor = defaultOptions.selectedIconColor;
72
         if (!selectedIconColor.hasValue()) selectedIconColor = defaultOptions.selectedIconColor;
64
         if (!badge.hasValue()) badge = defaultOptions.badge;
73
         if (!badge.hasValue()) badge = defaultOptions.badge;
74
+        if (!fontSize.hasValue()) fontSize = defaultOptions.fontSize;
75
+        if (!selectedFontSize.hasValue()) selectedFontSize = defaultOptions.selectedFontSize;
65
         if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
76
         if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
66
     }
77
     }
67
 }
78
 }

+ 9
- 7
lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabOptionsPresenter.java View File

39
 
39
 
40
     public void present() {
40
     public void present() {
41
         for (int i = 0; i < tabs.size(); i++) {
41
         for (int i = 0; i < tabs.size(); i++) {
42
-            BottomTabOptions bottomTab = tabs.get(i).options.copy().withDefaultOptions(defaultOptions).bottomTabOptions;
43
-            bottomTabs.setBadge(i, bottomTab.badge.get(""));
44
-            bottomTabs.setTitleTypeface(i, bottomTab.fontFamily);
45
-            bottomTabs.setIconActiveColor(i, bottomTab.selectedIconColor.get(null));
46
-            bottomTabs.setIconInactiveColor(i, bottomTab.iconColor.get(null));
47
-            bottomTabs.setTitleActiveColor(i, bottomTab.selectedTextColor.get(null));
48
-            bottomTabs.setTitleInactiveColor(i, bottomTab.textColor.get(null));
42
+            BottomTabOptions tab = tabs.get(i).options.copy().withDefaultOptions(defaultOptions).bottomTabOptions;
43
+            bottomTabs.setBadge(i, tab.badge.get(""));
44
+            bottomTabs.setTitleTypeface(i, tab.fontFamily);
45
+            bottomTabs.setIconActiveColor(i, tab.selectedIconColor.get(null));
46
+            bottomTabs.setIconInactiveColor(i, tab.iconColor.get(null));
47
+            bottomTabs.setTitleActiveColor(i, tab.selectedTextColor.get(null));
48
+            bottomTabs.setTitleInactiveColor(i, tab.textColor.get(null));
49
+            bottomTabs.setTitleInactiveTextSizeInSp(i, tab.fontSize.hasValue() ? Float.valueOf(tab.fontSize.get()) : null);
50
+            bottomTabs.setTitleActiveTextSizeInSp(i, tab.selectedFontSize.hasValue() ? Float.valueOf(tab.selectedFontSize.get()) : null);
49
         }
51
         }
50
     }
52
     }
51
 
53