react-native-orientation-director 1.1.0 → 1.2.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 (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 +38 -4
  4. package/android/src/main/java/com/orientationdirector/implementation/OrientationDirectorUtilsImpl.kt +1 -0
  5. package/android/src/oldarch/OrientationDirectorSpec.kt +2 -1
  6. package/ios/OrientationDirector.mm +12 -0
  7. package/ios/implementation/OrientationDirectorImpl.swift +58 -24
  8. package/ios/implementation/OrientationDirectorUtils.swift +17 -0
  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,6 +71,14 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
59
71
  return lastDeviceOrientation
60
72
  }
61
73
 
74
+ fun getIsLocked(): Boolean {
75
+ return isLocked
76
+ }
77
+
78
+ fun getIsAutoRotationEnabled(): Boolean {
79
+ return mAutoRotationObserver.getLastAutoRotationStatus()
80
+ }
81
+
62
82
  fun lockTo(jsOrientation: Int) {
63
83
  val interfaceOrientation = mUtils.getOrientationFromJsOrientation(jsOrientation)
64
84
  val screenOrientation =
@@ -75,6 +95,12 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
75
95
  adaptInterfaceTo(getDeviceOrientation())
76
96
  }
77
97
 
98
+ fun resetSupportedInterfaceOrientations() {
99
+ context.currentActivity?.requestedOrientation = initialSupportedInterfaceOrientations
100
+ updateIsLockedTo(initIsLocked())
101
+ updateLastInterfaceOrientationTo(initInterfaceOrientation())
102
+ }
103
+
78
104
  private fun initInterfaceOrientation(): Orientation {
79
105
  val rotation = mUtils.getInterfaceRotation()
80
106
  return mUtils.getOrientationFromRotation(rotation)
@@ -106,6 +132,10 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
106
132
  }
107
133
 
108
134
  private fun adaptInterfaceTo(deviceOrientation: Orientation) {
135
+ if (!mAutoRotationObserver.getLastAutoRotationStatus()) {
136
+ return
137
+ }
138
+
109
139
  if (isLocked) {
110
140
  return
111
141
  }
@@ -114,8 +144,7 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
114
144
  return
115
145
  }
116
146
 
117
- lastInterfaceOrientation = deviceOrientation
118
- mEventEmitter.sendInterfaceOrientationDidChange(lastInterfaceOrientation.ordinal)
147
+ updateLastInterfaceOrientationTo(deviceOrientation)
119
148
  }
120
149
 
121
150
  private fun updateIsLockedTo(value: Boolean) {
@@ -123,6 +152,11 @@ class OrientationDirectorImpl internal constructor(private val context: ReactApp
123
152
  isLocked = value
124
153
  }
125
154
 
155
+ private fun updateLastInterfaceOrientationTo(value: Orientation) {
156
+ lastInterfaceOrientation = value
157
+ mEventEmitter.sendInterfaceOrientationDidChange(value.ordinal)
158
+ }
159
+
126
160
  companion object {
127
161
  const val NAME = "OrientationDirectorImpl"
128
162
  }
@@ -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
@@ -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
  }
@@ -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:
@@ -67,6 +67,34 @@ import UIKit
67
67
  self.adaptInterfaceTo(deviceOrientation: deviceOrientation)
68
68
  }
69
69
 
