react-native-unistyles 3.0.0-alpha.23 → 3.0.0-alpha.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. package/cxx/common/Helpers.h +10 -0
  2. package/cxx/core/UnistylesState.cpp +13 -1
  3. package/cxx/core/UnistylesState.h +2 -1
  4. package/cxx/hybridObjects/HybridStyleSheet.cpp +38 -5
  5. package/cxx/hybridObjects/HybridStyleSheet.h +3 -0
  6. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +23 -3
  7. package/cxx/hybridObjects/HybridUnistylesRuntime.h +5 -0
  8. package/cxx/parser/Parser.cpp +1 -1
  9. package/ios/Equatable.swift +2 -1
  10. package/ios/NativePlatform+ios.swift +6 -1
  11. package/ios/NativePlatformListener+ios.swift +19 -19
  12. package/lib/commonjs/core/index.js +20 -0
  13. package/lib/commonjs/core/index.js.map +1 -0
  14. package/lib/commonjs/core/useBreakpoint.js +22 -0
  15. package/lib/commonjs/core/useBreakpoint.js.map +1 -0
  16. package/lib/commonjs/core/useBreakpoint.native.js +24 -0
  17. package/lib/commonjs/core/useBreakpoint.native.js.map +1 -0
  18. package/lib/commonjs/core/useTheme.js +22 -0
  19. package/lib/commonjs/core/useTheme.js.map +1 -0
  20. package/lib/commonjs/core/useTheme.native.js +24 -0
  21. package/lib/commonjs/core/useTheme.native.js.map +1 -0
  22. package/lib/commonjs/index.js +16 -1
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  25. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  26. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  27. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  28. package/lib/commonjs/specs/index.js +7 -0
  29. package/lib/commonjs/specs/index.js.map +1 -1
  30. package/lib/commonjs/web/runtime.js +13 -9
  31. package/lib/commonjs/web/runtime.js.map +1 -1
  32. package/lib/module/core/index.js +5 -0
  33. package/lib/module/core/index.js.map +1 -0
  34. package/lib/module/core/useBreakpoint.js +17 -0
  35. package/lib/module/core/useBreakpoint.js.map +1 -0
  36. package/lib/module/core/useBreakpoint.native.js +19 -0
  37. package/lib/module/core/useBreakpoint.native.js.map +1 -0
  38. package/lib/module/core/useTheme.js +17 -0
  39. package/lib/module/core/useTheme.js.map +1 -0
  40. package/lib/module/core/useTheme.native.js +19 -0
  41. package/lib/module/core/useTheme.native.js.map +1 -0
  42. package/lib/module/index.js +1 -0
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  45. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  46. package/lib/module/specs/StatusBar/index.js.map +1 -1
  47. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  48. package/lib/module/specs/index.js +2 -1
  49. package/lib/module/specs/index.js.map +1 -1
  50. package/lib/module/web/runtime.js +13 -9
  51. package/lib/module/web/runtime.js.map +1 -1
  52. package/lib/typescript/example/App.d.ts.map +1 -1
  53. package/lib/typescript/example/Typography.d.ts +28 -5
  54. package/lib/typescript/example/Typography.d.ts.map +1 -1
  55. package/lib/typescript/src/core/index.d.ts +3 -0
  56. package/lib/typescript/src/core/index.d.ts.map +1 -0
  57. package/lib/typescript/src/core/useBreakpoint.d.ts +2 -0
  58. package/lib/typescript/src/core/useBreakpoint.d.ts.map +1 -0
  59. package/lib/typescript/src/core/useBreakpoint.native.d.ts +2 -0
  60. package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +1 -0
  61. package/lib/typescript/src/core/useTheme.d.ts +41 -0
  62. package/lib/typescript/src/core/useTheme.d.ts.map +1 -0
  63. package/lib/typescript/src/core/useTheme.native.d.ts +41 -0
  64. package/lib/typescript/src/core/useTheme.native.d.ts.map +1 -0
  65. package/lib/typescript/src/index.d.ts +2 -0
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
  68. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  69. package/lib/typescript/src/specs/NavigtionBar/index.d.ts +5 -0
  70. package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
  71. package/lib/typescript/src/specs/StatusBar/index.d.ts +5 -0
  72. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  73. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +2 -0
  74. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  75. package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
  76. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  77. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +0 -1
  78. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  79. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +3 -1
  80. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  81. package/lib/typescript/src/specs/index.d.ts +4 -2
  82. package/lib/typescript/src/specs/index.d.ts.map +1 -1
  83. package/lib/typescript/src/types/index.d.ts +1 -1
  84. package/lib/typescript/src/types/index.d.ts.map +1 -1
  85. package/lib/typescript/src/types/variants.d.ts +3 -0
  86. package/lib/typescript/src/types/variants.d.ts.map +1 -1
  87. package/lib/typescript/src/web/runtime.d.ts +1 -0
  88. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  89. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +8 -6
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +2 -1
  91. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +2 -2
  92. package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
  93. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -0
  94. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +6 -3
  95. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
  96. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
  97. package/package.json +1 -1
  98. package/plugin/common.js +3 -1
  99. package/plugin/stylesheet.js +2 -1
  100. package/src/core/index.ts +2 -0
  101. package/src/core/useBreakpoint.native.ts +21 -0
  102. package/src/core/useBreakpoint.ts +18 -0
  103. package/src/core/useTheme.native.ts +21 -0
  104. package/src/core/useTheme.ts +18 -0
  105. package/src/index.ts +3 -0
  106. package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
  107. package/src/specs/NavigtionBar/index.ts +5 -0
  108. package/src/specs/StatusBar/index.ts +5 -0
  109. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +3 -0
  110. package/src/specs/StyleSheet/index.ts +1 -1
  111. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +0 -1
  112. package/src/specs/UnistylesRuntime/index.ts +3 -1
  113. package/src/specs/index.ts +6 -2
  114. package/src/types/index.ts +1 -1
  115. package/src/types/variants.ts +6 -0
  116. package/src/web/runtime.ts +17 -12
