Skip to content

Commit 267b25f

Browse files
authored
macOS menu bar access (add/delete menu items) (#5)
* initial native part for accessing menu items * initial spec * add useMenuItem * refactor to aware of entire menu structure * add config for remove item * add separator, delete position in the config * update comments * add useMenuItem usage * cleanup * use same separator tag and string to simplify * colocate native source code * add wildcard remove * set initial menu items * remove top level menu when unmounting
1 parent 8de5c1b commit 267b25f

File tree

6 files changed

+846
-19
lines changed

6 files changed

+846
-19
lines changed

app/app.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@ import { useTheme, useThemeName, withTheme } from "./theme/theme"
1010
import { useEffect } from "react"
1111
import { TimelineScreen } from "./screens/TimelineScreen"
1212
import { AppHeader } from "./components/AppHeader"
13+
import { useMenuItem } from "./utils/useMenuItem"
1314

1415
if (__DEV__) {
1516
// This is for debugging Reactotron with ... Reactotron!
1617
// Load Reactotron client in development only.
1718
require("./devtools/ReactotronConfig.ts")
1819
}
1920

21+
const menuConfig = {
22+
remove: ["File", "Edit", "Format"],
23+
}
24+
2025
function App(): React.JSX.Element {
2126
const [theme] = useThemeName()
2227
const { colors } = useTheme(theme)
2328

29+
useMenuItem(menuConfig)
30+
2431
setTimeout(() => {
2532
fetch("https://www.google.com")
2633
.then((res) => res.text())
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#import <AppSpec/AppSpec.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
@interface IRMenuItemManager : NativeIRMenuItemManagerSpecBase <NativeIRMenuItemManagerSpec>
6+
@end
7+
8+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)