-
Notifications
You must be signed in to change notification settings - Fork 585
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
Lay the foundation for a Swift migration #547
Merged
scarlac
merged 20 commits into
teslamotors:master
from
DavidBertet:task/swift_migration
Jul 12, 2023
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9342a1d
Lay the foundation for a Swift migration
DavidBertet bdbfac1
Swift migration & rewrite
DavidBertet baf3e11
Fix Git Action iOS build
DavidBertet d730a76
Fix small issues, throttle scanner
DavidBertet a23aa47
Remove prints & signpost
DavidBertet 01c2367
Remove unused protocol
DavidBertet 5a7df3e
Removed CameraScreen
scarlac 37737ac
Rewrote example project
scarlac fee756b
Fixed orientation issues for both orientation locked and rotated UIs
scarlac 8b34666
Small refinements
DavidBertet d92b40b
Make button targets bigger by adding some padding
DavidBertet 6c7e0fe
Fix default zoomFactor when we switch camera
DavidBertet d738b6c
Using hooks/functional component for App
DavidBertet 13aed71
Refine orientation
DavidBertet 231bb30
Try to match native app pinch to zoom
DavidBertet 2f0195b
Enable videoStabilization if supported
DavidBertet fedec20
Remove extensions & unused pinch velocity
DavidBertet b0048a0
Remove `setTorchMode` method on Android
DavidBertet 5f10962
Rework UI to make it work on both platforms
DavidBertet 478a68b
Fixed scan frame dimensions on Android
scarlac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,9 +232,9 @@ class CameraView: UIView { | |
self?.camera.previewView.alpha = 1 | ||
}) | ||
} | ||
}, onSuccess: { [weak self] imageData in | ||
}, onSuccess: { [weak self] imageData, thumbnailData in | ||
DispatchQueue.global(qos: .default).async { | ||
self?.writeCaptured(imageData: imageData, onSuccess: onSuccess, onError: onError) | ||
self?.writeCaptured(imageData: imageData, thumbnailData: thumbnailData, onSuccess: onSuccess, onError: onError) | ||
|
||
self?.focusInterfaceView.resetFocus() | ||
} | ||
|
@@ -262,15 +262,21 @@ class CameraView: UIView { | |
} | ||
} | ||
|
||
private func writeCaptured(imageData: Data, | ||
private func writeCaptured(imageData: Data, | ||
thumbnailData: Data?, | ||
onSuccess: @escaping (_ imageObject: [String: Any]) -> (), | ||
onError: @escaping (_ error: String) -> ()) { | ||
do { | ||
let temporaryFileURL = try saveToTmpFolder(imageData) | ||
var temporaryThumbFileURL: URL? = nil | ||
if let t = thumbnailData { | ||
temporaryThumbFileURL = try saveToTmpFolder(t) | ||
} | ||
onSuccess([ | ||
"size": imageData.count, | ||
"uri": temporaryFileURL.description, | ||
"name": temporaryFileURL.lastPathComponent | ||
"name": temporaryFileURL.lastPathComponent, | ||
"thumb": temporaryThumbFileURL?.description ?? "" | ||
]) | ||
} catch { | ||
let errorMessage = "Error occurred while writing image data to a temporary file: \(error)" | ||
|
@@ -304,9 +310,8 @@ class CameraView: UIView { | |
// MARK: - Gesture selectors | ||
|
||
@objc func handlePinchToZoomRecognizer(_ pinchRecognizer: UIPinchGestureRecognizer) { | ||
var zoomScale = pinchRecognizer.scale | ||
if pinchRecognizer.state == .changed { | ||
camera.update(zoomScale: zoomScale) | ||
camera.update(pinchVelocity: pinchRecognizer.velocity, pinchScale: pinchRecognizer.scale) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do want to use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't matter a ton to me. I was just playing with various algorithms to get an improved behavior. |
||
pinchRecognizer.scale = 1.0 | ||
} | ||
} | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you getting a thumbnail? Seems like we have to explicitly enable it
https://developer.apple.com/documentation/avfoundation/avcapturephoto/2873984-previewpixelbuffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's just laying some preparation for later changes. I had it working locally but have not committed enabling it since it needs several other features enabled and must be an opt-in feature. We can leave it in for now.