@@ -2,7 +2,8 @@ import type { UnistylesRuntime as UnistylesRuntimeSpec, UnistylesMiniRuntime } f
2
2
  import type { AppBreakpoint, AppTheme, AppThemeName, Color, ColorScheme, Orientation } from '../types';
3
3
  import { type UnistylesStatusBar } from '../StatusBar';
4
4
  import { type UnistylesNavigationBar } from '../NavigtionBar';
5
- import type { AndroidContentSizeCategory, IOSContentSizeCategory } from '../../types';
5
+ import type { AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesTheme } from '../../types';
6
+ import type { UnistylesThemes } from '../../global';
6
7
  export interface UnistylesRuntimePrivate extends Omit<UnistylesRuntimeSpec, 'setRootViewBackgroundColor'> {
7
8
  readonly colorScheme: ColorScheme;
8
9
  readonly themeName?: AppThemeName;
@@ -11,6 +12,7 @@ export interface UnistylesRuntimePrivate extends Omit<UnistylesRuntimeSpec, 'set
11
12
  readonly orientation: Orientation;
12
13
  statusBar: UnistylesStatusBar;
13
14
  navigationBar: UnistylesNavigationBar;
15
+ getTheme(themeName?: keyof UnistylesThemes): UnistylesTheme;
14
16
  setTheme(themeName: AppThemeName): void;
15
17
  updateTheme(themeName: AppThemeName, updater: (currentTheme: AppTheme) => AppTheme): void;
16
18
  setRootViewBackgroundColor(color?: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/specs/UnistylesRuntime/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC9G,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtG,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EAAgC,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAC3F,OAAO,KAAK,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAGrF,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,4BAA4B,CAAC;IACrG,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,CAAC;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAGlC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,aAAa,EAAE,sBAAsB,CAAC;IAEtC,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI,CAA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IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE,sBAAsB,GAAG,0BAA0B,CAAC;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAGlC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,aAAa,EAAE,sBAAsB,CAAC;IAEtC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,eAAe,GAAG,cAAc,CAAC;IAC5D,QAAQ,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI,CAAA;IACvC,WAAW,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,GAAG,IAAI,CAAC;IAC1F,0BAA0B,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,2BAA2B,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;IAGhD,qBAAqB,IAAI,kBAAkB,CAAC;IAC5C,yBAAyB,IAAI,sBAAsB,CAAA;CACtD;AAED,KAAK,cAAc,GACd,uBAAuB,GACtB,2BAA2B,GAC3B,SAAS,GACT,aAAa,GACb,6BAA6B,CAAA;AAEnC,KAAK,gBAAgB,GAAG,IAAI,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAA;AAsBrE,eAAO,MAAM,OAAO,EAA6B,gBAAgB,CAAA;AAEjE,YAAY,EACR,oBAAoB,EACvB,CAAA"}
@@ -1,10 +1,12 @@
1
1
  import './TurboUnistyles';
2
2
  import { Runtime } from './UnistylesRuntime';
3
3
  import { StyleSheet } from './StyleSheet';
4
+ import type { UnistylesStyleSheet } from './StyleSheet';
4
5
  import { UnistylesShadowRegistry } from './ShadowRegistry';
5
6
  import type { UnistylesMiniRuntime } from './UnistylesRuntime';
6
7
  import { StatusBarStyle, ColorScheme, Orientation } from './types';
7
- export { StatusBarStyle, ColorScheme, Orientation };
8
+ import { UnistyleDependency } from './NativePlatform';
9
+ export { StatusBarStyle, ColorScheme, Orientation, UnistyleDependency };
8
10
  export { UnistylesShadowRegistry, Runtime as UnistylesRuntime, StyleSheet, };
9
- export type { UnistylesMiniRuntime };
11
+ export type { UnistylesMiniRuntime, UnistylesStyleSheet };
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/specs/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,EACH,cAAc,EACd,WAAW,EACX,WAAW,EACd,CAAA;AAED,OAAO,EACH,uBAAuB,EACvB,OAAO,IAAI,gBAAgB,EAC3B,UAAU,GACb,CAAA;AAED,YAAY,EACR,oBAAoB,EACvB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/specs/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EACH,cAAc,EACd,WAAW,EACX,WAAW,EACX,kBAAkB,EACrB,CAAA;AAED,OAAO,EACH,uBAAuB,EACvB,OAAO,IAAI,gBAAgB,EAC3B,UAAU,GACb,CAAA;AAED,YAAY,EACR,oBAAoB,EACpB,mBAAmB,EACtB,CAAA"}
@@ -2,6 +2,6 @@ export type { Optional, Nullable } from './common';
2
2
  export type { NestedStylePairs, UnistylesTheme, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
3
3
  export type { CreateUnistylesStyleSheet, StyleSheet, AllAvailableKeys, UnistylesValues, UnistyleText, UnistyleView, UnistyleImage } from './stylesheet';
4
4
  export type { ReactNativeStyleSheet } from './breakpoints';
5
- export type { ExtractVariantNames } from './variants';
5
+ export type { ExtractVariantNames, UnistylesVariants } from './variants';
6
6
  export { AndroidContentSizeCategory, IOSContentSizeCategory, WebContentSizeCategory } from './accessibility';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EACR,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EACR,yBAAyB,EACzB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EAChB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EACR,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EACR,yBAAyB,EACzB,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EAChB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACxE,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA"}
@@ -8,5 +8,8 @@ type ExtractVariant<T> = T extends {
8
8
  } ? {
9
9
  [key in keyof V]?: ExtractSubVariantKeys<V[key]>;
10
10
  } : T;
11
+ export type UnistylesVariants<ST> = ST extends {
12
+ useVariants: infer V;
13
+ } ? V extends (variants: infer T) => void ? T : never : never;
11
14
  export {};
12
15
  //# sourceMappingURL=variants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/types/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE9C,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAE1E,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GACvC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAC1C,KAAK,CAAA;AAEX,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EA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SAAS,IAAI,GAC9B,MAAM,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,OAAO,GAAG,SAAS,GAC9C,MAAM,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,SAAS,GACxC,KAAK,CAAA;AAEX,KAAK,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;CAAE,GAClD;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;CAAE,GACpD,CAAC,CAAA;AAEP,MAAM,MAAM,iBAAiB,CAAC,EAAE,IAAI,EAAE,SAAS;IAAE,WAAW,EAAE,MAAM,CAAC,CAAA;CAAE,GACjE,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,IAAI,GACjC,CAAC,GACD,KAAK,GACT,KAAK,CAAA"}
@@ -35,6 +35,7 @@ declare class UnistylesRuntimeBuilder {
35
35
  setRootViewBackgroundColor: (hex: string, alpha?: number) => void;
36
36
  setImmersiveMode: () => void;
37
37
  updateTheme: (themeName: AppThemeName, updater: (currentTheme: AppTheme) => AppTheme) => void;
38
+ getTheme: (themeName?: keyof import("react-native-unistyles").UnistylesThemes | undefined) => import("../types").UnistylesTheme;
38
39
  }
39
40
  export declare const UnistylesRuntime: UnistylesRuntimeBuilder;
40
41
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,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IAAI,KAAK,sCAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,UAQlC;IAED,iBAAiB,cAAe,OAAO,UAQtC;IAED,0BAA0B,QAAS,MAAM,UAAU,MAAM,UAMxD;IAED,gBAAgB,aAAW;IAE3B,WAAW,cAAe,YAAY,WAAW,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAQpF;IAED,QAAQ,wHAYP;CACJ;AAED,eAAO,MAAM,gBAAgB,yBAAgC,CAAA"}
@@ -16,8 +16,6 @@
16
16
  #include "JColorScheme.hpp"
17
17
  #include "JDimensions.hpp"
18
18
  #include "JInsets.hpp"
19
- #include "JOrientation.hpp"
20
- #include "Orientation.hpp"
21
19
  #include <string>
22
20
 
23
21
  namespace margelo::nitro::unistyles {
@@ -56,8 +54,10 @@ namespace margelo::nitro::unistyles {
56
54
  jni::local_ref<JDimensions> statusBar = this->getFieldValue(fieldStatusBar);
57
55
  static const auto fieldNavigationBar = clazz->getField<JDimensions>("navigationBar");
58
56
  jni::local_ref<JDimensions> navigationBar = this->getFieldValue(fieldNavigationBar);
59
- static const auto fieldOrientation = clazz->getField<JOrientation>("orientation");
60
- jni::local_ref<JOrientation> orientation = this->getFieldValue(fieldOrientation);
57
+ static const auto fieldIsPortrait = clazz->getField<jboolean>("isPortrait");
58
+ jboolean isPortrait = this->getFieldValue(fieldIsPortrait);
59
+ static const auto fieldIsLandscape = clazz->getField<jboolean>("isLandscape");
60
+ jboolean isLandscape = this->getFieldValue(fieldIsLandscape);
61
61
  return UnistylesNativeMiniRuntime(
62
62
  colorScheme->toCpp(),
63
63
  screen->toCpp(),
@@ -68,7 +68,8 @@ namespace margelo::nitro::unistyles {
68
68
  rtl,
69
69
  statusBar->toCpp(),
70
70
  navigationBar->toCpp(),
71
- orientation->toCpp()
71
+ isPortrait,
72
+ isLandscape
72
73
  );
73
74
  }
74
75
 
@@ -88,7 +89,8 @@ namespace margelo::nitro::unistyles {
88
89
  value.rtl,
89
90
  JDimensions::fromCpp(value.statusBar),
90
91
  JDimensions::fromCpp(value.navigationBar),
91
- JOrientation::fromCpp(value.orientation)
92
+ value.isPortrait,
93
+ value.isLandscape
92
94
  );
93
95
  }
94
96
  };
@@ -25,5 +25,6 @@ data class UnistylesNativeMiniRuntime(
25
25
  val rtl: Boolean,
26
26
  val statusBar: Dimensions,
27
27
  val navigationBar: Dimensions,
28
- val orientation: Orientation
28
+ val isPortrait: Boolean,
29
+ val isLandscape: Boolean
29
30
  )
@@ -46,7 +46,7 @@ namespace margelo::nitro::unistyles::bridge::swift {
46
46
  vector.reserve(size);
47
47
  return vector;
48
48
  }
49
-
49
+
50
50
  // pragma MARK: std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>
51
51
  /**
52
52
  * Specialized version of `std::function<void(const std::vector<UnistyleDependency>&)>`.
@@ -74,7 +74,7 @@ namespace margelo::nitro::unistyles::bridge::swift {
74
74
  inline std::shared_ptr<Func_void_std__vector_UnistyleDependency__Wrapper> share_Func_void_std__vector_UnistyleDependency_(const Func_void_std__vector_UnistyleDependency_& value) {
75
75
  return std::make_shared<Func_void_std__vector_UnistyleDependency__Wrapper>(value);
76
76
  }
77
-
77
+
78
78
  // pragma MARK: std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>
79
79
  /**
80
80
  * Specialized version of `std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpec>`.
@@ -18,8 +18,8 @@ public extension UnistylesNativeMiniRuntime {
18
18
  /**
19
19
  * Create a new instance of `UnistylesNativeMiniRuntime`.
20
20
  */
21
- init(colorScheme: ColorScheme, screen: Dimensions, contentSizeCategory: String, insets: Insets, pixelRatio: Double, fontScale: Double, rtl: Bool, statusBar: Dimensions, navigationBar: Dimensions, orientation: Orientation) {
22
- self.init(colorScheme, screen, std.string(contentSizeCategory), insets, pixelRatio, fontScale, rtl, statusBar, navigationBar, orientation)
21
+ init(colorScheme: ColorScheme, screen: Dimensions, contentSizeCategory: String, insets: Insets, pixelRatio: Double, fontScale: Double, rtl: Bool, statusBar: Dimensions, navigationBar: Dimensions, isPortrait: Bool, isLandscape: Bool) {
22
+ self.init(colorScheme, screen, std.string(contentSizeCategory), insets, pixelRatio, fontScale, rtl, statusBar, navigationBar, isPortrait, isLandscape)
23
23
  }
24
24
 
25
25
  var colorScheme: ColorScheme {
@@ -121,14 +121,25 @@ public extension UnistylesNativeMiniRuntime {
121
121
  }
122
122
  }
123
123
 
124
- var orientation: Orientation {
124
+ var isPortrait: Bool {
125
125
  @inline(__always)
126
126
  get {
127
- return self.__orientation
127
+ return self.__isPortrait
128
128
  }
129
129
  @inline(__always)
130
130
  set {
131
- self.__orientation = newValue
131
+ self.__isPortrait = newValue
132
+ }
133
+ }
134
+
135
+ var isLandscape: Bool {
136
+ @inline(__always)
137
+ get {
138
+ return self.__isLandscape
139
+ }
140
+ @inline(__always)
141
+ set {
142
+ self.__isLandscape = newValue
132
143
  }
133
144
  }
134
145
  }
@@ -16,6 +16,7 @@ namespace margelo::nitro::unistyles {
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
17
  prototype.registerHybridGetter("hairlineWidth", &HybridUnistylesStyleSheetSpec::getHairlineWidth);
18
18
  prototype.registerHybridGetter("unid", &HybridUnistylesStyleSheetSpec::getUnid);
19
+ prototype.registerHybridMethod("addChangeListener", &HybridUnistylesStyleSheetSpec::addChangeListener);
19
20
  });
20
21
  }
21
22
 
@@ -13,9 +13,12 @@
13
13
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
14
  #endif
15
15
 
16
+ // Forward declaration of `UnistyleDependency` to properly resolve imports.
17
+ namespace margelo::nitro::unistyles { enum class UnistyleDependency; }
16
18
 
17
-
18
-
19
+ #include <functional>
20
+ #include <vector>
21
+ #include "UnistyleDependency.hpp"
19
22
 
20
23
  namespace margelo::nitro::unistyles {
21
24
 
@@ -49,7 +52,7 @@ namespace margelo::nitro::unistyles {
49
52
 
50
53
  public:
51
54
  // Methods
52
-
55
+ virtual std::function<void()> addChangeListener(const std::function<void(const std::vector<UnistyleDependency>& /* dependencies */)>& onChanged) = 0;
53
56
 
54
57
  protected:
55
58
  // Hybrid Setup
@@ -18,8 +18,6 @@
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
20
 
21
- // Forward declaration of `Orientation` to properly resolve imports.
22
- namespace margelo::nitro::unistyles { enum class Orientation; }
23
21
  // Forward declaration of `ColorScheme` to properly resolve imports.
24
22
  namespace margelo::nitro::unistyles { enum class ColorScheme; }
25
23
  // Forward declaration of `Dimensions` to properly resolve imports.
@@ -29,7 +27,6 @@ namespace margelo::nitro::unistyles { struct Insets; }
29
27
 
30
28
  #include <optional>
31
29
  #include <string>
32
- #include "Orientation.hpp"
33
30
  #include "ColorScheme.hpp"
34
31
  #include "Dimensions.hpp"
35
32
  #include "Insets.hpp"
@@ -43,7 +40,6 @@ namespace margelo::nitro::unistyles {
43
40
  public:
44
41
  std::optional<std::string> themeName SWIFT_PRIVATE;
45
42
  std::optional<std::string> breakpoint SWIFT_PRIVATE;
46
- Orientation orientation SWIFT_PRIVATE;
47
43
  bool hasAdaptiveThemes SWIFT_PRIVATE;
48
44
  ColorScheme colorScheme SWIFT_PRIVATE;
49
45
  Dimensions screen SWIFT_PRIVATE;
@@ -54,9 +50,11 @@ namespace margelo::nitro::unistyles {
54
50
  bool rtl SWIFT_PRIVATE;
55
51
  Dimensions statusBar SWIFT_PRIVATE;
56
52
  Dimensions navigationBar SWIFT_PRIVATE;
53
+ bool isPortrait SWIFT_PRIVATE;
54
+ bool isLandscape SWIFT_PRIVATE;
57
55
 
58
56
  public:
59
- explicit UnistylesCxxMiniRuntime(std::optional<std::string> themeName, std::optional<std::string> breakpoint, Orientation orientation, bool hasAdaptiveThemes, ColorScheme colorScheme, Dimensions screen, std::string contentSizeCategory, Insets insets, double pixelRatio, double fontScale, bool rtl, Dimensions statusBar, Dimensions navigationBar): themeName(themeName), breakpoint(breakpoint), orientation(orientation), hasAdaptiveThemes(hasAdaptiveThemes), colorScheme(colorScheme), screen(screen), contentSizeCategory(contentSizeCategory), insets(insets), pixelRatio(pixelRatio), fontScale(fontScale), rtl(rtl), statusBar(statusBar), navigationBar(navigationBar) {}
57
+ explicit UnistylesCxxMiniRuntime(std::optional<std::string> themeName, std::optional<std::string> breakpoint, bool hasAdaptiveThemes, ColorScheme colorScheme, Dimensions screen, std::string contentSizeCategory, Insets insets, double pixelRatio, double fontScale, bool rtl, Dimensions statusBar, Dimensions navigationBar, bool isPortrait, bool isLandscape): themeName(themeName), breakpoint(breakpoint), hasAdaptiveThemes(hasAdaptiveThemes), colorScheme(colorScheme), screen(screen), contentSizeCategory(contentSizeCategory), insets(insets), pixelRatio(pixelRatio), fontScale(fontScale), rtl(rtl), statusBar(statusBar), navigationBar(navigationBar), isPortrait(isPortrait), isLandscape(isLandscape) {}
60
58
  };
61
59
 
62
60
  } // namespace margelo::nitro::unistyles
@@ -73,7 +71,6 @@ namespace margelo::nitro {
73
71
  return UnistylesCxxMiniRuntime(
74
72
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "themeName")),
75
73
  JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "breakpoint")),
76
- JSIConverter<Orientation>::fromJSI(runtime, obj.getProperty(runtime, "orientation")),
77
74
  JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "hasAdaptiveThemes")),
78
75
  JSIConverter<ColorScheme>::fromJSI(runtime, obj.getProperty(runtime, "colorScheme")),
79
76
  JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "screen")),
@@ -83,14 +80,15 @@ namespace margelo::nitro {
83
80
  JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "fontScale")),
84
81
  JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "rtl")),
85
82
  JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "statusBar")),
86
- JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar"))
83
+ JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar")),
84
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isPortrait")),
85
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isLandscape"))
87
86
  );
88
87
  }
89
88
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const UnistylesCxxMiniRuntime& arg) {
90
89
  jsi::Object obj(runtime);
91
90
  obj.setProperty(runtime, "themeName", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.themeName));
92
91
  obj.setProperty(runtime, "breakpoint", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.breakpoint));
93
- obj.setProperty(runtime, "orientation", JSIConverter<Orientation>::toJSI(runtime, arg.orientation));
94
92
  obj.setProperty(runtime, "hasAdaptiveThemes", JSIConverter<bool>::toJSI(runtime, arg.hasAdaptiveThemes));
95
93
  obj.setProperty(runtime, "colorScheme", JSIConverter<ColorScheme>::toJSI(runtime, arg.colorScheme));
96
94
  obj.setProperty(runtime, "screen", JSIConverter<Dimensions>::toJSI(runtime, arg.screen));
