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
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)}
+ />