70
+ @objc public func resetSupportedInterfaceOrientations() {
71
+ self.supportedInterfaceOrientations = self.initialSupportedInterfaceOrientations
72
+ self.requestInterfaceUpdateTo(mask: self.supportedInterfaceOrientations)
73
+ self.updateIsLockedTo(value: self.initIsLocked())
74
+
75
+ let lastMask = OrientationDirectorUtils.getMaskFrom(orientation: lastInterfaceOrientation)
76
+ let isLastInterfaceOrientationAlreadySupported = self.supportedInterfaceOrientations.contains(lastMask)
77
+ if (isLastInterfaceOrientationAlreadySupported) {
78
+ return
79
+ }
80
+
81
+ let supportedInterfaceOrientations = OrientationDirectorUtils.readSupportedInterfaceOrientationsFromBundle()
82
+ if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.portrait)) {
83
+ self.updateLastInterfaceOrientation(value: Orientation.PORTRAIT)
84
+ return
85
+ }
86
+ if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeRight)) {
87
+ self.updateLastInterfaceOrientation(value: Orientation.LANDSCAPE_LEFT)
88
+ return
89
+ }
90
+ if (supportedInterfaceOrientations.contains(UIInterfaceOrientationMask.landscapeLeft)) {
91
+ self.updateLastInterfaceOrientation(value: Orientation.LANDSCAPE_RIGHT)
92
+ return
93
+ }
94
+
95
+ self.updateLastInterfaceOrientation(value: Orientation.PORTRAIT_UPSIDE_DOWN)
96
+ }
97
+
70
98
  private func initInitialSupportedInterfaceOrientations() -> UIInterfaceOrientationMask {
71
99
  let supportedInterfaceOrientations = OrientationDirectorUtils.readSupportedInterfaceOrientationsFromBundle()
72
100
  return supportedInterfaceOrientations.reduce(UIInterfaceOrientationMask()) { $0.union($1) }
@@ -93,29 +121,25 @@ import UIKit
93
121
  private func requestInterfaceUpdateTo(mask: UIInterfaceOrientationMask) {
94
122
  self.supportedInterfaceOrientations = mask
95
123
 
96
- DispatchQueue.main.async {
97
- if #available(iOS 16.0, *) {
98
- guard let window = OrientationDirectorUtils.getCurrentWindow() else {
99
- return
100
- }
124
+ if #available(iOS 16.0, *) {
125
+ let window = OrientationDirectorUtils.getCurrentWindow()
101
126
 
102
- guard let rootViewController = window.rootViewController else {
103
- return
104
- }
127
+ guard let rootViewController = window?.rootViewController else {
128
+ return
129
+ }
105
130
 
106
- guard let windowScene = window.windowScene else {
107
- return
108
- }
131
+ guard let windowScene = window?.windowScene else {
132
+ return
133
+ }
109
134
 
110
- rootViewController.setNeedsUpdateOfSupportedInterfaceOrientations()
135
+ rootViewController.setNeedsUpdateOfSupportedInterfaceOrientations()
111
136
 
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()
137
+ windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: mask)) { error in
138
+ print("\(OrientationDirectorImpl.TAG) - requestGeometryUpdate error", error)
118
139
  }
140
+ } else {
141
+ UIDevice.current.setValue(mask.rawValue, forKey: "orientation")
142
+ UIViewController.attemptRotationToDeviceOrientation()
119
143
  }
120
144
  }
121
145
 
@@ -128,23 +152,33 @@ import UIKit
128
152
 
129
153
  private func adaptInterfaceTo(deviceOrientation: Orientation) {
130
154
  if (isLocked) {
131
- return
155
+ return
132
156
  }
133
157
 
134
158
  if (lastInterfaceOrientation == deviceOrientation) {
135
- return
159
+ return
136
160
  }
137
-
161
+
138
162
  if (deviceOrientation == Orientation.FACE_UP || deviceOrientation == Orientation.FACE_DOWN) {
139
- return
163
+ return
140
164
  }
141
165
 
142
- self.eventManager.sendInterfaceOrientationDidChange(orientationValue: deviceOrientation.rawValue)
143
- lastInterfaceOrientation = deviceOrientation
166
+ let deviceOrientationMask = OrientationDirectorUtils.getMaskFrom(orientation: deviceOrientation)
167
+ let isDeviceOrientationMaskSupported = self.supportedInterfaceOrientations.contains(deviceOrientationMask)
168
+ if (!isDeviceOrientationMaskSupported) {
169
+ return
170
+ }
171
+
172
+ updateLastInterfaceOrientation(value: deviceOrientation)
144
173
  }
145
174
 
146
175
  private func updateIsLockedTo(value: Bool) {
147
176
  eventManager.sendLockDidChange(value: value)
148
177
  isLocked = value
149
178
  }
179
+
180
+ private func updateLastInterfaceOrientation(value: Orientation) {
181
+ self.eventManager.sendInterfaceOrientationDidChange(orientationValue: value.rawValue)
182
+ lastInterfaceOrientation = value
183
+ }
150
184
  }
@@ -65,6 +65,23 @@ 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_LEFT
77
+ case UIInterfaceOrientationMask.landscapeLeft:
78
+ orientation = Orientation.LANDSCAPE_RIGHT
79
+ default:
80
+ orientation = Orientation.PORTRAIT
81
+ }
82
+
83
+ return orientation
84
+ }
68
85
 
69
86
  /*
70
87
  Note: .portraitUpsideDown only works for devices with home button
@@ -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,C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AMA,CAACC,WAAgC,EAAE;IAC9CH,eAAM,CAACE,MAAM,CAACC,WAAW,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","listenForLockChanges","LockDidChange","convertOrientationToHumanReadableString","_default","exports"],"sourceRoot":"../../src","sources":["RNOrientationDirector.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AAAyD,SAAAI,uBAAAG,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,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAZ,CAAA,oBAAAY,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAd,CAAA,EAAAY,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAX,CAAA,EAAAY,CAAA,UAAAG,CAAA,KAAAA,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AIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOC,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,C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[]}
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,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OAAO,CAAC,MAAM,CAAC,wBAAwB,CASnC;IAEJ,0BAA0B,CACxB,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.0",
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
+ }