@@ -101,6 +99,8 @@ namespace margelo::nitro {
101
99
  obj.setProperty(runtime, "rtl", JSIConverter<bool>::toJSI(runtime, arg.rtl));
102
100
  obj.setProperty(runtime, "statusBar", JSIConverter<Dimensions>::toJSI(runtime, arg.statusBar));
103
101
  obj.setProperty(runtime, "navigationBar", JSIConverter<Dimensions>::toJSI(runtime, arg.navigationBar));
102
+ obj.setProperty(runtime, "isPortrait", JSIConverter<bool>::toJSI(runtime, arg.isPortrait));
103
+ obj.setProperty(runtime, "isLandscape", JSIConverter<bool>::toJSI(runtime, arg.isLandscape));
104
104
  return obj;
105
105
  }
106
106
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -110,7 +110,6 @@ namespace margelo::nitro {
110
110
  jsi::Object obj = value.getObject(runtime);
111
111
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "themeName"))) return false;
112
112
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "breakpoint"))) return false;
113
- if (!JSIConverter<Orientation>::canConvert(runtime, obj.getProperty(runtime, "orientation"))) return false;
114
113
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "hasAdaptiveThemes"))) return false;
115
114
  if (!JSIConverter<ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
116
115
  if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "screen"))) return false;
@@ -121,6 +120,8 @@ namespace margelo::nitro {
121
120
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "rtl"))) return false;
122
121
  if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "statusBar"))) return false;
