dominicstop / react-native-ios-context-menu

A react-native component to use context menu's (UIMenu) on iOS 13/14+
MIT License
572 stars 29 forks source link

Add "FIT" to MenuPreviewSize #88

Open mozzius opened 11 months ago

mozzius commented 11 months ago

I'm trying to recreate twitter's context menu behaviour for images. Images are usually cropped, and long pressing them grows them to their natural aspect ratio, as large as possible. Here are some examples:

  1. Cropped image before long press. Note how it's basically square

image

  1. Long pressing it grows it to be full height, and half width.

image

  1. Here's an example of a wide, short image:

image

However, previewSize: "STRETCH" seems to just set the preview to the maximum possible size, regardless of the size of the rendered preview.

I can either set the image to maintain it's aspect ratio, like so:

Simulator Screenshot - iPhone 15 - 2023-12-13 at 14 48 18

Or I can set it to fill the area, like so:

Simulator Screenshot - iPhone 15 - 2023-12-13 at 14 47 53

I'd love if I could set the preview area to respect the aspect ratio of the original image (alternatively, I wouldn't mind passing in an "aspectRatio" prop)