Code Monkey home page Code Monkey logo

Comments (2)

alinz avatar alinz commented on July 22, 2024

Can you wrap that component with another View and set the style of that to flex:1? Also can you provide us with some code or screen shot?

from react-native-side-menu.

troywatt avatar troywatt commented on July 22, 2024

Thanks, I tried your suggestion and it does work but I also have to set the width/height explicitly on the wrapping component
when using a Navigator component, otherwise the content is still hidden by the absolute positioned menu.

Not a big deal, I guess it's more of an implementation detail.

Here is an example.

'use strict';

var React = require( 'react-native' );
var deviceScreen = require( 'Dimensions' ).get( 'window' );
var SideMenu = require( 'react-native-side-menu' );
var {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    NavigatorIOS,
    TouchableHighlight,
    } = React;


var menuPaneWidth = deviceScreen.width - 72;

var MenuContent = React.createClass({

    onPress: function(){
        this.props.navigator.push({
            component: MenuContent,
            title: 'Next Pane'
        });
    },

    render: function() {
        return (
            <TouchableHighlight style={ styles.container } onPress={ this.onPress.bind( this ) }>
                <View style={ styles.menu }>
                    <Text style={ styles.menuText }>Menu Pane</Text>
                </View>
            </TouchableHighlight>
        );
    }
});

var MenuExample = React.createClass( {
    render: function () {

        // Note: hidden due to no width/height on menu container
        var menuNav = <NavigatorIOS
            itemWrapperStyle={ styles.menu }
            style={{ flex: 1, width: menuPaneWidth, height: deviceScreen.height }}
            initialRoute={{
                component: MenuContent,
                title: 'Menu'
            }} />;

        // Note: works as expected with flex: 1 and explicit width/height on View wrapper
        /*var menuNav = <View style={{ flex: 1, width: menuPaneWidth, height: deviceScreen.height }}>
            <NavigatorIOS
                style={{ flex: 1 }}
                itemWrapperStyle={ styles.menu }
                initialRoute={{
                    component: MenuContent,
                    title: 'Menu'
                }} />
        </View>;*/

        return (
            <SideMenu menu={ menuNav }
                openMenuOffset={ menuPaneWidth }
                style={ styles.container }>
                <View style={ styles.container }>
                    <Text style={ styles.text }>Main Pane</Text>
                </View>
            </SideMenu>
        );
    }
} );

var styles = StyleSheet.create( {

    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    menu: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#333333',
    },
    text: {
        fontSize: 20
    },
    menuText: {
        color: '#aaaaaa',
        fontSize: 20
    }
} );

AppRegistry.registerComponent( 'MenuExample', () => MenuExample );

My pull request (#55) was merge in already to fix this, so I'll close this issue.

from react-native-side-menu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.