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

[android][camera] Set the previews scaleType when changing ratio #30831

Merged
merged 5 commits into from
Aug 6, 2024

Conversation

alanjhughes
Copy link
Collaborator

Why

Closes #30829
When setting the aspect ratio, it will not take effect unless you also change the scaleType on the preview. By default, it is set to FILL_CENTER, which ignores the aspect ratio setting and scales the image up to fill its container.

How

Based on the ratio value, set the scaleType of the previewView.

Test Plan

Bare-expo. Changing ratios now affects the preview correctly.

@alanjhughes alanjhughes requested a review from Kudo August 6, 2024 07:59
@@ -394,7 +394,7 @@ export type CameraProps = ViewProps & {
responsiveOrientationWhenOrientationLocked?: boolean;
/**
* A string representing the aspect ratio of the preview. For example, `4:3` and `16:9`.
* @default 4:3
* @default 1:1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Default was set to 1:1 to maintain current behaviour.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Aug 6, 2024
@expo-bot
Copy link
Collaborator

expo-bot commented Aug 6, 2024

The Pull Request introduced fingerprint changes against the base commit: 8b52504

Fingerprint diff
[
  {
    "op": "changed",
    "source": {
      "type": "dir",
      "filePath": "../../packages/expo-camera/android",
      "reasons": [
        "expoAutolinkingAndroid"
      ],
      "hash": "3b80516fc1fcaa90fc5e350a5f40b87ee10c1574"
    }
  }
]

Generated by PR labeler 🤖

@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Aug 6, 2024
@alanjhughes alanjhughes marked this pull request as ready for review August 6, 2024 08:33
@alanjhughes alanjhughes requested a review from lukmccall as a code owner August 6, 2024 08:33
Copy link
Contributor

@Kudo Kudo left a comment

Choose a reason for hiding this comment

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

thanks for fixing this. just adding some nit comment if that makes sense to you.

Copy link
Contributor

@Kudo Kudo left a comment

Choose a reason for hiding this comment

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

rebuild js and doc then good to merge 🚀

@alanjhughes alanjhughes merged commit 948ac89 into main Aug 6, 2024
10 checks passed
@alanjhughes alanjhughes deleted the @alanhughes/camera/fix-preview-scale branch August 6, 2024 15:20
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[expo-camera] [android] [patched-package] Patched expo-camera does not change ratio when add it as attribute
6 participants