• Stars
    star
    588
  • Rank 75,502 (Top 2 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use native context menus in React Native

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, subtitle?: string, systemIcon?: string, destructive?: boolean, disabled?: boolean, disabled?: boolean, inlineChildren?: boolean, actions?: Array<ContextMenuAction> }.

Subtitle is only available on iOS 15+.

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, indexPath, name } }. When a nested action is selected the top level parent index is used for the callback.

iOS only: to get the full path to the item, indexPath is an array of indices to reach the item. For a top-levle item, it'll be an array with a single index. For an item one deep, it'll be an array with two indicies.

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.

disabled

Optional. Currently iOS only. Disable menu interaction.

More Repositories

1

gnome-shell-extended-gestures

Better touchpad gesture handling for GNOME
JavaScript
300
star
2

surfpy

Surfing math library for Python
Python
91
star
3

gribberish

Read GRIB files with Rust
Rust
31
star
4

peakdetect

Peak Detection with Golang
Go
11
star
5

grippy

Pure Python GRIB2 parsing
Python
11
star
6

react-native-uimenu

Use iOS 13 Context Menus in React Native
Objective-C
6
star
7

surfnerd

A comprehensive suite of surf forecasting and wave analysis tools
Go
6
star
8

surfrs

Tools for creating surfing and weather forecasts
Rust
5
star
9

buoyfinder-v3

A cross platform app for viewing NOAA buoys and data
Rust
5
star
10

HelloMSP430

Simple blinking light example for the MSP430
C
4
star
11

charizarr

A small, opinionated, async zarr 3.0 implementation written in rust
Rust
4
star
12

HackWinds-iOS

Rhode Island surf camera and forecast app for iOS
Objective-C
3
star
13

shhhecrets

iOS tweak to password protect iMessage conversations
Logos
2
star
14

InspiredEnergyBattery

A python library for interfacing Inspired Energy Smart Batteries
Python
1
star
15

MiniMaestro

A python library for interfacing a Polulu Mini Maestro servo controller.
Python
1
star
16

hello-zig

Test project for integrating zig with ios, android, macos, etc
Swift
1
star
17

HackWinds-Android

Rhode Island surf camera and forecasting application for Android.
Java
1
star
18

SwiftContour

Compute contour polygons using marching squares in Swift
Swift
1
star
19

ocean-notebooks

Ocean Data Notebooks and Experimentation
Jupyter Notebook
1
star
20

redis-fsspec-cache

A redis based filesystem cache for fsspec
Python
1
star
21

readap

Read OpenDAP binary data with rust
Rust
1
star