react-native-menu / menu

UIMenu Component for React Native
MIT License
989 stars 58 forks source link

How to use an "icon name included in the project" for the action image #331

Open jacklj opened 2 years ago

jacklj commented 2 years ago

Hi, it says in the README:

   * - Allows icon name included in project or system (Android) resources drawables and
   * in SF Symbol (iOS)

Does it mean you add the icon to the native project, and then you can refer to it? How do you do this?

Thanks

kayode0x commented 2 years ago

You can find all the icons on Hotpot.

Then to select an Icon, just click it, this copies the icon name to your clipboard.

Here's an example to get the Safari (Browser) icon, for iOS only.

{ id: 'open', title: 'Open', image: Platform.select({ ios: 'safari', }), }

Hope this answers your question 😁

jacklj commented 2 years ago

Thanks @kayode0x.

Sorry, I wasn’t clear enough - I know about using SF Symbols and Material Design icons.

The readme implies that you can alternatively use an “icon name that is included in the project” - or am I misreading it?

Thanks

hanishbasheer commented 2 years ago

it is not working for android the app is crashing when i use the name you mentioned

lclarkg18 commented 1 year ago
  • For Android Icons, click the Material Design option.
  • For iOS Icons, click the SF Symbols option.

Hi there, I'm experiencing the same issue as @hanishbasheer, my android icons are not working (they are working on iOS) It simply doesn't render any image even using the example code in the docs

Brma1048 commented 1 year ago

Same issue on android React Native: 0.71.2 @react-native-menu/menu": "0.7.3"

willxy commented 1 year ago

Same for me, for android:

Using eg 'ic_menu_add' works and gives me a plus sign in a circle. But none of the names for android on Hotspot work in the code. And none of the icons for android on Hotspot seem to be named 'ic_menu_add'.

So it looks like the code is using a different set of icon names for android than Hotspot is.

Where do I find the list of icon names, and their images, that work in this code?

Brma1048 commented 1 year ago

@willxy you need to add the icons via android studio In Android Studio, right-click on the “drawable” folder and select “New” » “Vector Asset”.

ShivamJoker commented 1 year ago

@willxy you need to add the icons via android studio In Android Studio, right-click on the “drawable” folder and select “New” » “Vector Asset”.

Thanks this helped.

focux commented 1 year ago

@willxy you need to add the icons via android studio In Android Studio, right-click on the “drawable” folder and select “New” » “Vector Asset”.

This kinda worked for me but instead of using right-click on the "drawable" folder, I clicked on the "Resource Manager" tab on the left and then clicked the plus button and selected Vector Asset.

PierreCapo commented 10 months ago

For those wondering, the default icons present for android can be found here (those that don't need an extra-install step): https://developer.android.com/reference/android/R.drawable

For instance: android: "ic_menu_gallery"