Browse Source

Support setting button font family on Android

Until now, buttons would use the same font family used by the title,
this commit introduces navBarButtonFontFamily property which allows to set
a different font family for title and buttons.
Guy Carmeli 7 years ago
parent
commit
a3b4caf707

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

115
     public boolean titleBarTitleTextCentered;
115
     public boolean titleBarTitleTextCentered;
116
     public int titleBarHeight;
116
     public int titleBarHeight;
117
     public boolean backButtonHidden;
117
     public boolean backButtonHidden;
118
+    public Font titleBarButtonFontFamily;
118
 
119
 
119
     public Color topTabTextColor;
120
     public Color topTabTextColor;
120
     public Color topTabIconColor;
121
     public Color topTabIconColor;

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

7
     @Override
7
     @Override
8
     public void setStyleFromScreen(StyleParams styleParams) {
8
     public void setStyleFromScreen(StyleParams styleParams) {
9
         super.setStyleFromScreen(styleParams);
9
         super.setStyleFromScreen(styleParams);
10
-        font = styleParams.titleBarTitleFont;
10
+        font = styleParams.titleBarButtonFontFamily.hasFont() ? styleParams.titleBarButtonFontFamily : styleParams.titleBarTitleFont;
11
     }
11
     }
12
 
12
 
13
     public boolean hasFont() {
13
     public boolean hasFont() {

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

58
         result.titleBarSubtitleFontSize = getInt("titleBarSubtitleFontSize", getDefaultSubtitleTextFontSize());
58
         result.titleBarSubtitleFontSize = getInt("titleBarSubtitleFontSize", getDefaultSubtitleTextFontSize());
59
         result.titleBarSubtitleFontFamily = getFont("titleBarSubtitleFontFamily", getDefaultSubtitleFontFamily());
59
         result.titleBarSubtitleFontFamily = getFont("titleBarSubtitleFontFamily", getDefaultSubtitleFontFamily());
60
         result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
60
         result.titleBarButtonColor = getColor("titleBarButtonColor", getTitleBarButtonColor());
61
+        result.titleBarButtonFontFamily = getFont("titleBarButtonFontFamily", getDefaultTitleBarButtonFont());
61
         result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
62
         result.titleBarDisabledButtonColor = getColor("titleBarDisabledButtonColor", getTitleBarDisabledButtonColor());
62
         result.titleBarTitleFont = getFont("titleBarTitleFontFamily", getDefaultTitleTextFontFamily());
63
         result.titleBarTitleFont = getFont("titleBarTitleFontFamily", getDefaultTitleTextFontFamily());
63
         result.titleBarTitleFontSize = getInt("titleBarTitleFontSize", getDefaultTitleTextFontSize());
64
         result.titleBarTitleFontSize = getInt("titleBarTitleFontSize", getDefaultTitleTextFontSize());
118
         result.bottomTabFontFamily = new StyleParams.Font();
119
         result.bottomTabFontFamily = new StyleParams.Font();
119
         result.titleBarTitleFont = new StyleParams.Font();
120
         result.titleBarTitleFont = new StyleParams.Font();
120
         result.titleBarSubtitleFontFamily = new StyleParams.Font();
121
         result.titleBarSubtitleFontFamily = new StyleParams.Font();
122
+        result.titleBarButtonFontFamily = new StyleParams.Font();
121
         result.titleBarHeight = -1;
123
         result.titleBarHeight = -1;
122
         return result;
124
         return result;
123
     }
125
     }
294
         return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarSubtitleFontFamily;
296
         return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarSubtitleFontFamily;
295
     }
297
     }
296
 
298
 
299
+    private StyleParams.Font getDefaultTitleBarButtonFont() {
300
+        return AppStyle.appStyle == null ? new StyleParams.Font() : AppStyle.appStyle.titleBarButtonFontFamily;
301
+    }
302
+
297
     private boolean getDefaultTitleTextFontBold() {
303
     private boolean getDefaultTitleTextFontBold() {
298
         return AppStyle.appStyle != null && AppStyle.appStyle.titleBarTitleFontBold;
304
         return AppStyle.appStyle != null && AppStyle.appStyle.titleBarTitleFontBold;
299
     }
305
     }

+ 1
- 0
docs/styling-the-navigator.md View File

98
   // Android only
98
   // Android only
99
   navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.
99
   navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.
100
   navBarTitleTextCentered: true, // default: false. centers the title.
100
   navBarTitleTextCentered: true, // default: false. centers the title.
101
+  navBarButtonFontFamily: 'sans-serif-thin', // Change the font family of textual buttons
101
   topBarElevationShadowEnabled: false, // default: true. Disables TopBar elevation shadow on Lolipop and above
102
   topBarElevationShadowEnabled: false, // default: true. Disables TopBar elevation shadow on Lolipop and above
102
   statusBarColor: '#000000', // change the color of the status bar.
103
   statusBarColor: '#000000', // change the color of the status bar.
103
   collapsingToolBarImage: "http://lorempixel.com/400/200/", // Collapsing Toolbar image.
104
   collapsingToolBarImage: "http://lorempixel.com/400/200/", // Collapsing Toolbar image.

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

165
     titleBarSubtitleFontSize: originalStyleObject.navBarSubtitleFontSize,
165
     titleBarSubtitleFontSize: originalStyleObject.navBarSubtitleFontSize,
166
     titleBarSubtitleFontFamily: originalStyleObject.navBarSubtitleFontFamily,
166
     titleBarSubtitleFontFamily: originalStyleObject.navBarSubtitleFontFamily,
167
     titleBarButtonColor: processColor(originalStyleObject.navBarButtonColor),
167
     titleBarButtonColor: processColor(originalStyleObject.navBarButtonColor),
168
+    titleBarButtonFontFamily: originalStyleObject.navBarButtonFontFamily,
168
     titleBarDisabledButtonColor: processColor(originalStyleObject.titleBarDisabledButtonColor),
169
     titleBarDisabledButtonColor: processColor(originalStyleObject.titleBarDisabledButtonColor),
169
     titleBarTitleFontFamily: originalStyleObject.navBarTextFontFamily,
170
     titleBarTitleFontFamily: originalStyleObject.navBarTextFontFamily,
170
     titleBarTitleFontSize: originalStyleObject.navBarTextFontSize,
171
     titleBarTitleFontSize: originalStyleObject.navBarTextFontSize,