react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[V2] property "enabled" for side menu is not respected in setRoot.

Open terreb opened this issue 8 years ago • 7 comments

Issue Description

Enabled property in initial config (setRoot) is not respected on both iOS and Android.

Steps to Reproduce / Code Snippets / Screenshots

Init the navigation like shown below.

    Navigation.setRoot({
        root: {
            sideMenu: {
                right: {
                    component: {
                        id: 'sideManu',
                        name: 'myApp.sideManu',
                        enabled: false,
                        visible: false,
                    },
                },
                center: {...}
            }
    })

The drawer is still enabled on the app startup and I can toggle it with swipe. Expected behaviour it doesn't show up when swiping since should be disabled.

FYI, however if I do later in the code on iOS:

    Navigation.mergeOptions('sideDrawer', {
        sideMenu: {
            right: {
                visible: false,
                enabled: false,
            }
        }
    })

It does get disabled. So the problem only with initial settings on iOS. On Android it never works.


Environment

  • React Native Navigation version: 2.0.2485
  • React Native version: 0.56.0
  • Platform(s) (iOS, Android, or both?): iOS, Android
  • Device info (Simulator/Device? OS version? Debug/Release?): simulator, iPhone 7 iOS 11.4, debug emulator, Genymotion Google Pixel 2.0 Android 8.0, debug

terreb avatar Aug 23 '18 10:08 terreb

The Android SideMenuOptions don’t seem to include an enabled flag: https://github.com/wix/react-native-navigation/blob/v2/lib/android/app/src/main/java/com/reactnativenavigation/parse/SideMenuOptions.java

haggholm avatar Sep 21 '18 23:09 haggholm

After https://github.com/wix/react-native-navigation/pull/4037

Navigation.setRoot({
    root: {
        sideMenu: {
            left: {
                component: {
                    id: 'SideMenu',
                    name: 'Drawer',
                }
            },
            center: {
                stack: {
                    id: 'RootStack',
                    children: [{
                        component: {
                            name: 'LoginScreen',
                        }
                    }],
                },
            }
        }
    }
});
Navigation.mergeOptions('SideMenu', {
        sideMenu: {
            left: {
                visible: false,
                enabled: false,
            }
        }
    });

is working :)

rafirr avatar Sep 27 '18 09:09 rafirr

@rafirr , it works only when the drawer is closed. i can still swipe and close it if it is openned

creative-git avatar Oct 17 '18 10:10 creative-git

how to disabled open/close gestures sideMenu of RNN V2?

NweThazin avatar Oct 17 '18 15:10 NweThazin

@NweThazin, to disable gestures try:

static options() {
    return {
      sideMenu: {
        left: {
            enabled: false
        }
      }
    };
  }

or

Navigation.mergeOptions('SideMenu', {
      sideMenu: {
        left: {
          enabled: false
        }
      }
});

and then to open / close drawer:

Navigation.mergeOptions('SideMenu', {
        sideMenu: {
            left: {
                visible: true, //false
            },
        }
    });

and my setRoot function:

Navigation.setRoot({
        root: {
        sideMenu: {
            left: {
            component: {
                id: 'SideMenu',
                name: 'Drawer',
            }
            },
            center: {
            stack: {
                id: 'RootStack',
                children: [{
                component: {
                    name: componentName,
                    options: {
                      animated: true
                    }     
                }
                }],
            },
            options: {
                topBar: {
                visible: false
                }
            }
            }
        }
        }
    });

It works for me :)

rafirr avatar Oct 17 '18 15:10 rafirr

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

stale[bot] avatar Nov 26 '18 12:11 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Dec 03 '18 12:12 stale[bot]