Skip to content

Scan barcodes/qrcodes only inside the highlighted area#3697

Merged
bgoncal merged 3 commits intomasterfrom
improve-scanner
Jul 4, 2025
Merged

Scan barcodes/qrcodes only inside the highlighted area#3697
bgoncal merged 3 commits intomasterfrom
improve-scanner

Conversation

@bgoncal
Copy link
Copy Markdown
Member

@bgoncal bgoncal commented Jul 4, 2025

Summary

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

@bgoncal bgoncal requested a review from Copilot July 4, 2025 13:38
@bgoncal bgoncal self-assigned this Jul 4, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR restricts barcode/QR code scanning to a fixed, highlighted square and updates the messaging UI.

  • Add screenSize propagation and normalize rectOfInterest in BarcodeScannerCamera
  • Refactor BarcodeScannerCameraView and BarcodeScannerView to render a fixed scanning square overlay
  • Replace alert presentation in WebViewExternalMessageHandler with a SwiftMessages banner

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Sources/App/WebView/WebViewExternalMessageHandler.swift Annotate handler with @MainActor and extract alert to presentBarcodeScannerMessage using SwiftMessages
Sources/App/BarcodeScanner/Camera/BarcodeScannerView.swift Define static square size, use @StateObject for model, and update layout to overlay scanning region
Sources/App/BarcodeScanner/Camera/BarcodeScannerCameraView.swift Add screenSize parameter and forward it to model.camera for rect of interest setup
Sources/App/BarcodeScanner/Camera/BarcodeScannerCamera.swift Implement screenSize property to compute and apply normalized rectOfInterest on capture session
Comments suppressed due to low confidence (2)

Sources/App/BarcodeScanner/Camera/BarcodeScannerCamera.swift:30

  • The new screenSize-based rectOfInterest logic isn't covered by existing tests. Consider adding unit tests to verify the normalized rectOfInterest is calculated correctly for various screen sizes.
    public var screenSize: CGSize? {

Sources/App/BarcodeScanner/Camera/BarcodeScannerView.swift:60

  • [nitpick] The accessibilityHint is attached to the HStack instead of the CloseButton. Consider moving accessibility modifiers (hint and label) directly to the button so that screen readers announce it correctly.
                .accessibilityHint(.init(L10n.closeLabel))

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 45.62%. Comparing base (4f60d68) to head (b6fe786).
Report is 70 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3697      +/-   ##
==========================================
+ Coverage   44.72%   45.62%   +0.90%     
==========================================
  Files         232      233       +1     
  Lines       13911    14101     +190     
==========================================
+ Hits         6221     6434     +213     
+ Misses       7690     7667      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgoncal bgoncal merged commit 62fcf1d into master Jul 4, 2025
14 checks passed
@bgoncal bgoncal deleted the improve-scanner branch July 4, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants