react-native-unistyles 2.4.0-rc.1 → 2.4.0-rc.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +5 -2
- package/android/src/main/cxx/cpp-adapter.cpp +28 -13
- package/android/src/main/cxx/helpers.cpp +21 -56
- package/android/src/main/cxx/helpers.h +3 -3
- package/android/src/main/java/com/unistyles/Config.kt +116 -0
- package/android/src/main/java/com/unistyles/Insets.kt +138 -0
- package/android/src/main/java/com/unistyles/Models.kt +85 -0
- package/android/src/main/java/com/unistyles/Platform.kt +10 -79
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +85 -25
- package/cxx/UnistylesRuntime.cpp +57 -42
- package/cxx/UnistylesRuntime.h +30 -19
- package/ios/UnistylesModule.mm +20 -6
- package/ios/platform/Platform_iOS.h +5 -4
- package/ios/platform/Platform_iOS.mm +35 -22
- package/ios/platform/Platform_macOS.h +5 -4
- package/ios/platform/Platform_macOS.mm +18 -25
- package/lib/commonjs/common.js +7 -0
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.js +6 -0
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +8 -0
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/hooks/useUnistyles.js +18 -1
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/module/common.js +7 -0
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +6 -0
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +8 -0
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/hooks/useUnistyles.js +18 -1
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/typescript/src/common.d.ts +8 -1
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +6 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useUnistyles.d.ts +14 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +6 -2
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common.ts +8 -1
- package/src/core/UnistylesModule.ts +8 -2
- package/src/core/UnistylesRuntime.ts +8 -0
- package/src/hooks/useUnistyles.ts +18 -1
- package/src/types/unistyles.ts +6 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,MAAM,oCAEhB;IAED;;;OAGG;IACH,IAAW,SAAS,
|
1
|
+
{"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,mBAAmB,gGAE7B;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,MAAM,oCAEhB;IAED;;;OAGG;IACH,IAAW,SAAS,wCAEnB;IAED;;;OAGG;IACH,IAAW,aAAa,wCAEvB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;;;OAKG;IACI,WAAW,SAAU,MAAM,eAAe,mBAAmB,eAAe,CAAC,MAAM,eAAe,CAAC,KAAK,eAAe,CAAC,MAAM,eAAe,CAAC,UAEpJ;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
|
@@ -8,6 +8,20 @@ export declare const useUnistyles: () => {
|
|
8
8
|
width: number;
|
9
9
|
height: number;
|
10
10
|
};
|
11
|
+
statusBar: {
|
12
|
+
width: number;
|
13
|
+
height: number;
|
14
|
+
};
|
15
|
+
navigationBar: {
|
16
|
+
width: number;
|
17
|
+
height: number;
|
18
|
+
};
|
19
|
+
insets: {
|
20
|
+
top: number;
|
21
|
+
bottom: number;
|
22
|
+
left: number;
|
23
|
+
right: number;
|
24
|
+
};
|
11
25
|
};
|
12
26
|
contentSizeCategory: import("../common").IOSContentSizeCategory | import("../common").AndroidContentSizeCategory;
|
13
27
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY
|
1
|
+
{"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;CAwExB,CAAA"}
|
@@ -9,7 +9,7 @@ export type ScreenInsets = {
|
|
9
9
|
bottom: number;
|
10
10
|
left: number;
|
11
11
|
};
|
12
|
-
export type
|
12
|
+
export type ScreenDimensions = {
|
13
13
|
height: number;
|
14
14
|
width: number;
|
15
15
|
};
|
@@ -30,7 +30,8 @@ export type UnistylesBridge = {
|
|
30
30
|
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory;
|
31
31
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
|
32
32
|
insets: ScreenInsets;
|
33
|
-
statusBar:
|
33
|
+
statusBar: ScreenDimensions;
|
34
|
+
navigationBar: ScreenDimensions;
|
34
35
|
themes: Array<keyof UnistylesThemes>;
|
35
36
|
useBreakpoints(breakpoints: UnistylesBreakpoints): void;
|
36
37
|
useTheme(name: keyof UnistylesThemes): void;
|
@@ -49,6 +50,9 @@ export type UnistylesMobileLayoutEvent = {
|
|
49
50
|
type: UnistylesEventType.Layout;
|
50
51
|
payload: {
|
51
52
|
screen: ScreenSize;
|
53
|
+
statusBar: ScreenDimensions;
|
54
|
+
navigationBar: ScreenDimensions;
|
55
|
+
insets: ScreenInsets;
|
52
56
|
breakpoint: keyof UnistylesBreakpoints;
|
53
57
|
orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation];
|
54
58
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACrH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,YAAY,GAAG;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACrH,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAA;AAE9D,MAAM,MAAM,YAAY,GA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AiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACzC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACrD,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC;IAC/B,OAAO,EAAE;QACL,SAAS,EAAE,MAAM,eAAe,CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC;IAChC,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC;QACnB,SAAS,EAAE,gBAAgB,CAAC;QAC5B,aAAa,EAAE,gBAAgB,CAAC;QAChC,MAAM,EAAE,YAAY,CAAC;QACrB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IACxC,IAAI,EAAE,kBAAkB,CAAC,eAAe,CAAC;IACzC,OAAO,EAAE;QACL,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,CAAA;KAC3E,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,GAAG,6BAA6B,CAAA"}
|
package/package.json
CHANGED
package/src/common.ts
CHANGED
@@ -16,6 +16,11 @@ export const ScreenOrientation = {
|
|
16
16
|
} as const
|
17
17
|
|
18
18
|
export enum IOSContentSizeCategory {
|
19
|
+
AccessibilityExtraExtraExtraLarge = 'accessibilityExtraExtraExtraLarge',
|
20
|
+
AccessibilityExtraExtraLarge = 'accessibilityExtraExtraLarge',
|
21
|
+
AccessibilityExtraLarge = 'accessibilityExtraLarge',
|
22
|
+
AccessibilityLarge = 'accessibilityLarge',
|
23
|
+
AccessibilityMedium = 'accessibilityMedium',
|
19
24
|
ExtraExtraExtraLarge = 'xxxLarge',
|
20
25
|
ExtraExtraLarge = 'xxLarge',
|
21
26
|
ExtraLarge = 'xLarge',
|
@@ -31,7 +36,9 @@ export enum AndroidContentSizeCategory {
|
|
31
36
|
Default = 'Default',
|
32
37
|
Large = 'Large',
|
33
38
|
ExtraLarge = 'ExtraLarge',
|
34
|
-
Huge = 'Huge'
|
39
|
+
Huge = 'Huge',
|
40
|
+
ExtraHuge = 'ExtraHuge',
|
41
|
+
ExtraExtraHuge = 'ExtraExtraHuge'
|
35
42
|
}
|
36
43
|
|
37
44
|
export enum UnistylesEventType {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { NativeEventEmitter, NativeModules } from 'react-native'
|
2
2
|
import type { UnistylesThemes, UnistylesBreakpoints } from 'react-native-unistyles'
|
3
|
-
import type { ColorSchemeName, ScreenInsets,
|
3
|
+
import type { ColorSchemeName, ScreenInsets, ScreenDimensions } from '../types'
|
4
4
|
import { normalizeWebStylesPlugin } from '../plugins'
|
5
5
|
import { isServer } from '../common'
|
6
6
|
|
@@ -25,7 +25,11 @@ export class UnistylesBridgeWeb {
|
|
25
25
|
bottom: 0,
|
26
26
|
left: 0
|
27
27
|
}
|
28
|
-
#statusBar:
|
28
|
+
#statusBar: ScreenDimensions = {
|
29
|
+
height: 0,
|
30
|
+
width: 0
|
31
|
+
}
|
32
|
+
#navigationBar: ScreenDimensions = {
|
29
33
|
height: 0,
|
30
34
|
width: 0
|
31
35
|
}
|
@@ -68,6 +72,8 @@ export class UnistylesBridgeWeb {
|
|
68
72
|
return this.#insets
|
69
73
|
case 'statusBar':
|
70
74
|
return this.#statusBar
|
75
|
+
case 'navigationBar':
|
76
|
+
return this.#navigationBar
|
71
77
|
case 'useTheme':
|
72
78
|
return (themeName: keyof UnistylesThemes) => this.useTheme(themeName)
|
73
79
|
case 'updateTheme':
|
@@ -92,6 +92,14 @@ export class UnistylesRuntime {
|
|
92
92
|
return this.unistylesBridge.statusBar
|
93
93
|
}
|
94
94
|
|
95
|
+
/**
|
96
|
+
* Get the navigation bar info (Android)
|
97
|
+
* @returns - The navigation bar size { width, height }
|
98
|
+
*/
|
99
|
+
public get navigationBar() {
|
100
|
+
return this.unistylesBridge.navigationBar
|
101
|
+
}
|
102
|
+
|
95
103
|
/**
|
96
104
|
* Get the screen orientation
|
97
105
|
* @returns - The screen orientation
|
@@ -16,6 +16,20 @@ export const useUnistyles = () => {
|
|
16
16
|
screenSize: {
|
17
17
|
width: unistyles.runtime.screen.width,
|
18
18
|
height: unistyles.runtime.screen.height
|
19
|
+
},
|
20
|
+
statusBar: {
|
21
|
+
width: unistyles.runtime.statusBar.width,
|
22
|
+
height: unistyles.runtime.statusBar.height
|
23
|
+
},
|
24
|
+
navigationBar: {
|
25
|
+
width: unistyles.runtime.navigationBar.width,
|
26
|
+
height: unistyles.runtime.navigationBar.height
|
27
|
+
},
|
28
|
+
insets: {
|
29
|
+
top: unistyles.runtime.insets.top,
|
30
|
+
bottom: unistyles.runtime.insets.bottom,
|
31
|
+
left: unistyles.runtime.insets.left,
|
32
|
+
right: unistyles.runtime.insets.right
|
19
33
|
}
|
20
34
|
})
|
21
35
|
|
@@ -35,7 +49,10 @@ export const useUnistyles = () => {
|
|
35
49
|
return setLayout({
|
36
50
|
breakpoint: layoutEvent.payload.breakpoint,
|
37
51
|
orientation: layoutEvent.payload.orientation,
|
38
|
-
screenSize: layoutEvent.payload.screen
|
52
|
+
screenSize: layoutEvent.payload.screen,
|
53
|
+
statusBar: layoutEvent.payload.statusBar,
|
54
|
+
insets: layoutEvent.payload.insets,
|
55
|
+
navigationBar: layoutEvent.payload.navigationBar
|
39
56
|
})
|
40
57
|
}
|
41
58
|
case UnistylesEventType.Plugin: {
|
package/src/types/unistyles.ts
CHANGED
@@ -12,7 +12,7 @@ export type ScreenInsets = {
|
|
12
12
|
left: number
|
13
13
|
}
|
14
14
|
|
15
|
-
export type
|
15
|
+
export type ScreenDimensions = {
|
16
16
|
height: number,
|
17
17
|
width: number
|
18
18
|
}
|
@@ -36,7 +36,8 @@ export type UnistylesBridge = {
|
|
36
36
|
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory,
|
37
37
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
|
38
38
|
insets: ScreenInsets,
|
39
|
-
statusBar:
|
39
|
+
statusBar: ScreenDimensions,
|
40
|
+
navigationBar: ScreenDimensions
|
40
41
|
|
41
42
|
// setters
|
42
43
|
themes: Array<keyof UnistylesThemes>,
|
@@ -59,6 +60,9 @@ export type UnistylesMobileLayoutEvent = {
|
|
59
60
|
type: UnistylesEventType.Layout,
|
60
61
|
payload: {
|
61
62
|
screen: ScreenSize,
|
63
|
+
statusBar: ScreenDimensions,
|
64
|
+
navigationBar: ScreenDimensions,
|
65
|
+
insets: ScreenInsets,
|
62
66
|
breakpoint: keyof UnistylesBreakpoints,
|
63
67
|
orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation]
|
64
68
|
}
|