Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions ios/implementation/EventManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import Foundation

@objc public class EventManager : NSObject {
@objc public weak var delegate: OrientationEventEmitterDelegate? = nil
@objc public class EventManager: NSObject {
@objc public weak var delegate: OrientationEventEmitterDelegate?

func sendDeviceOrientationDidChange(orientationValue: Int) {
guard let delegate = delegate else {
return
}

if (!delegate.isJsListening) {
if !delegate.isJsListening {
return
}

Expand All @@ -28,20 +28,20 @@ import Foundation
return
}

if (!delegate.isJsListening) {
if !delegate.isJsListening {
return
}

let params = Dictionary(dictionaryLiteral: ("orientation", orientationValue))
delegate.sendEvent(name: Event.InterfaceOrientationDidChange.rawValue, params: params as NSDictionary)
}

func sendLockDidChange(value: Bool) {
guard let delegate = delegate else {
return
}

if (!delegate.isJsListening) {
if !delegate.isJsListening {
return
}

Expand All @@ -65,6 +65,6 @@ public extension EventManager {
}

@objc static var supportedEvents: [String] {
return Event.allCases.map(\.rawValue);
return Event.allCases.map(\.rawValue)
}
}
24 changes: 12 additions & 12 deletions ios/implementation/OrientationDirectorImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import UIKit

@objc public class OrientationDirectorImpl : NSObject {
@objc public class OrientationDirectorImpl: NSObject {
private static let TAG = "OrientationDirectorImpl"

private let bundleManager: BundleManager = BundleManager()
Expand Down Expand Up @@ -62,16 +62,16 @@ import UIKit

updateIsLockedTo(value: true)

let orientationCanBeUpdatedDirectly = jsOrientation != Orientation.LANDSCAPE;
if (orientationCanBeUpdatedDirectly) {
let orientationCanBeUpdatedDirectly = jsOrientation != Orientation.LANDSCAPE
if orientationCanBeUpdatedDirectly {
updateLastInterfaceOrientationTo(value: jsOrientation)
return
}

let lastInterfaceOrientationIsAlreadyInLandscape = lastInterfaceOrientation == Orientation.LANDSCAPE_RIGHT || lastInterfaceOrientation == Orientation.LANDSCAPE_LEFT
if (lastInterfaceOrientationIsAlreadyInLandscape) {
if lastInterfaceOrientationIsAlreadyInLandscape {
updateLastInterfaceOrientationTo(value: lastInterfaceOrientation)
return;
return
}

let systemDefaultLandscapeOrientation = Orientation.LANDSCAPE_RIGHT
Expand All @@ -92,20 +92,20 @@ import UIKit

let lastMask = utils.convertToMaskFrom(jsOrientation: lastInterfaceOrientation)
let isLastMaskSupported = self.supportedInterfaceOrientations.contains(lastMask)
if (isLastMaskSupported) {
if isLastMaskSupported {
return
}

let supportedInterfaceOrientations = bundleManager.getSupportedInterfaceOrientations()
if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.portrait)) {
if supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.portrait) {
self.updateLastInterfaceOrientationTo(value: Orientation.PORTRAIT)
return
}
if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeRight)) {
if supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeRight) {
self.updateLastInterfaceOrientationTo(value: Orientation.LANDSCAPE_RIGHT)
return
}
if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeLeft)) {
if supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeLeft) {
self.updateLastInterfaceOrientationTo(value: Orientation.LANDSCAPE_LEFT)
return
}
Expand All @@ -128,7 +128,7 @@ import UIKit

private func initIsLocked() -> Bool {
let supportedOrientations = bundleManager.getSupportedInterfaceOrientations()
if (supportedOrientations.count > 1) {
if supportedOrientations.count > 1 {
return false
}

Expand Down Expand Up @@ -169,11 +169,11 @@ import UIKit

private func adaptInterfaceTo(deviceOrientation: Orientation) {
let supportsLandscape = self.supportedInterfaceOrientations.contains(.landscape)
if (isLocked && !supportsLandscape) {
if isLocked && !supportsLandscape {
return
}

if (deviceOrientation == Orientation.FACE_UP || deviceOrientation == Orientation.FACE_DOWN) {
if deviceOrientation == Orientation.FACE_UP || deviceOrientation == Orientation.FACE_DOWN {
return
}

Expand Down
2 changes: 1 addition & 1 deletion ios/implementation/SensorListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

public class SensorListener {
private var onOrientationDidChangeCallback: ((_ deviceOrientation: UIDeviceOrientation) -> Void)? = nil
private var onOrientationDidChangeCallback: ((_ deviceOrientation: UIDeviceOrientation) -> Void)?

init() {
NotificationCenter.default.addObserver(
Expand Down
10 changes: 5 additions & 5 deletions ios/implementation/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Utils {

// TODO: Add .unknown
public func convertToOrientationFrom(uiInterfaceOrientation: UIInterfaceOrientation) -> Orientation {
switch(uiInterfaceOrientation) {
switch uiInterfaceOrientation {
case .landscapeRight:
return .LANDSCAPE_RIGHT
case .portraitUpsideDown:
Expand All @@ -26,7 +26,7 @@ class Utils {
}

public func convertToOrientationFrom(deviceOrientation: UIDeviceOrientation) -> Orientation {
switch(deviceOrientation) {
switch deviceOrientation {
case .landscapeRight:
return .LANDSCAPE_RIGHT
case .portraitUpsideDown:
Expand All @@ -43,7 +43,7 @@ class Utils {
}

public func convertToOrientationFrom(jsValue: NSNumber) -> Orientation {
switch(jsValue) {
switch jsValue {
case 2:
return .LANDSCAPE_RIGHT
case 3:
Expand All @@ -62,7 +62,7 @@ class Utils {
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations
*/
public func convertToMaskFrom(jsOrientation: Orientation) -> UIInterfaceOrientationMask {
switch(jsOrientation) {
switch jsOrientation {
case .PORTRAIT:
return .portrait
case .LANDSCAPE_RIGHT:
Expand All @@ -83,7 +83,7 @@ class Utils {
return UIInterfaceOrientation.unknown
}

return windowScene.interfaceOrientation;
return windowScene.interfaceOrientation
}

/* This function is needed to get the current available window.
Expand Down