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 @@ -5,4 +5,5 @@
public class SideMenuParams extends BaseScreenParams {
public boolean disableOpenGesture;
public SideMenu.Side side;
public int fixedWidth;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private static SideMenuParams parseSideMenu(@Nullable Bundle sideMenu, Side side
result.screenId = sideMenu.getString("screenId");
result.navigationParams = new NavigationParams(sideMenu.getBundle("navigationParams"));
result.disableOpenGesture = sideMenu.getBoolean("disableOpenGesture", false);
result.fixedWidth = sideMenu.getInt("fixedWidth", 0);
result.side = side;
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,23 @@ private ContentView createSideMenu(@Nullable SideMenuParams params) {
ContentView sideMenuView = new ContentView(getContext(), params.screenId, params.navigationParams);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
lp.gravity = params.side.gravity;
setSideMenuWidth(sideMenuView);
setSideMenuWidth(sideMenuView, params);
addView(sideMenuView, lp);
return sideMenuView;
}

private void setSideMenuWidth(final ContentView sideMenuView) {
private void setSideMenuWidth(final ContentView sideMenuView, @Nullable final SideMenuParams params) {
sideMenuView.setOnDisplayListener(new Screen.OnDisplayListener() {
@Override
public void onDisplay() {
ViewGroup.LayoutParams lp = sideMenuView.getLayoutParams();
lp.width = sideMenuView.getChildAt(0).getWidth();
if (params != null
&& params.fixedWidth > 0) {
lp.width = params.fixedWidth;
} else {
lp.width = sideMenuView.getChildAt(0).getWidth();
}

sideMenuView.setLayoutParams(lp);
}
});
Expand Down
6 changes: 5 additions & 1 deletion docs/top-level-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ Navigation.startTabBasedApp({
drawer: { // optional, add this if you want a side menu drawer in your app
left: { // optional, define if you want a drawer from the left
screen: 'example.FirstSideMenu', // unique ID registered with Navigation.registerScreen
passProps: {} // simple serializable object that will pass as props to all top screens (optional)
passProps: {} // simple serializable object that will pass as props to all top screens (optional),
fixedWidth: 500, // a fixed width you want your left drawer to have (optional)
},
right: { // optional, define if you want a drawer from the right
screen: 'example.SecondSideMenu', // unique ID registered with Navigation.registerScreen
passProps: {} // simple serializable object that will pass as props to all top screens (optional)
fixedWidth: 500, // a fixed width you want your right drawer to have (optional)
},
style: { // ( iOS only )
     drawerShadow: true, // optional, add this if you want a side menu drawer shadow
Expand Down Expand Up @@ -105,11 +107,13 @@ Navigation.startSingleScreenApp({
screen: 'example.FirstSideMenu', // unique ID registered with Navigation.registerScreen
passProps: {}, // simple serializable object that will pass as props to all top screens (optional)
disableOpenGesture: false // can the drawer be opened with a swipe instead of button (optional, Android only)
fixedWidth: 500, // a fixed width you want your left drawer to have (optional)
},
right: { // optional, define if you want a drawer from the right
screen: 'example.SecondSideMenu', // unique ID registered with Navigation.registerScreen
passProps: {} // simple serializable object that will pass as props to all top screens (optional)
disableOpenGesture: false // can the drawer be opened with a swipe instead of button (optional, Android only)
fixedWidth: 500, // a fixed width you want your right drawer to have (optional)
},
style: { // ( iOS only )
     drawerShadow: true, // optional, add this if you want a side menu drawer shadow
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-navigation",
"version": "1.1.85",
"version": "1.1.314",
"description": "React Native Navigation - truly native navigation for iOS and Android",
"license": "MIT",
"nativePackage": true,
Expand Down
10 changes: 8 additions & 2 deletions src/deprecated/platformSpecificDeprecated.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,15 @@ function convertDrawerParamsToSideMenuParams(drawerParams) {
result[key] = adaptNavigationParams(result[key]);
result[key].passProps = drawer[key].passProps;
if (drawer.disableOpenGesture) {
result[key].disableOpenGesture = drawer.disableOpenGesture;
result[key].disableOpenGesture = parseInt(drawer.disableOpenGesture);
} else {
result[key].disableOpenGesture = drawer[key].disableOpenGesture;
let fixedWidth = drawer[key].disableOpenGesture;
result[key].disableOpenGesture = fixedWidth ? parseInt(fixedWidth) : null;
}
if (drawer.fixedWidth) {
result[key].fixedWidth = drawer.fixedWidth;
} else {
result[key].fixedWidth = drawer[key].fixedWidth;
}

} else {
Expand Down