Skip to content

Conversation

@batuhanoztrk
Copy link
Contributor

Add Imperative Menu Control for Android

Changes

  • Added a new show() method to programmatically display menus on Android
  • Implemented ref forwarding to expose the show() method to React Native components
  • Added TypeScript types to support the new functionality
  • Updated example app to demonstrate the new feature

Implementation Details

  • Added native Android command handling in MenuViewManagerBase.kt
  • Created a new MenuComponentRef type for TypeScript support
  • Wrapped the native component with ref forwarding in UIMenuView.android.tsx
  • Added example usage with a button trigger in the example app

Example Usage

const menuRef = useRef<MenuComponentRef>(null);
// Show menu programmatically
menuRef.current?.show();
// In JSX
<MenuView
    ref={menuRef}
    title="Menu Title"
    actions={...}
/>

Testing

  • Verified menu display using the example app
  • Confirmed TypeScript types work correctly
  • Tested compatibility with existing menu functionality

Notes

  • This feature is currently Android-only
  • Existing menu behavior remains unchanged

Copy link
Member

@Naturalclar Naturalclar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants