react-native-orientation-director 1.1.0 → 1.2.1

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 (35) hide show
  1. package/android/src/main/java/com/orientationdirector/OrientationDirectorModule.kt +11 -1
  2. package/android/src/main/java/com/orientationdirector/implementation/OrientationAutoRotationObserver.kt +45 -0
  3. package/android/src/main/java/com/orientationdirector/implementation/OrientationDirectorImpl.kt +47 -11
  4. package/android/src/main/java/com/orientationdirector/implementation/OrientationDirectorUtilsImpl.kt +11 -0
  5. package/android/src/oldarch/OrientationDirectorSpec.kt +2 -1
  6. package/ios/OrientationDirector.mm +13 -1
  7. package/ios/implementation/OrientationDirectorImpl.swift +66 -34
  8. package/ios/implementation/OrientationDirectorUtils.swift +51 -17
  9. package/lib/commonjs/NativeOrientationDirector.js.map +1 -1
  10. package/lib/commonjs/RNOrientationDirector.js +11 -0
  11. package/lib/commonjs/RNOrientationDirector.js.map +1 -1
  12. package/lib/commonjs/index.js +7 -0
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/types/AutoRotation.enum.js +13 -0
  15. package/lib/commonjs/types/AutoRotation.enum.js.map +1 -0
  16. package/lib/module/NativeOrientationDirector.js.map +1 -1
  17. package/lib/module/RNOrientationDirector.js +11 -0
  18. package/lib/module/RNOrientationDirector.js.map +1 -1
  19. package/lib/module/index.js +1 -0
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/module/types/AutoRotation.enum.js +7 -0
  22. package/lib/module/types/AutoRotation.enum.js.map +1 -0
  23. package/lib/typescript/src/NativeOrientationDirector.d.ts +2 -0
  24. package/lib/typescript/src/NativeOrientationDirector.d.ts.map +1 -1
  25. package/lib/typescript/src/RNOrientationDirector.d.ts +3 -0
  26. package/lib/typescript/src/RNOrientationDirector.d.ts.map +1 -1
  27. package/lib/typescript/src/index.d.ts +1 -0
  28. package/lib/typescript/src/index.d.ts.map +1 -1
  29. package/lib/typescript/src/types/AutoRotation.enum.d.ts +6 -0
  30. package/lib/typescript/src/types/AutoRotation.enum.d.ts.map +1 -0
  31. package/package.json +1 -1
  32. package/src/NativeOrientationDirector.ts +2 -0
  33. package/src/RNOrientationDirector.ts +15 -0
  34. package/src/index.tsx +1 -0
  35. package/src/types/AutoRotation.enum.ts +5 -0
@@ -38,9 +38,19 @@ class OrientationDirectorModule internal constructor(context: ReactApplicationCo
38
38
  orientationDirectorImpl.unlock()
39
39
  }
40
40
 
41
+ @ReactMethod()
42
+ override fun resetSupportedInterfaceOrientations() {
43
+ orientationDirectorImpl.resetSupportedInterfaceOrientations()
44
+ }
45
+
41
46
  @ReactMethod(isBlockingSynchronousMethod = true)
42
47
  override fun isLocked(): Boolean {
43
- return orientationDirectorImpl.isLocked
48
+ return orientationDirectorImpl.getIsLocked()
49
+ }
50
+
51
+ @ReactMethod(isBlockingSynchronousMethod = true)
52
+ override fun isAutoRotationEnabled(): Boolean {
53
+ return orientationDirectorImpl.getIsAutoRotationEnabled()
44
54
  }
45
55
 
46
56
  @ReactMethod()
@@ -0,0 +1,45 @@
1
+ package com.orientationdirector.implementation
2
+
3
+ import android.database.ContentObserver
4
+ import android.os.Handler
5
+ import android.provider.Settings
6
+ import android.util.Log
7
+ import com.facebook.react.bridge.ReactContext
8
+
9
+ class OrientationAutoRotationObserver(val context: ReactContext, handler: Handler?) : ContentObserver(handler) {
10
+ private var lastAutoRotationStatus: Boolean = isAutoRotationEnabled()
11
+
12
+ fun getLastAutoRotationStatus(): Boolean {
13
+ return lastAutoRotationStatus
14
+ }
15
+
16
+ override fun onChange(selfChange: Boolean) {
17
+ super.onChange(selfChange)
18
+ val status = isAutoRotationEnabled()
19
+ lastAutoRotationStatus = status
20
+ }
21
+
22
+ fun enable() {
23
+ context.contentResolver.registerContentObserver(
24
+ Settings.System.getUriFor(Settings.System.ACCELEROMETER_ROTATION),
25
+ true,
26
+ this,
27
+ )
28
+ }
29
+
30
+ fun disable() {
31
+ context.contentResolver.unregisterContentObserver(this)
32
+ }
33
+
34
+ private fun isAutoRotationEnabled(): Boolean {
35
+ return try {
36
+ Settings.System.getInt(context.contentResolver, Settings.System.ACCELEROMETER_ROTATION) == 1;
37
+ } catch (ex: Settings.SettingNotFoundException) {
38
+ false
39
+ }
40
+ }
41
+
42
+ companion object {
43
+ const val NAME = "AutoRotationObserver"
44
+ }
45
+ }
@@ -1,20 +1,26 @@
1
1
  package com.orientationdirector.implementation
2
2
 
3
3
  import android.content.pm.ActivityInfo
4
+ import android.os.Handler
5
+ import android.os.Looper
4
6
  import com.facebook.react.bridge.ReactApplicationContext
5
7
 
