diff --git a/README.md b/README.md index bc31868..1ab5533 100644 --- a/README.md +++ b/README.md @@ -154,11 +154,11 @@ The most important prop is `onPress` which defines what kind of overflow menu we The package exports common handlers you can use, but you can provide your own too (via the `onPress` prop): | exported handler | description | -| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -------------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `overflowMenuPressHandlerActionSheet` | This is iOS-only: it displays overflow items in an `ActionSheetIOS` | | `overflowMenuPressHandlerPopupMenu` | This is Android-only: it displays overflow items using `UIManager.showPopupMenu` | | `overflowMenuPressHandlerDropdownMenu` | Can be used in iOS, Android and Web. Displays overflow items in a material popup adapted from [react-native-paper](https://callstack.github.io/react-native-paper/menu.html), credit for an amazing job goes to them. This `Menu` is bundled in this library (no dependency on `react-native-paper`). | -| `defaultOnOverflowMenuPress` | The default. Uses `overflowMenuPressHandlerActionSheet` on iOS, and `overflowMenuPressHandlerDropdownMenu` otherwise. | +| `defaultOnOverflowMenuPress` | The default. Uses `overflowMenuPressHandlerActionSheet` on iOS, `overflowMenuPressHandlerPopupMenu` on Android, and `overflowMenuPressHandlerDropdownMenu` otherwise. | You can also use the [react-native-menu](https://github.com/react-native-menu/menu) to show the overflow menu, as seen in the example app. diff --git a/example/metro.config.js b/example/metro.config.js index 1feeb9e..114d792 100644 --- a/example/metro.config.js +++ b/example/metro.config.js @@ -58,5 +58,4 @@ const config = { }, {}), }, }; -console.log({ config }); module.exports = config; diff --git a/example/package.json b/example/package.json index fc5c306..a445851 100644 --- a/example/package.json +++ b/example/package.json @@ -6,7 +6,8 @@ "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web", - "fix-deps": "npx expo install --check" + "fix-deps": "npx expo install --check", + "list-modules": "yarn metro get-dependencies --entry-file App.js --platform ios --output list-of-modules.txt" }, "dependencies": { "@expo/react-native-action-sheet": "^4.0.1", diff --git a/src/HeaderItems.tsx b/src/HeaderItems.tsx index 59dc258..8d63961 100644 --- a/src/HeaderItems.tsx +++ b/src/HeaderItems.tsx @@ -15,7 +15,7 @@ export function HiddenItem({ }: T) { const { closeMenu } = useOverflowMenu(); - // when rendering dropdown menu (e.g. android default) the return value is actually rendered + // when rendering dropdown menu, the return value is actually rendered // when we show action sheet, we do not render the returned value, // but just extract title, onPress and destructive passed to HiddenItem. HiddenItem() is not called const onMenuItemPress: MenuItemProps['onPress'] = (nativeEvent) => { diff --git a/src/overflowMenu/overflowMenuPressHandlers.ts b/src/overflowMenu/overflowMenuPressHandlers.ts index 9a9ca59..eabab9f 100644 --- a/src/overflowMenu/overflowMenuPressHandlers.ts +++ b/src/overflowMenu/overflowMenuPressHandlers.ts @@ -124,6 +124,11 @@ export const overflowMenuPressHandlerDropdownMenu = ({ export const defaultOnOverflowMenuPress: ( params: OnOverflowMenuPressParams ) => void = Platform.select({ + // the iOS and Android defaults look okay and don't bloat bundle size + // overflowMenuPressHandlerDropdownMenu is nice, but it's extra code that isn't needed + // if you don't use it. With Hermes, extra code in bundle doesn't matter so much + // but I did this change as an exercise in minimizing bundle size :D ios: overflowMenuPressHandlerActionSheet, + android: overflowMenuPressHandlerPopupMenu, default: overflowMenuPressHandlerDropdownMenu, });