Coder Social home page Coder Social logo

jacobp100 / react-native-context-menu-view Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mpiannucci/react-native-context-menu-view

0.0 2.0 0.0 3.94 MB

Use native context menus in React Native

License: MIT License

Java 37.77% JavaScript 12.79% Ruby 4.93% Objective-C 42.71% Starlark 1.79%

react-native-context-menu-view's Introduction

react-native-context-menu-view

Use native context menu functionality from React Native. On iOS 13+ this uses UIMenu functionality, and on Android it uses a PopUpMenu.

On iOS 12 and below, nothing happens. You may wish to do a Platform.OS === 'ios' && parseInt(Platform.Version, 10) <= 12 check, and add your own onLongPress handler.

Getting started

$ npm install react-native-context-menu-view --save

Mostly automatic installation

cd ios/
pod install

Usage

import ContextMenu from "react-native-context-menu-view";

const Example = () => {
  return (
    <ContextMenu
      actions={[{ title: "Title 1" }, { title: "Title 2" }]}
      onPress={(e) => {
        console.warn(
          `Pressed ${e.nativeEvent.name} at index ${e.nativeEvent.index}`
        );
      }}
    >
      <View style={styles.yourOwnStyles} />
    </ContextMenu>
  );
};

See example/ for basic usage.

Props

title

Optional. The title above the popup menu.

actions

Array of { title: string, systemIcon?: string, destructive?: boolean, disabled?: boolean, inlineChildren?: boolean, children?: Array<ContextMenuAction> }.

System icon refers to an icon name within SF Symbols.

Destructive items are rendered in red on iOS, and unchanged on Android.

Nested menus are supported on iOS only and result in nested UIMenu which can be optionally displayed inline.

onPress

Optional. When the popup is opened and the user picks an option. Called with { nativeEvent: { index, name } }. When a nested action is selected the top level parent index is used for the callback.

onCancel

Optional. When the popop is opened and the user cancels.

previewBackgroundColor

Optional. The background color of the preview. This is displayed underneath your view. Set this to transparent (or another color) if the default causes issues.

dropdownMenuMode

Optional. When set to true, the context menu is triggered with a single tap instead of a long press, and a preview is not show and no blur occurs. Uses the iOS 14 Menu API and a simple tap listener on android.

react-native-context-menu-view's People

Contributors

mpiannucci avatar jacobp100 avatar mrousavy avatar dependabot[bot] avatar a7medev avatar alessandrod avatar nucleartux avatar fakeheal avatar maartenvanvliet avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.