React native action bar and react native menu

后端 未结 3 1612
轮回少年
轮回少年 2021-01-06 05:09

I am new to React-Native and love it so far. I am trying to create a screen (for the cross-platform app) with a menu icon on top right and when clicked, I want to open a men

3条回答
  •  孤街浪徒
    2021-01-06 05:51

    react-native-modal-dropdown implement these things

    +import ModalDropdown from 'react-native-modal-dropdown';
    class FooBar extends PureComponent {
         constructor(props) {
             super(props);
    +        this.dropdownOptions = [{
    +            text: 'Scan',
    +            icon: require('../images/scan.png'),
    +            onPress: this.toScan,
    +        }, {
    +            text: 'Share',
    +            icon: require('../images/share.png'),
    +            onPress: this.toShare,
    +        }];
    
    
    +    adjustDropdownStyle = style => {
    +        return {
    +            width: 110,
    +            height: 96, // calculated from margin and height of renderDropdownItem bellow
    +            right: 0,
    +            top: style.top,
    +        };
    +    }
    +
    +    renderDropdownItem = (item, index, highlighted) => {
    +        return (
    +            
    +                
    +                
    +                    {item.text}
    +                
    +            
    +        );
    +    }
    +
    +    onDropdownSelect = (index, item) => item.onPress()
    +
         render() {
            let navs = {
                Center: {
                    text: 'Home',
                },
                Right: {
                    image: require('../images/more.png'),
    +                onPress: () => this.dropdown && this.dropdown.show(),
                },
            };
    
                      
    + {this.dropdown = view;}} + style={{height: 0}} + adjustFrame={this.adjustDropdownStyle} + options={this.dropdownOptions} + renderRow={this.renderDropdownItem.bind(this)} + onSelect={this.onDropdownSelect.bind(this)} + />

提交回复
热议问题