Skip to content

fix: iPad preview shifted left and wrongly rotated in landscape#639

Open
damianr13 wants to merge 2 commits intoApparence-io:masterfrom
minimistapp:fix/ipad-preview-orientation
Open

fix: iPad preview shifted left and wrongly rotated in landscape#639
damianr13 wants to merge 2 commits intoApparence-io:masterfrom
minimistapp:fix/ipad-preview-orientation

Conversation

@damianr13
Copy link
Copy Markdown

Summary

Fixes #625 — Camera preview is broken on iPads:

  • Preview shifted to the left in portrait mode (not centered)
  • Preview wrongly rotated in landscape mode

Changes

  • awesome_preview_fit.dart: Add explicit width constraint to the preview SizedBox. Previously only height was set, causing the preview to not be horizontally centered (shifted left on iPads).
  • awesome_camera_preview.dart: Track device orientation via getNativeOrientation() stream. Apply RotatedBox to rotate the camera texture when the device is in landscape, and swap preview dimensions so the layout engine sizes the preview correctly.
  • MotionController.m/.h: Add onOrientationChanged callback so the native motion controller can notify when orientation changes, enabling the Dart-side orientation tracking.
  • camera_awesome_builder.dart: Remove SystemChrome.setPreferredOrientations([portraitUp]) from didChangeDependencies — this was forcing portrait-only and preventing landscape from working at all.

Test plan

  • Tested on iPad (portrait): preview is centered, no black bar on the right
  • Tested on iPad (landscape): preview is correctly rotated and fills the view
  • Tested on iPhone (portrait): no regression, preview works as before
  • Tested on iPhone (landscape): preview rotates correctly

@g-apparence
Copy link
Copy Markdown
Collaborator

Thanks a lot for your PR 🙏🏻

@g-apparence
Copy link
Copy Markdown
Collaborator

You removed

SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

The problem is that we wanted to mimic the iphone normal behavior.
All element are fixed. (open native camera to see what I mean)

This also can impact android

damianr13 added a commit to minimistapp/CameraAwesome that referenced this pull request Apr 4, 2026
Reverts orientation tracking and RotatedBox rotation that caused
viewport shifting on iPads. Restores setPreferredOrientations portrait
lock and adds native hardening to keep AVCaptureConnection locked to
portrait regardless of device motion.

Addresses feedback on PR Apparence-io#639.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Reverts orientation tracking and RotatedBox rotation that caused
viewport shifting on iPads. Restores setPreferredOrientations portrait
lock and adds native hardening to keep AVCaptureConnection locked to
portrait regardless of device motion.

Addresses feedback on PR Apparence-io#639.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@damianr13
Copy link
Copy Markdown
Author

@g-apparence

Thanks for pointing that. Our users have also raised this issue since we rolled out this update. I worked on it a bit more and now the camera viewport is stable on my iPad 6 Mini. Please have a look and consider if these changes might be useful for the library

Happy Easter 🐰

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.

Camera preview broken on iPads

2 participants