expo-screen-orientation 5.2.0 → 6.0.0

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +8 -1
  3. package/android/build.gradle +8 -10
  4. package/android/src/main/AndroidManifest.xml +1 -1
  5. package/android/src/main/java/expo/modules/screenorientation/ScreenOrientationModule.kt +7 -3
  6. package/build/ExpoScreenOrientation.d.ts.map +1 -1
  7. package/build/ExpoScreenOrientation.js +2 -5
  8. package/build/ExpoScreenOrientation.js.map +1 -1
  9. package/expo-module.config.json +2 -1
  10. package/ios/{EXScreenOrientation.podspec → ExpoScreenOrientation.podspec} +9 -2
  11. package/ios/{EXScreenOrientation/ScreenOrientationAppDelegate.swift → ScreenOrientationAppDelegate.swift} +5 -3
  12. package/ios/ScreenOrientationExceptions.swift +16 -0
  13. package/ios/ScreenOrientationModule.swift +118 -0
  14. package/ios/ScreenOrientationRNSScreenWindowTraits.h +11 -0
  15. package/ios/{EXScreenOrientation/ScreenOrientationReactDelegateHandler.swift → ScreenOrientationReactDelegateHandler.swift} +1 -1
  16. package/ios/ScreenOrientationRegistry.swift +252 -0
  17. package/ios/ScreenOrientationUtilities.swift +110 -0
  18. package/ios/ScreenOrientationViewController.swift +64 -0
  19. package/ios/enums/ModuleOrientation.swift +39 -0
  20. package/ios/enums/ModuleOrientationLock.swift +60 -0
  21. package/package.json +2 -2
  22. package/src/ExpoScreenOrientation.ts +2 -5
  23. package/ios/EXScreenOrientation/EXScreenOrientationModule.h +0 -11
  24. package/ios/EXScreenOrientation/EXScreenOrientationModule.m +0 -177
  25. package/ios/EXScreenOrientation/EXScreenOrientationRegistry.h +0 -46
  26. package/ios/EXScreenOrientation/EXScreenOrientationRegistry.m +0 -272
  27. package/ios/EXScreenOrientation/EXScreenOrientationUtilities.h +0 -25
  28. package/ios/EXScreenOrientation/EXScreenOrientationUtilities.m +0 -172
  29. package/ios/EXScreenOrientation/EXScreenOrientationViewController.h +0 -14
  30. package/ios/EXScreenOrientation/EXScreenOrientationViewController.m +0 -88
  31. package/ios/EXScreenOrientation/NSString+UIInterfaceOrientationMask.h +0 -9
  32. package/ios/EXScreenOrientation/NSString+UIInterfaceOrientationMask.m +0 -21