123
122
  if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "navigationBar"))) return false;
123
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isPortrait"))) return false;
124
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isLandscape"))) return false;
124
125
  return true;
125
126
  }
126
127
  };
@@ -24,14 +24,11 @@ namespace margelo::nitro::unistyles { enum class ColorScheme; }
24
24
  namespace margelo::nitro::unistyles { struct Dimensions; }
25
25
  // Forward declaration of `Insets` to properly resolve imports.
26
26
  namespace margelo::nitro::unistyles { struct Insets; }
27
- // Forward declaration of `Orientation` to properly resolve imports.
28
- namespace margelo::nitro::unistyles { enum class Orientation; }
29
27
 
30
28
  #include "ColorScheme.hpp"
31
29
  #include "Dimensions.hpp"
32
30
  #include <string>
33
31
  #include "Insets.hpp"
34
- #include "Orientation.hpp"
35
32
 
36
33
  namespace margelo::nitro::unistyles {
37
34
 
@@ -49,10 +46,11 @@ namespace margelo::nitro::unistyles {
49
46
  bool rtl SWIFT_PRIVATE;
50
47
  Dimensions statusBar SWIFT_PRIVATE;
51
48
  Dimensions navigationBar SWIFT_PRIVATE;
52
- Orientation orientation SWIFT_PRIVATE;
49
+ bool isPortrait SWIFT_PRIVATE;
50
+ bool isLandscape SWIFT_PRIVATE;
53
51
 
54
52
  public:
55
- explicit UnistylesNativeMiniRuntime(ColorScheme colorScheme, Dimensions screen, std::string contentSizeCategory, Insets insets, double pixelRatio, double fontScale, bool rtl, Dimensions statusBar, Dimensions navigationBar, Orientation orientation): colorScheme(colorScheme), screen(screen), contentSizeCategory(contentSizeCategory), insets(insets), pixelRatio(pixelRatio), fontScale(fontScale), rtl(rtl), statusBar(statusBar), navigationBar(navigationBar), orientation(orientation) {}
53
+ explicit UnistylesNativeMiniRuntime(ColorScheme colorScheme, Dimensions screen, std::string contentSizeCategory, Insets insets, double pixelRatio, double fontScale, bool rtl, Dimensions statusBar, Dimensions navigationBar, bool isPortrait, bool isLandscape): colorScheme(colorScheme), screen(screen), contentSizeCategory(contentSizeCategory), insets(insets), pixelRatio(pixelRatio), fontScale(fontScale), rtl(rtl), statusBar(statusBar), navigationBar(navigationBar), isPortrait(isPortrait), isLandscape(isLandscape) {}
56
54
  };
57
55
 
58
56
  } // namespace margelo::nitro::unistyles
