1 | export interface AppDimensions {
|
2 | screenWidth?: number
|
3 | screenHeight?: number
|
4 | screenScale?: number
|
5 | screenFontScale?: number
|
6 | windowWidth?: number
|
7 | windowHeight?: number
|
8 | windowScale?: number
|
9 | windowFontScale?: number
|
10 | }
|
11 |
|
12 | export function getReactNativeDimensionsWithDimensions(
|
13 | screen: any,
|
14 | win: any
|
15 | ): AppDimensions | null {
|
16 | try {
|
17 | let screenInfo = {}
|
18 | let windowInfo = {}
|
19 |
|
20 | if (screen) {
|
21 | screenInfo = {
|
22 | screenWidth: Math.ceil(screen.width),
|
23 | screenHeight: Math.ceil(screen.height),
|
24 | screenScale: screen.scale,
|
25 | screenFontScale: screen.fontScale,
|
26 | }
|
27 | }
|
28 |
|
29 | if (win) {
|
30 | windowInfo = {
|
31 | windowWidth: Math.ceil(win.width),
|
32 | windowHeight: Math.ceil(win.height),
|
33 | windowScale: win.scale,
|
34 | windowFontScale: win.fontScale,
|
35 | }
|
36 | }
|
37 |
|
38 | return {
|
39 | ...screenInfo,
|
40 | ...windowInfo,
|
41 | }
|
42 | } catch (e) {}
|
43 |
|
44 | return null
|
45 | }
|