6
8
  class OrientationDirectorImpl internal constructor(private val context: ReactApplicationContext) {
7
9
  private var mUtils = OrientationDirectorUtilsImpl(context)
8
10
  private var mEventEmitter = OrientationEventManager(context)
9
11
  private var mSensorListener = OrientationSensorListener(context)
12
+ private var mAutoRotationObserver = OrientationAutoRotationObserver(
13
+ context, Handler(
14
+ Looper.getMainLooper()
15
+ )
16
+ )
10
17
  private var mLifecycleListener = OrientationLifecycleListener()
11
18
 
12
19
  private var initialSupportedInterfaceOrientations = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
13
20
  private var lastInterfaceOrientation = Orientation.UNKNOWN
14
21
  private var lastDeviceOrientation = Orientation.UNKNOWN
15
22
  private var initialized = false
16
-
17
- var isLocked: Boolean = false
23
+ private var isLocked: Boolean = false
18
24
 
19
25
  init {
20
26
  mSensorListener.setOnOrientationChangedCallback { orientation ->
@@ -27,19 +33,25 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
27
33
  mSensorListener.disable()
28
34
  }
29
35
 
36
+ mAutoRotationObserver.enable()
37
+
30
38
  context.addLifecycleEventListener(mLifecycleListener)
31
39
  mLifecycleListener.setOnHostResumeCallback {
32
40
  if (mSensorListener.canDetectOrientation()) {
33
41
  mSensorListener.enable()
34
42
  }
43
+
44
+ mAutoRotationObserver.enable()
35
45
  }
36
46
  mLifecycleListener.setOnHostPauseCallback {
37
47
  if (initialized) {
38
48
  mSensorListener.disable()
49
+ mAutoRotationObserver.disable()
39
50
  }
40
51
  }
41
52
  mLifecycleListener.setOnHostDestroyCallback {
42
53
  mSensorListener.disable()
54
+ mAutoRotationObserver.disable()
43
55
  }
44
56
 
45
57
  initialSupportedInterfaceOrientations =
@@ -59,20 +71,35 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
59
71
  return lastDeviceOrientation
60
72
  }
61
73
 
62
- fun lockTo(jsOrientation: Int) {
63
- val interfaceOrientation = mUtils.getOrientationFromJsOrientation(jsOrientation)
74
+ fun getIsLocked(): Boolean {
75
+ return isLocked
76
+ }
77
+
78
+ fun getIsAutoRotationEnabled(): Boolean {
79
+ return mAutoRotationObserver.getLastAutoRotationStatus()
80
+ }
81
+
82
+ fun lockTo(rawJsOrientation: Int) {
83
+ val jsOrientation = mUtils.getOrientationFromJsOrientation(rawJsOrientation)
64
84
  val screenOrientation =
65
- mUtils.getActivityOrientationFrom(interfaceOrientation)
85
+ mUtils.getActivityOrientationFrom(jsOrientation)
66
86
  context.currentActivity?.requestedOrientation = screenOrientation
67
- mEventEmitter.sendInterfaceOrientationDidChange(interfaceOrientation.ordinal)
68
- lastInterfaceOrientation = interfaceOrientation
87
+
69
88
  updateIsLockedTo(true)
89
+ updateLastInterfaceOrientationTo(jsOrientation)
70
90
  }
71
91
 
72
92
  fun unlock() {
73
93
  context.currentActivity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
94
+
74
95
  updateIsLockedTo(false)
75
- adaptInterfaceTo(getDeviceOrientation())
96
+ adaptInterfaceTo(lastDeviceOrientation)
97
+ }
98
+
99
+ fun resetSupportedInterfaceOrientations() {
100
+ context.currentActivity?.requestedOrientation = initialSupportedInterfaceOrientations
101
+ updateIsLockedTo(initIsLocked())
102
+ updateLastInterfaceOrientationTo(initInterfaceOrientation())
76
103
  }
77
104
 
78
105
  private fun initInterfaceOrientation(): Orientation {
@@ -106,16 +133,20 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
106
133
  }
107
134
 
108
135
  private fun adaptInterfaceTo(deviceOrientation: Orientation) {
136
+ if (!mAutoRotationObserver.getLastAutoRotationStatus()) {
137
+ return
138
+ }
139
+
109
140
  if (isLocked) {
110
141
  return
111
142
  }
112
143
 
113
- if (lastInterfaceOrientation == deviceOrientation) {
144
+ val newInterfaceOrientation = mUtils.getInterfaceOrientationFromDeviceOrientation(deviceOrientation);
145
+ if (newInterfaceOrientation == lastInterfaceOrientation) {
114
146
  return
115
147
  }
116
148
 
117
- lastInterfaceOrientation = deviceOrientation
118
- mEventEmitter.sendInterfaceOrientationDidChange(lastInterfaceOrientation.ordinal)
149
+ updateLastInterfaceOrientationTo(newInterfaceOrientation)
119
150
  }
120
151
 
121
152
  private fun updateIsLockedTo(value: Boolean) {
@@ -123,6 +154,11 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
123
154
  isLocked = value
124
155
  }
125
156
 
157
+ private fun updateLastInterfaceOrientationTo(value: Orientation) {
158
+ lastInterfaceOrientation = value
159
+ mEventEmitter.sendInterfaceOrientationDidChange(value.ordinal)
160
+ }
161
+
126
162
  companion object {
127
163
  const val NAME = "OrientationDirectorImpl"
128
164
  }
@@ -3,6 +3,7 @@ package com.orientationdirector.implementation
3
3
  import android.content.Context
4
4
  import android.content.pm.ActivityInfo
5
5
  import android.os.Build
6
+ import android.provider.Settings
6
7
  import android.view.Surface
7
8
  import android.view.WindowManager
8
9
  import com.facebook.react.bridge.ReactContext
@@ -63,4 +64,14 @@ class OrientationDirectorUtilsImpl(val context: ReactContext) {
63
64
  else -> Orientation.PORTRAIT
64
65
  }
65
66
  }
67
+
68
+ fun getInterfaceOrientationFromDeviceOrientation(deviceOrientation: Orientation): Orientation {
69
+ return when(deviceOrientation) {
70
+ Orientation.PORTRAIT -> Orientation.PORTRAIT
71
+ Orientation.LANDSCAPE_RIGHT -> Orientation.LANDSCAPE_LEFT
72
+ Orientation.PORTRAIT_UPSIDE_DOWN -> Orientation.PORTRAIT_UPSIDE_DOWN
73
+ Orientation.LANDSCAPE_LEFT -> Orientation.LANDSCAPE_RIGHT
74
+ else -> Orientation.UNKNOWN
75
+ }
76
+ }
66
77
  }
@@ -10,8 +10,9 @@ abstract class OrientationDirectorSpec internal constructor(context: ReactApplic
10
10
  abstract fun getDeviceOrientation(promise: Promise)
11
11
  abstract fun lockTo(orientation: Double)
12
12
  abstract fun unlock()
13
-
13
+ abstract fun resetSupportedInterfaceOrientations()
14
14
  abstract fun isLocked(): Boolean
15
+ abstract fun isAutoRotationEnabled(): Boolean
15
16
  abstract fun addListener(eventName: String)
16
17
  abstract fun removeListeners(count: Double)
17
18
  }
@@ -99,7 +99,7 @@ RCT_EXPORT_METHOD(lockTo:(double)jsOrientation)
99
99
  {
100
100
  NSNumber *jsOrientationNumber = @(jsOrientation);
101
101
  dispatch_async(dispatch_get_main_queue(), ^{
102
- [_director lockToJsOrientation:jsOrientationNumber];
102
+ [_director lockToRawJsOrientation:jsOrientationNumber];
103
103
  });
104
104
  }
105
105
 
@@ -123,6 +123,18 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isLocked)
123
123
  return @([_director isLocked]);