@@ -76,7 +74,8 @@ namespace margelo::nitro {
76
74
  JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "rtl")),
77
75
  JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "statusBar")),
78
76
  JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar")),
79
- JSIConverter<Orientation>::fromJSI(runtime, obj.getProperty(runtime, "orientation"))
77
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isPortrait")),
78
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isLandscape"))
80
79
  );
81
80
  }
82
81
  static inline jsi::Value toJSI(jsi::Runtime& runtime, const UnistylesNativeMiniRuntime& arg) {
@@ -90,7 +89,8 @@ namespace margelo::nitro {
90
89
  obj.setProperty(runtime, "rtl", JSIConverter<bool>::toJSI(runtime, arg.rtl));
91
90
  obj.setProperty(runtime, "statusBar", JSIConverter<Dimensions>::toJSI(runtime, arg.statusBar));
92
91
  obj.setProperty(runtime, "navigationBar", JSIConverter<Dimensions>::toJSI(runtime, arg.navigationBar));
93
- obj.setProperty(runtime, "orientation", JSIConverter<Orientation>::toJSI(runtime, arg.orientation));
92
+ obj.setProperty(runtime, "isPortrait", JSIConverter<bool>::toJSI(runtime, arg.isPortrait));
93
+ obj.setProperty(runtime, "isLandscape", JSIConverter<bool>::toJSI(runtime, arg.isLandscape));
94
94
  return obj;
95
95
  }
96
96
  static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
@@ -107,7 +107,8 @@ namespace margelo::nitro {
107
107
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "rtl"))) return false;
108
108
  if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "statusBar"))) return false;
