Scan barcodes/qrcodes only inside the highlighted area#3697
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR restricts barcode/QR code scanning to a fixed, highlighted square and updates the messaging UI.
- Add
screenSizepropagation and normalizerectOfInterestinBarcodeScannerCamera - Refactor
BarcodeScannerCameraViewandBarcodeScannerViewto render a fixed scanning square overlay - Replace alert presentation in
WebViewExternalMessageHandlerwith 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-basedrectOfInterestlogic isn't covered by existing tests. Consider adding unit tests to verify the normalizedrectOfInterestis calculated correctly for various screen sizes.
public var screenSize: CGSize? {
Sources/App/BarcodeScanner/Camera/BarcodeScannerView.swift:60
- [nitpick] The
accessibilityHintis 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 ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes