React Native的popup menu

单淳
2023-12-01
import Menu, {MenuOptions, MenuOption, MenuTrigger} from 'react-native-popup-menu';

const triggerCustomStyle = {
    triggerOuterWrapper: {
        width: 50,
        alignItems: 'center',
        justifyContent: 'center',
        flex: 1
    }
};
const optionsCustomStyle = {
    optionsContainer: {
        backgroundColor: 'black',
        marginTop: 50
    },
    optionTouchable: {
        underlayColor: 'gray',
        activeOpacity: 40,
    },
    optionWrapper: {
        margin: 5,
    },
    optionText: {
        color: 'white',
    },
};

class DropdownButton extends Component {
    render() {
        return (
            <Menu onSelect={(value) => alert(`User selected the number ${value}`)}>
                <MenuTrigger customStyles={triggerCustomStyle}>
                    <Icon name="navicon" size={20}/>
                </MenuTrigger>
                <MenuOptions customStyles={optionsCustomStyle}>
                    <MenuOption value={1} text="扫一扫"/>
                    <MenuOption value={2} text="帮助"/>
                </MenuOptions>
            </Menu>
        )
    }
}

转载于:https://my.oschina.net/u/2266730/blog/843684

 类似资料: