Browse Source

Add paddingTop to android ToolBar. (#2266)

* Add paddingTop to android ToolBar.

* Update documentation
Chaitanya Bhagvan 6 years ago
parent
commit
5a2bc27ef4

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

123
     public int titleBarHeight;
123
     public int titleBarHeight;
124
     public boolean backButtonHidden;
124
     public boolean backButtonHidden;
125
     public Font titleBarButtonFontFamily;
125
     public Font titleBarButtonFontFamily;
126
+    public int titleBarTopPadding;
126
 
127
 
127
     public Color topTabTextColor;
128
     public Color topTabTextColor;
128
     public Font topTabTextFontFamily;
129
     public Font topTabTextFontFamily;

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

69
         result.titleBarHeight = getInt("titleBarHeight", getDefaultTitleBarHeight());
69
         result.titleBarHeight = getInt("titleBarHeight", getDefaultTitleBarHeight());
70
         result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
70
         result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
71
         result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
71
         result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
72
+        result.titleBarTopPadding = getInt("titleBarTopPadding", getTitleBarTopPadding());
72
 
73
 
73
         result.topTabTextColor = getColor("topTabTextColor", getDefaultTopTabTextColor());
74
         result.topTabTextColor = getColor("topTabTextColor", getDefaultTopTabTextColor());
74
         result.topTabTextFontFamily = getFont("topTabTextFontFamily", getDefaultTopTabTextFontFamily());
75
         result.topTabTextFontFamily = getFont("topTabTextFontFamily", getDefaultTopTabTextFontFamily());
328
         return AppStyle.appStyle == null ? -1 : AppStyle.appStyle.titleBarHeight;
329
         return AppStyle.appStyle == null ? -1 : AppStyle.appStyle.titleBarHeight;
329
     }
330
     }
330
 
331
 
332
+    private int getTitleBarTopPadding() {
333
+        return AppStyle.appStyle == null ? 0 : AppStyle.appStyle.titleBarTopPadding;
334
+    }
335
+
331
     private boolean getBoolean(String key, boolean defaultValue) {
336
     private boolean getBoolean(String key, boolean defaultValue) {
332
         return params.containsKey(key) ? params.getBoolean(key) : defaultValue;
337
         return params.containsKey(key) ? params.getBoolean(key) : defaultValue;
333
     }
338
     }

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

85
         colorOverflowButton(params);
85
         colorOverflowButton(params);
86
         setBackground(params);
86
         setBackground(params);
87
         centerTitle(params);
87
         centerTitle(params);
88
+        setTopPadding(params);
88
     }
89
     }
89
 
90
 
90
     public void setVisibility(boolean titleBarHidden) {
91
     public void setVisibility(boolean titleBarHidden) {
134
         });
135
         });
135
     }
136
     }
136
 
137
 
138
+    private void setTopPadding(final StyleParams params) {
139
+        setPadding(0, params.titleBarTopPadding, 0,0);
140
+    }
141
+
137
     private void colorOverflowButton(StyleParams params) {
142
     private void colorOverflowButton(StyleParams params) {
138
         Drawable overflowIcon = actionMenuView.getOverflowIcon();
143
         Drawable overflowIcon = actionMenuView.getOverflowIcon();
139
         if (shouldColorOverflowButton(params, overflowIcon)) {
144
         if (shouldColorOverflowButton(params, overflowIcon)) {

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

107
   collapsingToolBarCollapsedColor: '#0f2362', // Collapsing Toolbar scrim color.
107
   collapsingToolBarCollapsedColor: '#0f2362', // Collapsing Toolbar scrim color.
108
   navBarTextFontBold: false, // Optional. Set the title to bold.
108
   navBarTextFontBold: false, // Optional. Set the title to bold.
109
   navBarHeight: 70, // Optional, set the navBar height in pixels.
109
   navBarHeight: 70, // Optional, set the navBar height in pixels.
110
+  navBarTopPadding: 24, // Optional, set navBar top padding in pixels. Useful when StatusBar.translucent=true on Android Lollipop and above.
110
   topTabsHeight: 70, // Optional, set topTabs height in pixels.
111
   topTabsHeight: 70, // Optional, set topTabs height in pixels.
111
   topBarBorderColor: 'red', Optional, set a flat border under the TopBar.
112
   topBarBorderColor: 'red', Optional, set a flat border under the TopBar.
112
   topBarBorderWidth: 5.5, // Optional, set the width of the border.
113
   topBarBorderWidth: 5.5, // Optional, set the width of the border.

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

181
     titleBarTitleFontBold: originalStyleObject.navBarTextFontBold,
181
     titleBarTitleFontBold: originalStyleObject.navBarTextFontBold,
182
     titleBarTitleTextCentered: originalStyleObject.navBarTitleTextCentered,
182
     titleBarTitleTextCentered: originalStyleObject.navBarTitleTextCentered,
183
     titleBarHeight: originalStyleObject.navBarHeight,
183
     titleBarHeight: originalStyleObject.navBarHeight,
184
+    titleBarTopPadding: originalStyleObject.navBarTopPadding,
184
     backButtonHidden: originalStyleObject.backButtonHidden,
185
     backButtonHidden: originalStyleObject.backButtonHidden,
185
     topTabsHidden: originalStyleObject.topTabsHidden,
186
     topTabsHidden: originalStyleObject.topTabsHidden,
186
     contextualMenuStatusBarColor: processColor(originalStyleObject.contextualMenuStatusBarColor),
187
     contextualMenuStatusBarColor: processColor(originalStyleObject.contextualMenuStatusBarColor),