Skip to content

Commit 9f34fcb

Browse files
author
rmotygullin
committed
Merge branch 'fix_rotation'
2 parents 7916101 + 139082d commit 9f34fcb

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Example/ContainerControllerSwift/Maps/MapsViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate,
105105

106106
@objc func rotated() {
107107

108-
let orint = UIDevice.current.orientation
109-
if orint == .faceUp || orint == .faceDown || orint == .portraitUpsideDown { return }
108+
if !UIDevice.current.orientation.isRotateAllowed { return }
110109

111110
updateMapViewTopPadding()
112111
}

Sources/ContainerController/ContainerController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ open class ContainerController: NSObject {
211211

212212
@objc func rotated() {
213213

214-
let orint = UIDevice.current.orientation
215-
if orint == .faceUp || orint == .faceDown || orint == .portraitUpsideDown { return }
214+
if !UIDevice.current.orientation.isRotateAllowed { return }
216215

217216
if ContainerDevice.orientation == oldOrientation { return }
218217
oldOrientation = ContainerDevice.orientation

Sources/ContainerController/ContainerDevice.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import UIKit
1010

1111
@available(iOS 13.0, *)
1212
public extension ContainerDevice {
13-
1413
enum Orientation {
1514
case portrait
1615
case landscapeLeft
@@ -85,7 +84,7 @@ open class ContainerDevice {
8584
switch UIDevice.current.orientation {
8685
case .landscapeLeft, .landscapeRight:
8786
portrait = false
88-
case .portrait, .portraitUpsideDown:
87+
case .portrait:
8988
portrait = true
9089
default: break
9190
}
@@ -120,6 +119,18 @@ open class ContainerDevice {
120119
return .landscapeLeft
121120
}
122121
}
122+
}
123+
124+
public extension UIDeviceOrientation {
123125

126+
var isRotateAllowed: Bool {
127+
return !(face || self == .portraitUpsideDown)
128+
}
124129

130+
var face: Bool {
131+
switch self {
132+
case .faceUp, .faceDown: return true
133+
default: return false
134+
}
135+
}
125136
}

0 commit comments

Comments
 (0)