109
109
  if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "navigationBar"))) return false;
110
- if (!JSIConverter<Orientation>::canConvert(runtime, obj.getProperty(runtime, "orientation"))) return false;
110
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isPortrait"))) return false;
111
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isLandscape"))) return false;
111
112
  return true;
112
113
  }
113
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-alpha.23",
3
+ "version": "3.0.0-alpha.25",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/plugin/common.js CHANGED
@@ -34,7 +34,8 @@ function getIdentifierNameFromExpression(t, memberExpression) {
34
34
  getIdentifierNameFromExpression(t, memberExpression.test.left),
35
35
  getIdentifierNameFromExpression(t, memberExpression.test.right),
36
36
  getIdentifierNameFromExpression(t, memberExpression.alternate),
37
- getIdentifierNameFromExpression(t,memberExpression.consequent),
37
+ getIdentifierNameFromExpression(t, memberExpression.consequent),
38
+ getIdentifierNameFromExpression(t, memberExpression.test)
38
39
  ].flat()
39
40
  }
40
41
 
@@ -66,6 +67,7 @@ function getSecondPropertyName(t, memberExpression) {
66
67
  getSecondPropertyName(t, memberExpression.test.right),
67
68
  getSecondPropertyName(t, memberExpression.alternate),
68
69
  getSecondPropertyName(t, memberExpression.consequent),
70
+ getSecondPropertyName(t, memberExpression.test)
69
71
  ].flat()
70
72
  }
71
73
 
@@ -100,7 +100,8 @@ function analyzeDependencies(t, state, name, unistyleObj, themeName, rtName) {
100
100
 
101
101
  return
102
102
  }
103
- case 'orientation': {
103
+ case 'isPortrait':
104
+ case 'isLandscape': {
104
105
  dependencies.push(UnistyleDependency.Orientation)
105
106
 
106
107
  return
@@ -0,0 +1,2 @@
1
+ export { useBreakpoint } from './useBreakpoint'
2
+ export { useTheme } from './useTheme'
@@ -0,0 +1,21 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
3
+ import type { UnistylesStyleSheet } from '../specs'
4
+
5
+ export const useBreakpoint = () => {
6
+ const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint)
7
+
8
+ useEffect(() => {
9
+ const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
10
+ if (dependencies.includes(UnistyleDependency.Breakpoints)) {
11
+ setBreakpoint(UnistylesRuntime.breakpoint)
12
+ }
13
+ })
14
+
15
+ return () => {
16
+ removeChangeListener()
17
+ }
18
+ }, [])
19
+
20
+ return breakpoint
21
+ }
@@ -0,0 +1,18 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { UnistylesRuntime } from '../web'
3
+ import { UnistylesListener } from '../web/listener'
4
+ import { UnistyleDependency } from '../specs/NativePlatform'
5
+
6
+ export const useBreakpoint = () => {
7
+ const [breakpoint, setBreakpoint] = useState(UnistylesRuntime.breakpoint)
8
+
9
+ useEffect(() => {
10
+ const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Breakpoints], () => setBreakpoint(UnistylesRuntime.breakpoint))
11
+
12
+ return () => {
13
+ removeChangeListener()
14
+ }
15
+ }, [])
16
+
17
+ return breakpoint
18
+ }
@@ -0,0 +1,21 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime } from '../specs'
3
+ import type { UnistylesStyleSheet } from '../specs'
4
+
5
+ export const useTheme = () => {
6
+ const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
7
+
8
+ useEffect(() => {
9
+ const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
10
+ if (dependencies.includes(UnistyleDependency.Theme)) {
11
+ setTheme(UnistylesRuntime.getTheme())
12
+ }
13
+ })
14
+
15
+ return () => {
16
+ removeChangeListener()
17
+ }
18
+ }, [])
19
+
20
+ return theme
21
+ }
@@ -0,0 +1,18 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { UnistylesRuntime } from '../web'
3
+ import { UnistylesListener } from '../web/listener'
4
+ import { UnistyleDependency } from '../specs/NativePlatform'
5
+
6
+ export const useTheme = () => {
7
+ const [theme, setTheme] = useState(UnistylesRuntime.getTheme())
8
+
9
+ useEffect(() => {
10
+ const removeChangeListener = UnistylesListener.addListeners([UnistyleDependency.Theme], () => setTheme(UnistylesRuntime.getTheme()))
11
+
12
+ return () => {
13
+ removeChangeListener()
14
+ }
15
+ }, [])
16
+
17
+ return theme
18
+ }
package/src/index.ts CHANGED
@@ -3,6 +3,9 @@ import React from 'react'
3
3
  export * from './specs'
