package com.reactnativenavigation.params.parsers;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.reactnativenavigation.params.NavigationParams;
import com.reactnativenavigation.params.SideMenuParams;
import com.reactnativenavigation.views.SideMenu.Side;

class SideMenuParamsParser extends Parser {
    public static SideMenuParams[] parse(Bundle sideMenues) {
        SideMenuParams[] result = new SideMenuParams[2];
        result[Side.Left.ordinal()] = parseSideMenu(sideMenues.getBundle("left"), Side.Left);
        result[Side.Right.ordinal()] = parseSideMenu(sideMenues.getBundle("right"), Side.Right);
        return result;
    }

    private static SideMenuParams parseSideMenu(@Nullable Bundle sideMenu, Side side) {
        if (sideMenu == null || sideMenu.isEmpty()) {
            return null;
        }
        SideMenuParams result = new SideMenuParams();
        result.screenId = sideMenu.getString("screenId");
        result.navigationParams = new NavigationParams(sideMenu.getBundle("navigationParams"));
        result.disableOpenGesture = sideMenu.getBoolean("disableOpenGesture", false);
        result.drawerWidth = (int)Math.ceil(sideMenu.getDouble("drawerWidth", -1));
        result.side = side;
        return result;
    }
}

@@ -1220,13 +1220,45 @@
 th%22,
+ sideMenu.getInt(%22drawerWidth%22,
  -1))
+)
 ;%0A  

Fix drawer width double / int issues