Skip to content
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

feat(camera): wide zoom cameras in custom camera #948

Merged
merged 5 commits into from
Nov 6, 2024

Conversation

tsinis
Copy link
Contributor

@tsinis tsinis commented Nov 1, 2024

Hey again @longitachi, thanks for reviewing my previous PRs, here is another one.

This PR introduces a new feature to the ZLCustomCamera that allows users to utilize wide cameras (e.g., .builtInTripleCamera, .builtInDualWideCamera, .builtInDualCamera). This enhancement is designed to improve the flexibility and functionality of the camera, especially for users who need to capture wider shots. And it's also a feature that exists in the original UIImagePickerController but is missing in ZLCustomCamera.

Key Changes

  • Added a new boolean property enableWideCameras to ZLCameraConfiguration.

  • Updated the getCamera method in ZLCustomCamera to include the cameraConfig.enableWideCameras flag check along with the #available check.

  • Modified the setInitialZoomFactor method in ZLCustomCamera to use an early return with the guard statement if cameraConfig.enableWideCameras is false.

  • Enhanced the setVideoZoomFactor method in ZLCustomCamera to use the new implementation only if cameraConfig.enableWideCameras is true. Otherwise, it uses the original implementation.

Benefits

  • Flexibility: This feature allows users to take advantage of wide cameras, providing more options for capturing photos and videos.

  • User Experience: Users can now capture wider shots, which is especially useful for landscape photography, group photos, and more.

Non-Breaking Change

This change is non-breaking and does not affect existing functionality. The wide camera feature is disabled by default and can be enabled by setting the enableWideCameras parameter to true.


Please review the changes and let me know if there are any adjustments or additional features you would like to include. Thank you!

@@ -1032,7 +1077,13 @@ open class ZLCustomCamera: UIViewController {
}
do {
try device.lockForConfiguration()
device.videoZoomFactor = zoomFactor
if cameraConfig.enableWideCameras {
let minZoomFactor = device.minAvailableVideoZoomFactor
Copy link
Owner

@longitachi longitachi Nov 6, 2024

Choose a reason for hiding this comment

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

@available(iOS 11.0, *)
open var minAvailableVideoZoomFactor: CGFloat { get }

The minAvailableVideoZoomFactor property supports iOS 11 at the minimum, and an error will be reported when running here.

I noticed that when you used enableWideCameras, there were several places where @available(iOS 13.0, *) was judged, so I think it would be better to mark the enableWideCameras property as @available(iOS 13.0, *), what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @longitachi, yes, it makes sense, I wanted this PR to have as few LOC changes as possible since an explicit availability check will still be needed for AVCaptureDevice.DeviceType. I provided changes, thanks!

@longitachi longitachi merged commit 995b76b into longitachi:master Nov 6, 2024
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