124
124
  }
125
125
 
126
+ #ifdef RCT_NEW_ARCH_ENABLED
127
+ - (void)resetSupportedInterfaceOrientations
128
+ #else
129
+ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(resetSupportedInterfaceOrientations)
130
+ #endif
131
+ {
132
+ dispatch_async(dispatch_get_main_queue(), ^{
133
+ [_director resetSupportedInterfaceOrientations];
134
+ });
135
+ }
136
+
137
+
126
138
  // Don't compile this code when we build for the old architecture.
127
139
  #ifdef RCT_NEW_ARCH_ENABLED
128
140
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
@@ -48,23 +48,48 @@ import UIKit
48
48
  return lastDeviceOrientation
49
49
  }
50
50
 
51
- @objc public func lockTo(jsOrientation: NSNumber) {
52
- let orientation = OrientationDirectorUtils.getOrientationFrom(jsOrientation: jsOrientation)
53
- let mask = OrientationDirectorUtils.getMaskFrom(orientation: orientation)
54
-
51
+ @objc public func lockTo(rawJsOrientation: NSNumber) {
52
+ let jsOrientation = OrientationDirectorUtils.getOrientationFrom(jsOrientation: rawJsOrientation)
53
+ let mask = OrientationDirectorUtils.getMaskFrom(jsOrientation: jsOrientation)
55
54
  self.requestInterfaceUpdateTo(mask: mask)
56
55
 
57
- eventManager.sendInterfaceOrientationDidChange(orientationValue: orientation.rawValue)
58
- lastInterfaceOrientation = orientation
59
56
  updateIsLockedTo(value: true)
57
+ updateLastInterfaceOrientationTo(value: jsOrientation)
60
58
  }
61
59
 
62
60
  @objc public func unlock() {
63
61
  self.requestInterfaceUpdateTo(mask: UIInterfaceOrientationMask.all)
64
62
 
65
- let deviceOrientation = OrientationDirectorUtils.getOrientationFrom(deviceOrientation: UIDevice.current.orientation)
66
63
  updateIsLockedTo(value: false)
67
- self.adaptInterfaceTo(deviceOrientation: deviceOrientation)
64
+ self.adaptInterfaceTo(deviceOrientation: lastDeviceOrientation)
65
+ }
66
+
67
+ @objc public func resetSupportedInterfaceOrientations() {
68
+ self.supportedInterfaceOrientations = self.initialSupportedInterfaceOrientations
69
+ self.requestInterfaceUpdateTo(mask: self.supportedInterfaceOrientations)
70
+ self.updateIsLockedTo(value: self.initIsLocked())
71
+
72
+ let lastMask = OrientationDirectorUtils.getMaskFrom(jsOrientation: lastInterfaceOrientation)
73
+ let isLastMaskSupported = self.supportedInterfaceOrientations.contains(lastMask)
74
+ if (isLastMaskSupported) {
75
+ return
76
+ }
77
+
78
+ let supportedInterfaceOrientations = OrientationDirectorUtils.readSupportedInterfaceOrientationsFromBundle()
79
+ if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.portrait)) {
80
+ self.updateLastInterfaceOrientationTo(value: Orientation.PORTRAIT)
81
+ return
82
+ }
83
+ if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeRight)) {
84
+ self.updateLastInterfaceOrientationTo(value: Orientation.LANDSCAPE_RIGHT)
85
+ return
86
+ }
87
+ if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeLeft)) {
88
+ self.updateLastInterfaceOrientationTo(value: Orientation.LANDSCAPE_LEFT)
89
+ return
90
+ }
91
+
92
+ self.updateLastInterfaceOrientationTo(value: Orientation.PORTRAIT_UPSIDE_DOWN)
68
93
  }
69
94
 
70
95
  private func initInitialSupportedInterfaceOrientations() -> UIInterfaceOrientationMask {
@@ -93,29 +118,25 @@ import UIKit
93
118
  private func requestInterfaceUpdateTo(mask: UIInterfaceOrientationMask) {
94
119
  self.supportedInterfaceOrientations = mask
95
120
 
96
- DispatchQueue.main.async {
97
- if #available(iOS 16.0, *) {
98
- guard let window = OrientationDirectorUtils.getCurrentWindow() else {
99
- return
100
- }
121
+ if #available(iOS 16.0, *) {
122
+ let window = OrientationDirectorUtils.getCurrentWindow()
101
123
 
102
- guard let rootViewController = window.rootViewController else {
103
- return
104
- }
124
+ guard let rootViewController = window?.rootViewController else {
125
+ return
126
+ }
105
127
 
106
- guard let windowScene = window.windowScene else {
107
- return
108
- }
128
+ guard let windowScene = window?.windowScene else {
129
+ return
130
+ }
109
131
 
110
- rootViewController.setNeedsUpdateOfSupportedInterfaceOrientations()
132
+ rootViewController.setNeedsUpdateOfSupportedInterfaceOrientations()
111
133
 
112
- windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: mask)) { error in
113
- print("\(OrientationDirectorImpl.TAG) - requestGeometryUpdate error", error)
114
- }
115
- } else {
116
- UIDevice.current.setValue(mask.rawValue, forKey: "orientation")
117
- UIViewController.attemptRotationToDeviceOrientation()
134
+ windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: mask)) { error in
135
+ print("\(OrientationDirectorImpl.TAG) - requestGeometryUpdate error", error)
118
136
  }
137
+ } else {
138
+ UIDevice.current.setValue(mask.rawValue, forKey: "orientation")
139
+ UIViewController.attemptRotationToDeviceOrientation()
119
140
  }
120
141
  }
121
142
 
@@ -128,23 +149,34 @@ import UIKit
128
149
 
