Closed subelsky closed 5 months ago
Hi @subelsky. Awesome code! I’ve reviewed the code and tested it on the device and it looks good to me 👍. I'll be merge this into the latest version for release.
The issue you mentioned in your note is something I've been thinking about for a while too, but I haven't been able to crack it yet 😅. If you have some time later, I’d love for you to share some of your works. Maybe we can brainstorm and work through it together!
Thanks again for your contribution!
Summary
Improved the handling of orientation changes in the
InteractivePreview
andPreview
classes to ensure proper resizing and layout adjustments of theAVCaptureVideoPreviewLayer
during device rotation. These changes address issues where the preview layer would not correctly adapt to new geometry sizes, leading to misalignment.Details
InteractivePreview
:onChange
modifier to observe changes in the geometry size.layer
frame on the main dispatch queue to ensure proper resizing.Preview
:previewLayer.frame
inupdateUIViewController
.previewLayer
is added to the view controller’s layer only if it hasn’t been added already.previewLayer.frame
on the main dispatch queue to ensure it resizes correctly when the view bounds change.Note
This will not affect the orientation of the session. To do that, application code must wrap the preview layer with handlers that call
aespaSession.common(.orientation(orientation: ...))
. I have some code that demonstrates this, but it's very specific to my app, so I couldn't cleanly extract a good example for the README. I can try to tackle that in a future commit.