Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
node-version: 'lts/*'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ You can fully customize what it renders inside of the `PlatformPressable` using

## Recipes

#### Closing the overflow menu from `overflowMenuPressHandlerDropdownMenu` manually

`overflowMenuPressHandlerDropdownMenu` supports rendering custom items in the menu. In your item's onPress handler, you can call `closeMenu` to close the menu manually.

```ts
const { closeMenu } = useOverflowMenu();
```

#### Customizing the overflow menu

The default handler for overflow menu on iOS is `overflowMenuPressHandlerActionSheet`.
Expand Down
8 changes: 8 additions & 0 deletions example/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { registerRootComponent } from 'expo';

import App from './App';

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App);
16 changes: 8 additions & 8 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"@react-navigation/stack": "^6.3.16",
"expo": "~49.0.13",
"expo-splash-screen": "~0.20.5",
"expo-status-bar": "~1.6.0",
"expo": "~50.0.6",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.72.5",
"react-native-gesture-handler": "~2.12.0",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native": "0.73.4",
"react-native-gesture-handler": "~2.14.0",
"react-native-safe-area-context": "4.8.2",
"react-native-screens": "~3.29.0",
"react-native-web": "~0.19.6"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@expo/webpack-config": "^19.0.0",
"@expo/webpack-config": "~19.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-module-resolver": "^4.1.0"
},
Expand Down
11 changes: 6 additions & 5 deletions example/src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function HomeScreen({ navigation }: ScreenProps<'HomeScreen'>) {
const { toggleTheme } = React.useContext(ThemeContext);

return (
<ScrollView>
<ScrollView contentContainerStyle={{ rowGap: 10 }}>
<Text style={{ margin: 15 }}>Explore possible usages with:</Text>
<Button
onPress={() => _navigateTo('UsageWithIcons')}
Expand All @@ -47,6 +47,10 @@ export function HomeScreen({ navigation }: ScreenProps<'HomeScreen'>) {
onPress={() => _navigateTo('UsageWithCustomOverflow')}
title="Custom overflow menu action"
/>
<Button
onPress={() => _navigateTo('UsageNativeMenu')}
title="Native menu overflow"
/>
<Button
onPress={() => _navigateTo('UsageWithOverflowComplex')}
title="Overflow menu - all handlers"
Expand All @@ -67,10 +71,7 @@ export function HomeScreen({ navigation }: ScreenProps<'HomeScreen'>) {
onPress={() => _navigateTo('UsageCustom')}
title="Custom elements"
/>
<Button
onPress={() => _navigateTo('UsageNativeMenu')}
title="Native menu overflow"
/>

<Button
onPress={toggleTheme}
title="Toggle Theme (ripple, text and icon color changes)"
Expand Down
22 changes: 15 additions & 7 deletions example/src/screens/UsageWithOverflowComplex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
overflowMenuPressHandlerDropdownMenu,
HiddenItemProps,
OnOverflowMenuPressParams,
useOverflowMenu,
} from 'react-navigation-header-buttons';
import type { ScreenProps } from '../NavTypes';
import { Button } from '../components/PaddedButton';
Expand All @@ -30,10 +31,22 @@ const handlers = {
overflowMenuPressHandlerActionSheet,
overflowMenuPressHandlerPopupMenu,
custom: function custom(obj: OnOverflowMenuPressParams) {
alert('you custom function will receive:' + Object.keys(obj));
alert('you custom function will receive:' + Object.keys(obj).join(', '));
},
};

const CustomViewInOverflow = () => {
const { closeMenu } = useOverflowMenu();
return (
<View style={{ backgroundColor: 'orange', maxWidth: 200 }}>
<Text onPress={closeMenu}>
custom view that will only be considered for
overflowMenuPressHandlerDropdownMenu
</Text>
</View>
);
};

export function UsageWithOverflowComplex({
navigation,
}: ScreenProps<'UsageWithOverflowComplex'>) {
Expand Down Expand Up @@ -64,12 +77,7 @@ export function UsageWithOverflowComplex({
onPress={() => alert('hidden4')}
/>,
]}
<View style={{ backgroundColor: 'orange', maxWidth: 200 }}>
<Text>
custom view that will only be considered for
overflowMenuPressHandlerDropdownMenu
</Text>
</View>
<CustomViewInOverflow />
</OverflowMenu>
),
});
Expand Down
Loading