129
150
  private func adaptInterfaceTo(deviceOrientation: Orientation) {
130
151
  if (isLocked) {
131
- return
152
+ return
132
153
  }
133
-
134
- if (lastInterfaceOrientation == deviceOrientation) {
135
- return
154
+
155
+ if (deviceOrientation == Orientation.FACE_UP || deviceOrientation == Orientation.FACE_DOWN) {
156
+ return
136
157
  }
137
158
 
138
- if (deviceOrientation == Orientation.FACE_UP || deviceOrientation == Orientation.FACE_DOWN) {
139
- return
159
+ let newInterfaceOrientationMask = OrientationDirectorUtils.getMaskFrom(deviceOrientation: deviceOrientation)
160
+ let isSupported = self.supportedInterfaceOrientations.contains(newInterfaceOrientationMask)
161
+ if (!isSupported) {
162
+ return
140
163
  }
141
164
 
142
- self.eventManager.sendInterfaceOrientationDidChange(orientationValue: deviceOrientation.rawValue)
143
- lastInterfaceOrientation = deviceOrientation
165
+ let newInterfaceOrientation = OrientationDirectorUtils.getOrientationFrom(mask: newInterfaceOrientationMask)
166
+ if (newInterfaceOrientation == lastInterfaceOrientation) {
167
+ return
168
+ }
169
+
170
+ updateLastInterfaceOrientationTo(value: newInterfaceOrientation)
144
171
  }
145
172
 
146
173
  private func updateIsLockedTo(value: Bool) {
147
174
  eventManager.sendLockDidChange(value: value)
148
175
  isLocked = value
149
176
  }
177
+
178
+ private func updateLastInterfaceOrientationTo(value: Orientation) {
179
+ self.eventManager.sendInterfaceOrientationDidChange(orientationValue: value.rawValue)
180
+ lastInterfaceOrientation = value
181
+ }
150
182
  }
@@ -15,12 +15,12 @@ class OrientationDirectorUtils {
15
15
  var orientation = Orientation.UNKNOWN
16
16
 
17
17
  switch(uiInterfaceOrientation) {
18
- case UIInterfaceOrientation.landscapeRight: // Home button on the right
19
- orientation = Orientation.LANDSCAPE_LEFT
18
+ case UIInterfaceOrientation.landscapeRight:
19
+ orientation = Orientation.LANDSCAPE_RIGHT
20
20
  case UIInterfaceOrientation.portraitUpsideDown:
21
21
  orientation = Orientation.PORTRAIT_UPSIDE_DOWN
22
- case UIInterfaceOrientation.landscapeLeft: // Home button on the left
23
- orientation = Orientation.LANDSCAPE_RIGHT
22
+ case UIInterfaceOrientation.landscapeLeft:
23
+ orientation = Orientation.LANDSCAPE_LEFT
24
24
  default:
25
25
  orientation = Orientation.PORTRAIT
26
26
  }
@@ -65,26 +65,60 @@ class OrientationDirectorUtils {
65
65
 
66
66
  return orientation
67
67
  }
68
+
69
+ public static func getOrientationFrom(mask: UIInterfaceOrientationMask) -> Orientation {
70
+ var orientation = Orientation.UNKNOWN
71
+
72
+ switch(mask) {
73
+ case UIInterfaceOrientationMask.portraitUpsideDown:
74
+ orientation = Orientation.PORTRAIT_UPSIDE_DOWN
75
+ case UIInterfaceOrientationMask.landscapeRight:
76
+ orientation = Orientation.LANDSCAPE_RIGHT
77
+ case UIInterfaceOrientationMask.landscapeLeft:
78
+ orientation = Orientation.LANDSCAPE_LEFT
79
+ default:
80
+ orientation = Orientation.PORTRAIT
81
+ }
68
82
 
69
- /*
70
- Note: .portraitUpsideDown only works for devices with home button
71
- //https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations
72
- */
73
- public static func getMaskFrom(orientation: Orientation) -> UIInterfaceOrientationMask {
74
- var mask = UIInterfaceOrientationMask.portrait
83
+ return orientation
84
+ }
75
85
 
76
- switch(orientation) {
86
+ /**
87
+ Note: .portraitUpsideDown only works for devices with home button and iPads
88
+ https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations
89
+ */
90
+ public static func getMaskFrom(jsOrientation: Orientation) -> UIInterfaceOrientationMask {
91
+ switch(jsOrientation) {
92
+ case Orientation.PORTRAIT:
93
+ return UIInterfaceOrientationMask.portrait
77
94
  case Orientation.LANDSCAPE_RIGHT:
78
- mask = UIInterfaceOrientationMask.landscapeLeft
95
+ return UIInterfaceOrientationMask.landscapeRight
79
96
  case Orientation.PORTRAIT_UPSIDE_DOWN:
80
- mask = UIInterfaceOrientationMask.portraitUpsideDown
97
+ return UIInterfaceOrientationMask.portraitUpsideDown
81
98
  case Orientation.LANDSCAPE_LEFT:
82
- mask = UIInterfaceOrientationMask.landscapeRight
99
+ return UIInterfaceOrientationMask.landscapeLeft
83
100
  default:
84
- mask = UIInterfaceOrientationMask.portrait
101
+ return UIInterfaceOrientationMask.all
102
+ }
103
+ }
104
+
105
+ /**
106
+ Note: .portraitUpsideDown only works for devices with home button and iPads
107
+ https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations
108
+ */
109
+ public static func getMaskFrom(deviceOrientation: Orientation) -> UIInterfaceOrientationMask {
110
+ switch(deviceOrientation) {
111
+ case Orientation.PORTRAIT:
112
+ return UIInterfaceOrientationMask.portrait
113
+ case Orientation.LANDSCAPE_RIGHT:
114
+ return UIInterfaceOrientationMask.landscapeLeft
115
+ case Orientation.PORTRAIT_UPSIDE_DOWN:
116
+ return UIInterfaceOrientationMask.portraitUpsideDown
117
+ case Orientation.LANDSCAPE_LEFT:
118
+ return UIInterfaceOrientationMask.landscapeRight
119
+ default:
120
+ return UIInterfaceOrientationMask.all
85
121
  }
86
-
87
- return mask
88
122
  }
89
123
 
90
124
  public static func getInterfaceOrientation() -> UIInterfaceOrientation {
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAapCC,gCAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAepCC,gCAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _reactNative = require("react-native");
7
8
  var _module = _interopRequireWildcard(require("./module"));
8
9
  var _Event = _interopRequireDefault(require("./types/Event.enum"));
9
10
  var _Orientation = require("./types/Orientation.enum");
11
+ var _AutoRotation = require("./types/AutoRotation.enum");
10
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -38,6 +40,15 @@ class RNOrientationDirector {
38
40
  static isLocked() {
39
41
  return _module.default.isLocked();
40
42
  }
43
+ static isAutoRotationEnabled() {
44
+ if (_reactNative.Platform.OS !== 'android') {
45
+ return _AutoRotation.AutoRotation.unknown;
46
+ }
47
+ return _module.default.isAutoRotationEnabled() ? _AutoRotation.AutoRotation.enabled : _AutoRotation.AutoRotation.disabled;
48
+ }
49
+ static resetSupportedInterfaceOrientations() {
50
+ _module.default.resetSupportedInterfaceOrientations();
51
+ }
41
52
  static listenForDeviceOrientationChanges(callback) {
42
53
  return _module.EventEmitter.addListener(_Event.default.DeviceOrientationDidChange, callback);
43
54
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_module","_interopRequireWildcard","require","_Event","_interopRequireDefault","_Orientation","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","RNOrientationDirector","_localizedStringProvider","Orientation","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","setLocalizedStringProvider","provider","getInterfaceOrientation","Module","getDeviceOrientation","lockTo","orientation","unlock","isLocked","listenForDeviceOrientationChanges","callback","EventEmitter","addListener","Event","DeviceOrientationDidChange","listenForInterfaceOrientationChanges","InterfaceOrientationDidChange","listenForLockChanges","LockDidChange","convertOrientationToHumanReadableString","_default","exports"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAAuD,SAAAE,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,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AAW,CAAC;EAC5B;EAEA,OAAOC,MAAMA,CAAA,EAAG;IACdJ,eAAM,CAACI,MAAM,CAAC,CAAC;EACjB;EAEA,OAAOC,QAAQA,CAAA,EAAG;IAChB,OAAOL,eAAM,CAACK,QAAQ,CAAC,CAAC;EAC1B;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAOC,oBAAY,CAACC,WAAW,CAACC,cAAK,CAACC,0BAA0B,EAAEJ,QAAQ,CAAC;EAC7E;EAEA,OAAOK,oCAAoCA,CACzCL,QAAiD,EACjD;IACA,OAAOC,oBAAY,CAACC,WAAW,CAC7BC,cAAK,CAACG,6BAA6B,EACnCN,QACF,CAAC;EACH;EAEA,OAAOO,oBAAoBA,CAACP,QAA4C,EAAE;IACxE,OAAOC,oBAAY,CAACC,WAAW,CAACC,cAAK,CAACK,aAAa,EAAER,QAAQ,CAAC;EAChE;EAEA,OAAOS,uCAAuCA,CAC5Cb,WAAwB,EAChB;IACR,OAAOhB,qBAAqB,CAACC,wBAAwB,CAACe,WAAW,CAAC;EACpE;AACF;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAlD,OAAA,GAEcmB,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_module","_interopRequireWildcard","_Event","_interopRequireDefault","_Orientation","_AutoRotation","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","RNOrientationDirector","_localizedStringProvider","Orientation","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","setLocalizedStringProvider","provider","getInterfaceOrientation","Module","getDeviceOrientation","lockTo","orientation","unlock","isLocked","isAutoRotationEnabled","Platform","OS","AutoRotation","enabled","disabled","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","EventEmitter","addListener","Event","DeviceOrientationDidChange","listenForInterfaceOrientationChanges","InterfaceOrientationDidChange","listenForL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0BAAY,CAACnB,OAAO;IAC7B;IACA,OAAOU,eAAM,CAACM,qBAAqB,CAAC,CAAC,GACjCG,0BAAY,CAACC,OAAO,GACpBD,0BAAY,CAACE,QAAQ;EAC3B;EAEA,OAAOC,mCAAmCA,CAAA,EAAS;IACjDZ,eAAM,CAACY,mCAAmC,CAAC,CAAC;EAC9C;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAOC,oBAAY,CAACC,WAAW,CAACC,cAAK,CAACC,0BAA0B,EAAEJ,QAAQ,CAAC;EAC7E;EAEA,OAAOK,oCAAoCA,CACzCL,QAAiD,EACjD;IACA,OAAOC,oBAAY,CAACC,WAAW,CAC7BC,cAAK,CAACG,6BAA6B,EACnCN,QACF,CAAC;EACH;EAEA,OAAOO,oBAAoBA,CAACP,QAA4C,EAAE;IACxE,OAAOC,oBAAY,CAACC,WAAW,CAACC,cAAK,CAACK,aAAa,EAAER,QAAQ,CAAC;EAChE;EAEA,OAAOS,uCAAuCA,CAC5CpB,WAAwB,EAChB;IACR,OAAOhB,qBAAqB,CAACC,wBAAwB,CAACe,WAAW,CAAC;EACpE;AACF;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAAzD,OAAA,GAEcmB,qBAAqB","ignoreList":[]}
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "AutoRotation", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _AutoRotation.AutoRotation;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "Orientation", {
7
13
  enumerable: true,
8
14
  get: function () {
@@ -29,6 +35,7 @@ Object.defineProperty(exports, "useIsInterfaceOrientationLocked", {
29
35
  }
30
36
  });
31
37
  var _Orientation = require("./types/Orientation.enum");
38
+ var _AutoRotation = require("./types/AutoRotation.enum");
32
39
  var _useDeviceOrientation = _interopRequireDefault(require("./hooks/useDeviceOrientation.hook"));
33
40
  var _useInterfaceOrientation = _interopRequireDefault(require("./hooks/useInterfaceOrientation.hook"));
34
41
  var _useIsInterfaceOrientationLocked = _interopRequireDefault(require("./hooks/useIsInterfaceOrientationLocked.hook"));
@@ -1 +1 @@
1
- {"version":3,"names":["_Orientation","require","_useDeviceOrientation","_interopRequireDefault","_useInterfaceOrientation","_useIsInterfaceOrientationLocked","_RNOrientationDirector","obj","__esModule","default","_default","exports","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,qBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,wBAAA,GAAAD,sBAAA,CAAAF,OAAA;AAGA,IAAAI,gCAAA,GAAAF,sBAAA,CAAAF,OAAA;AAGA,IAAAK,sBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAA4D,SAAAE,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAC7CG,8BAAqB","ignoreList":[]}
1
+ {"version":3,"names":["_Orientation","require","_AutoRotation","_useDeviceOrientation","_interopRequireDefault","_useInterfaceOrientation","_useIsInterfaceOrientationLocked","_RNOrientationDirector","obj","__esModule","default","_default","exports","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGA,IAAAI,wBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAGA,IAAAK,gCAAA,GAAAF,sBAAA,CAAAH,OAAA;AAGA,IAAAM,sBAAA,GAAAH,sBAAA,CAAAH,OAAA;AAA4D,SAAAG,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAC7CG,8BAAqB","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AutoRotation = void 0;
7
+ let AutoRotation = exports.AutoRotation = /*#__PURE__*/function (AutoRotation) {
8
+ AutoRotation[AutoRotation["unknown"] = 0] = "unknown";
9
+ AutoRotation[AutoRotation["enabled"] = 1] = "enabled";
10
+ AutoRotation[AutoRotation["disabled"] = 2] = "disabled";
11
+ return AutoRotation;
12
+ }({});
13
+ //# sourceMappingURL=AutoRotation.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AutoRotation","exports"],"sourceRoot":"../../../src","sources":["types/AutoRotation.enum.ts"],"mappings":";;;;;;IAAYA,YAAY,GAAAC,OAAA,CAAAD,YAAA,0BAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAalD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeOrientationDirector.ts"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,cAAc;AAelD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,qBAAqB,CAAC","ignoreList":[]}
@@ -1,6 +1,8 @@
1
+ import { Platform } from 'react-native';
1
2
  import Module, { EventEmitter } from './module';
2
3
  import Event from './types/Event.enum';
3
4
  import { Orientation } from './types/Orientation.enum';
5
+ import { AutoRotation } from './types/AutoRotation.enum';
4
6
  class RNOrientationDirector {
5
7
  static _localizedStringProvider = {
6
8
  [Orientation.unknown]: 'Unknown',
@@ -29,6 +31,15 @@ class RNOrientationDirector {
29
31
  static isLocked() {
30
32
  return Module.isLocked();
31
33
  }
34
+ static isAutoRotationEnabled() {
35
+ if (Platform.OS !== 'android') {
36
+ return AutoRotation.unknown;
37
+ }
38
+ return Module.isAutoRotationEnabled() ? AutoRotation.enabled : AutoRotation.disabled;
39
+ }
40
+ static resetSupportedInterfaceOrientations() {
41
+ Module.resetSupportedInterfaceOrientations();
42
+ }
32
43
  static listenForDeviceOrientationChanges(callback) {
33
44
  return EventEmitter.addListener(Event.DeviceOrientationDidChange, callback);
34
45
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Module","EventEmitter","Event","Orientation","RNOrientationDirector","_localizedStringProvider","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","setLocalizedStringProvider","provider","getInterfaceOrientation","getDeviceOrientation","lockTo","orientation","unlock","isLocked","listenForDeviceOrientationChanges","callback","addListener","DeviceOrientationDidChange","listenForInterfaceOrientationChanges","InterfaceOrientationDidChange","listenForLockChanges","LockDidChange","convertOrientationToHumanReadableString"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,YAAY,QAAQ,UAAU;AAC/C,OAAOC,KAAK,MAAM,oBAAoB;AAEtC,SAASC,WAAW,QAAQ,0BAA0B;AAKtD,MAAMC,qBAAqB,CAAC;EAC1B,OAAeC,wBAAwB,GACrC;IACE,CAACF,WAAW,CAACG,OAAO,GAAG,SAAS;IAChC,CAACH,WAAW,CAACI,QAAQ,GAAG,UAAU;IAClC,CAACJ,WAAW,CAACK,kBAAkB,GAAG,sBAAsB;IACxD,CAACL,WAAW,CAACM,aAAa,GAAG,gBAAgB;IAC7C,CAACN,WAAW,CAACO,cAAc,GAAG,iBAAiB;IAC/C,CAACP,WAAW,CAACQ,MAAM,GAAG,SAAS;IAC/B,CAACR,WAAW,CAACS,QAAQ,GAAG;EAC1B,CAAC;EAEHC,0BAA0BA,CACxBC,QAAuD,EACvD;IACAV,qBAAqB,CAACC,wBAAwB,GAAGS,QAAQ;EAC3D;EAEA,OAAOC,uBAAuBA,CAAA,EAAyB;IACrD,OAAOf,MAAM,CAACe,uBAAuB,CAAC,CAAC;EACzC;EAEA,OAAOC,oBAAoBA,CAAA,EAAyB;IAClD,OAAOhB,MAAM,CAACgB,oBAAoB,CAAC,CAAC;EACtC;EAEA,OAAOC,MAAMA,CAACC,WAAgC,EAAE;IAC9ClB,MAAM,CAACiB,MAAM,CAACC,WAAW,CAAC;EAC5B;EAEA,OAAOC,MAAMA,CAAA,EAAG;IACdnB,MAAM,CAACmB,MAAM,CAAC,CAAC;EACjB;EAEA,OAAOC,QAAQA,CAAA,EAAG;IAChB,OAAOpB,MAAM,CAACoB,QAAQ,CAAC,CAAC;EAC1B;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAOrB,YAAY,CAACsB,WAAW,CAACrB,KAAK,CAACsB,0BAA0B,EAAEF,QAAQ,CAAC;EAC7E;EAEA,OAAOG,oCAAoCA,CACzCH,QAAiD,EACjD;IACA,OAAOrB,YAAY,CAACsB,WAAW,CAC7BrB,KAAK,CAACwB,6BAA6B,EACnCJ,QACF,CAAC;EACH;EAEA,OAAOK,oBAAoBA,CAACL,QAA4C,EAAE;IACxE,OAAOrB,YAAY,CAACsB,WAAW,CAACrB,KAAK,CAAC0B,aAAa,EAAEN,QAAQ,CAAC;EAChE;EAEA,OAAOO,uCAAuCA,CAC5CX,WAAwB,EAChB;IACR,OAAOd,qBAAqB,CAACC,wBAAwB,CAACa,WAAW,CAAC;EACpE;AACF;AAEA,eAAed,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["Platform","Module","EventEmitter","Event","Orientation","AutoRotation","RNOrientationDirector","_localizedStringProvider","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","setLocalizedStringProvider","provider","getInterfaceOrientation","getDeviceOrientation","lockTo","orientation","unlock","isLocked","isAutoRotationEnabled","OS","enabled","disabled","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","addListener","DeviceOrientationDidChange","listenForInterfaceOrientationChanges","InterfaceOrientationDidChange","listenForLockChanges","LockDidChange","convertOrientationToHumanReadableString"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,MAAM,IAAIC,YAAY,QAAQ,UAAU;AAC/C,OAAOC,KAAK,MAAM,oBAAoB;AAEtC,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,YAAY,QAAQ,2BAA2B;AAKxD,MAAMC,qBAAqB,CAAC;EAC1B,OAAeC,wBAAwB,GACrC;IACE,CAACH,WAAW,CAACI,OAAO,GAAG,SAAS;IAChC,CAACJ,WAAW,CAACK,QAAQ,GAAG,UAAU;IAClC,CAACL,WAAW,CAACM,kBAAkB,GAAG,sBAAsB;IACxD,CAACN,WAAW,CAACO,aAAa,GAAG,gBAAgB;IAC7C,CAACP,WAAW,CAACQ,cAAc,GAAG,iBAAiB;IAC/C,CAACR,WAAW,CAACS,MAAM,GAAG,SAAS;IAC/B,CAACT,WAAW,CAACU,QAAQ,GAAG;EAC1B,CAAC;EAEHC,0BAA0BA,CACxBC,QAAuD,EACvD;IACAV,qBAAqB,CAACC,wBAAwB,GAAGS,QAAQ;EAC3D;EAEA,OAAOC,uBAAuBA,CAAA,EAAyB;IACrD,OAAOhB,MAAM,CAACgB,uBAAuB,CAAC,CAAC;EACzC;EAEA,OAAOC,oBAAoBA,CAAA,EAAyB;IAClD,OAAOjB,MAAM,CAACiB,oBAAoB,CAAC,CAAC;EACtC;EAEA,OAAOC,MAAMA,CAACC,WAAgC,EAAE;IAC9CnB,MAAM,CAACkB,MAAM,CAACC,WAAW,CAAC;EAC5B;EAEA,OAAOC,MAAMA,CAAA,EAAG;IACdpB,MAAM,CAACoB,MAAM,CAAC,CAAC;EACjB;EAEA,OAAOC,QAAQA,CAAA,EAAG;IAChB,OAAOrB,MAAM,CAACqB,QAAQ,CAAC,CAAC;EAC1B;EAEA,OAAOC,qBAAqBA,CAAA,EAAiB;IAC3C,IAAIvB,QAAQ,CAACwB,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOnB,YAAY,CAACG,OAAO;IAC7B;IACA,OAAOP,MAAM,CAACsB,qBAAqB,CAAC,CAAC,GACjClB,YAAY,CAACoB,OAAO,GACpBpB,YAAY,CAACqB,QAAQ;EAC3B;EAEA,OAAOC,mCAAmCA,CAAA,EAAS;IACjD1B,MAAM,CAAC0B,mCAAmC,CAAC,CAAC;EAC9C;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAO3B,YAAY,CAAC4B,WAAW,CAAC3B,KAAK,CAAC4B,0BAA0B,EAAEF,QAAQ,CAAC;EAC7E;EAEA,OAAOG,oCAAoCA,CACzCH,QAAiD,EACjD;IACA,OAAO3B,YAAY,CAAC4B,WAAW,CAC7B3B,KAAK,CAAC8B,6BAA6B,EACnCJ,QACF,CAAC;EACH;EAEA,OAAOK,oBAAoBA,CAACL,QAA4C,EAAE;IACxE,OAAO3B,YAAY,CAAC4B,WAAW,CAAC3B,KAAK,CAACgC,aAAa,EAAEN,QAAQ,CAAC;EAChE;EAEA,OAAOO,uCAAuCA,CAC5ChB,WAAwB,EAChB;IACR,OAAOd,qBAAqB,CAACC,wBAAwB,CAACa,WAAW,CAAC;EACpE;AACF;AAEA,eAAed,qBAAqB","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  export { Orientation } from './types/Orientation.enum';
2
+ export { AutoRotation } from './types/AutoRotation.enum';
2
3
  import useDeviceOrientation from './hooks/useDeviceOrientation.hook';
3
4
  export { useDeviceOrientation };
4
5
  import useInterfaceOrientation from './hooks/useInterfaceOrientation.hook';
@@ -1 +1 @@
1
- {"version":3,"names":["Orientation","useDeviceOrientation","useInterfaceOrientation","useIsInterfaceOrientationLocked","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,WAAW,QAAQ,0BAA0B;AAEtD,OAAOC,oBAAoB,MAAM,mCAAmC;AACpE,SAASA,oBAAoB;AAE7B,OAAOC,uBAAuB,MAAM,sCAAsC;AAC1E,SAASA,uBAAuB;AAEhC,OAAOC,+BAA+B,MAAM,8CAA8C;AAC1F,SAASA,+BAA+B;AAExC,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,eAAeA,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["Orientation","AutoRotation","useDeviceOrientation","useInterfaceOrientation","useIsInterfaceOrientationLocked","RNOrientationDirector"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,YAAY,QAAQ,2BAA2B;AAExD,OAAOC,oBAAoB,MAAM,mCAAmC;AACpE,SAASA,oBAAoB;AAE7B,OAAOC,uBAAuB,MAAM,sCAAsC;AAC1E,SAASA,uBAAuB;AAEhC,OAAOC,+BAA+B,MAAM,8CAA8C;AAC1F,SAASA,+BAA+B;AAExC,OAAOC,qBAAqB,MAAM,yBAAyB;AAC3D,eAAeA,qBAAqB","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ export let AutoRotation = /*#__PURE__*/function (AutoRotation) {
2
+ AutoRotation[AutoRotation["unknown"] = 0] = "unknown";
3
+ AutoRotation[AutoRotation["enabled"] = 1] = "enabled";
4
+ AutoRotation[AutoRotation["disabled"] = 2] = "disabled";
5
+ return AutoRotation;
6
+ }({});
7
+ //# sourceMappingURL=AutoRotation.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AutoRotation"],"sourceRoot":"../../../src","sources":["types/AutoRotation.enum.ts"],"mappings":"AAAA,WAAYA,YAAY,0BAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAZA,YAAY,CAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
@@ -5,6 +5,8 @@ export interface Spec extends TurboModule {
5
5
  lockTo(orientation: number): void;
6
6
  unlock(): void;
7
7
  isLocked(): boolean;
8
+ isAutoRotationEnabled(): boolean;
9
+ resetSupportedInterfaceOrientations(): void;
8
10
  addListener: (eventType: string) => void;
9
11
  removeListeners: (count: number) => void;
10
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NativeOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/NativeOrientationDirector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,QAAQ,IAAI,OAAO,CAAC;IAEpB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;;AAED,wBAA6E"}
1
+ {"version":3,"file":"NativeOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/NativeOrientationDirector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,QAAQ,IAAI,OAAO,CAAC;IACpB,qBAAqB,IAAI,OAAO,CAAC;IACjC,mCAAmC,IAAI,IAAI,CAAC;IAE5C,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;;AAED,wBAA6E"}
@@ -1,5 +1,6 @@
1
1
  import type { InterfaceOrientationToLocalizedStringProvider } from './types/InterfaceOrientationToLocalizedStringProvider.type';
2
2
  import { Orientation } from './types/Orientation.enum';
3
+ import { AutoRotation } from './types/AutoRotation.enum';
3
4
  import type { OrientationEvent } from './types/OrientationEvent.interface';
4
5
  import type { LockableOrientation } from './types/LockableOrientation.type';
5
6
  import type { LockedEvent } from './types/LockedEvent.interface';
@@ -11,6 +12,8 @@ declare class RNOrientationDirector {
11
12
  static lockTo(orientation: LockableOrientation): void;
12
13
  static unlock(): void;
13
14
  static isLocked(): boolean;
15
+ static isAutoRotationEnabled(): AutoRotation;
16
+ static resetSupportedInterfaceOrientations(): void;
14
17
  static listenForDeviceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
15
18
  static listenForInterfaceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
16
19
  static listenForLockChanges(callback: (orientation: LockedEvent) => void): import("react-native").EmitterSubscription;
@@ -1 +1 @@
1
- {"version":3,"file":"RNOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/RNOrientationDirector.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,4DAA4D,CAAC;AAChI,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAA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B,QAAQ,EAAE,6CAA6C;IAKzD,MAAM,CAAC,uBAAuB,IAAI,OAAO,CAAC,WAAW,CAAC;IAItD,MAAM,CAAC,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC;IAInD,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,mBAAmB;IAI9C,MAAM,CAAC,MAAM;IAIb,MAAM,CAAC,QAAQ;IAIf,MAAM,CAAC,qBAAqB,IAAI,YAAY;IAS5C,MAAM,CAAC,mCAAmC,IAAI,IAAI;IAIlD,MAAM,CAAC,iCAAiC,CACtC,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAKnD,MAAM,CAAC,oCAAoC,CACzC,QAAQ,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,IAAI;IAQnD,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI;IAIxE,MAAM,CAAC,uCAAuC,CAC5C,WAAW,EAAE,WAAW,GACvB,MAAM;CAGV;AAED,eAAe,qBAAqB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export { Orientation } from './types/Orientation.enum';
2
+ export { AutoRotation } from './types/AutoRotation.enum';
2
3
  import useDeviceOrientation from './hooks/useDeviceOrientation.hook';
3
4
  export { useDeviceOrientation };
4
5
  import useInterfaceOrientation from './hooks/useInterfaceOrientation.hook';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,+BAA+B,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,CAAC;AAE3C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,oBAAoB,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,OAAO,uBAAuB,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,OAAO,+BAA+B,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,+BAA+B,EAAE,CAAC;AAE3C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare enum AutoRotation {
2
+ unknown = 0,
3
+ enabled = 1,
4
+ disabled = 2
5
+ }
6
+ //# sourceMappingURL=AutoRotation.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoRotation.enum.d.ts","sourceRoot":"","sources":["../../../../src/types/AutoRotation.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,QAAQ,IAAI;CACb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-orientation-director",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "A Modern React Native library that allows you to access orientation",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -7,6 +7,8 @@ export interface Spec extends TurboModule {
7
7
  lockTo(orientation: number): void;
8
8
  unlock(): void;
9
9
  isLocked(): boolean;
10
+ isAutoRotationEnabled(): boolean;
11
+ resetSupportedInterfaceOrientations(): void;
10
12
 
11
13
  addListener: (eventType: string) => void;
12
14
  removeListeners: (count: number) => void;
@@ -1,7 +1,9 @@
1
+ import { Platform } from 'react-native';
1
2
  import Module, { EventEmitter } from './module';
2
3
  import Event from './types/Event.enum';
3
4
  import type { InterfaceOrientationToLocalizedStringProvider } from './types/InterfaceOrientationToLocalizedStringProvider.type';
4
5
  import { Orientation } from './types/Orientation.enum';
6
+ import { AutoRotation } from './types/AutoRotation.enum';
5
7
  import type { OrientationEvent } from './types/OrientationEvent.interface';
6
8
  import type { LockableOrientation } from './types/LockableOrientation.type';
7
9
  import type { LockedEvent } from './types/LockedEvent.interface';
@@ -44,6 +46,19 @@ class RNOrientationDirector {
44
46
  return Module.isLocked();
45
47
  }
46
48
 
49
+ static isAutoRotationEnabled(): AutoRotation {
50
+ if (Platform.OS !== 'android') {
51
+ return AutoRotation.unknown;
52
+ }
53
+ return Module.isAutoRotationEnabled()
54
+ ? AutoRotation.enabled
55
+ : AutoRotation.disabled;
56
+ }
57
+
58
+ static resetSupportedInterfaceOrientations(): void {
59
+ Module.resetSupportedInterfaceOrientations();
60
+ }
61
+
47
62
  static listenForDeviceOrientationChanges(
48
63
  callback: (orientation: OrientationEvent) => void
49
64
  ) {
package/src/index.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Orientation } from './types/Orientation.enum';
2
+ export { AutoRotation } from './types/AutoRotation.enum';
2
3
 
3
4
  import useDeviceOrientation from './hooks/useDeviceOrientation.hook';
4
5
  export { useDeviceOrientation };
@@ -0,0 +1,5 @@
1
+ export enum AutoRotation {
2
+ unknown = 0,
3
+ enabled = 1,
4
+ disabled = 2,
5
+ }