Real original pop-up menu Moving options window

I have a React Native Popup Menu implemented as follows:

import React, { Component } from 'react';
import { Text } from 'react-native';
import { Icon, Divider } from 'react-native-elements';
import {
  Menu,
  MenuTrigger,
  MenuOptions,
  MenuOption
} from 'react-native-popup-menu';
import { connect } from 'react-redux';
import firebase from 'firebase';
import { STATUS_BAR_HEIGHT } from '../constants';

class PopUpMenu extends Component {
  render() {
    const { menuStyle, menuOptionsStyle, menuTriggerStyle } = styles;

    return (
      <Menu style={menuStyle}>
        <MenuTrigger style={menuTriggerStyle}>
          <Icon
            name="menu"
            color="white"
            size={30}
          />
        </MenuTrigger>
        <MenuOptions style={menuOptionsStyle}>
          <MenuOption>
            <Text>{this.props.user.email}</Text>
          </MenuOption>
          <MenuOption>
            <Divider />
          </MenuOption>
          <MenuOption text="Log Out" onSelect={() => this.signOutUser()} />
        </MenuOptions>
      </Menu>
    );
  }
}

const styles = {
  menuStyle: {
    marginTop: STATUS_BAR_HEIGHT,
    marginRight: 12
  },
  menuTriggerStyle: {},
  menuOptionsStyle: {}
};

Now it now looks like this closed:

Closed

And it opened:

Open

I want the open box to move down under the trigger button, while keeping the trigger in the same place. How to do this with styles?

+4
source share
1 answer

You can achieve this by passing the optionsContainerStyledetails to the MenuOptions component, rather than the props style.

Something like that.

<MenuOptions optionsContainerStyle={{ marginTop: 40 }}>
...
</MenuOptions>
+3
source

Source: https://habr.com/ru/post/1683285/


All Articles