react-native-unistyles 2.4.0 → 2.4.1
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 +72 -26
- package/android/CMakeLists.txt +18 -2
- package/android/build.gradle +5 -1
- package/android/src/main/cxx/cpp-adapter.cpp +16 -80
- package/android/src/main/cxx/helpers.cpp +61 -0
- package/android/src/main/cxx/helpers.h +7 -0
- package/android/src/main/cxx/platform.cpp +170 -0
- package/android/src/main/cxx/platform.h +20 -0
- package/android/src/main/java/com/unistyles/Models.kt +12 -70
- package/android/src/main/java/com/unistyles/Platform.kt +311 -10
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +145 -153
- package/cxx/Macros.h +11 -0
- package/cxx/UnistylesImpl.cpp +310 -0
- package/cxx/UnistylesModel.cpp +234 -0
- package/cxx/UnistylesModel.h +141 -0
- package/cxx/UnistylesRuntime.cpp +17 -356
- package/cxx/UnistylesRuntime.h +71 -87
- package/ios/UnistylesModule.h +13 -0
- package/ios/UnistylesModule.mm +20 -90
- package/ios/platform/Platform_Shared.h +8 -0
- package/ios/platform/Platform_Shared.mm +160 -0
- package/ios/platform/Platform_iOS.h +6 -10
- package/ios/platform/Platform_iOS.mm +143 -93
- package/ios/platform/Platform_macOS.h +3 -7
- package/ios/platform/Platform_macOS.mm +52 -34
- package/ios/platform/Platform_tvOS.h +17 -0
- package/ios/platform/Platform_tvOS.mm +96 -0
- package/ios/platform/Platform_visionOS.h +20 -0
- package/ios/platform/Platform_visionOS.mm +120 -0
- package/lib/commonjs/UnistylesProvider.js +32 -0
- package/lib/commonjs/UnistylesProvider.js.map +1 -0
- package/lib/commonjs/common.js +3 -2
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +14 -4
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +7 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.js +52 -8
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.native.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.windows.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +114 -4
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js +36 -0
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js +46 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +122 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/commonjs/core/mocks/index.js +27 -0
- package/lib/commonjs/core/mocks/index.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/global.js.map +1 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.native.js.map +1 -1
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -1
- package/lib/commonjs/hooks/useSharedContext.js +77 -0
- package/lib/commonjs/hooks/useSharedContext.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +18 -65
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/normalizer/index.js.map +1 -1
- package/lib/commonjs/normalizer/module.d.js.map +1 -1
- package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.js +1 -1
- package/lib/commonjs/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -1
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -1
- package/lib/commonjs/plugins/index.js.map +1 -1
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/commonjs/types/breakpoints.js.map +1 -1
- package/lib/commonjs/types/color.js +2 -0
- package/lib/commonjs/types/color.js.map +1 -0
- package/lib/commonjs/types/common.js.map +1 -1
- package/lib/commonjs/types/core.js.map +1 -1
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/normalizer.js.map +1 -1
- package/lib/commonjs/types/plugin.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/types/unistyles.js.map +1 -1
- package/lib/commonjs/types/variants.js.map +1 -1
- package/lib/commonjs/useStyles.js +1 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
- package/lib/commonjs/utils/generateId.js.map +1 -1
- package/lib/commonjs/utils/hash32.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/parseColor.js +35 -0
- package/lib/commonjs/utils/parseColor.js.map +1 -0
- package/lib/commonjs/utils/styles.js +15 -1
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js.map +1 -1
- package/lib/module/UnistylesProvider.js +24 -0
- package/lib/module/UnistylesProvider.js.map +1 -0
- package/lib/module/common.js +2 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +15 -5
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +8 -1
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +52 -8
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesModule.native.js.map +1 -1
- package/lib/module/core/UnistylesModule.windows.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +115 -4
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/core/index.js +2 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/mocks/UnistylesMockedBridge.js +29 -0
- package/lib/module/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js +39 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js +114 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/module/core/mocks/index.js +4 -0
- package/lib/module/core/mocks/index.js.map +1 -0
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/global.js.map +1 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useCSS.js.map +1 -1
- package/lib/module/hooks/useCSS.native.js.map +1 -1
- package/lib/module/hooks/useInitialTheme.js.map +1 -1
- package/lib/module/hooks/useSharedContext.js +70 -0
- package/lib/module/hooks/useSharedContext.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +19 -66
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizer/index.js.map +1 -1
- package/lib/module/normalizer/module.d.js.map +1 -1
- package/lib/module/normalizer/normalizeStyle.js.map +1 -1
- package/lib/module/normalizer/normalizer.js.map +1 -1
- package/lib/module/normalizer/normalizer.macos.js.map +1 -1
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -1
- package/lib/module/plugins/index.js.map +1 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/module/types/breakpoints.js.map +1 -1
- package/lib/module/types/color.js +2 -0
- package/lib/module/types/color.js.map +1 -0
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/core.js.map +1 -1
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/normalizer.js.map +1 -1
- package/lib/module/types/plugin.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/types/unistyles.js.map +1 -1
- package/lib/module/types/variants.js.map +1 -1
- package/lib/module/useStyles.js +1 -1
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js.map +1 -1
- package/lib/module/utils/generateId.js.map +1 -1
- package/lib/module/utils/hash32.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/parseColor.js +28 -0
- package/lib/module/utils/parseColor.js.map +1 -0
- package/lib/module/utils/styles.js +15 -1
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js.map +1 -1
- package/lib/typescript/src/UnistylesProvider.d.ts +20 -0
- package/lib/typescript/src/UnistylesProvider.d.ts.map +1 -0
- package/lib/typescript/src/common.d.ts +3 -2
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.windows.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +84 -8
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +3 -1
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts +28 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts +21 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +79 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/index.d.ts +4 -0
- package/lib/typescript/src/core/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useSharedContext.d.ts +33 -0
- package/lib/typescript/src/hooks/useSharedContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +4 -19
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -15
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +9 -8
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/color.d.ts +4 -0
- package/lib/typescript/src/types/color.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +2 -2
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/normalizer.d.ts +1 -1
- package/lib/typescript/src/types/normalizer.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +9 -6
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +20 -9
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/parseColor.d.ts +3 -0
- package/lib/typescript/src/utils/parseColor.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +38 -25
- package/react-native-unistyles.podspec +4 -1
- package/src/UnistylesProvider.tsx +33 -0
- package/src/common.ts +3 -2
- package/src/core/UnistyleRegistry.ts +19 -5
- package/src/core/Unistyles.ts +10 -1
- package/src/core/UnistylesModule.ts +61 -14
- package/src/core/UnistylesRuntime.ts +120 -5
- package/src/core/index.ts +7 -1
- package/src/core/mocks/UnistylesMockedBridge.ts +30 -0
- package/src/core/mocks/UnistylesMockedRegistry.ts +47 -0
- package/src/core/mocks/UnistylesMockedRuntime.ts +144 -0
- package/src/core/mocks/index.ts +3 -0
- package/src/hooks/useSharedContext.ts +83 -0
- package/src/hooks/useUnistyles.ts +15 -71
- package/src/index.ts +10 -4
- package/src/types/breakpoints.ts +19 -9
- package/src/types/color.ts +26 -0
- package/src/types/core.ts +2 -2
- package/src/types/index.ts +5 -1
- package/src/types/normalizer.ts +1 -1
- package/src/types/stylesheet.ts +10 -7
- package/src/types/unistyles.ts +28 -12
- package/src/useStyles.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/parseColor.ts +33 -0
- package/src/utils/styles.ts +24 -1
- package/windows/ExperimentalFeatures.props +4 -4
- package/windows/NuGet.Config +0 -1
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.h +42 -118
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.vcxproj +7 -2
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.vcxproj.filters +6 -1
- package/windows/ReactNativeUnistyles/packages.lock.json +31 -31
- package/android/src/main/java/com/unistyles/Config.kt +0 -116
- package/android/src/main/java/com/unistyles/Insets.kt +0 -138
- package/ios/UnistylesHelpers.h +0 -3
- package/ios/UnistylesHelpers.mm +0 -5
@@ -0,0 +1,47 @@
|
|
1
|
+
// @ts-nocheck
|
2
|
+
import type { UnistylesBreakpoints, UnistylesThemes } from '../../global'
|
3
|
+
import type { UnistylesPlugin, UnistylesConfig, UnistylesBridge } from '../../types'
|
4
|
+
|
5
|
+
export class UnistylesMockedRegistry {
|
6
|
+
public config: UnistylesConfig = {}
|
7
|
+
public breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
|
8
|
+
public sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]> = []
|
9
|
+
public plugins: Array<UnistylesPlugin> = []
|
10
|
+
public themes: UnistylesThemes = {} as UnistylesThemes
|
11
|
+
public themeNames: Array<keyof UnistylesThemes> = []
|
12
|
+
|
13
|
+
constructor(private unistylesBridge: UnistylesBridge) {}
|
14
|
+
|
15
|
+
public addThemes = (themes: UnistylesThemes) => {
|
16
|
+
this.themes = themes
|
17
|
+
this.themeNames = Object.keys(themes) as Array<keyof UnistylesThemes>
|
18
|
+
|
19
|
+
return this
|
20
|
+
}
|
21
|
+
public addBreakpoints = (breakpoints: UnistylesBreakpoints) => {
|
22
|
+
this.breakpoints = breakpoints
|
23
|
+
this.sortedBreakpointPairs = Object
|
24
|
+
.entries(breakpoints)
|
25
|
+
.sort((breakpoint1, breakpoint2) => {
|
26
|
+
const [, value1] = breakpoint1
|
27
|
+
const [, value2] = breakpoint2
|
28
|
+
|
29
|
+
return value1 - value2
|
30
|
+
}) as Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>
|
31
|
+
|
32
|
+
return this
|
33
|
+
}
|
34
|
+
public addConfig = (config: UnistylesConfig) => {}
|
35
|
+
public getTheme = (forName: keyof UnistylesThemes) => {
|
36
|
+
if (this.themeNames.length === 0) {
|
37
|
+
return {} as UnistylesThemes[keyof UnistylesThemes]
|
38
|
+
}
|
39
|
+
|
40
|
+
return this.themes[forName]
|
41
|
+
}
|
42
|
+
|
43
|
+
public addPlugin = (plugin: UnistylesPlugin, notify: boolean = true) => {}
|
44
|
+
public removePlugin = (plugin: UnistylesPlugin) => {}
|
45
|
+
public updateTheme = (name: keyof UnistylesThemes, theme: UnistylesThemes[keyof UnistylesThemes]) => {}
|
46
|
+
public hasTheme = (name: keyof UnistylesThemes) => true
|
47
|
+
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
// @ts-nocheck
|
2
|
+
import { ScreenOrientation } from '../../common'
|
3
|
+
import type { Color, UnistylesBridge, UnistylesPlugin } from '../../types'
|
4
|
+
import type { UnistylesThemes } from '../../global'
|
5
|
+
import type { UnistylesMockedRegistry } from './UnistylesMockedRegistry'
|
6
|
+
import type { UnistyleRegistry } from '../UnistyleRegistry'
|
7
|
+
|
8
|
+
export class UnistylesMockedRuntime {
|
9
|
+
private unistylesRegistry: UnistylesMockedRegistry
|
10
|
+
|
11
|
+
constructor(private unistylesBridge: UnistylesBridge, private unistylesRegistry: UnistyleRegistry) {
|
12
|
+
this.unistylesRegistry = unistylesRegistry as unknown as UnistylesMockedRegistry
|
13
|
+
}
|
14
|
+
|
15
|
+
public get miniRuntime() {
|
16
|
+
return {
|
17
|
+
contentSizeCategory: this.contentSizeCategory,
|
18
|
+
breakpoint: this.breakpoint,
|
19
|
+
screen: this.screen,
|
20
|
+
insets: this.insets,
|
21
|
+
statusBar: {
|
22
|
+
width: this.statusBar.width,
|
23
|
+
height: this.statusBar.height
|
24
|
+
},
|
25
|
+
navigationBar: {
|
26
|
+
width: this.navigationBar.width,
|
27
|
+
height: this.navigationBar.height
|
28
|
+
},
|
29
|
+
orientation: this.orientation,
|
30
|
+
pixelRatio: this.pixelRatio,
|
31
|
+
fontScale: this.fontScale,
|
32
|
+
hairlineWidth: this.hairlineWidth,
|
33
|
+
rtl: this.rtl
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
public get colorScheme() {
|
38
|
+
return 'dark'
|
39
|
+
}
|
40
|
+
|
41
|
+
public get hasAdaptiveThemes() {
|
42
|
+
return true
|
43
|
+
}
|
44
|
+
|
45
|
+
public get themeName() {
|
46
|
+
return this.unistylesRegistry.themeNames.length > 0
|
47
|
+
? this.unistylesRegistry.themeNames.at(0)
|
48
|
+
: undefined
|
49
|
+
}
|
50
|
+
|
51
|
+
public get contentSizeCategory() {
|
52
|
+
return 'unspecified'
|
53
|
+
}
|
54
|
+
|
55
|
+
public get breakpoint() {
|
56
|
+
if (this.unistylesRegistry.sortedBreakpointPairs.length === 0) {
|
57
|
+
return undefined
|
58
|
+
}
|
59
|
+
|
60
|
+
const firstBreakpoint = this.unistylesRegistry.sortedBreakpointPairs.at(0)
|
61
|
+
|
62
|
+
return firstBreakpoint
|
63
|
+
? firstBreakpoint.at(0)
|
64
|
+
: undefined
|
65
|
+
}
|
66
|
+
|
67
|
+
public get rtl() {
|
68
|
+
return false
|
69
|
+
}
|
70
|
+
|
71
|
+
public get breakpoints() {
|
72
|
+
return this.unistylesRegistry.breakpoints
|
73
|
+
}
|
74
|
+
|
75
|
+
public get enabledPlugins() {
|
76
|
+
return this.unistylesRegistry.plugins
|
77
|
+
}
|
78
|
+
|
79
|
+
public get screen() {
|
80
|
+
return {
|
81
|
+
width: 360,
|
82
|
+
height: 800
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
public get insets() {
|
87
|
+
return {
|
88
|
+
top: 0,
|
89
|
+
right: 0,
|
90
|
+
bottom: 0,
|
91
|
+
left: 0
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
public get pixelRatio() {
|
96
|
+
return 1.0
|
97
|
+
}
|
98
|
+
|
99
|
+
public get hairlineWidth() {
|
100
|
+
return 0.333333
|
101
|
+
}
|
102
|
+
|
103
|
+
public get fontScale() {
|
104
|
+
return 1.0
|
105
|
+
}
|
106
|
+
|
107
|
+
public get statusBar() {
|
108
|
+
return {
|
109
|
+
height: 24,
|
110
|
+
width: 800,
|
111
|
+
setColor: () => {},
|
112
|
+
setHidden: () => {}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
public get navigationBar() {
|
117
|
+
return {
|
118
|
+
height: 0,
|
119
|
+
width: 0,
|
120
|
+
setColor: () => {},
|
121
|
+
setHidden: () => {}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
public get orientation() {
|
126
|
+
return ScreenOrientation.Portrait
|
127
|
+
}
|
128
|
+
|
129
|
+
public getTheme = (themeName?: keyof UnistylesThemes) => {
|
130
|
+
if (!themeName) {
|
131
|
+
return this.unistylesRegistry.getTheme(this.themeName)
|
132
|
+
}
|
133
|
+
|
134
|
+
return this.unistylesRegistry.getTheme(themeName)
|
135
|
+
}
|
136
|
+
|
137
|
+
public setTheme = (name: keyof UnistylesThemes) => true
|
138
|
+
public updateTheme = (name: keyof UnistylesThemes, theme: UnistylesThemes[keyof UnistylesThemes]) => {}
|
139
|
+
public setAdaptiveThemes = (enabled: boolean) => {}
|
140
|
+
public addPlugin = (plugin: UnistylesPlugin) => {}
|
141
|
+
public removePlugin = (plugin: UnistylesPlugin) => {}
|
142
|
+
public setRootViewBackgroundColor = (color?: Color | string) => {}
|
143
|
+
public setImmersiveMode = (isEnabled: boolean) => {}
|
144
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { type DependencyList, useEffect, useState } from 'react'
|
2
|
+
import { NativeEventEmitter, NativeModules } from 'react-native'
|
3
|
+
import { unistyles } from '../core'
|
4
|
+
import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
|
5
|
+
import { UnistylesEventType } from '../common'
|
6
|
+
|
7
|
+
type SharedContextConfig = {
|
8
|
+
useContext: boolean,
|
9
|
+
deps: DependencyList
|
10
|
+
}
|
11
|
+
|
12
|
+
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
13
|
+
|
14
|
+
export const useSharedContext = (config: SharedContextConfig) => {
|
15
|
+
const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins)
|
16
|
+
const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName))
|
17
|
+
const [layout, setLayout] = useState({
|
18
|
+
breakpoint: unistyles.runtime.breakpoint,
|
19
|
+
orientation: unistyles.runtime.orientation,
|
20
|
+
screen: {
|
21
|
+
width: unistyles.runtime.screen.width,
|
22
|
+
height: unistyles.runtime.screen.height
|
23
|
+
},
|
24
|
+
statusBar: {
|
25
|
+
width: unistyles.runtime.statusBar.width,
|
26
|
+
height: unistyles.runtime.statusBar.height
|
27
|
+
},
|
28
|
+
navigationBar: {
|
29
|
+
width: unistyles.runtime.navigationBar.width,
|
30
|
+
height: unistyles.runtime.navigationBar.height
|
31
|
+
},
|
32
|
+
insets: {
|
33
|
+
top: unistyles.runtime.insets.top,
|
34
|
+
bottom: unistyles.runtime.insets.bottom,
|
35
|
+
left: unistyles.runtime.insets.left,
|
36
|
+
right: unistyles.runtime.insets.right
|
37
|
+
}
|
38
|
+
})
|
39
|
+
|
40
|
+
useEffect(() => {
|
41
|
+
if (config.useContext) {
|
42
|
+
return
|
43
|
+
}
|
44
|
+
|
45
|
+
const subscription = unistylesEvents.addListener(
|
46
|
+
'__unistylesOnChange',
|
47
|
+
(event: UnistylesEvents) => {
|
48
|
+
switch (event.type) {
|
49
|
+
case UnistylesEventType.Theme: {
|
50
|
+
const themeEvent = event as UnistylesThemeEvent
|
51
|
+
|
52
|
+
return setTheme(unistyles.registry.getTheme(themeEvent.payload.themeName))
|
53
|
+
}
|
54
|
+
case UnistylesEventType.Layout: {
|
55
|
+
const layoutEvent = event as UnistylesMobileLayoutEvent
|
56
|
+
|
57
|
+
return setLayout({
|
58
|
+
breakpoint: layoutEvent.payload.breakpoint,
|
59
|
+
orientation: layoutEvent.payload.orientation,
|
60
|
+
screen: layoutEvent.payload.screen,
|
61
|
+
statusBar: layoutEvent.payload.statusBar,
|
62
|
+
insets: layoutEvent.payload.insets,
|
63
|
+
navigationBar: layoutEvent.payload.navigationBar
|
64
|
+
})
|
65
|
+
}
|
66
|
+
case UnistylesEventType.Plugin: {
|
67
|
+
return setPlugins(unistyles.runtime.enabledPlugins)
|
68
|
+
}
|
69
|
+
default:
|
70
|
+
return
|
71
|
+
}
|
72
|
+
}
|
73
|
+
)
|
74
|
+
|
75
|
+
return subscription.remove
|
76
|
+
}, config.deps)
|
77
|
+
|
78
|
+
return {
|
79
|
+
plugins,
|
80
|
+
theme,
|
81
|
+
layout
|
82
|
+
}
|
83
|
+
}
|
@@ -1,81 +1,25 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { UnistylesEventType } from '../common'
|
5
|
-
import type { UnistylesDynamicTypeSizeEvent, UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
|
6
|
-
|
7
|
-
const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
|
1
|
+
import { useContext } from 'react'
|
2
|
+
import { UnistylesContext } from '../UnistylesProvider'
|
3
|
+
import { useSharedContext } from './useSharedContext'
|
8
4
|
|
9
5
|
export const useUnistyles = () => {
|
10
|
-
const
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
breakpoint: unistyles.runtime.breakpoint,
|
15
|
-
orientation: unistyles.runtime.orientation,
|
16
|
-
screenSize: {
|
17
|
-
width: unistyles.runtime.screen.width,
|
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
|
33
|
-
}
|
6
|
+
const unistylesContext = useContext(UnistylesContext)
|
7
|
+
const { theme, layout, plugins } = useSharedContext({
|
8
|
+
useContext: unistylesContext !== undefined,
|
9
|
+
deps: unistylesContext ? [unistylesContext] : []
|
34
10
|
})
|
35
11
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
return setTheme(unistyles.registry.getTheme(themeEvent.payload.themeName))
|
45
|
-
}
|
46
|
-
case UnistylesEventType.Layout: {
|
47
|
-
const layoutEvent = event as UnistylesMobileLayoutEvent
|
48
|
-
|
49
|
-
return setLayout({
|
50
|
-
breakpoint: layoutEvent.payload.breakpoint,
|
51
|
-
orientation: layoutEvent.payload.orientation,
|
52
|
-
screenSize: layoutEvent.payload.screen,
|
53
|
-
statusBar: layoutEvent.payload.statusBar,
|
54
|
-
insets: layoutEvent.payload.insets,
|
55
|
-
navigationBar: layoutEvent.payload.navigationBar
|
56
|
-
})
|
57
|
-
}
|
58
|
-
case UnistylesEventType.Plugin: {
|
59
|
-
return setPlugins(unistyles.runtime.enabledPlugins)
|
60
|
-
}
|
61
|
-
case UnistylesEventType.DynamicTypeSize: {
|
62
|
-
const dynamicTypeSizeEvent = event as UnistylesDynamicTypeSizeEvent
|
63
|
-
|
64
|
-
return setContentSizeCategory(dynamicTypeSizeEvent.payload.contentSizeCategory)
|
65
|
-
}
|
66
|
-
default:
|
67
|
-
return
|
68
|
-
}
|
69
|
-
}
|
70
|
-
)
|
71
|
-
|
72
|
-
return subscription.remove
|
73
|
-
}, [])
|
12
|
+
if (unistylesContext !== undefined) {
|
13
|
+
return {
|
14
|
+
plugins: unistylesContext.plugins,
|
15
|
+
theme: unistylesContext.theme,
|
16
|
+
layout: unistylesContext.layout
|
17
|
+
}
|
18
|
+
}
|
74
19
|
|
75
20
|
return {
|
76
21
|
plugins,
|
77
22
|
theme,
|
78
|
-
layout
|
79
|
-
contentSizeCategory
|
23
|
+
layout
|
80
24
|
}
|
81
25
|
}
|
package/src/index.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { unistyles } from './core'
|
2
2
|
import { mq } from './utils'
|
3
3
|
import { useInitialTheme } from './hooks'
|
4
|
-
import type { UnistylesPlugin, UnistylesValues } from './types'
|
4
|
+
import type { UnistylesPlugin, UnistylesValues, UnistyleText, UnistyleView, UnistyleImage, ExtractVariantNames, UnistylesTheme } from './types'
|
5
5
|
import type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
6
6
|
import { ScreenOrientation, AndroidContentSizeCategory, IOSContentSizeCategory } from './common'
|
7
7
|
import { useStyles } from './useStyles'
|
8
8
|
import { createStyleSheet } from './createStyleSheet'
|
9
|
-
|
9
|
+
import { UnistylesProvider } from './UnistylesProvider'
|
10
10
|
/**
|
11
11
|
* Utility to interact with the Unistyles
|
12
12
|
* (should be called only once)
|
@@ -40,12 +40,18 @@ export {
|
|
40
40
|
AndroidContentSizeCategory,
|
41
41
|
IOSContentSizeCategory,
|
42
42
|
UnistylesRegistry,
|
43
|
-
UnistylesRuntime
|
43
|
+
UnistylesRuntime,
|
44
|
+
UnistylesProvider
|
44
45
|
}
|
45
46
|
|
46
47
|
export type {
|
48
|
+
UnistylesTheme,
|
47
49
|
UnistylesThemes,
|
48
50
|
UnistylesBreakpoints,
|
49
51
|
UnistylesPlugin,
|
50
|
-
UnistylesValues
|
52
|
+
UnistylesValues,
|
53
|
+
UnistyleText,
|
54
|
+
UnistyleView,
|
55
|
+
UnistyleImage,
|
56
|
+
ExtractVariantNames as UnistylesVariants
|
51
57
|
}
|
package/src/types/breakpoints.ts
CHANGED
@@ -2,6 +2,7 @@ import type { ColorValue, OpaqueColorValue } from 'react-native'
|
|
2
2
|
import type { UnistylesTheme } from '../types'
|
3
3
|
import type { BreakpointsOrMediaQueries, ToDeepUnistyles } from './stylesheet'
|
4
4
|
import type { TransformStyles } from './core'
|
5
|
+
import type { UnistylesMiniRuntime } from '../core'
|
5
6
|
|
6
7
|
type ExtractTransformArray<T> = T extends object
|
7
8
|
? { [K in keyof T]: ExtractBreakpoints<T[K]> }
|
@@ -17,26 +18,33 @@ type ExtractBreakpoints<T> = T extends object
|
|
17
18
|
}
|
18
19
|
: T
|
19
20
|
|
20
|
-
type ParseNestedObject<T> = T extends (...args: infer A) => infer R
|
21
|
-
? (...args: A) => ParseNestedObject<R>
|
21
|
+
type ParseNestedObject<T, ShouldFlatten> = T extends (...args: infer A) => infer R
|
22
|
+
? (...args: A) => ParseNestedObject<R, false>
|
22
23
|
: T extends object
|
23
24
|
? T extends { variants: infer R }
|
24
|
-
|
25
|
+
// if intersection of Base and Variants is never, then flatten variants to generic "string"
|
26
|
+
? (ParseVariants<FlattenVariants<R, false>> & ParseNestedObject<Omit<T, 'variants'>, false>) extends never
|
27
|
+
? ParseVariants<FlattenVariants<R, true>> & ParseNestedObject<Omit<T, 'variants'>, false>
|
28
|
+
: ParseVariants<FlattenVariants<R, false>> & ParseNestedObject<Omit<T, 'variants'>, false>
|
25
29
|
: {
|
26
30
|
[K in keyof T]: T[K] extends object
|
27
31
|
? T[K] extends OpaqueColorValue
|
28
32
|
? ColorValue
|
29
33
|
: ExtractBreakpoints<T[K]>
|
30
|
-
: T[K]
|
34
|
+
: T[K] extends string
|
35
|
+
? ShouldFlatten extends true
|
36
|
+
? string
|
37
|
+
: T[K]
|
38
|
+
: T[K]
|
31
39
|
}
|
32
40
|
: T
|
33
41
|
|
34
|
-
type FlattenVariants<T> = T extends object
|
42
|
+
type FlattenVariants<T, ShouldFlatten> = T extends object
|
35
43
|
? {
|
36
44
|
[K in keyof T]: T[K] extends object
|
37
45
|
? {
|
38
46
|
[key in keyof T[K]]: T[K][key] extends object
|
39
|
-
? ParseNestedObject<T[K][key]>
|
47
|
+
? ParseNestedObject<T[K][key], ShouldFlatten>
|
40
48
|
: never
|
41
49
|
}
|
42
50
|
: never
|
@@ -45,7 +53,9 @@ type FlattenVariants<T> = T extends object
|
|
45
53
|
|
46
54
|
type ParseVariants<T> = T extends object
|
47
55
|
? T[keyof T] extends object
|
48
|
-
? UnionToIntersection<ParseVariants<T[keyof T]>>
|
56
|
+
? UnionToIntersection<ParseVariants<T[keyof T]>> extends never
|
57
|
+
? ParseVariants<T[keyof T]>
|
58
|
+
: UnionToIntersection<ParseVariants<T[keyof T]>>
|
49
59
|
: T
|
50
60
|
: T
|
51
61
|
|
@@ -53,9 +63,9 @@ type UnionToIntersection<U> =
|
|
53
63
|
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
|
54
64
|
|
55
65
|
type ParseStyleKeys<T> = T extends object
|
56
|
-
? { [K in keyof T]: ParseNestedObject<T[K]> }
|
66
|
+
? { [K in keyof T]: ParseNestedObject<T[K], false> }
|
57
67
|
: never
|
58
68
|
|
59
|
-
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme) => infer R
|
69
|
+
export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme, runtime: UnistylesMiniRuntime) => infer R
|
60
70
|
? ParseStyleKeys<R>
|
61
71
|
: ParseStyleKeys<T>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
type AndroidColor = 'red'
|
2
|
+
| 'blue'
|
3
|
+
| 'green'
|
4
|
+
| 'black'
|
5
|
+
| 'white'
|
6
|
+
| 'gray'
|
7
|
+
| 'cyan'
|
8
|
+
| 'magenta'
|
9
|
+
| 'yellow'
|
10
|
+
| 'light gray'
|
11
|
+
| 'dark gray'
|
12
|
+
| 'grey'
|
13
|
+
| 'light grey'
|
14
|
+
| 'dark grey'
|
15
|
+
| 'aqua'
|
16
|
+
| 'fuchsia'
|
17
|
+
| 'lime'
|
18
|
+
| 'maroon'
|
19
|
+
| 'navy'
|
20
|
+
| 'olive'
|
21
|
+
| 'purple'
|
22
|
+
| 'silver'
|
23
|
+
| 'teal'
|
24
|
+
| 'transparent'
|
25
|
+
|
26
|
+
export type Color = AndroidColor | string | undefined
|
package/src/types/core.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type {
|
2
2
|
MatrixTransform,
|
3
|
-
|
3
|
+
PerspectiveTransform,
|
4
4
|
RotateTransform,
|
5
5
|
RotateXTransform,
|
6
6
|
RotateYTransform,
|
@@ -22,7 +22,7 @@ export type ShadowOffset = {
|
|
22
22
|
}
|
23
23
|
|
24
24
|
export type TransformStyles =
|
25
|
-
&
|
25
|
+
& PerspectiveTransform
|
26
26
|
& RotateTransform
|
27
27
|
& RotateXTransform
|
28
28
|
& RotateYTransform
|
package/src/types/index.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
export * from './normalizer'
|
2
2
|
export * from './unistyles'
|
3
|
+
export * from './color'
|
3
4
|
export type { Optional, Nullable } from './common'
|
4
5
|
export type {
|
5
6
|
NestedStylePairs,
|
@@ -13,7 +14,10 @@ export type {
|
|
13
14
|
StyleSheetWithSuperPowers,
|
14
15
|
StyleSheet,
|
15
16
|
AllAvailableKeys,
|
16
|
-
UnistylesValues
|
17
|
+
UnistylesValues,
|
18
|
+
UnistyleText,
|
19
|
+
UnistyleView,
|
20
|
+
UnistyleImage
|
17
21
|
} from './stylesheet'
|
18
22
|
export type { ReactNativeStyleSheet } from './breakpoints'
|
19
23
|
export type { ExtractVariantNames } from './variants'
|
package/src/types/normalizer.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ShadowStyleIOS, TextStyle, TransformsStyle } from 'react-native'
|
2
2
|
|
3
|
-
type TransformArrayElement<T> = T extends
|
3
|
+
type TransformArrayElement<T> = T extends ReadonlyArray<infer U> ? U : never
|
4
4
|
type BoxShadow = Required<ShadowStyleIOS>
|
5
5
|
type TextShadow = Required<Pick<TextStyle, 'textShadowColor' | 'textShadowOffset' | 'textShadowRadius'>>
|
6
6
|
type Transforms = Array<TransformArrayElement<TransformsStyle['transform']>>
|
package/src/types/stylesheet.ts
CHANGED
@@ -1,18 +1,21 @@
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
1
|
+
import type { BoxShadowValue, FilterFunction, ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
2
2
|
import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core'
|
3
3
|
import type { UnistylesBreakpoints } from '../global'
|
4
|
+
import type { UnistylesMiniRuntime } from '../core'
|
4
5
|
|
5
6
|
// these props are treated differently to nest breakpoints and media queries
|
6
|
-
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset'
|
7
|
+
type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset' | 'boxShadow' | 'filter'
|
7
8
|
|
8
|
-
type UnistyleView = Omit<ViewStyle, NestedKeys>
|
9
|
-
type UnistyleText = Omit<TextStyle, NestedKeys>
|
10
|
-
type UnistyleImage = Omit<ImageStyle, NestedKeys>
|
9
|
+
export type UnistyleView = Omit<ViewStyle, NestedKeys>
|
10
|
+
export type UnistyleText = Omit<TextStyle, NestedKeys>
|
11
|
+
export type UnistyleImage = Omit<ImageStyle, NestedKeys>
|
11
12
|
|
12
13
|
type UnistyleNestedStyles = {
|
13
14
|
shadowOffset?: ToDeepUnistyles<ShadowOffset>,
|
14
15
|
textShadowOffset?: ToDeepUnistyles<ShadowOffset>,
|
15
|
-
transform?: Array<ToDeepUnistyles<TransformStyles
|
16
|
+
transform?: Array<ToDeepUnistyles<TransformStyles>>,
|
17
|
+
boxShadow?: Array<ToDeepUnistyles<BoxShadowValue>> | string,
|
18
|
+
filter?: Array<ToDeepUnistyles<FilterFunction>> | string
|
16
19
|
}
|
17
20
|
|
18
21
|
type Variants = {
|
@@ -46,4 +49,4 @@ export type StyleSheet = {
|
|
46
49
|
[styleName: string]: UnistylesValues | ((...args: any) => UnistylesValues)
|
47
50
|
}
|
48
51
|
|
49
|
-
export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme) => StyleSheet) | StyleSheet
|
52
|
+
export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme, miniRuntime: UnistylesMiniRuntime) => StyleSheet) | StyleSheet
|
package/src/types/unistyles.ts
CHANGED
@@ -17,11 +17,23 @@ export type ScreenDimensions = {
|
|
17
17
|
width: number
|
18
18
|
}
|
19
19
|
|
20
|
+
export interface StatusBar extends ScreenDimensions {
|
21
|
+
setColor(color?: string, alpha?: number): void,
|
22
|
+
setHidden(hidden: boolean): void
|
23
|
+
}
|
24
|
+
|
25
|
+
export interface NavigationBar extends ScreenDimensions {
|
26
|
+
setColor(color?: string, alpha?: number): void,
|
27
|
+
setHidden(hidden: boolean): void
|
28
|
+
}
|
29
|
+
|
20
30
|
export type UnistylesConfig = {
|
21
31
|
adaptiveThemes?: boolean,
|
22
32
|
initialTheme?: keyof UnistylesThemes,
|
23
33
|
plugins?: Array<UnistylesPlugin>,
|
24
|
-
experimentalCSSMediaQueries?: boolean
|
34
|
+
experimentalCSSMediaQueries?: boolean,
|
35
|
+
windowResizeDebounceTimeMs?: number,
|
36
|
+
disableAnimatedInsets?: boolean
|
25
37
|
}
|
26
38
|
|
27
39
|
export type UnistylesBridge = {
|
@@ -36,8 +48,11 @@ export type UnistylesBridge = {
|
|
36
48
|
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory,
|
37
49
|
sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>,
|
38
50
|
insets: ScreenInsets,
|
39
|
-
statusBar:
|
40
|
-
navigationBar:
|
51
|
+
statusBar: StatusBar,
|
52
|
+
navigationBar: NavigationBar,
|
53
|
+
pixelRatio: number,
|
54
|
+
fontScale: number,
|
55
|
+
rtl: boolean
|
41
56
|
|
42
57
|
// setters
|
43
58
|
themes: Array<keyof UnistylesThemes>,
|
@@ -46,7 +61,15 @@ export type UnistylesBridge = {
|
|
46
61
|
updateTheme(name: keyof UnistylesThemes): void,
|
47
62
|
useAdaptiveThemes(enable: boolean): void,
|
48
63
|
addPlugin(pluginName: string, notify: boolean): void,
|
49
|
-
removePlugin(pluginName: string): void
|
64
|
+
removePlugin(pluginName: string): void,
|
65
|
+
setRootViewBackgroundColor(color?: string, alpha?: number): void,
|
66
|
+
setImmersiveMode(isEnabled: boolean): void
|
67
|
+
|
68
|
+
// web only
|
69
|
+
setWindowResizeDebounceTimeMs(timeMs: number): void
|
70
|
+
|
71
|
+
// android only
|
72
|
+
disableAnimatedInsets(): void
|
50
73
|
}
|
51
74
|
|
52
75
|
export type UnistylesThemeEvent = {
|
@@ -72,11 +95,4 @@ export type UnistylesPluginEvent = {
|
|
72
95
|
type: UnistylesEventType.Plugin
|
73
96
|
}
|
74
97
|
|
75
|
-
export type
|
76
|
-
type: UnistylesEventType.DynamicTypeSize,
|
77
|
-
payload: {
|
78
|
-
contentSizeCategory: IOSContentSizeCategory | AndroidContentSizeCategory
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent | UnistylesDynamicTypeSizeEvent
|
98
|
+
export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent
|
package/src/useStyles.ts
CHANGED
@@ -26,7 +26,7 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
|
|
26
26
|
const { theme, layout, plugins } = useUnistyles()
|
27
27
|
const variants = useVariants(variantsMap)
|
28
28
|
const parsedStyles = useMemo(() => typeof stylesheet === 'function'
|
29
|
-
? stylesheet(theme)
|
29
|
+
? stylesheet(theme, unistyles.runtime.miniRuntime)
|
30
30
|
: stylesheet, [theme, stylesheet, layout])
|
31
31
|
|
32
32
|
const dynamicStyleSheet = useMemo(() => Object
|
package/src/utils/index.ts
CHANGED