Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help With Drawer Menu #2793

Closed
Schabaani opened this issue Jan 13, 2018 · 4 comments
Closed

Help With Drawer Menu #2793

Schabaani opened this issue Jan 13, 2018 · 4 comments

Comments

@Schabaani
Copy link

I am new in react world. I want to have a side menu. However, it does not show anything.

App.js

const App = () => {
    return (
        <Router>
            <Scene key="root">
                <Scene
                    key="LoginScreen"
                    component={LoginScreen}
                    initial
                />
                <Scene
                    key="CodeValidationScreen"
                    component={CodeValidationScreen}
                />

                <Scene
                    key="ProfileScreen"
                    component={ProfileScreen}
                />

                <Scene
                    key="RegisterScreen"
                    component={RegisterScreen}
                />

                <Scene
                    key="CarsListScreen"
                    component={CarsListScreen}
                />

                <Scene
                    key="CarViewScreen"
                    component={CarViewScreen}
                />

                <Scene contentComponent={NavigationDrawer} drawer  key="drawer">
                    <Scene key="main">
                        <Scene
                            key="LogoutScreen"
                            component={LogoutScreen}
                        />
                    </Scene>
                </Scene>
            </Scene>

        </Router>
    )
};

index.js:

AppRegistry.registerComponent('sidemenu', () => App);

Drawer.js

export default class NavigationDrawer extends Component {
    constructor(props) {
        super(props);
    };
    render(){
        const state = this.props.navigationState;
        const children = state.children;
        return (
            <Drawer
                ref="navigation"
                open={state.open}
                onOpen={()=>Actions.refresh({key:state.key, open: true})}
                onClose={()=>Actions.refresh({key:state.key, open: false})}
                type="displace"
                content={<SideMenu />}
                tapToClose={true}
                openDrawerOffset={0.2}
                panCloseMask={0.2}
                negotiatePan={true}
                tweenHandler={(ratio) => ({
                    main: { opacity:Math.max(0.54,1-ratio) }
                })}>
                {this.props.children[0]}
                {/*<DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate} />*/}
            </Drawer>
        );
    }
}

SideMenu.js

export default class SideMenu extends Component<{}> {
    constructor(props) {
        super(props);

    };

    render() {
        return (
            <View style={styles.container}>
                <Text>menu items go here</Text>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        flexDirection: 'column',
        justifyContent: 'flex-start',
        alignItems: 'stretch',
        backgroundColor: '#F5FCFF',
        paddingRight: 20,
        paddingLeft: 20,
        paddingBottom: 10,
    },

});

showDrawer function (when I click on a button, I expect SideMenu shows. ):

_showDrawer  = () => {
    return () => {
            Actions.refresh({key: 'drawer', open: true });
};

This is all of my code. I can navigate between screens, however, side menu doesn't work. What is my mistake?

@Schabaani
Copy link
Author

    <Router>
        <Scene>
            <Scene
                key="login"
                component={LoginScreen}
                initial
                type="reset"
            />
            <Scene
                key="registerScreen"
                component={RegisterScreen}
            />

            <Scene
                key="codeValidationScreen"
                component={CodeValidationScreen}
            />

            <Drawer
                hideNavBar
                key="drawerMenu"
                contentComponent={SideMenu}
                drawerWidth={250}
                drawerPosition="right"
            >
                <Scene
                    key="profileScreen"
                    component={ProfileScreen}

                />
                <Scene
                    key="carsListScreen"
                    component={CarsListScreen}
                />

                <Scene
                    key="carViewScreen"
                    component={CarViewScreen}
                />

            </Drawer>
        </Scene>





    </Router>);

And:
Actions.drawerMenu(params)

And there is no need to Drawer.js

@wayne811
Copy link

can you share your code for me.

@nguyenvanphuc2203
Copy link

@Schabaani can you share your params code

@Schabaani
Copy link
Author

@nguyenvanphuc2203 and @wayne811 , unfortunately this is the old code and I don't have access to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants