react-native-orientation-director 1.2.3 → 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 +14 -2
- 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/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
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ This library takes inspiration from and builds upon the following amazing altern
|
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
29
29
|
|
|
30
|
+
### React Native Bare
|
|
31
|
+
|
|
30
32
|
You can install the package via npm or yarn:
|
|
31
33
|
|
|
32
34
|
```sh
|
|
@@ -38,6 +40,15 @@ yarn add react-native-orientation-director
|
|
|
38
40
|
|
|
39
41
|
Don't forget to run pod-install.
|
|
40
42
|
|
|
43
|
+
### Expo
|
|
44
|
+
|
|
45
|
+
This library can be installed only for [Development Builds](https://docs.expo.dev/develop/development-builds/introduction/)
|
|
46
|
+
using the following command:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npx expo install react-native-orientation-director
|
|
50
|
+
```
|
|
51
|
+
|
|
41
52
|
## Setup
|
|
42
53
|
|
|
43
54
|
To properly handle interface orientation changes in iOS, you need to update your AppDelegate.mm file.
|
|
@@ -72,7 +83,9 @@ This library exports a class called: [RNOrientationDirector](https://github.com/
|
|
|
72
83
|
| listenForInterfaceOrientationChanges | Triggers a provided callback each time the interface orientation changes |
|
|
73
84
|
| listenForLockChanges | Triggers a provided callback each time the interface orientation status changes |
|
|
74
85
|
| convertOrientationToHumanReadableString | Returns a human readable string based on the given orientation |
|
|
75
|
-
|
|
|
86
|
+
| convertAutoRotationToHumanReadableString | Returns a human readable string based on the given auto rotation |
|
|
87
|
+
| setHumanReadableOrientations | Sets the mapping needed to convert orientation values to human readable strings |
|
|
88
|
+
| setHumanReadableAutoRotations | Sets the mapping needed to convert auto rotation values to human readable strings |
|
|
76
89
|
| resetSupportedInterfaceOrientations | Resets the supported interface orientations to settings |
|
|
77
90
|
|
|
78
91
|
In addition, the library exposes the following hooks:
|
|
@@ -87,7 +100,6 @@ Head over to the [example project](example) to see how to use the library.
|
|
|
87
100
|
|
|
88
101
|
## Roadmap
|
|
89
102
|
|
|
90
|
-
- [ ] Add support for Expo
|
|
91
103
|
- [ ] Add JS side tests
|
|
92
104
|
- [ ] Add Android side tests
|
|
93
105
|
- [ ] Add iOS side tests
|
|
@@ -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,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,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,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":["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;AAMxD,MAAMC,qBAAqB,CAAC;EAC1B,OAAeC,kCAAkC,GAC/C;IACE,CAACH,WAAW,CAACI,OAAO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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,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.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 +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"}
|