-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add resize mode cover/contain #644
Conversation
ios/ReactNativeCameraKit/Types.swift
Outdated
@@ -105,6 +105,19 @@ public enum ZoomMode: Int, CustomStringConvertible { | |||
} | |||
} | |||
|
|||
@objc(CKResizeMode) | |||
public enum ResizeMode: Int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make it consistent with the other ones, like the one above?
No = 0
, implements CustomStringConvertible
, description
instead of stringValue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lichstam what about this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lichstam!
Can you:
- add the documentation in the README
- check
CameraProps
where I guess it should be added in iOS specific section - see if we can add it in the example somehow? so we can easily test/showcase it
- maybe add a label in the simulator to see what mode we are on
Who is calling func update(resizeMode: ResizeMode)
? I feel like the logic in CameraView
is missing, but you seem to say that its working
i'll have a look tomorrow! |
355e711
to
5f4c07a
Compare
5f4c07a
to
8978035
Compare
RPReplay_Final1709062570.MP4This 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 :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On small feedback, but otherwise it's looking good 👍
@@ -27,6 +27,7 @@ class RealCamera: NSObject, CameraProtocol, AVCaptureMetadataOutputObjectsDelega | |||
private let photoOutput = AVCapturePhotoOutput() | |||
private let metadataOutput = AVCaptureMetadataOutput() | |||
|
|||
private var resizeMode: ResizeMode = .contain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we do .contain
here, and .cover
in CameraView? Seems like we should have contain
for all default values to keep things consistent (and say so in the doc)
i'll take a look at the minor comments, however, is this repo even alive? |
@lichstam Yes, still alive. Thank you for the contribution for iOS. |
np :) |
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.