Home

Awesome

<h1 align="center"> <p align="center"> <img src="https://github.com/zawadz88/MaterialPopupMenu/raw/master/art/components_menus.png" width="300" height="300" /> </p> <p align="center"> <a href="https://www.npmjs.com/package/react-native-popover-menu"><img src="http://img.shields.io/npm/v/react-native-popover-menu.svg?style=flat" /></a> <a href="https://github.com/prscX/react-native-popover-menu/pulls"><img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" /></a> <a href="https://github.com/prscX/react-native-popover-menu#License"><img src="https://img.shields.io/npm/l/react-native-popover-menu.svg?style=flat" /></a> </p>
ReactNative: Native Popover Menu (Android/iOS)

If this project has helped you out, please support us with a star 🌟

</h1>

This library is a React Native bridge around native popover libraries. It allows show/guide beautiful popover menus:

Android: zawadz88/MaterialPopupMenu
<img src="https://github.com/zawadz88/MaterialPopupMenu/raw/master/art/sample_sections_light.png" height="600" />
iOS: liufengting/FTPopOverMenu
<img src="https://raw.githubusercontent.com/liufengting/FTResourceRepo/master/Resource/FTPopOverMenu/screenshots.gif" height="600" />

📖 Getting started

$ npm install react-native-popover-menu --save

RN61 >= RNBAS V2 >

$ npm install react-native-image-helper --save

$ npm install react-native-vector-icons --save

iOS Prerequisite: Please make sure CocoaPods is installed on your system

- Add the following to your `Podfile` -> `ios/Podfile` and run pod update:
  use_native_modules!

  pod 'RNPopoverMenu', :path => '../node_modules/react-native-popover-menu/ios'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
  end

Please add below snippet into your app build.gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

RN61 >= RNPM V1 >

RN60 above please use react-native-popover-menu V1 and above

iOS Prerequisite: Please make sure CocoaPods is installed on your system

- Add the following to your `Podfile` -> `ios/Podfile` and run pod update:
  use_native_modules!

  pod 'RNPopoverMenu', :path => '../node_modules/react-native-popover-menu/ios'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
      end
    end
  end

Please add below snippet into your app build.gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

RN61 < RNPO V1 <

RN60 below please use react-native-popover-menu V.0.*

$ react-native link react-native-popover-menu

$ react-native link react-native-vector-icons

Please add below snippet into your app build.gradle


buildscript {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
    ...
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven { url "https://maven.google.com" }
        ...
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

Note: This library is supported Android SDK 28 > above

💻 Usage

import RNPopover from 'react-native-popover-menu';

import Icon from 'react-native-vector-icons'


let copy = <Icon family={'FontAwesome'} name={'copy'} color={'#000000'} size={30} />
let paste = <Icon family={'FontAwesome'} name={'paste'} color={'#000000'} size={30} />
let share = <Icon family={'FontAwesome'} name={'share'} color={'#000000'} size={30} />

<RNPopover visible={this.state.visible} reference={this.ref}>
  <RNPopover.Menu label={"Editing"}>
    <RNPopover.Menu label={"Copy"} icon={copy} />
    <RNPopover.Menu label={"Paste"} icon={paste} />
  </RNPopover.Menu>
  <RNPopover.Menu >
    <RNPopover.Menu label={"Share"} icon={share} />
  </RNPopover.Menu>
</RNPopover>;


let copy = <Icon family={'FontAwesome'} name={'copy'} color={'#000000'} size={30} />
let paste = <Icon family={'FontAwesome'} name={'paste'} color={'#000000'} size={30} />
let share = <Icon family={'FontAwesome'} name={'share'} color={'#000000'} size={30} />

let menus = [
  {
    label: "Editing",
    menus: [
      { label: "Copy", icon: copy },
      { label: "Paste", icon: paste }
    ]
  },
  {
    label: "Other",
    menus: [
      { label: "Share", icon: share }
    ]
  },
  {
    label: "",
    menus: [
      { label: "Share me please" }
    ]
  }
]

RNPopover.Show(this.ref, {
  title: "",
  menus: menus,
  onDone: selection => { }
});

Note:

💡 Props

PropTypeDefaultNote
titlestringTitle of popover section
menusarrayArray of Menus
onDone(sectionSelection, menuSelection)funcIt is called when menu is selected
PropTypeDefaultNote
themestringlightLight & Dark theme support only on Android Platform
PropTypeDefaultNote
tintColorstring'#FFFFFF'Color of tint
menuWidthnumberSpecify menu width of the Popover
rowHeightnumberHeight of the menu row
rowHeightnumberHeight of the menu row
textMarginnumberSpecify text margin from icon
iconMarginnumberSpecify icon margin from border
selectedRowBackgroundColorstringSpecify selected row background color
roundedArrowboolSpecify whether rounded arrow required or not
textColorstringSpecify text color
borderColorstringSpecify border color
borderWidthnumberSpecify border width
separatorColorstringSpecify the menu separator color
shadowColorstringSpecify the shadow color
shadowOpacityfloatSpecify shadow opacity between 0 and 1. 0 disables the shadow.
shadowRadiusnumberSpecify shadow radius
shadowOffsetXnumberSpecify the horizontal shadow offset
shadowOffsetYnumberSpecify the vertical shadow offset

Icons

	let facebook = <Icon family={'FontAwesome'} name={'facebook'} color={'#000000'} size={30} />

	<RNPopover.Menu label={"Facebook"} icon={facebook} />

Note:

Note: Since we are using native libraries, we have not found a solution in order to render RN Images in production, therefore please copy all your image assets in platform specific folders:

Please refer example application for the image usage.

✨ Credits

🤔 How to contribute

Have an idea? Found a bug? Please raise to ISSUES. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list below. ✨

📜 License

This library is provided under the Apache License.

RNPopoverMenu @ prscX

💖 Support my projects

I open-source almost everything I can, and I try to reply everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it: