[BREAKGLASS] Append-only mirror of github.com/bluewallet/menu
Go to file
Jesse Katsumata 89ccb2dd89
Some checks failed
Build / lint (12) (push) Has been cancelled
Build / tsc (12) (push) Has been cancelled
Build / android (12) (push) Has been cancelled
Build / ios (12) (push) Has been cancelled
0.3.2
2021-03-30 13:49:06 +09:00
.github fix: Podspec (#1) 2020-11-09 03:02:03 +09:00
android fix: android build (#73) 2021-03-30 13:48:38 +09:00
example feat(#57): android missing action properties, ios image color (#59) 2021-03-25 13:14:58 +09:00
ios feat(#57): android missing action properties, ios image color (#59) 2021-03-25 13:14:58 +09:00
src feat(#57): android missing action properties, ios image color (#59) 2021-03-25 13:14:58 +09:00
.editorconfig chore: initial commit 2020-11-03 07:23:20 +09:00
.gitattributes chore: initial commit 2020-11-03 07:23:20 +09:00
.gitignore chore: initial commit 2020-11-03 07:23:20 +09:00
babel.config.js chore: initial commit 2020-11-03 07:23:20 +09:00
CONTRIBUTING.md chore: initial commit 2020-11-03 07:23:20 +09:00
LICENSE chore: initial commit 2020-11-03 07:23:20 +09:00
package.json 0.3.2 2021-03-30 13:49:06 +09:00
react-native-menu.podspec fix: Podspec (#1) 2020-11-09 03:02:03 +09:00
README.md docs: update screenshots (#62) 2021-03-25 13:45:41 +09:00
tsconfig.json chore: fix example package name (#3) 2020-11-10 00:15:27 +09:00
yarn.lock chore(deps-dev): bump @types/react-native from 0.64.1 to 0.64.2 (#72) 2021-03-30 13:28:19 +09:00

@react-native-menu/menu

Supports Android, iOSGithub Action Badge npm

Android PopupMenu and iOS14+ UIMenu components for react-native. Falls back to ActionSheet for versions below iOS14.

Android iOS 14+ iOS 13

Installation

via npm:

npm install @react-native-menu/menu

via yarn:

yarn add @react-native-menu/menu

Installing on iOS with React Native 0.63

There is an issue(https://github.com/facebook/react-native/issues/29246) causing projects with this module to fail on build on React Native 0.63. This issue may be fixed in future versions of react native. As a work around, look for lines in [YourPrject].xcodeproj under LIBRARY_SEARCH_PATHS with "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", and change swift-5.0 to swift-5.3.

Linking

The package is automatically linked when building the app. All you need to do is:

npx pod-install

Usage

import { MenuView } from '@react-native-menu/menu';

// ...

const App = () => {
  return (
    <View style={styles.container}>
      <MenuView
        title="Menu Title"
        onPressAction={({ nativeEvent }) => {
          console.warn(JSON.stringify(nativeEvent));
        }}
        actions={[
          {
            id: 'add',
            titleColor: '#2367A2',
            image: Platform.select({
              ios: 'plus',
              android: 'ic_menu_add',
            }),
            imageColor: '#2367A2',
          },
          {
            id: 'share',
            title: 'Share Action',
            titleColor: '#46F289',
            subtitle: 'Share action on SNS',
            image: Platform.select({
              ios: 'square.and.arrow.up',
              android: 'ic_menu_share',
            }),
            imageColor: '#46F289',
            state: 'on',
          },
          {
            id: 'destructive',
            title: 'Destructive Action',
            attributes: {
              destructive: true,
            },
            image: Platform.select({
              ios: 'trash',
              android: 'ic_menu_delete',
            }),
          },
        ]}
      >
        <View style={styles.button}>
          <Text style={styles.buttonText}>Test</Text>
        </View>
      </MenuView>
    </View>
  );
};

Reference

Props

title (iOS only)

The title of the menu.

Type Required
string No

actions

Actions to be displayed in the menu.

Type Required
MenuAction[] Yes

MenuAction

Object representing Menu Action.

export type MenuAction = {
  /**
   * Identifier of the menu action.
   * The value set in this id will be returned when menu is selected.
   */
  id?: string;
  /**
   * The action's title.
   */
  title: string;
  /**
   * (Android only)
   * The action's title color.
   * @platform Android
   */
  titleColor?: number | ColorValue;
  /**
   * (iOS14+ only)
   * An elaborated title that explains the purpose of the action.
   * @platform iOS
   */
  subtitle?: string;
  /**
   * The attributes indicating the style of the action.
   */
  attributes?: MenuAttributes;
  /**
   * (iOS14+ only)
   * The state of the action.
   * @platform iOS
   */
  state?: MenuState;
  /**
   * (Android and iOS13+ only)
   * - The action's image.
   * - Allows icon name included in project or system (Android) resources drawables and
   * in SF Symbol (iOS)
   * @example // (iOS)
   * image="plus"
   * @example // (Android)
   * image="ic_menu_add"
   * - TODO: Allow images other than those included in SF Symbol and resources drawables
   */
  image?: string;
  /**
   * (Android and iOS13+ only)
   * - The action's image color.
   */
  imageColor?: number | ColorValue;
};

MenuAttributes

The attributes indicating the style of the action.

type MenuAttributes = {
  /**
   * An attribute indicating the destructive style.
   */
  destructive?: boolean;
  /**
   * An attribute indicating the disabled style.
   */
  disabled?: boolean;
  /**
   * An attribute indicating the hidden style.
   */
  hidden?: boolean;
};

MenuState

The state of the action.

/**
 * The state of the action.
 * - off: A constant indicating the menu element is in the “off” state.
 * - on: A constant indicating the menu element is in the “on” state.
 * - mixed: A constant indicating the menu element is in the “mixed” state.
 */
type MenuState = 'off' | 'on' | 'mixed';

onPressAction

Callback function that will be called when selecting a menu item. It will contain id of the given action.

Type Required
({nativeEvent}) => void No

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT