react-native-orientation-director 1.2.2 → 1.3.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.
- package/README.md +18 -2
- package/android/src/main/java/com/orientationdirector/implementation/{OrientationAutoRotationObserver.kt → AutoRotationObserver.kt} +1 -2
- package/android/src/main/java/com/orientationdirector/implementation/{OrientationEventManager.kt → EventManager.kt} +2 -4
- package/android/src/main/java/com/orientationdirector/implementation/{OrientationLifecycleListener.kt → LifecycleListener.kt} +2 -2
- package/android/src/main/java/com/orientationdirector/implementation/OrientationDirectorImpl.kt +26 -15
- package/android/src/main/java/com/orientationdirector/implementation/{OrientationSensorListener.kt → SensorListener.kt} +1 -1
- package/android/src/main/java/com/orientationdirector/implementation/{OrientationDirectorUtilsImpl.kt → Utils.kt} +21 -24
- package/ios/OrientationDirector.mm +23 -10
- package/ios/implementation/BundleManager.swift +45 -0
- package/ios/implementation/{OrientationEventManager.swift → EventManager.swift} +2 -2
- package/ios/implementation/OrientationDirectorImpl.swift +30 -22
- package/ios/implementation/{OrientationSensorListener.swift → SensorListener.swift} +6 -6
- package/ios/implementation/Utils.swift +130 -0
- package/lib/commonjs/RNOrientationDirector.js +15 -4
- package/lib/commonjs/RNOrientationDirector.js.map +1 -1
- package/lib/commonjs/types/{InterfaceOrientationToLocalizedStringProvider.type.js → HumanReadableAutoRotationsResource.type.js} +1 -1
- package/lib/commonjs/types/HumanReadableAutoRotationsResource.type.js.map +1 -0
- package/lib/commonjs/types/HumanReadableOrientationsResource.type.js +6 -0
- package/lib/commonjs/types/HumanReadableOrientationsResource.type.js.map +1 -0
- package/lib/module/RNOrientationDirector.js +15 -4
- package/lib/module/RNOrientationDirector.js.map +1 -1
- package/lib/module/types/HumanReadableAutoRotationsResource.type.js +2 -0
- package/lib/module/types/HumanReadableAutoRotationsResource.type.js.map +1 -0
- package/lib/module/types/HumanReadableOrientationsResource.type.js +2 -0
- package/lib/module/types/HumanReadableOrientationsResource.type.js.map +1 -0
- package/lib/typescript/src/RNOrientationDirector.d.ts +7 -3
- package/lib/typescript/src/RNOrientationDirector.d.ts.map +1 -1
- package/lib/typescript/src/types/HumanReadableAutoRotationsResource.type.d.ts +3 -0
- package/lib/typescript/src/types/HumanReadableAutoRotationsResource.type.d.ts.map +1 -0
- package/lib/typescript/src/types/HumanReadableOrientationsResource.type.d.ts +3 -0
- package/lib/typescript/src/types/HumanReadableOrientationsResource.type.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/RNOrientationDirector.ts +28 -12
- package/src/types/HumanReadableAutoRotationsResource.type.ts +3 -0
- package/src/types/HumanReadableOrientationsResource.type.ts +3 -0
- package/ios/implementation/OrientationDirectorUtils.swift +0 -166
- package/lib/commonjs/types/InterfaceOrientationToLocalizedStringProvider.type.js.map +0 -1
- package/lib/module/types/InterfaceOrientationToLocalizedStringProvider.type.js +0 -2
- package/lib/module/types/InterfaceOrientationToLocalizedStringProvider.type.js.map +0 -1
- package/lib/typescript/src/types/InterfaceOrientationToLocalizedStringProvider.type.d.ts +0 -3
- package/lib/typescript/src/types/InterfaceOrientationToLocalizedStringProvider.type.d.ts.map +0 -1
- package/src/types/InterfaceOrientationToLocalizedStringProvider.type.ts +0 -6
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//
|
|
2
|
+
// OrientationDirectorUtils.swift
|
|
3
|
+
// react-native-orientation-director
|
|
4
|
+
//
|
|
5
|
+
// Created by gladiuscode on 18/05/2024.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
class Utils {
|
|
11
|
+
|
|
12
|
+
private static let TAG = "Utils"
|
|
13
|
+
|
|
14
|
+
// TODO: Add .unknown
|
|
15
|
+
public func convertToOrientationFrom(uiInterfaceOrientation: UIInterfaceOrientation) -> Orientation {
|
|
16
|
+
switch(uiInterfaceOrientation) {
|
|
17
|
+
case .landscapeRight:
|
|
18
|
+
return .LANDSCAPE_RIGHT
|
|
19
|
+
case .portraitUpsideDown:
|
|
20
|
+
return .PORTRAIT_UPSIDE_DOWN
|
|
21
|
+
case .landscapeLeft:
|
|
22
|
+
return .LANDSCAPE_LEFT
|
|
23
|
+
default:
|
|
24
|
+
return .PORTRAIT
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public func convertToOrientationFrom(deviceOrientation: UIDeviceOrientation) -> Orientation {
|
|
29
|
+
switch(deviceOrientation) {
|
|
30
|
+
case .landscapeRight:
|
|
31
|
+
return .LANDSCAPE_RIGHT
|
|
32
|
+
case .portraitUpsideDown:
|
|
33
|
+
return .PORTRAIT_UPSIDE_DOWN
|
|
34
|
+
case .landscapeLeft:
|
|
35
|
+
return .LANDSCAPE_LEFT
|
|
36
|
+
case .faceUp:
|
|
37
|
+
return .FACE_UP
|
|
38
|
+
case .faceDown:
|
|
39
|
+
return .FACE_DOWN
|
|
40
|
+
default:
|
|
41
|
+
return .PORTRAIT
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public func convertToOrientationFrom(jsValue: NSNumber) -> Orientation {
|
|
46
|
+
switch(jsValue) {
|
|
47
|
+
case 2:
|
|
48
|
+
return .LANDSCAPE_RIGHT
|
|
49
|
+
case 3:
|
|
50
|
+
return .PORTRAIT_UPSIDE_DOWN
|
|
51
|
+
case 4:
|
|
52
|
+
return .LANDSCAPE_LEFT
|
|
53
|
+
default:
|
|
54
|
+
return .PORTRAIT
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public func convertToOrientationFrom(mask: UIInterfaceOrientationMask) -> Orientation {
|
|
59
|
+
switch(mask) {
|
|
60
|
+
case .portraitUpsideDown:
|
|
61
|
+
return .PORTRAIT_UPSIDE_DOWN
|
|
62
|
+
case .landscapeRight:
|
|
63
|
+
return .LANDSCAPE_RIGHT
|
|
64
|
+
case .landscapeLeft:
|
|
65
|
+
return .LANDSCAPE_LEFT
|
|
66
|
+
default:
|
|
67
|
+
return .PORTRAIT
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
Note: .portraitUpsideDown only works for devices with home button and iPads
|
|
73
|
+
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations
|
|
74
|
+
*/
|
|
75
|
+
public func convertToMaskFrom(jsOrientation: Orientation) -> UIInterfaceOrientationMask {
|
|
76
|
+
switch(jsOrientation) {
|
|
77
|
+
case .PORTRAIT:
|
|
78
|
+
return .portrait
|
|
79
|
+
case .LANDSCAPE_RIGHT:
|
|
80
|
+
return .landscapeRight
|
|
81
|
+
case .PORTRAIT_UPSIDE_DOWN:
|
|
82
|
+
return .portraitUpsideDown
|
|
83
|
+
case .LANDSCAPE_LEFT:
|
|
84
|
+
return .landscapeLeft
|
|
85
|
+
default:
|
|
86
|
+
return .all
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
Note: .portraitUpsideDown only works for devices with home button and iPads
|
|
92
|
+
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations
|
|
93
|
+
*/
|
|
94
|
+
public func convertToMaskFrom(deviceOrientation: Orientation) -> UIInterfaceOrientationMask {
|
|
95
|
+
switch(deviceOrientation) {
|
|
96
|
+
case .PORTRAIT:
|
|
97
|
+
return .portrait
|
|
98
|
+
case .LANDSCAPE_RIGHT:
|
|
99
|
+
return .landscapeLeft
|
|
100
|
+
case .PORTRAIT_UPSIDE_DOWN:
|
|
101
|
+
return .portraitUpsideDown
|
|
102
|
+
case .LANDSCAPE_LEFT:
|
|
103
|
+
return .landscapeRight
|
|
104
|
+
default:
|
|
105
|
+
return .all
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public func getInterfaceOrientation() -> UIInterfaceOrientation {
|
|
110
|
+
guard let windowScene = self.getCurrentWindow()?.windowScene else {
|
|
111
|
+
return UIInterfaceOrientation.unknown
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return windowScene.interfaceOrientation;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* This function is needed to get the current available window.
|
|
118
|
+
Here in React Native we should have only one window tho.
|
|
119
|
+
https://stackoverflow.com/questions/57134259/how-to-resolve-keywindow-was-deprecated-in-ios-13-0/58031897#58031897
|
|
120
|
+
*/
|
|
121
|
+
public func getCurrentWindow() -> UIWindow? {
|
|
122
|
+
return UIApplication
|
|
123
|
+
.shared
|
|
124
|
+
.connectedScenes
|
|
125
|
+
.compactMap { $0 as? UIWindowScene }
|
|
126
|
+
.flatMap { $0.windows }
|
|
127
|
+
.last { $0.isKeyWindow }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
}
|
|
@@ -13,7 +13,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
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); }
|
|
14
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; }
|
|
15
15
|
class RNOrientationDirector {
|
|
16
|
-
static
|
|
16
|
+
static _humanReadableOrientationsResource = {
|
|
17
17
|
[_Orientation.Orientation.unknown]: 'Unknown',
|
|
18
18
|
[_Orientation.Orientation.portrait]: 'Portrait',
|
|
19
19
|
[_Orientation.Orientation.portraitUpsideDown]: 'Portrait Upside Down',
|
|
@@ -22,8 +22,16 @@ class RNOrientationDirector {
|
|
|
22
22
|
[_Orientation.Orientation.faceUp]: 'Face Up',
|
|
23
23
|
[_Orientation.Orientation.faceDown]: 'Face Down'
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
static _humanReadableAutoRotationsResource = {
|
|
26
|
+
[_AutoRotation.AutoRotation.unknown]: 'Unknown',
|
|
27
|
+
[_AutoRotation.AutoRotation.enabled]: 'Enabled',
|
|
28
|
+
[_AutoRotation.AutoRotation.disabled]: 'Disabled'
|
|
29
|
+
};
|
|
30
|
+
setHumanReadableOrientations(resource) {
|
|
31
|
+
RNOrientationDirector._humanReadableOrientationsResource = resource;
|
|
32
|
+
}
|
|
33
|
+
setHumanReadableAutoRotations(resource) {
|
|
34
|
+
RNOrientationDirector._humanReadableAutoRotationsResource = resource;
|
|
27
35
|
}
|
|
28
36
|
static getInterfaceOrientation() {
|
|
29
37
|
return _module.default.getInterfaceOrientation();
|
|
@@ -59,7 +67,10 @@ class RNOrientationDirector {
|
|
|
59
67
|
return _module.EventEmitter.addListener(_Event.default.LockDidChange, callback);
|
|
60
68
|
}
|
|
61
69
|
static convertOrientationToHumanReadableString(orientation) {
|
|
62
|
-
return RNOrientationDirector.
|
|
70
|
+
return RNOrientationDirector._humanReadableOrientationsResource[orientation];
|
|
71
|
+
}
|
|
72
|
+
static convertAutoRotationToHumanReadableString(autoRotation) {
|
|
73
|
+
return RNOrientationDirector._humanReadableAutoRotationsResource[autoRotation];
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
var _default = exports.default = RNOrientationDirector;
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","_humanReadableOrientationsResource","Orientation","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","_humanReadableAutoRotationsResource","AutoRotation","enabled","disabled","setHumanReadableOrientations","resource","setHumanReadableAutoRotations","getInterfaceOrientation","Module","getDeviceOrientation","lockTo","orientation","unlock","isLocked","isAutoRotationEnabled","Platform","OS","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","EventEmitter","addListener","Event","DeviceOrientationDidChange","listenForInterfaceOrientationChanges","InterfaceOrientationDidChange","listenForLockChanges","LockDidChange","convertOrientationToHumanReadableString","convertAutoRotationToHumanReadableString","autoRotation","_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,W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H;EAEA,OAAOO,oBAAoBA,CAACP,QAA4C,EAAE;IACxE,OAAOC,oBAAY,CAACC,WAAW,CAACC,cAAK,CAACK,aAAa,EAAER,QAAQ,CAAC;EAChE;EAEA,OAAOS,uCAAuCA,CAACjB,WAAwB,EAAE;IACvE,OAAOrB,qBAAqB,CAACC,kCAAkC,CAC7DoB,WAAW,CACZ;EACH;EAEA,OAAOkB,wCAAwCA,CAACC,YAA0B,EAAE;IAC1E,OAAOxC,qBAAqB,CAACU,mCAAmC,CAC9D8B,YAAY,CACb;EACH;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7D,OAAA,GAEcmB,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/HumanReadableAutoRotationsResource.type.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/HumanReadableOrientationsResource.type.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ import Event from './types/Event.enum';
|
|
|
4
4
|
import { Orientation } from './types/Orientation.enum';
|
|
5
5
|
import { AutoRotation } from './types/AutoRotation.enum';
|
|
6
6
|
class RNOrientationDirector {
|
|
7
|
-
static
|
|
7
|
+
static _humanReadableOrientationsResource = {
|
|
8
8
|
[Orientation.unknown]: 'Unknown',
|
|
9
9
|
[Orientation.portrait]: 'Portrait',
|
|
10
10
|
[Orientation.portraitUpsideDown]: 'Portrait Upside Down',
|
|
@@ -13,8 +13,16 @@ class RNOrientationDirector {
|
|
|
13
13
|
[Orientation.faceUp]: 'Face Up',
|
|
14
14
|
[Orientation.faceDown]: 'Face Down'
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
static _humanReadableAutoRotationsResource = {
|
|
17
|
+
[AutoRotation.unknown]: 'Unknown',
|
|
18
|
+
[AutoRotation.enabled]: 'Enabled',
|
|
19
|
+
[AutoRotation.disabled]: 'Disabled'
|
|
20
|
+
};
|
|
21
|
+
setHumanReadableOrientations(resource) {
|
|
22
|
+
RNOrientationDirector._humanReadableOrientationsResource = resource;
|
|
23
|
+
}
|
|
24
|
+
setHumanReadableAutoRotations(resource) {
|
|
25
|
+
RNOrientationDirector._humanReadableAutoRotationsResource = resource;
|
|
18
26
|
}
|
|
19
27
|
static getInterfaceOrientation() {
|
|
20
28
|
return Module.getInterfaceOrientation();
|
|
@@ -50,7 +58,10 @@ class RNOrientationDirector {
|
|
|
50
58
|
return EventEmitter.addListener(Event.LockDidChange, callback);
|
|
51
59
|
}
|
|
52
60
|
static convertOrientationToHumanReadableString(orientation) {
|
|
53
|
-
return RNOrientationDirector.
|
|
61
|
+
return RNOrientationDirector._humanReadableOrientationsResource[orientation];
|
|
62
|
+
}
|
|
63
|
+
static convertAutoRotationToHumanReadableString(autoRotation) {
|
|
64
|
+
return RNOrientationDirector._humanReadableAutoRotationsResource[autoRotation];
|
|
54
65
|
}
|
|
55
66
|
}
|
|
56
67
|
export default RNOrientationDirector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","Module","EventEmitter","Event","Orientation","AutoRotation","RNOrientationDirector","
|
|
1
|
+
{"version":3,"names":["Platform","Module","EventEmitter","Event","Orientation","AutoRotation","RNOrientationDirector","_humanReadableOrientationsResource","unknown","portrait","portraitUpsideDown","landscapeLeft","landscapeRight","faceUp","faceDown","_humanReadableAutoRotationsResource","enabled","disabled","setHumanReadableOrientations","resource","setHumanReadableAutoRotations","getInterfaceOrientation","getDeviceOrientation","lockTo","orientation","unlock","isLocked","isAutoRotationEnabled","OS","resetSupportedInterfaceOrientations","listenForDeviceOrientationChanges","callback","addListener","DeviceOrientationDidChange","listenForInterfaceOrientationChanges","InterfaceOrientationDidChange","listenForLockChanges","LockDidChange","convertOrientationToHumanReadableString","convertAutoRotationToHumanReadableString","autoRotation"],"sourceRoot":"../../src","sources":["RNOrientationDir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AACwB,MAAM,CAAC,CAAC;EACjB;EAEA,OAAOC,QAAQA,CAAA,EAAG;IAChB,OAAOzB,MAAM,CAACyB,QAAQ,CAAC,CAAC;EAC1B;EAEA,OAAOC,qBAAqBA,CAAA,EAAG;IAC7B,IAAI3B,QAAQ,CAAC4B,EAAE,KAAK,SAAS,EAAE;MAC7B,OAAOvB,YAAY,CAACG,OAAO;IAC7B;IACA,OAAOP,MAAM,CAAC0B,qBAAqB,CAAC,CAAC,GACjCtB,YAAY,CAACW,OAAO,GACpBX,YAAY,CAACY,QAAQ;EAC3B;EAEA,OAAOY,mCAAmCA,CAAA,EAAG;IAC3C5B,MAAM,CAAC4B,mCAAmC,CAAC,CAAC;EAC9C;EAEA,OAAOC,iCAAiCA,CACtCC,QAAiD,EACjD;IACA,OAAO7B,YAAY,CAAC8B,WAAW,CAAC7B,KAAK,CAAC8B,0BAA0B,EAAEF,QAAQ,CAAC;EAC7E;EAEA,OAAOG,oCAAoCA,CACzCH,QAAiD,EACjD;IACA,OAAO7B,YAAY,CAAC8B,WAAW,CAC7B7B,KAAK,CAACgC,6BAA6B,EACnCJ,QACF,CAAC;EACH;EAEA,OAAOK,oBAAoBA,CAACL,QAA4C,EAAE;IACxE,OAAO7B,YAAY,CAAC8B,WAAW,CAAC7B,KAAK,CAACkC,aAAa,EAAEN,QAAQ,CAAC;EAChE;EAEA,OAAOO,uCAAuCA,CAACd,WAAwB,EAAE;IACvE,OAAOlB,qBAAqB,CAACC,kCAAkC,CAC7DiB,WAAW,CACZ;EACH;EAEA,OAAOe,wCAAwCA,CAACC,YAA0B,EAAE;IAC1E,OAAOlC,qBAAqB,CAACS,mCAAmC,CAC9DyB,YAAY,CACb;EACH;AACF;AAEA,eAAelC,qBAAqB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/HumanReadableAutoRotationsResource.type.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/HumanReadableOrientationsResource.type.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HumanReadableOrientationsResource } from './types/HumanReadableOrientationsResource.type';
|
|
2
2
|
import { Orientation } from './types/Orientation.enum';
|
|
3
3
|
import { AutoRotation } from './types/AutoRotation.enum';
|
|
4
4
|
import type { OrientationEvent } from './types/OrientationEvent.interface';
|
|
5
5
|
import type { LockableOrientation } from './types/LockableOrientation.type';
|
|
6
6
|
import type { LockedEvent } from './types/LockedEvent.interface';
|
|
7
|
+
import type { HumanReadableAutoRotationsResource } from './types/HumanReadableAutoRotationsResource.type';
|
|
7
8
|
declare class RNOrientationDirector {
|
|
8
|
-
private static
|
|
9
|
-
|
|
9
|
+
private static _humanReadableOrientationsResource;
|
|
10
|
+
private static _humanReadableAutoRotationsResource;
|
|
11
|
+
setHumanReadableOrientations(resource: HumanReadableOrientationsResource): void;
|
|
12
|
+
setHumanReadableAutoRotations(resource: HumanReadableAutoRotationsResource): void;
|
|
10
13
|
static getInterfaceOrientation(): Promise<Orientation>;
|
|
11
14
|
static getDeviceOrientation(): Promise<Orientation>;
|
|
12
15
|
static lockTo(orientation: LockableOrientation): void;
|
|
@@ -18,6 +21,7 @@ declare class RNOrientationDirector {
|
|
|
18
21
|
static listenForInterfaceOrientationChanges(callback: (orientation: OrientationEvent) => void): import("react-native").EmitterSubscription;
|
|
19
22
|
static listenForLockChanges(callback: (orientation: LockedEvent) => void): import("react-native").EmitterSubscription;
|
|
20
23
|
static convertOrientationToHumanReadableString(orientation: Orientation): string;
|
|
24
|
+
static convertAutoRotationToHumanReadableString(autoRotation: AutoRotation): string;
|
|
21
25
|
}
|
|
22
26
|
export default RNOrientationDirector;
|
|
23
27
|
//# sourceMappingURL=RNOrientationDirector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/RNOrientationDirector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"RNOrientationDirector.d.ts","sourceRoot":"","sources":["../../../src/RNOrientationDirector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AAE1G,cAAM,qBAAqB;IACzB,OAAO,CAAC,MAAM,CAAC,kCAAkC,CAS7C;IAEJ,OAAO,CAAC,MAAM,CAAC,mCAAmC,CAK9C;IAEJ,4BAA4B,CAAC,QAAQ,EAAE,iCAAiC;IAIxE,6BAA6B,CAAC,QAAQ,EAAE,kCAAkC;IAI1E,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;IAS5B,MAAM,CAAC,mCAAmC;IAI1C,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,CAAC,WAAW,EAAE,WAAW;IAMvE,MAAM,CAAC,wCAAwC,CAAC,YAAY,EAAE,YAAY;CAK3E;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HumanReadableAutoRotationsResource.type.d.ts","sourceRoot":"","sources":["../../../../src/types/HumanReadableAutoRotationsResource.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,kCAAkC,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HumanReadableOrientationsResource.type.d.ts","sourceRoot":"","sources":["../../../../src/types/HumanReadableOrientationsResource.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,iCAAiC,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-orientation-director",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.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",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"eslint-plugin-prettier": "^5.0.1",
|
|
67
67
|
"jest": "^29.7.0",
|
|
68
68
|
"prettier": "^3.0.3",
|
|
69
|
-
"react": "18.
|
|
70
|
-
"react-native": "0.
|
|
69
|
+
"react": "18.3.1",
|
|
70
|
+
"react-native": "0.75.3",
|
|
71
71
|
"react-native-builder-bob": "^0.23.2",
|
|
72
72
|
"release-it": "^15.0.0",
|
|
73
73
|
"turbo": "^1.10.7",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Platform } from 'react-native';
|
|
2
2
|
import Module, { EventEmitter } from './module';
|
|
3
3
|
import Event from './types/Event.enum';
|
|
4
|
-
import type {
|
|
4
|
+
import type { HumanReadableOrientationsResource } from './types/HumanReadableOrientationsResource.type';
|
|
5
5
|
import { Orientation } from './types/Orientation.enum';
|
|
6
6
|
import { AutoRotation } from './types/AutoRotation.enum';
|
|
7
7
|
import type { OrientationEvent } from './types/OrientationEvent.interface';
|
|
8
8
|
import type { LockableOrientation } from './types/LockableOrientation.type';
|
|
9
9
|
import type { LockedEvent } from './types/LockedEvent.interface';
|
|
10
|
+
import type { HumanReadableAutoRotationsResource } from './types/HumanReadableAutoRotationsResource.type';
|
|
10
11
|
|
|
11
12
|
class RNOrientationDirector {
|
|
12
|
-
private static
|
|
13
|
+
private static _humanReadableOrientationsResource: HumanReadableOrientationsResource =
|
|
13
14
|
{
|
|
14
15
|
[Orientation.unknown]: 'Unknown',
|
|
15
16
|
[Orientation.portrait]: 'Portrait',
|
|
@@ -20,10 +21,19 @@ class RNOrientationDirector {
|
|
|
20
21
|
[Orientation.faceDown]: 'Face Down',
|
|
21
22
|
};
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
private static _humanReadableAutoRotationsResource: HumanReadableAutoRotationsResource =
|
|
25
|
+
{
|
|
26
|
+
[AutoRotation.unknown]: 'Unknown',
|
|
27
|
+
[AutoRotation.enabled]: 'Enabled',
|
|
28
|
+
[AutoRotation.disabled]: 'Disabled',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
setHumanReadableOrientations(resource: HumanReadableOrientationsResource) {
|
|
32
|
+
RNOrientationDirector._humanReadableOrientationsResource = resource;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setHumanReadableAutoRotations(resource: HumanReadableAutoRotationsResource) {
|
|
36
|
+
RNOrientationDirector._humanReadableAutoRotationsResource = resource;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
39
|
static getInterfaceOrientation(): Promise<Orientation> {
|
|
@@ -46,7 +56,7 @@ class RNOrientationDirector {
|
|
|
46
56
|
return Module.isLocked();
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
static isAutoRotationEnabled()
|
|
59
|
+
static isAutoRotationEnabled() {
|
|
50
60
|
if (Platform.OS !== 'android') {
|
|
51
61
|
return AutoRotation.unknown;
|
|
52
62
|
}
|
|
@@ -55,7 +65,7 @@ class RNOrientationDirector {
|
|
|
55
65
|
: AutoRotation.disabled;
|
|
56
66
|
}
|
|
57
67
|
|
|
58
|
-
static resetSupportedInterfaceOrientations()
|
|
68
|
+
static resetSupportedInterfaceOrientations() {
|
|
59
69
|
Module.resetSupportedInterfaceOrientations();
|
|
60
70
|
}
|
|
61
71
|
|
|
@@ -78,10 +88,16 @@ class RNOrientationDirector {
|
|
|
78
88
|
return EventEmitter.addListener(Event.LockDidChange, callback);
|
|
79
89
|
}
|
|
80
90
|
|
|
81
|
-
static convertOrientationToHumanReadableString(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
static convertOrientationToHumanReadableString(orientation: Orientation) {
|
|
92
|
+
return RNOrientationDirector._humanReadableOrientationsResource[
|
|
93
|
+
orientation
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static convertAutoRotationToHumanReadableString(autoRotation: AutoRotation) {
|
|
98
|
+
return RNOrientationDirector._humanReadableAutoRotationsResource[
|
|
99
|
+
autoRotation
|
|
100
|
+
];
|
|
85
101
|
}
|
|
86
102
|
}
|
|
87
103
|
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// OrientationDirectorUtils.swift
|
|
3
|
-
// react-native-orientation-director
|
|
4
|
-
//
|
|
5
|
-
// Created by gladiuscode on 18/05/2024.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
import Foundation
|
|
9
|
-
|
|
10
|
-
class OrientationDirectorUtils {
|
|
11
|
-
|
|
12
|
-
private static let TAG = "OrientationDirectorUtils"
|
|
13
|
-
|
|
14
|
-
public static func getOrientationFrom(uiInterfaceOrientation: UIInterfaceOrientation) -> Orientation {
|
|
15
|
-
var orientation = Orientation.UNKNOWN
|
|
16
|
-
|
|
17
|
-
switch(uiInterfaceOrientation) {
|
|
18
|
-
case UIInterfaceOrientation.landscapeRight:
|
|
19
|
-
orientation = Orientation.LANDSCAPE_RIGHT
|
|
20
|
-
case UIInterfaceOrientation.portraitUpsideDown:
|
|
21
|
-
orientation = Orientation.PORTRAIT_UPSIDE_DOWN
|
|
22
|
-
case UIInterfaceOrientation.landscapeLeft:
|
|
23
|
-
orientation = Orientation.LANDSCAPE_LEFT
|
|
24
|
-
default:
|
|
25
|
-
orientation = Orientation.PORTRAIT
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return orientation
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public static func getOrientationFrom(deviceOrientation: UIDeviceOrientation) -> Orientation {
|
|
32
|
-
var orientation = Orientation.UNKNOWN
|
|
33
|
-
|
|
34
|
-
switch(deviceOrientation) {
|
|
35
|
-
case UIDeviceOrientation.landscapeRight:
|
|
36
|
-
orientation = Orientation.LANDSCAPE_RIGHT
|
|
37
|
-
case UIDeviceOrientation.portraitUpsideDown:
|
|
38
|
-
orientation = Orientation.PORTRAIT_UPSIDE_DOWN
|
|
39
|
-
case UIDeviceOrientation.landscapeLeft:
|
|
40
|
-
orientation = Orientation.LANDSCAPE_LEFT
|
|
41
|
-
case UIDeviceOrientation.faceUp:
|
|
42
|
-
orientation = Orientation.FACE_UP
|
|
43
|
-
case UIDeviceOrientation.faceDown:
|
|
44
|
-
orientation = Orientation.FACE_DOWN
|
|
45
|
-
default:
|
|
46
|
-
orientation = Orientation.PORTRAIT
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return orientation
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public static func getOrientationFrom(jsOrientation: NSNumber) -> Orientation {
|
|
53
|
-
var orientation = Orientation.UNKNOWN
|
|
54
|
-
|
|
55
|
-
switch(jsOrientation) {
|
|
56
|
-
case 2:
|
|
57
|
-
orientation = Orientation.LANDSCAPE_RIGHT
|
|
58
|
-
case 3:
|
|
59
|
-
orientation = Orientation.PORTRAIT_UPSIDE_DOWN
|
|
60
|
-
case 4:
|
|
61
|
-
orientation = Orientation.LANDSCAPE_LEFT
|
|
62
|
-
default:
|
|
63
|
-
orientation = Orientation.PORTRAIT
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return orientation
|
|
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
|
-
}
|
|
82
|
-
|
|
83
|
-
return orientation
|
|
84
|
-
}
|
|
85
|
-
|
|
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
|
|
94
|
-
case Orientation.LANDSCAPE_RIGHT:
|
|
95
|
-
return UIInterfaceOrientationMask.landscapeRight
|
|
96
|
-
case Orientation.PORTRAIT_UPSIDE_DOWN:
|
|
97
|
-
return UIInterfaceOrientationMask.portraitUpsideDown
|
|
98
|
-
case Orientation.LANDSCAPE_LEFT:
|
|
99
|
-
return UIInterfaceOrientationMask.landscapeLeft
|
|
100
|
-
default:
|
|
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
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
public static func getInterfaceOrientation() -> UIInterfaceOrientation {
|
|
125
|
-
guard let windowScene = self.getCurrentWindow()?.windowScene else {
|
|
126
|
-
return UIInterfaceOrientation.unknown
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return windowScene.interfaceOrientation;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/* This function is needed to get the current available window.
|
|
133
|
-
Here in React Native we should have only one window tho.
|
|
134
|
-
https://stackoverflow.com/questions/57134259/how-to-resolve-keywindow-was-deprecated-in-ios-13-0/58031897#58031897
|
|
135
|
-
*/
|
|
136
|
-
public static func getCurrentWindow() -> UIWindow? {
|
|
137
|
-
return UIApplication
|
|
138
|
-
.shared
|
|
139
|
-
.connectedScenes
|
|
140
|
-
.compactMap { $0 as? UIWindowScene }
|
|
141
|
-
.flatMap { $0.windows }
|
|
142
|
-
.last { $0.isKeyWindow }
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
public static func readSupportedInterfaceOrientationsFromBundle() -> [UIInterfaceOrientationMask] {
|
|
146
|
-
guard let rawOrientations = Bundle.main.object(forInfoDictionaryKey: "UISupportedInterfaceOrientations") as? [String] else {
|
|
147
|
-
return [UIInterfaceOrientationMask.all]
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return rawOrientations.compactMap { orientation in
|
|
151
|
-
switch orientation {
|
|
152
|
-
case "UIInterfaceOrientationPortrait":
|
|
153
|
-
return UIInterfaceOrientationMask.portrait
|
|
154
|
-
case "UIInterfaceOrientationLandscapeLeft":
|
|
155
|
-
return UIInterfaceOrientationMask.landscapeLeft
|
|
156
|
-
case "UIInterfaceOrientationLandscapeRight":
|
|
157
|
-
return UIInterfaceOrientationMask.landscapeRight
|
|
158
|
-
case "UIInterfaceOrientationPortraitUpsideDown":
|
|
159
|
-
return UIInterfaceOrientationMask.portraitUpsideDown
|
|
160
|
-
default:
|
|
161
|
-
return UIInterfaceOrientationMask.allButUpsideDown
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/InterfaceOrientationToLocalizedStringProvider.type.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/InterfaceOrientationToLocalizedStringProvider.type.ts"],"mappings":"","ignoreList":[]}
|
package/lib/typescript/src/types/InterfaceOrientationToLocalizedStringProvider.type.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InterfaceOrientationToLocalizedStringProvider.type.d.ts","sourceRoot":"","sources":["../../../../src/types/InterfaceOrientationToLocalizedStringProvider.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,6CAA6C,GAAG,MAAM,CAChE,WAAW,EACX,MAAM,CACP,CAAC"}
|