Skip to content

Commit

Permalink
chore: add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak committed Apr 9, 2024
1 parent fadaada commit 0ab738a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 0 additions & 1 deletion example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ const config = {
}, {}),
},
};
console.log({ config });
module.exports = config;
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/HeaderItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function HiddenItem<T extends HiddenItemProps>({
}: 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) => {
Expand Down
5 changes: 5 additions & 0 deletions src/overflowMenu/overflowMenuPressHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

0 comments on commit 0ab738a

Please sign in to comment.