4
4
  export { mq } from './mq'
5
5
  export type { UnistylesThemes, UnistylesBreakpoints } from './global'
6
+ export { useTheme, useBreakpoint } from './core'
7
+ export type { UnistylesVariants } from './types'
8
+
6
9
  // TODO: export Native createUnistylesComponent
7
10
  // can't import it this way, it will break native build
8
11
  // export { createUnistylesComponent } from './web/createUnistylesComponent'
@@ -31,7 +31,8 @@ export interface UnistylesNativeMiniRuntime {
31
31
  readonly rtl: boolean
32
32
  readonly statusBar: Dimensions,
33
33
  readonly navigationBar: Dimensions
34
- readonly orientation: Orientation
34
+ readonly isPortrait: boolean,
35
+ readonly isLandscape: boolean
35
36
  }
36
37
 
37
38
  // represents any native API that can communicate with Unistyles
@@ -3,6 +3,11 @@ import type { UnistylesNavigationBar as UnistylesNavigationBarSpec } from './Uni
3
3
  import type { Color } from '../types'
4
4
 
5
5
  interface PrivateUnistylesNavigationBar extends Omit<UnistylesNavigationBarSpec, 'setBackgroundColor'> {
6
+ /**
7
+ * Apps targeting Android SDK 35
8
+ * This API is deprecated but continues to affect 3-button navigation
9
+ * @deprecated
10
+ */
6
11
  setBackgroundColor(color?: string): void,
7
12
  _setBackgroundColor(color?: Color): void
8
13
  }
@@ -8,6 +8,11 @@ interface PrivateUnistylesStatusBar extends Omit<UnistylesStatusBarSpec, 'setBac
8
8
  setStyle(style: StatusBarStyle, animated?: boolean): void,
9
9
  setHidden(isHidden: boolean, animation?: StatusBarHiddenAnimation): void,
10
10
  _setHidden(isHidden: boolean, animation?: StatusBarHiddenAnimation): void,
11
+ /**
12
+ * Apps targeting Android SDK 35
13
+ * This API is deprecated as status bar background color is always transparent
14
+ * @deprecated
15
+ */
11
16
  setBackgroundColor(color?: string): void,
12
17
  _setBackgroundColor(color?: Color): void
13
18
  }
@@ -1,6 +1,9 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules'
2
+ import { UnistyleDependency } from '../NativePlatform'
2
3
 
3
4
  export interface UnistylesStyleSheet extends HybridObject<{ ios: 'c++', android: 'c++' }> {
4
5
  readonly hairlineWidth: number
5
6
  readonly unid: number
7
+
8
+ addChangeListener(onChanged: (dependencies: Array<UnistyleDependency>) => void): () => void
6
9
  }
@@ -41,6 +41,6 @@ HybridUnistylesStyleSheet.jsMethods = {
41
41
  processColor
42
42
  }
43
43
 
44
- type PrivateMethods = 'jsMethods'
44
+ type PrivateMethods = 'jsMethods' | 'addChangeListener'
45
45
 
46
46
  export const StyleSheet = HybridUnistylesStyleSheet as Omit<UnistylesStyleSheet, PrivateMethods>
@@ -10,7 +10,6 @@ type Orientation = 'portrait' | 'landscape'
10
10
  export interface UnistylesCxxMiniRuntime extends UnistylesNativeMiniRuntime {
11
11
  readonly themeName?: string,
12
12
  readonly breakpoint?: string,
13
- readonly orientation: Orientation,
14
13
  readonly hasAdaptiveThemes: boolean,
15
14
  }
16
15
 
@@ -4,8 +4,9 @@ import type { UnistylesRuntime as UnistylesRuntimeSpec, UnistylesMiniRuntime } f
4
4
  import type { AppBreakpoint, AppTheme, AppThemeName, Color, ColorScheme, Orientation } from '../types'
5
5
  import { attachStatusBarJSMethods, type UnistylesStatusBar } from '../StatusBar'
6
6
  import { attachNavigationBarJSMethods, type UnistylesNavigationBar } from '../NavigtionBar'
7
- import type { AndroidContentSizeCategory, IOSContentSizeCategory } from '../../types'
7
+ import type { AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesTheme } from '../../types'
8
8
  import { isIOS } from '../../common'
9
+ import type { UnistylesThemes } from '../../global'
9
10
 
10
11
  export interface UnistylesRuntimePrivate extends Omit<UnistylesRuntimeSpec, 'setRootViewBackgroundColor'> {
11
12
  readonly colorScheme: ColorScheme,
@@ -18,6 +19,7 @@ export interface UnistylesRuntimePrivate extends Omit<UnistylesRuntimeSpec, 'set
18
19
  statusBar: UnistylesStatusBar,
19
20
  navigationBar: UnistylesNavigationBar,
20
21
 
22
+ getTheme(themeName?: keyof UnistylesThemes): UnistylesTheme,
21
23
  setTheme(themeName: AppThemeName): void
22
24
  updateTheme(themeName: AppThemeName, updater: (currentTheme: AppTheme) => AppTheme): void,
23
25
  setRootViewBackgroundColor(color?: string): void,