teslamotors / react-native-camera-kit

A high performance, easy to use, rock solid camera library for React Native apps.
MIT License
2.42k stars 577 forks source link

Add resize mode cover/contain #644

Closed lichstam closed 1 month ago

lichstam commented 4 months ago

Motivation

I've added support for a dynamic resizeMode in the RealCamera class to address the need for flexible aspect ratio handling of the camera's preview layer. This enhancement allows switching between .resizeAspectFill and .resizeAspect, improving UI flexibility. My main goal was to enable both a full-cover and contained fit for the camera preview without manual adjustments. This feature is critical for applications requiring dynamic adjustments to the camera preview based on user interaction or specific UI layouts.

Testing on iOS

Despite not being a Swift developer, I managed to implement and test these changes on iOS:

Manual Testing: Conducted to ensure the resizeMode property correctly updates the videoGravity of the AVCaptureVideoPreviewLayer. UI Verification: Confirmed the UI updates accordingly, without any disruptions or visual glitches. Regression Testing: Checked that existing functionalities (camera initialization, capture functionality, zoom, and focus adjustments) remain unaffected. Testing was limited to iOS due to my current setup. Android testing is needed to ensure cross-platform compatibility and functionality.

lichstam commented 4 months ago

i'll have a look tomorrow!

lichstam commented 4 months ago

https://github.com/teslamotors/react-native-camera-kit/assets/34944192/87beb715-02d6-42e3-affb-e6bcbbb15bdc

This is how I made the example

All other issues are addressed. You were right btw, somehow the call to the function didn't make it in the first iteration of this PR :)

lichstam commented 2 months ago

i'll take a look at the minor comments, however, is this repo even alive?

scarlac commented 1 month ago

@lichstam Yes, still alive. Thank you for the contribution for iOS.

lichstam commented 1 month ago

np :)