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

fix(llm): πŸŽ₯ render camera feed right after granting access #8712

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-toes-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Fix camera rendering right after granting access
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import BottomContainer from "./BottomContainer";
import { CameraView, BarcodeScanningResult } from "expo-camera";
import ScanTargetSvg from "./ScanTargetSvg";
import RequiresCameraPermissions from "~/components/RequiresCameraPermissions";
import CameraPermissionContext from "~/components/RequiresCameraPermissions/CameraPermissionContext";

type Props = {
onQrCodeScanned: (data: string) => void;
Expand Down Expand Up @@ -72,17 +73,22 @@ const ScanQrCode = ({ onQrCodeScanned }: Props) => {
justifyContent={"center"}
alignItems={"center"}
>
<CameraView
style={{
backgroundColor: colors.neutral.c50,
width: 280,
height: 280,
}}
barcodeScannerSettings={{
barcodeTypes: ["qr"],
}}
onBarcodeScanned={onBarCodeScanned}
/>
<CameraPermissionContext.Consumer>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to define a component to avoid using CameraPermissionContext.Consumer:

function WaitForPermissionCameraView(props: CameraProps) {
  const { permissionGranted } = useContext(CameraPermissionContext);
  return <CameraView active={permissionGranted ?? false} {...props} />;
}

But this implementation didn't solves the problem on iOS (even when adding a key changing based on the permission).

{({ permissionGranted }) => (
<CameraView
active={permissionGranted ?? false}
style={{
backgroundColor: colors.neutral.c50,
width: 280,
height: 280,
}}
barcodeScannerSettings={{
barcodeTypes: ["qr"],
}}
onBarcodeScanned={onBarCodeScanned}
/>
)}
</CameraPermissionContext.Consumer>
<ScanTargetSvg style={{ position: "absolute" }} />
</Flex>
<Flex flexDirection={"row"} alignItems={"center"} columnGap={8}>
Expand Down