Apparence-io / CamerAwesome

📸 Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
919 stars 207 forks source link

iOS 16:9 aspect ratio is changed to 4:3 when switching cameras #225

Closed migalv closed 1 year ago

migalv commented 1 year ago

Steps to Reproduce

  1. Add camerawesome: ^1.2.0 as a dependency
  2. Use the CameraAwesomeBuilder.custom builder method.
  3. Set aspectRatio: CameraAspectRatios.ratio_16_9
  4. Set sensor: Sensors.front
  5. Switch between front & selfie camera
CameraAwesomeBuilder.custom(
  previewFit: CameraPreviewFit.contain,
  sensor: Sensors.front,
  aspectRatio: CameraAspectRatios.ratio_16_9,
  ...
),

Expected results

The aspect ratio stays 16:9 when switching from selfie to front camera

Actual results

The aspect ratio changes to 4:3 when switching from selfie to front camera

Here is an example

About your device

Brand Model OS
Apple iPhone XR 15.5

apalala-dev commented 1 year ago

Thank you for raising this issue!

We linked a few properties to each Sensor (back camera or front camera). Aspect ratio is among them. When switching camera, these properties are reset to their default value.

I am not sure that we could have a behaviour that fits for everyone. For example, some people might want to reset to the original aspect ratio set in CamerAwesomeBuilder, others would like to keep the last aspect ratio chosen.

I will add optional parameters in my next PR to switchCameraSensor() to let you provide Sensor related properties (flash, aspect ratio...). I'll let you updated when it's ready.

migalv commented 1 year ago

Hello, @apalala-dev thanks a lot again for your quick response. That makes sense, I'll take a look.

Then I would have to store the current config somewhere and when the camera switches then reset the values of the current config is that right?

apalala-dev commented 1 year ago

I've made a draft for the previously mentioned PR. It includes an example on what you could do to keep the same aspect ratio on both back and front cameras.

Your switch camera sensor button would look like this (custom_awesome_ui.dart example):

AwesomeCameraSwitchButton(
  state: state,
  scale: 1.0,
  onSwitchTap: (state) {
    state.switchCameraSensor(
      aspectRatio: state.sensorConfig.aspectRatio,
    );
  },
)

There are still lot of things to change/improve. I'll try to stick to the dart part for now to minimize potential iOS breaking changes (I don't have an iPhone to try the new changes).

More documentation should be available when this PR will land.

If you have any feedback on the PR btw, feel free to share it. :)

migalv commented 1 year ago

Hey @apalala-dev I just saw this.

Can you share the PR? I'm not sure which one it is :)

apalala-dev commented 1 year ago

Sure! It's #228

migalv commented 1 year ago

Hey @apalala-dev I see that you merged the PR.

Could you solve this? When is there a new version available?

apalala-dev commented 1 year ago

Hey @migalv

We'll try to publish it early next week. You can check the updated documentation in the meanwhile. There are several examples as well in the repo to demonstrate how to customize the UI / buttons behaviours with the updated API.

apalala-dev commented 1 year ago

We finally published the 1.3. 🎉 It includes the ability to override the behaviour when switching sensors (and let you keep the same aspect ratio for example).

Closing this since it should be fixed now.