@@ -0,0 +1,110 @@
1
+ import ExpoModulesCore
2
+
3
+ internal func isPad() -> Bool {
4
+ return UIDevice.current.userInterfaceIdiom == .pad
5
+ }
6
+
7
+ // https://medium.com/@cafielo/how-to-detect-notch-screen-in-swift-56271827625d
8
+ internal var doesDeviceHaveNotch = {
9
+ var bottomSafeAreaInsetIsPositive = false
10
+ EXUtilities.performSynchronously {
11
+ bottomSafeAreaInsetIsPositive = (UIApplication.shared.delegate?.window??.safeAreaInsets.bottom ?? 0.0) > 0.0
12
+ }
13
+ return bottomSafeAreaInsetIsPositive
14
+ }()
15
+
16
+ extension UIInterfaceOrientationMask {
17
+ internal func toUIInterfaceOrientation() -> UIInterfaceOrientation {
18
+ switch self {
19
+ case .portrait: return .portrait
20
+ case .portraitUpsideDown: return.portraitUpsideDown
21
+ case .landscapeLeft: return .landscapeLeft
22
+ case .landscapeRight: return .landscapeRight
23
+ default: return .unknown
24
+ }
25
+ }
26
+
27
+ internal func contains(_ orientation: UIInterfaceOrientation) -> Bool {
28
+ // This is how the mask is created from the orientation
29
+ let maskFromOrientation = orientation.toInterfaceOrientationMask()
30
+ return self.contains(maskFromOrientation)
31
+ }
32
+
33
+ internal func isSupportedByDevice() -> Bool {
34
+ // Devices with a notch don't support upside down orientation mask.
35
+ return !self.contains(.portraitUpsideDown) || !doesDeviceHaveNotch
36
+ }
37
+
38
+ internal func defaultOrientation() -> UIInterfaceOrientation {
39
+ if self.contains(.portrait) {
40
+ return .portrait
41
+ }
42
+ if self.contains(.landscapeLeft) {
43
+ return .landscapeLeft
44
+ }
45
+ if self.contains(.landscapeRight) {
46
+ return .landscapeRight
47
+ }
48
+ if self.contains(.portraitUpsideDown) {
49
+ return .portraitUpsideDown
50
+ }
51
+ return .unknown
52
+ }
53
+ }
54
+
55
+ internal func plistStringToInterfaceOrientationMask(_ maskName: String) -> UIInterfaceOrientationMask? {
56
+ switch maskName {
57
+ case "UIInterfaceOrientationMaskPortrait":
58
+ return .portrait
59
+ case "UIInterfaceOrientationMaskLandscapeLeft":
60
+ return .landscapeLeft
61
+ case "UIInterfaceOrientationMaskLandscapeRight":
62
+ return .landscapeRight
63
+ case "UIInterfaceOrientationMaskPortraitUpsideDown":
64
+ return .portraitUpsideDown
65
+ case "UIInterfaceOrientationMaskLandscape":
66
+ return .landscape
67
+ case "UIInterfaceOrientationMaskAll":
68
+ return .all
69
+ case "UIInterfaceOrientationMaskAllButUpsideDown":
70
+ return .allButUpsideDown
71
+ default:
72
+ return nil
73
+ }
74
+ }
75
+
76
+ extension UIInterfaceOrientation {
77
+ internal func toInterfaceOrientationMask() -> UIInterfaceOrientationMask {
78
+ return UIInterfaceOrientationMask(rawValue: 1 << self.rawValue)
79
+ }
80
+ }
81
+
82
+ extension UIDeviceOrientation {
83
+ internal func toInterfaceOrientation() -> UIInterfaceOrientation {
84
+ switch self {
85
+ case .portrait:
86
+ return .portrait
87
+ case .portraitUpsideDown:
88
+ return .portraitUpsideDown
89
+ // UIDevice and UIInterface landscape orientations are switched
90
+ case .landscapeLeft:
91
+ return .landscapeRight
92
+ case .landscapeRight:
93
+ return .landscapeLeft
94
+ default:
95
+ return .unknown
96
+ }
97
+ }
98
+ }
99
+
100
+ extension UITraitCollection {
101
+ internal func isPortrait() -> Bool {
102
+ return verticalSizeClass == .regular && horizontalSizeClass == .compact
103
+ }
104
+
105
+ internal func isLandscape() -> Bool {
106
+ return (verticalSizeClass == .compact && horizontalSizeClass == .compact)
107
+ || (verticalSizeClass == .regular && horizontalSizeClass == .regular)
108
+ || (verticalSizeClass == .compact && horizontalSizeClass == .regular)
109
+ }
110
+ }
@@ -0,0 +1,64 @@
1
+ import ExpoModulesCore
2
+
3
+ let defaultScreenOrientationMask = "EXDefaultScreenOrientationMask"
4
+
5
+ class ScreenOrientationViewController: UIViewController {
6
+ let screenOrientationRegistry = ScreenOrientationRegistry.shared
7
+ private var defaultOrientationMask: UIInterfaceOrientationMask
8
+
9
+ init(defaultOrientationMask: UIInterfaceOrientationMask = .portrait) {
10
+ self.defaultOrientationMask = defaultOrientationMask
11
+ super.init(nibName: nil, bundle: nil)
12
+ }
13
+
14
+ convenience init(defaultScreenOrientationFromPlist: Void) {
15
+ guard let orientationString = Bundle.main.object(forInfoDictionaryKey: defaultScreenOrientationMask) as? String else {
16
+ self.init(defaultOrientationMask: .portrait)
17
+ return
18
+ }
19
+
20
+ guard let mask = plistStringToInterfaceOrientationMask(orientationString) else {
21
+ log.warn("Orientation lock string '\(orientationString)' provided in Info.plist does not correspond to a valid orientation mask. Application will default to portrait orientation lock.")
22
+ self.init(defaultOrientationMask: .portrait)
23
+ return
24
+ }
25
+
26
+ guard mask.isSupportedByDevice() else {
27
+ log.warn("Orientation lock string '\(orientationString)' provided in Info.plist is not supported by the device. Application will default to portrait orientation lock.")
28
+ self.init(defaultOrientationMask: .portrait)
29
+ return
30
+ }
31
+
32
+ self.init(defaultOrientationMask: mask)
33
+ }
34
+
35
+ @available(*, unavailable)
36
+ required init?(coder aDecoder: NSCoder) {
37
+ fatalError("init(coder:) has not been implemented")
38
+ }
39
+
40
+ override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
41
+ guard !shouldUseRNScreenOrientation() else {
42
+ return super.supportedInterfaceOrientations
43
+ }
44
+ let mask = screenOrientationRegistry.requiredOrientationMask()
45
+ return !mask.isEmpty ? mask : defaultOrientationMask
46
+ }
47
+
48
+ override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
49
+ super.traitCollectionDidChange(previousTraitCollection)
50
+
51
+ if traitCollection.verticalSizeClass != previousTraitCollection?.verticalSizeClass ||
52
+ traitCollection.horizontalSizeClass != previousTraitCollection?.horizontalSizeClass {
53
+ screenOrientationRegistry.traitCollectionDidChange(to: traitCollection)
54
+ }
55
+ }
56
+
57
+ private func shouldUseRNScreenOrientation() -> Bool {
58
+ // If RNScreens has set the orientation we want to use it instead of our orientation
59
+ guard let screenWindowTraitsClass = NSClassFromString("RNSScreenWindowTraits") else {
60
+ return false
61
+ }
62
+ return screenWindowTraitsClass.shouldAskScreensForScreenOrientation?(in: self) ?? false
63
+ }
64
+ }
@@ -0,0 +1,39 @@
1
+ import ExpoModulesCore
2
+
3
+ enum ModuleOrientation: Int, Enumerable {
4
+ case unknown = 0
5
+ case portraitUp = 1
6
+ case portraitDown = 2
7
+ case landscapeLeft = 3
8
+ case landscapeRight = 4
9
+
10
+ static func from (orientation interfaceOrientation: UIInterfaceOrientation) -> ModuleOrientation {
11
+ switch interfaceOrientation {
12
+ case .portrait:
13
+ return .portraitUp
14
+ case .portraitUpsideDown:
15
+ return .portraitDown
16
+ case .landscapeLeft:
17
+ return .landscapeLeft
18
+ case .landscapeRight:
19
+ return .landscapeRight
20
+ case .unknown:
21
+ return .unknown
22
+ }
23
+ }
24
+
25
+ func toInterfaceOrientation() -> UIInterfaceOrientation {
26
+ switch self {
27
+ case .portraitUp:
28
+ return .portrait
29
+ case .portraitDown:
30
+ return .portraitUpsideDown
31
+ case .landscapeLeft:
32
+ return .landscapeLeft
33
+ case .landscapeRight:
34
+ return .landscapeRight
35
+ case .unknown:
36
+ return .unknown
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,60 @@
1
+ import ExpoModulesCore
2
+
3
+ internal enum ModuleOrientationLock: Int, Enumerable {
4
+ case allButUpsideDown = 0
5
+ case all = 1
6
+ case portrait = 2
7
+ case portraitUp = 3
8
+ case portraitDown = 4
9
+ case landscape = 5
10
+ case landscapeLeft = 6
11
+ case landscapeRight = 7
12
+ case other = 8
13
+ case unknown = 9
14
+
15
+ static func from(mask: UIInterfaceOrientationMask) -> ModuleOrientationLock {
16
+ switch mask {
17
+ case .allButUpsideDown:
18
+ return .allButUpsideDown
19
+ case .all:
20
+ return .all
21
+ case [.portrait, .portraitUpsideDown]:
22
+ return .portrait
23
+ case .portrait:
24
+ return .portraitUp
25
+ case .portraitUpsideDown:
26
+ return .portraitDown
27
+ case .landscape:
28
+ return .landscape
29
+ case .landscapeLeft:
30
+ return .landscapeLeft
31
+ case .landscapeRight:
32
+ return .landscapeRight
33
+ default:
34
+ return UIInterfaceOrientationMask.all.contains(mask) ? .other : .unknown
35
+ }
36
+ }
37
+
38
+ func toInterfaceOrientationMask() -> UIInterfaceOrientationMask {
39
+ switch self {
40
+ case .allButUpsideDown:
41
+ return .allButUpsideDown
42
+ case .all:
43
+ return .all
44
+ case .portrait:
45
+ return [.portrait, .portraitUpsideDown]
46
+ case .portraitUp:
47
+ return .portrait
48
+ case .portraitDown:
49
+ return .portraitUpsideDown
50
+ case .landscape:
51
+ return .landscape
52
+ case .landscapeLeft:
53
+ return .landscapeLeft
54
+ case .landscapeRight:
55
+ return .landscapeRight
56
+ default:
57
+ return []
58
+ }
59
+ }
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-screen-orientation",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
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": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
44
+ "gitHead": "fa5ecca8251986b9f197cc14074eec0ab6dfb6db"
45
45
  }
@@ -1,6 +1,3 @@
1
- import { NativeModulesProxy, requireNativeModule } from 'expo-modules-core';
2
- import { Platform } from 'react-native';
1
+ import { requireNativeModule } from 'expo-modules-core';
3
2
 
4
- export default Platform.OS === 'android'
5
- ? requireNativeModule('ExpoScreenOrientation')
6
- : NativeModulesProxy.ExpoScreenOrientation || {};
3
+ export default requireNativeModule('ExpoScreenOrientation');
@@ -1,11 +0,0 @@
1
- // Copyright © 2019-present 650 Industries. All rights reserved.
2
-
3
- #import <ExpoModulesCore/EXEventEmitter.h>
4
- #import <ExpoModulesCore/EXExportedModule.h>
5
- #import <ExpoModulesCore/EXModuleRegistryConsumer.h>
6
- #import <ExpoModulesCore/EXAppLifecycleListener.h>
7
- #import <EXScreenOrientation/EXScreenOrientationRegistry.h>
8
-
9
- @interface EXScreenOrientationModule : EXExportedModule <EXModuleRegistryConsumer, EXEventEmitter, EXAppLifecycleListener, EXOrientationListener>
10
-
11
- @end
@@ -1,177 +0,0 @@
1
- // Copyright 2019-present 650 Industries. All rights reserved.
2
-
3
- #import <ExpoModulesCore/EXAppLifecycleService.h>
4
- #import <ExpoModulesCore/EXDefines.h>
5
- #import <ExpoModulesCore/EXEventEmitterService.h>
6
- #import <ExpoModulesCore/EXModuleRegistryProvider.h>
7
-
8
- #import <EXScreenOrientation/EXScreenOrientationModule.h>
9
- #import <EXScreenOrientation/EXScreenOrientationUtilities.h>
10
- #import <EXScreenOrientation/EXScreenOrientationRegistry.h>
11
-
12
- #import <UIKit/UIKit.h>
13
-
14
- static NSString *const EXScreenOrientationDidUpdateDimensions = @"expoDidUpdateDimensions";
15
-
16
- @interface EXScreenOrientationModule ()
17
-
18
- @property (nonatomic, weak) EXScreenOrientationRegistry *screenOrientationRegistry;
19
- @property (nonatomic, weak) id<EXEventEmitterService> eventEmitter;
20
-
21
- @end
22
-
23
- @implementation EXScreenOrientationModule
24
-
25
- EX_EXPORT_MODULE(ExpoScreenOrientation);
26
-
27
- -(void)dealloc
28
- {
29
- [self stopObserving];
30
- [_screenOrientationRegistry moduleWillDeallocate:self];
31
- }
32
-
33
- - (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
34
- {
35
- _screenOrientationRegistry = [moduleRegistry getSingletonModuleForName:@"ScreenOrientationRegistry"];
36
- [[moduleRegistry getModuleImplementingProtocol:@protocol(EXAppLifecycleService)] registerAppLifecycleListener:self];
37
- _eventEmitter = [moduleRegistry getModuleImplementingProtocol:@protocol(EXEventEmitterService)];
38
-
39
- // TODO: This shouldn't be here, but it temporarily fixes
40
- // https://github.com/expo/expo/issues/13641 and https://github.com/expo/expo/issues/11558
41
- // We're going to redesign this once we drop support for multiple apps being open in Expo Go at the same time.
42
- // Then we probably won't need the screen orientation registry at all. (@tsapeta)
43
- [self onAppForegrounded];
44
- }
45
-
46
- EX_EXPORT_METHOD_AS(lockAsync,
47
- lockAsync:(NSNumber *)orientationLock
48
- resolver:(EXPromiseResolveBlock)resolve
49
- rejecter:(EXPromiseRejectBlock)reject)
50
- {
51
- UIInterfaceOrientationMask orientationMask = [EXScreenOrientationUtilities importOrientationLock:orientationLock];
52
-
53
- if (!orientationMask) {
54
- return reject(@"ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK", [NSString stringWithFormat:@"Invalid screen orientation lock %@", orientationLock], nil);
55
- }
56
- if (![EXScreenOrientationUtilities doesDeviceSupportOrientationMask:orientationMask]) {
57
- return reject(@"ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK", [NSString stringWithFormat:@"This device does not support the requested orientation %@", orientationLock], nil);
58
- }
59
-
60
- [_screenOrientationRegistry setMask:orientationMask forModule:self];
61
- resolve(nil);
62
- }
63
-
64
- EX_EXPORT_METHOD_AS(lockPlatformAsync,
65
- lockPlatformAsync:(NSArray <NSNumber *> *)allowedOrientations
66
- resolver:(EXPromiseResolveBlock)resolve
67
- rejecter:(EXPromiseRejectBlock)reject)
68
- {
69
- // combine all the allowedOrientations into one bitmask
70
- UIInterfaceOrientationMask allowedOrientationsMask = 0;
71
- for (NSNumber *allowedOrientation in allowedOrientations) {
72
- UIInterfaceOrientation orientation = [EXScreenOrientationUtilities importOrientation:allowedOrientation];
73
- UIInterfaceOrientationMask orientationMask = [EXScreenOrientationUtilities maskFromOrientation:orientation];
74
- if (!orientationMask) {
75
- return reject(@"ERR_SCREEN_ORIENTATION_INVALID_ORIENTATION_LOCK", @"Invalid screen orientation lock.", nil);
76
- }
77
-
78
- allowedOrientationsMask = allowedOrientationsMask | orientationMask;
79
- }
80
-
81
- if (![EXScreenOrientationUtilities doesDeviceSupportOrientationMask:allowedOrientationsMask]) {
82
- return reject(@"ERR_SCREEN_ORIENTATION_UNSUPPORTED_ORIENTATION_LOCK", @"This device does not support the requested orientation.", nil);
83
- }
84
-
85
- [_screenOrientationRegistry setMask:allowedOrientationsMask forModule:self];
86
- resolve(nil);
87
- }
88
-
89
- EX_EXPORT_METHOD_AS(getOrientationLockAsync,
90
- getOrientationLockAsyncWithResolver:(EXPromiseResolveBlock)resolve
91
- rejecter:(EXPromiseRejectBlock)reject)
92
- {
93
- resolve([EXScreenOrientationUtilities exportOrientationLock:[_screenOrientationRegistry currentOrientationMask]]);
94
- }
95
-
96
- EX_EXPORT_METHOD_AS(getPlatformOrientationLockAsync,
97
- getPlatformOrientationLockAsyncResolver:(EXPromiseResolveBlock)resolve
98
- rejecter:(EXPromiseRejectBlock)reject)
99
- {
100
- UIInterfaceOrientationMask orientationMask = [_screenOrientationRegistry currentOrientationMask];
101
- NSDictionary *maskToOrienationMap = @{
102
- @(UIInterfaceOrientationMaskPortrait): @(UIInterfaceOrientationPortrait),
103
- @(UIInterfaceOrientationMaskPortraitUpsideDown): @(UIInterfaceOrientationPortraitUpsideDown),
104
- @(UIInterfaceOrientationMaskLandscapeLeft): @(UIInterfaceOrientationLandscapeLeft),
105
- @(UIInterfaceOrientationMaskLandscapeRight): @(UIInterfaceOrientationLandscapeRight)
106
- };
107
- // If the particular orientation is supported, we add it to the array of allowedOrientations
108
- NSMutableArray *allowedOrientations = [[NSMutableArray alloc] init];
109
- for (NSNumber *wrappedSingleOrientation in [maskToOrienationMap allKeys]) {
110
- UIInterfaceOrientationMask supportedOrientationMask = orientationMask & [wrappedSingleOrientation intValue];
111
- if (supportedOrientationMask) {
112
- UIInterfaceOrientation supportedOrientation = [maskToOrienationMap[@(supportedOrientationMask)] intValue];
113
- [allowedOrientations addObject:[EXScreenOrientationUtilities exportOrientation:supportedOrientation]];
114
- }
115
- }
116
- resolve(allowedOrientations);
117
- }
118
-
119
- EX_EXPORT_METHOD_AS(supportsOrientationLockAsync,
120
- supportsOrientationLockAsync:(NSNumber *)orientationLock
121
- resolver:(EXPromiseResolveBlock)resolve
122
- rejecter:(EXPromiseRejectBlock)reject)
123
- {
124
- UIInterfaceOrientationMask orientationMask = [EXScreenOrientationUtilities importOrientationLock:orientationLock];
125
-
126
- if (orientationMask && [EXScreenOrientationUtilities doesDeviceSupportOrientationMask:orientationMask]) {
127
- return resolve(@YES);
128
- }
129
-
130
- resolve(@NO);
131
- }
132
-
133
- EX_EXPORT_METHOD_AS(getOrientationAsync,
134
- getOrientationAsyncResolver:(EXPromiseResolveBlock)resolve
135
- rejecter:(EXPromiseRejectBlock)reject)
136
- {
137
- resolve([EXScreenOrientationUtilities exportOrientation:[_screenOrientationRegistry currentOrientation]]);
138
- }
139
-
140
- // Will be called when this module's first listener is added.
141
- - (void)startObserving
142
- {
143
- [_screenOrientationRegistry registerModuleToReceiveNotification:self];
144
- }
145
-
146
- // Will be called when this module's last listener is removed, or on dealloc.
147
- - (void)stopObserving
148
- {
149
- [_screenOrientationRegistry unregisterModuleFromReceivingNotification:self];
150
- }
151
-
152
- - (void)screenOrientationDidChange:(UIInterfaceOrientation)orientation
153
- {
154
- UITraitCollection * currentTraitCollection = [_screenOrientationRegistry currentTrailCollection];
155
- [_eventEmitter sendEventWithName:EXScreenOrientationDidUpdateDimensions body:@{
156
- @"orientationLock": [EXScreenOrientationUtilities exportOrientationLock:[_screenOrientationRegistry currentOrientationMask]],
157
- @"orientationInfo": @{
158
- @"orientation": [EXScreenOrientationUtilities exportOrientation:orientation],
159
- @"verticalSizeClass": EXNullIfNil(@(currentTraitCollection.verticalSizeClass)),
160
- @"horizontalSizeClass": EXNullIfNil(@(currentTraitCollection.horizontalSizeClass)),
161
- }
162
- }];
163
- }
164
-
165
- - (NSArray<NSString *> *)supportedEvents {
166
- return @[EXScreenOrientationDidUpdateDimensions];
167
- }
168
-
169
- - (void)onAppBackgrounded {
170
- [_screenOrientationRegistry moduleDidBackground:self];
171
- }
172
-
173
- - (void)onAppForegrounded {
174
- [_screenOrientationRegistry moduleDidForeground:self];
175
- }
176
-
177
- @end
@@ -1,46 +0,0 @@
1
- // Copyright © 2019-present 650 Industries. All rights reserved.
2
-
3
- #import <UIKit/UIKit.h>
4
- #import <Foundation/Foundation.h>
5
- #import <ExpoModulesCore/ExpoModulesCore.h>
6
- #import <ExpoModulesCore/EXSingletonModule.h>
7
-
8
- NS_ASSUME_NONNULL_BEGIN
9
-
10
- @protocol EXOrientationListener <NSObject>
11
-
12
- - (void)screenOrientationDidChange:(UIInterfaceOrientation)orientation;
13
-
14
- @end
15
-
16
- @protocol EXScreenOrientationEventEmitter <NSObject>
17
-
18
- - (void)unregisterModuleFromReceivingNotification:(id<EXOrientationListener>)module;
19
- - (void)registerModuleToReceiveNotification:(id<EXOrientationListener>)module;
20
-
21
- @end
22
-
23
- @protocol EXScreenOrientationRegistry <NSObject>
24
-
25
- - (UIInterfaceOrientation)currentOrientation;
26
- - (UIInterfaceOrientationMask)currentOrientationMask;
27
- - (UITraitCollection *)currentTrailCollection;
28
-
29
- - (void)setMask:(UIInterfaceOrientationMask)mask forModule:(id)module;
30
-
31
- - (void)moduleDidForeground:(id)module;
32
- - (void)moduleDidBackground:(id)module;
33
- - (void)moduleWillDeallocate:(id)module;
34
-
35
- @end
36
-
37
- @interface EXScreenOrientationRegistry : EXSingletonModule <UIApplicationDelegate, EXScreenOrientationEventEmitter, EXScreenOrientationRegistry>
38
-
39
- - (void)updateCurrentScreenOrientation;
40
-
41
- - (UIInterfaceOrientationMask)requiredOrientationMask;
42
- - (void)traitCollectionDidChangeTo:(UITraitCollection *)traitCollection;
43
-
44
- @end
45
-
46
- NS_ASSUME_NONNULL_END