expo-screen-orientation 6.0.1 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/ios/ScreenOrientationAppDelegate.swift +1 -0
- package/ios/ScreenOrientationModule.swift +8 -23
- package/ios/ScreenOrientationReactDelegateHandler.swift +1 -0
- package/ios/ScreenOrientationRegistry.swift +23 -25
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 6.0.2 — 2023-07-04
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- [iOS] Refactor the singleton class to work properly in versioned code in Expo Go. ([#23228](https://github.com/expo/expo/pull/23228) by [@tsapeta](https://github.com/tsapeta))
|
|
18
|
+
|
|
13
19
|
## 6.0.1 — 2023-06-23
|
|
14
20
|
|
|
15
21
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '6.0.
|
|
6
|
+
version = '6.0.2'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -67,7 +67,7 @@ android {
|
|
|
67
67
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
68
68
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
69
69
|
versionCode 7
|
|
70
|
-
versionName '6.0.
|
|
70
|
+
versionName '6.0.2'
|
|
71
71
|
}
|
|
72
72
|
lintOptions {
|
|
73
73
|
abortOnError false
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import ExpoModulesCore
|
|
4
4
|
|
|
5
|
+
@objc(EXScreenOrientationAppDelegate)
|
|
5
6
|
public class ScreenOrientationAppDelegate: ExpoAppDelegateSubscriber {
|
|
6
7
|
public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
|
|
7
8
|
ScreenOrientationRegistry.shared.updateCurrentScreenOrientation()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
|
|
3
|
-
public class ScreenOrientationModule: Module,
|
|
3
|
+
public class ScreenOrientationModule: Module, ScreenOrientationController {
|
|
4
4
|
static let didUpdateDimensionsEvent = "expoDidUpdateDimensions"
|
|
5
5
|
|
|
6
6
|
let screenOrientationRegistry = ScreenOrientationRegistry.shared
|
|
@@ -22,7 +22,7 @@ public class ScreenOrientationModule: Module, OrientationListener, Hashable {
|
|
|
22
22
|
throw UnsupportedOrientationLockException(orientationLock)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
screenOrientationRegistry.setMask(orientationMask,
|
|
25
|
+
screenOrientationRegistry.setMask(orientationMask, forController: self)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
AsyncFunction("lockPlatformAsync") { (allowedOrientations: [ModuleOrientation]) in
|
|
@@ -43,7 +43,7 @@ public class ScreenOrientationModule: Module, OrientationListener, Hashable {
|
|
|
43
43
|
throw UnsupportedOrientationLockException(nil)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
screenOrientationRegistry.setMask(allowedOrientationsMask,
|
|
46
|
+
screenOrientationRegistry.setMask(allowedOrientationsMask, forController: self)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
AsyncFunction("getOrientationLockAsync") {
|
|
@@ -75,23 +75,18 @@ public class ScreenOrientationModule: Module, OrientationListener, Hashable {
|
|
|
75
75
|
return ModuleOrientation.from(orientation: screenOrientationRegistry.currentScreenOrientation).rawValue
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
screenOrientationRegistry.
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
OnStopObserving {
|
|
83
|
-
screenOrientationRegistry.unregisterModuleFromReceivingNotification(self)
|
|
78
|
+
OnCreate {
|
|
79
|
+
screenOrientationRegistry.registerController(self)
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
OnDestroy {
|
|
87
|
-
screenOrientationRegistry.
|
|
88
|
-
screenOrientationRegistry.moduleWillDeallocate(self)
|
|
83
|
+
screenOrientationRegistry.unregisterController(self)
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
// MARK: -
|
|
87
|
+
// MARK: - ScreenOrientationController
|
|
93
88
|
|
|
94
|
-
func screenOrientationDidChange(_ orientation: UIInterfaceOrientation) {
|
|
89
|
+
public func screenOrientationDidChange(_ orientation: UIInterfaceOrientation) {
|
|
95
90
|
guard let currentTraitCollection = screenOrientationRegistry.currentTraitCollection else {
|
|
96
91
|
return
|
|
97
92
|
}
|
|
@@ -105,14 +100,4 @@ public class ScreenOrientationModule: Module, OrientationListener, Hashable {
|
|
|
105
100
|
] as [String: Any]
|
|
106
101
|
])
|
|
107
102
|
}
|
|
108
|
-
|
|
109
|
-
// MARK: - Hashable
|
|
110
|
-
|
|
111
|
-
public func hash(into hasher: inout Hasher) {
|
|
112
|
-
hasher.combine(ObjectIdentifier(self))
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public static func == (lhs: ScreenOrientationModule, rhs: ScreenOrientationModule) -> Bool {
|
|
116
|
-
return ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
|
|
117
|
-
}
|
|
118
103
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import ExpoModulesCore
|
|
4
4
|
|
|
5
|
+
@objc(EXScreenOrientationReactDelegateHandler)
|
|
5
6
|
public class ScreenOrientationReactDelegateHandler: ExpoReactDelegateHandler {
|
|
6
7
|
public override func createRootViewController(reactDelegate: ExpoReactDelegate) -> UIViewController? {
|
|
7
8
|
return ScreenOrientationViewController(defaultScreenOrientationFromPlist: ())
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import ExpoModulesCore
|
|
3
3
|
|
|
4
|
-
protocol
|
|
4
|
+
public protocol ScreenOrientationController: AnyObject {
|
|
5
5
|
func screenOrientationDidChange(_ orientation: UIInterfaceOrientation)
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -14,10 +14,10 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
14
14
|
@objc
|
|
15
15
|
public static let shared = ScreenOrientationRegistry()
|
|
16
16
|
|
|
17
|
-
var currentScreenOrientation: UIInterfaceOrientation
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
weak var currentTraitCollection: UITraitCollection?
|
|
17
|
+
public var currentScreenOrientation: UIInterfaceOrientation
|
|
18
|
+
var orientationControllers: [ScreenOrientationController] = []
|
|
19
|
+
var controllerInterfaceMasks: [ObjectIdentifier: UIInterfaceOrientationMask] = [:]
|
|
20
|
+
public weak var currentTraitCollection: UITraitCollection?
|
|
21
21
|
var lastOrientationMask: UIInterfaceOrientationMask
|
|
22
22
|
var rootViewController: UIViewController? {
|
|
23
23
|
let keyWindow = UIApplication
|
|
@@ -29,7 +29,7 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
29
29
|
return keyWindow?.rootViewController
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
var currentOrientationMask: UIInterfaceOrientationMask {
|
|
32
|
+
public var currentOrientationMask: UIInterfaceOrientationMask {
|
|
33
33
|
var currentOrientationMask: UIInterfaceOrientationMask = []
|
|
34
34
|
|
|
35
35
|
EXUtilities.performSynchronously {
|
|
@@ -61,7 +61,7 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
61
61
|
/**
|
|
62
62
|
Called by ScreenOrientationAppDelegate in order to set initial interface orientation.
|
|
63
63
|
*/
|
|
64
|
-
func updateCurrentScreenOrientation() {
|
|
64
|
+
public func updateCurrentScreenOrientation() {
|
|
65
65
|
let windows = UIApplication.shared.windows
|
|
66
66
|
if !windows.isEmpty {
|
|
67
67
|
self.currentScreenOrientation = windows[0].windowScene?.interfaceOrientation ?? .unknown
|
|
@@ -112,8 +112,10 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
func setMask(_ mask: UIInterfaceOrientationMask,
|
|
116
|
-
|
|
115
|
+
public func setMask(_ mask: UIInterfaceOrientationMask, forController controller: any ScreenOrientationController) {
|
|
116
|
+
let controllerIdentifier = ObjectIdentifier(controller)
|
|
117
|
+
|
|
118
|
+
controllerInterfaceMasks[controllerIdentifier] = mask
|
|
117
119
|
enforceDesiredDeviceOrientation(withOrientationMask: mask)
|
|
118
120
|
}
|
|
119
121
|
|
|
@@ -124,14 +126,14 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
124
126
|
*/
|
|
125
127
|
@objc
|
|
126
128
|
public func requiredOrientationMask() -> UIInterfaceOrientationMask {
|
|
127
|
-
if
|
|
129
|
+
if controllerInterfaceMasks.isEmpty {
|
|
128
130
|
return []
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
// We want to apply an orientation mask which is an intersection of locks applied by the modules.
|
|
132
134
|
var mask = doesDeviceHaveNotch ? UIInterfaceOrientationMask.allButUpsideDown : UIInterfaceOrientationMask.all
|
|
133
135
|
|
|
134
|
-
for moduleMask in
|
|
136
|
+
for moduleMask in controllerInterfaceMasks {
|
|
135
137
|
mask = mask.intersection(moduleMask.value)
|
|
136
138
|
}
|
|
137
139
|
|
|
@@ -231,28 +233,24 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
231
233
|
}
|
|
232
234
|
|
|
233
235
|
/**
|
|
234
|
-
Called at the end of the screen orientation change. Notifies
|
|
236
|
+
Called at the end of the screen orientation change. Notifies the controllers about the orientation change.
|
|
235
237
|
*/
|
|
236
238
|
func screenOrientationDidChange(_ newScreenOrientation: UIInterfaceOrientation) {
|
|
237
239
|
currentScreenOrientation = newScreenOrientation
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
|
|
241
|
+
for controller in orientationControllers {
|
|
242
|
+
controller.screenOrientationDidChange(newScreenOrientation)
|
|
240
243
|
}
|
|
241
244
|
}
|
|
242
245
|
|
|
243
|
-
func
|
|
244
|
-
|
|
246
|
+
public func registerController(_ controller: ScreenOrientationController) {
|
|
247
|
+
orientationControllers.append(controller)
|
|
245
248
|
}
|
|
246
249
|
|
|
247
|
-
func
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
+
public func unregisterController(_ controller: ScreenOrientationController) {
|
|
251
|
+
let controllerIdentifier = ObjectIdentifier(controller)
|
|
250
252
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if orientationListeners[i] === module || orientationListeners[i] == nil {
|
|
254
|
-
orientationListeners.remove(at: i)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
253
|
+
controllerInterfaceMasks.removeValue(forKey: controllerIdentifier)
|
|
254
|
+
orientationControllers.removeAll(where: { $0 === controller })
|
|
257
255
|
}
|
|
258
256
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-screen-orientation",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Expo universal module for managing device's screen orientation",
|
|
5
5
|
"main": "build/ScreenOrientation.js",
|
|
6
6
|
"types": "build/ScreenOrientation.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"expo": "*"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "cf90d5c30c2a08a6493ebfa8aa3791aa70666759"
|
|
45
45
|
}
|