Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

Conversation

@dulgan
Copy link

@dulgan dulgan commented Oct 1, 2019

This PR brings support to iPad and camera rotation (See #76 )

self.init(rawValue: AVCaptureVideoOrientation.portraitUpsideDown.rawValue)
default:
self.init(rawValue: AVCaptureVideoOrientation.portrait.rawValue)
case .portrait: self = .portrait
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

default:
self.init(rawValue: AVCaptureVideoOrientation.portrait.rawValue)
case .portrait: self = .portrait
case .portraitUpsideDown: self = .portraitUpsideDown
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

self.init(rawValue: AVCaptureVideoOrientation.portrait.rawValue)
case .portrait: self = .portrait
case .portraitUpsideDown: self = .portraitUpsideDown
case .landscapeLeft: self = .landscapeLeft
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portrait: self = .portrait
case .portraitUpsideDown: self = .portraitUpsideDown
case .landscapeLeft: self = .landscapeLeft
case .landscapeRight: self = .landscapeRight
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portraitUpsideDown: self = .portraitUpsideDown
case .landscapeLeft: self = .landscapeLeft
case .landscapeRight: self = .landscapeRight
case .faceUp: self = .portrait
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .landscapeLeft: self = .landscapeLeft
case .landscapeRight: self = .landscapeRight
case .faceUp: self = .portrait
case .faceDown: self = .portraitUpsideDown
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .landscapeRight: self = .landscapeRight
case .faceUp: self = .portrait
case .faceDown: self = .portraitUpsideDown
default: self = .portrait
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

/// Maps UIInterfaceOrientation to AVCaptureVideoOrientation
init?(interfaceOrientation: UIInterfaceOrientation) {
switch interfaceOrientation {
case .portrait: self = .portrait
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

init?(interfaceOrientation: UIInterfaceOrientation) {
switch interfaceOrientation {
case .portrait: self = .portrait
case .portraitUpsideDown: self = .portraitUpsideDown
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

switch interfaceOrientation {
case .portrait: self = .portrait
case .portraitUpsideDown: self = .portraitUpsideDown
case .landscapeLeft: self = .landscapeLeft
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portrait: self = .portrait
case .portraitUpsideDown: self = .portraitUpsideDown
case .landscapeLeft: self = .landscapeLeft
case .landscapeRight: self = .landscapeRight
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portraitUpsideDown: self = .portraitUpsideDown
case .landscapeLeft: self = .landscapeLeft
case .landscapeRight: self = .landscapeRight
default: return nil
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline


init(deviceOrientation: UIDeviceOrientation) {
switch deviceOrientation {
case .portrait: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

init(deviceOrientation: UIDeviceOrientation) {
switch deviceOrientation {
case .portrait: self = .up
case .portraitUpsideDown: self = .down
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

switch deviceOrientation {
case .portrait: self = .up
case .portraitUpsideDown: self = .down
case .landscapeLeft: self = .left
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portrait: self = .up
case .portraitUpsideDown: self = .down
case .landscapeLeft: self = .left
case .landscapeRight: self = .right
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portraitUpsideDown: self = .down
case .landscapeLeft: self = .left
case .landscapeRight: self = .right
case .unknown: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .landscapeLeft: self = .left
case .landscapeRight: self = .right
case .unknown: self = .up
case .faceUp: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .landscapeRight: self = .right
case .unknown: self = .up
case .faceUp: self = .up
case .faceDown: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline


init(interfaceOrientation: UIInterfaceOrientation) {
switch interfaceOrientation {
case .portrait: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

init(interfaceOrientation: UIInterfaceOrientation) {
switch interfaceOrientation {
case .portrait: self = .up
case .portraitUpsideDown: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

switch interfaceOrientation {
case .portrait: self = .up
case .portraitUpsideDown: self = .up
case .landscapeLeft: self = .left
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portrait: self = .up
case .portraitUpsideDown: self = .up
case .landscapeLeft: self = .left
case .landscapeRight: self = .right
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline

case .portraitUpsideDown: self = .up
case .landscapeLeft: self = .left
case .landscapeRight: self = .right
case .unknown: self = .up
Copy link

Choose a reason for hiding this comment

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

⚠️ Cases inside a switch should always be on a newline


override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: { [weak self] (context) in
Copy link

Choose a reason for hiding this comment

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

⚠️ Unused parameter “context” in a closure should be replaced with _.

@ghost
Copy link

ghost commented Oct 1, 2019

6 Warnings
⚠️ Consider to place some MARK: lines for WeScan/Common/Quadrilateral.swift, which is over 200 lines big.
⚠️ Capabilities for WeScanSampleProject may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the build settings editor. (in target ‘WeScanSampleProject’)
⚠️ The use of Swift 3 @objc inference in Swift 4 mode is deprecated. Please address deprecated @objc inference warnings, test your code with “Use of deprecated Swift 3 @objc inference” logging enabled, and then disable inference by changing the “Swift 3 @objc Inference” build setting to “Default” for the “FBSnapshotTestCase iOS” target. (in target ‘FBSnapshotTestCase iOS’)
⚠️ WeScan/Scan/CaptureSessionManager.swift#L239 - Function should have 5 parameters or less: it currently has 6
⚠️ WeScanSampleProject/HomeViewController.swift#L15 - Prefer object literals over image and color inits.
⚠️ WeScanSampleProject/HomeViewController.swift#L134 - Incorrect logging
1 Message
📖 Executed 56 tests, with 0 failures (0 unexpected) in 20.748 (20.921) seconds

Current coverage for WeScan is 39.74%

Files changed - -
CGImagePropertyOrientation.swift 0.00% 💀
UIInterfaceOrientation+Utils.swift 0.00% 💀
ScannerViewController.swift 0.00% 💀
CaptureSessionManager.swift 0.00% 💀
AVCaptureVideoOrientation+Utils.swift 55.00% ⚠️
Quadrilateral.swift 89.04%

Current coverage for WeScanSampleProject is 45.83%

Files changed - -
UIInterfaceOrientation+Utils.swift 0.00% 💀
HomeViewController.swift 49.61% 🚫

Powered by xcov

Generated by 🚫 Danger

@dulgan
Copy link
Author

dulgan commented Oct 1, 2019

That's a lot of emails I received, hope you'll use my work in any way since I won't have time to modify it.

@AvdLee AvdLee closed this Jan 28, 2020
@ghost ghost mentioned this pull request Feb 11, 2020
@willm132
Copy link

Has anyone found a fix to allow this in landscape only, not portrait?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants