Skip to content

Commit 364f4b3

Browse files
committed
make VideoRotationAngle enum
1 parent f855d6d commit 364f4b3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

WooCommerce/Classes/ViewRelated/Products/Scanner/CodeScannerViewController.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,28 @@ private extension CodeScannerViewController {
301301
// MARK: Orientation Handling
302302
//
303303
private extension CodeScannerViewController {
304+
enum VideoRotationAngle {
305+
static let portrait: CGFloat = 90
306+
static let landscapeRight: CGFloat = 0
307+
static let landscapeLeft: CGFloat = 180
308+
static let portraitUpsideDown: CGFloat = 270
309+
}
310+
304311
func updatePreviewLayerOrientation() {
305312
if let connection = previewLayer?.connection {
306313
let orientation = view.window?.windowScene?.interfaceOrientation
307314
let videoRotationAngle: CGFloat
308315
switch orientation {
309316
case .portrait:
310-
videoRotationAngle = 90
317+
videoRotationAngle = VideoRotationAngle.portrait
311318
case .landscapeRight:
312-
videoRotationAngle = 0
319+
videoRotationAngle = VideoRotationAngle.landscapeRight
313320
case .landscapeLeft:
314-
videoRotationAngle = 180
321+
videoRotationAngle = VideoRotationAngle.landscapeLeft
315322
case .portraitUpsideDown:
316-
videoRotationAngle = 270
323+
videoRotationAngle = VideoRotationAngle.portraitUpsideDown
317324
default:
318-
videoRotationAngle = 90
325+
videoRotationAngle = VideoRotationAngle.portrait
319326
}
320327
updatePreviewLayerVideoRotationAngle(connection: connection, angle: videoRotationAngle)
321328
}

0 commit comments

Comments
 (0)