expo-screen-orientation 6.0.4 → 6.0.5
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
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 6.0.5 — 2023-07-25
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix addOrientationChangeListener not working on iPadOS. ([#23656](https://github.com/expo/expo/pull/23656) by [@behenate](https://github.com/behenate))
|
|
18
|
+
|
|
13
19
|
## 6.0.4 — 2023-07-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.5'
|
|
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.5'
|
|
71
71
|
}
|
|
72
72
|
lintOptions {
|
|
73
73
|
abortOnError false
|
|
@@ -17,6 +17,7 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
17
17
|
public var currentScreenOrientation: UIInterfaceOrientation
|
|
18
18
|
var orientationControllers: [ScreenOrientationController] = []
|
|
19
19
|
var controllerInterfaceMasks: [ObjectIdentifier: UIInterfaceOrientationMask] = [:]
|
|
20
|
+
@objc
|
|
20
21
|
public weak var currentTraitCollection: UITraitCollection?
|
|
21
22
|
var lastOrientationMask: UIInterfaceOrientationMask
|
|
22
23
|
var rootViewController: UIViewController? {
|
|
@@ -45,13 +46,6 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
45
46
|
|
|
46
47
|
super.init()
|
|
47
48
|
|
|
48
|
-
NotificationCenter.default.addObserver(
|
|
49
|
-
self,
|
|
50
|
-
selector: #selector(self.handleDeviceOrientationChange(notification:)),
|
|
51
|
-
name: UIDevice.orientationDidChangeNotification,
|
|
52
|
-
object: UIDevice.current
|
|
53
|
-
)
|
|
54
|
-
|
|
55
49
|
// This is most likely already executed on the main thread, but we need to be sure
|
|
56
50
|
RCTExecuteOnMainQueue {
|
|
57
51
|
UIDevice.current.beginGeneratingDeviceOrientationNotifications()
|
|
@@ -143,56 +137,19 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
143
137
|
|
|
144
138
|
// MARK: - Events
|
|
145
139
|
|
|
146
|
-
/**
|
|
147
|
-
Called when the OS sends an OrientationDidChange notification.
|
|
148
|
-
*/
|
|
149
|
-
@objc
|
|
150
|
-
func handleDeviceOrientationChange(notification: Notification) {
|
|
151
|
-
let newScreenOrientation = UIDevice.current.orientation.toInterfaceOrientation()
|
|
152
|
-
|
|
153
|
-
interfaceOrientationDidChange(newScreenOrientation)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
Called when the device is physically rotated. Checks if screen orientation should be changed after user rotated the device.
|
|
158
|
-
*/
|
|
159
|
-
func interfaceOrientationDidChange(_ newScreenOrientation: UIInterfaceOrientation) {
|
|
160
|
-
if currentScreenOrientation == newScreenOrientation || newScreenOrientation == .unknown {
|
|
161
|
-
return
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if currentOrientationMask.contains(newScreenOrientation) {
|
|
165
|
-
// when changing orientation without changing dimensions traitCollectionDidChange isn't triggered so the event has to be called manually
|
|
166
|
-
if (newScreenOrientation.isPortrait && currentScreenOrientation.isPortrait)
|
|
167
|
-
|| (newScreenOrientation.isLandscape && currentScreenOrientation.isLandscape) {
|
|
168
|
-
screenOrientationDidChange(newScreenOrientation)
|
|
169
|
-
return
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// on iPads, traitCollectionDidChange isn't triggered at all, so we have to call screenOrientationDidChange manually
|
|
173
|
-
if isPad()
|
|
174
|
-
&& (newScreenOrientation.isPortrait && currentScreenOrientation.isLandscape
|
|
175
|
-
|| newScreenOrientation.isLandscape && currentScreenOrientation.isPortrait) {
|
|
176
|
-
screenOrientationDidChange(newScreenOrientation)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
140
|
/**
|
|
182
141
|
Called by ScreenOrientationViewController when the dimensions of the view change.
|
|
183
142
|
Also used for Expo Go in EXAppViewController.
|
|
184
143
|
*/
|
|
185
144
|
@objc
|
|
186
|
-
public func
|
|
187
|
-
currentTraitCollection = traitCollection
|
|
188
|
-
|
|
145
|
+
public func viewDidTransition(toOrientation orientation: UIInterfaceOrientation) {
|
|
189
146
|
let currentDeviceOrientation = UIDevice.current.orientation.toInterfaceOrientation()
|
|
190
147
|
let currentOrientationMask = self.rootViewController?.supportedInterfaceOrientations ?? []
|
|
191
148
|
|
|
192
149
|
var newScreenOrientation = UIInterfaceOrientation.unknown
|
|
193
150
|
|
|
194
151
|
// We need to deduce what is the new screen orientaiton based on currentOrientationMask and new dimensions of the view
|
|
195
|
-
if
|
|
152
|
+
if orientation.isPortrait {
|
|
196
153
|
// From trait collection, we know that screen is in portrait or upside down orientation.
|
|
197
154
|
let portraitMask = currentOrientationMask.intersection([.portrait, .portraitUpsideDown])
|
|
198
155
|
|
|
@@ -209,7 +166,7 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
209
166
|
// from device orientation.
|
|
210
167
|
newScreenOrientation = currentDeviceOrientation
|
|
211
168
|
}
|
|
212
|
-
} else if
|
|
169
|
+
} else if orientation.isLandscape {
|
|
213
170
|
// From trait collection, we know that screen is in landscape left or right orientation.
|
|
214
171
|
let landscapeMask = currentOrientationMask.intersection(.landscape)
|
|
215
172
|
|
|
@@ -233,6 +190,11 @@ public class ScreenOrientationRegistry: NSObject, UIApplicationDelegate {
|
|
|
233
190
|
screenOrientationDidChange(newScreenOrientation)
|
|
234
191
|
}
|
|
235
192
|
|
|
193
|
+
@objc
|
|
194
|
+
public func traitCollectionDidChange(to traitCollection: UITraitCollection) {
|
|
195
|
+
currentTraitCollection = traitCollection
|
|
196
|
+
}
|
|
197
|
+
|
|
236
198
|
/**
|
|
237
199
|
Called at the end of the screen orientation change. Notifies the controllers about the orientation change.
|
|
238
200
|
*/
|
|
@@ -7,10 +7,20 @@ let ipadSupportedOrientationsKey = "UISupportedInterfaceOrientations~ipad"
|
|
|
7
7
|
class ScreenOrientationViewController: UIViewController {
|
|
8
8
|
let screenOrientationRegistry = ScreenOrientationRegistry.shared
|
|
9
9
|
private var defaultOrientationMask: UIInterfaceOrientationMask
|
|
10
|
+
private var previousInterfaceOrientation: UIInterfaceOrientation = .unknown
|
|
11
|
+
private var windowInterfaceOrientation: UIInterfaceOrientation? {
|
|
12
|
+
return UIApplication.shared.windows.first?.windowScene?.interfaceOrientation
|
|
13
|
+
}
|
|
10
14
|
|
|
11
15
|
init(defaultOrientationMask: UIInterfaceOrientationMask = doesDeviceHaveNotch ? .allButUpsideDown : .all) {
|
|
12
16
|
self.defaultOrientationMask = defaultOrientationMask
|
|
13
17
|
super.init(nibName: nil, bundle: nil)
|
|
18
|
+
|
|
19
|
+
// For iPads traitCollectionDidChange will not be called (it's always in the same size class). It is necessary
|
|
20
|
+
// to init it in here, so it's possible to return it in the didUpdateDimensionsEvent of the module
|
|
21
|
+
if self.screenOrientationRegistry.currentTraitCollection == nil {
|
|
22
|
+
self.screenOrientationRegistry.traitCollectionDidChange(to: self.traitCollection)
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
25
|
|
|
16
26
|
convenience init(defaultScreenOrientationFromPlist: Void) {
|
|
@@ -57,11 +67,23 @@ class ScreenOrientationViewController: UIViewController {
|
|
|
57
67
|
|
|
58
68
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
59
69
|
super.traitCollectionDidChange(previousTraitCollection)
|
|
70
|
+
screenOrientationRegistry.traitCollectionDidChange(to: traitCollection)
|
|
71
|
+
}
|
|
60
72
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
|
74
|
+
super.viewWillTransition(to: size, with: coordinator)
|
|
75
|
+
|
|
76
|
+
// Update after the transition ends, this ensures that the trait collection passed to didUpdateDimensionsEvent is already updated
|
|
77
|
+
coordinator.animate(alongsideTransition: { [weak self] _ in
|
|
78
|
+
guard let self = self, let windowInterfaceOrientation = self.windowInterfaceOrientation else {
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if windowInterfaceOrientation != self.previousInterfaceOrientation {
|
|
83
|
+
self.screenOrientationRegistry.viewDidTransition(toOrientation: windowInterfaceOrientation)
|
|
84
|
+
}
|
|
85
|
+
self.previousInterfaceOrientation = windowInterfaceOrientation
|
|
86
|
+
})
|
|
65
87
|
}
|
|
66
88
|
|
|
67
89
|
private func shouldUseRNScreenOrientation() -> Bool {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-screen-orientation",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5",
|
|
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": "8c85313e05e38401d06dcac1addd8a0659ae37a3"
|
|
45
45
|
}
|