Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ public class Constants {
public static final String STATUS_BAR_HEIGHT_KEY = "statusBarHeight";
public static final String TOP_BAR_HEIGHT_KEY = "topBarHeight";
public static final String BOTTOM_TABS_HEIGHT_KEY = "bottomTabsHeight";
public static final int BOTTOM_TABS_HEIGHT = 56;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private WritableMap createNavigationConstantsMap() {
ReactApplicationContext ctx = getReactApplicationContext();
WritableMap constants = Arguments.createMap();
constants.putString(Constants.BACK_BUTTON_JS_KEY, Constants.BACK_BUTTON_ID);
constants.putDouble(Constants.BOTTOM_TABS_HEIGHT_KEY, Constants.BOTTOM_TABS_HEIGHT);
constants.putDouble(Constants.BOTTOM_TABS_HEIGHT_KEY, pxToDp(ctx, UiUtils.getBottomTabsHeight(ctx)));
constants.putDouble(Constants.STATUS_BAR_HEIGHT_KEY, pxToDp(ctx, StatusBarUtils.getStatusBarHeight(ctx)));
constants.putDouble(Constants.TOP_BAR_HEIGHT_KEY, pxToDp(ctx, UiUtils.getTopBarHeight(ctx)));
return constants;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

public class UiUtils {
private static final int DEFAULT_TOOLBAR_HEIGHT = 56;
private static final int DEFAULT_BOTTOM_TABS_HEIGHT = 56;

private static int topBarHeight = -1;
private static int bottomTabsHeight = -1;

public static <T extends View> void runOnPreDrawOnce(@Nullable final T view, final Functions.Func1<T> task) {
if (view == null) return;
Expand Down Expand Up @@ -117,6 +119,18 @@ public static int getTopBarHeight(Context context) {
return topBarHeight;
}

public static int getBottomTabsHeight(Context context) {
if (bottomTabsHeight > 0) {
return bottomTabsHeight;
}
final Resources resources = context.getResources();
final int resourceId = resources.getIdentifier("bottom_navigation_height", "dimen", context.getPackageName());
bottomTabsHeight = resourceId > 0 ?
resources.getDimensionPixelSize(resourceId) :
dpToPx(context, DEFAULT_BOTTOM_TABS_HEIGHT);
return bottomTabsHeight;
}

public static float dpToPx(Context context, float dp) {
Resources resources = context.getResources();
return dpToPx(resources.getDisplayMetrics(), dp);
Expand Down