History log of /expo/packages/expo-camera/ios/EXCamera/CameraViewModule.swift (Results 1 – 5 of 5)
Revision Date Author Comments
# 3346744d 01-Jul-2023 Chee Kit <[email protected]>

[camera] Fix crash when onBarCodeScanned or onFacesDetected callback is removed (#23223)


# b336087c 19-May-2023 chalenascholl <[email protected]>

[expo-camera][ios] Use CoreMotion to detect device orientation (#21956)

# Why

Expo-camera doesn't allow landscape photos when the screen orientation is locked or if the React native app orientati

[expo-camera][ios] Use CoreMotion to detect device orientation (#21956)

# Why

Expo-camera doesn't allow landscape photos when the screen orientation is locked or if the React native app orientation is locked. This is contrary to how most cameras work (including apple's native camera), which allow you to take landscape photos despite orientation being locked to portrait.

Closes https://github.com/expo/expo/issues/21938


# How

The reason this happens is because `expo-camera` [relies on UIDeviceOrientation](https://github.com/expo/expo/blob/6085491bf6236a1aa82f96616ea31bbf4eda06ae/packages/expo-camera/ios/EXCamera/EXCamera.m#L357) to determine what type of a photo to take (portrait or landscape). It then sets the AVVideoOrientation to pass to Apple's `takePicture` or `startRecordingToOutputFileURL` function based on that. However, if the orientation is locked, the device orientation is always given as portrait by Apple which means the picture is always taken in portrait.

The only workaround I am aware of is to use the `CoreMotion` framework to check where the device is in space and then use that to determine what type of photo should be taken (portrait or landscape). This was also how the react-native-camera [package worked](https://github.com/react-native-camera/react-native-camera/blob/7cdfb6ec127decf1ac5686635afb7f07557becc5/ios/RCT/RCTSensorOrientationChecker.m#L72)

- I've added a property (ios only) `responsiveOrientationWhenOrientationLocked' to determine whether or not we should use the physical orientation of the device to determine the capture orientation when orientation is locked. This way, we won't be breaking any users of the package who rely on the existing behavior.
- I've also added a callback that applies when this property is set to true. Since `responsiveOrientationWhenOrientationLocked` means that landscape photos can be taken when the app is locked to portrait or when the device is locked to portrait, the screen itself will no longer rotate. The callback provides the user with the ability to rotate icons/buttons when the camera capture orientation changes (also what the native iOS camera does)

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules.
-->

- [x] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
- [x] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [x] This diff will work correctly for `expo prebuild` & EAS Build (eg: updated a module plugin).

show more ...


# 8bc4cb96 19-Jan-2023 Petto Martino <[email protected]>

[ios][camera] Fix path where camera saves picture on simulator (#20872)

# Why
When taking photo using `takePictureAsync` there is a specific implementation for the simulator.
However when building

[ios][camera] Fix path where camera saves picture on simulator (#20872)

# Why
When taking photo using `takePictureAsync` there is a specific implementation for the simulator.
However when building the directory where the file will be save, there is a small bug with the concatenation. The concatenation with the cacheDirectory is missing the slash (`/`) so it creates a folder called `CachesCamera` rather than `Caches/Camera` as the device implementation does.
This creates an issue because FileSystem can't access this folder thus files can't be deleted. This issue creates in inconsistency between development environment and real device.

# How

I added a slash `/` to the string. Assuming this implementation works only on simulator which works only on macOS, the file system will always use `/` as directory separator so I believe we can just add this missing `/`

# Test Plan

Use `expo-camera` and call the method takePictureAsync. Check the uri of the file generated.
<!--
Please describe how you tested this change and how a reviewer could reproduce your test, especially if this PR does not include automated tests! If possible, please also provide terminal output and/or screenshots demonstrating your test/reproduction.
-->

# Checklist

<!--
Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `expo prebuild` & EAS Build (eg: updated a module plugin).

show more ...


# 2693ada1 26-Sep-2022 Tomasz Sapeta <[email protected]>

[ios] Fix constants exported by the camera and improve code quality (#19119)


# 63bd39de 23-Aug-2022 Tomasz Sapeta <[email protected]>

[camera][ios] Migrate the camera view module to Swift (#18703)