@luckylca/react-native-liquid-glass 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +20 -33
  2. package/README.zh-CN.md +20 -33
  3. package/THIRD_PARTY_NOTICES.md +1 -1
  4. package/android/build.gradle +4 -4
  5. package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/EffectiveScrollInputBridge.kt +2 -2
  6. package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassProviderCoreView.kt → liquidglass/GlassCaptureView.kt} +39 -39
  7. package/android/src/main/java/expo/modules/{newhuliquidglass/CoreLiquidGlassRegistry.kt → liquidglass/GlassRegistry.kt} +7 -7
  8. package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassSurfaceCoreView.kt → liquidglass/GlassSurfaceView.kt} +17 -17
  9. package/android/src/main/java/expo/modules/liquidglass/LiquidGlassModule.kt +205 -0
  10. package/android/src/main/java/expo/modules/{localglass/ExpoLocalGlassEngineModule.kt → liquidglass/LocalMaterialView.kt} +24 -27
  11. package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/PassSurfaceSuppression.kt +1 -1
  12. package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassProbeLog.kt +1 -1
  13. package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassWiring.kt +3 -3
  14. package/android-core/build.gradle +1 -1
  15. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/BackdropRecorder.kt +4 -4
  16. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/FrozenBackdrop.kt +1 -1
  17. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropCoordinator.kt +5 -5
  18. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropSourceHandle.kt +1 -1
  19. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassScrollSource.kt +1 -1
  20. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassViewController.kt +119 -722
  21. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassProviderLayout.kt +2 -2
  22. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassView.kt +2 -2
  23. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/ReferenceSourceWindowPolicy.kt +1 -1
  24. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/StableSceneTexturePolicy.kt +1 -1
  25. package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceFrameBuilder.kt +278 -0
  26. package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceInteraction.kt +359 -0
  27. package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassFrame.kt +110 -0
  28. package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassViewRenderer.kt +728 -0
  29. package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/ReferenceParityPasses.kt +705 -0
  30. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/ReferenceTabSampling.kt +1 -1
  31. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/SharedSceneCapture.kt +1 -1
  32. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassCapabilities.kt +1 -1
  33. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassEngine.kt +7 -7
  34. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMaterial.kt +1 -1
  35. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMath.kt +1 -1
  36. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassOpticalInsets.kt +1 -1
  37. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassRenderTier.kt +1 -1
  38. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassShapePacker.kt +1 -1
  39. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassSurfaceState.kt +1 -1
  40. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassUniforms.kt +1 -1
  41. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/LiquidGlassShaders.kt +1 -1
  42. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/SharedGlassPass.kt +6 -6
  43. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/G2RoundedRectangle.kt +2 -2
  44. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/ReferenceG2MaskTexture.kt +1 -1
  45. package/android-core/src/main/java/io/github/luckylca/liquidglass/core/shader/HeightFieldGlassShader.kt +7 -0
  46. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceBackdropBlurShader.kt +1 -1
  47. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGaussianDiscBackdropBlur.kt +1 -1
  48. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGlassUniforms.kt +4 -4
  49. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityGlassShader.kt +1 -1
  50. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityMultiShapeShader.kt +1 -1
  51. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/SdfScaleLensShader.kt +1 -1
  52. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassHardwareLayerExperiment.kt +1 -1
  53. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassMaterial.kt +1 -1
  54. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRenderer.kt +2 -2
  55. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRuntimeShader.kt +2 -2
  56. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassShader.kt +1 -1
  57. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassView.kt +2 -2
  58. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionDriver.kt +1 -1
  59. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionState.kt +1 -1
  60. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/PointerVelocityTracker.kt +1 -1
  61. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/SpringSpec.kt +1 -1
  62. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/G2Corner.kt +1 -1
  63. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassMaterial.kt +3 -3
  64. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassOpticsShader.kt +3 -3
  65. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassParityProbe.kt +1 -1
  66. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassShapeGeometry.kt +1 -1
  67. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassUniformBinder.kt +2 -2
  68. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/PixelDiff.kt +1 -1
  69. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/ReferenceOptics.kt +1 -1
  70. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceHost.kt +17 -17
  71. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceRenderer.kt +9 -9
  72. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/RetainedBackdropLayer.kt +1 -1
  73. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/scheduler/GlassFrameScheduler.kt +2 -2
  74. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/EffectiveScrollFpsProbe.kt +13 -13
  75. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/GlassTelemetry.kt +1 -1
  76. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassPerfTelemetry.kt +13 -13
  77. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassTrace.kt +3 -3
  78. package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LocalGlassTelemetry.kt +1 -1
  79. package/docs/architecture.md +61 -0
  80. package/docs/migration-0.3.md +19 -0
  81. package/docs/publishing.md +29 -7
  82. package/expo-module.config.json +4 -4
  83. package/lib/commonjs/GlassSurface.js +157 -585
  84. package/lib/commonjs/GlassSurface.js.map +1 -1
  85. package/lib/commonjs/GlassTabBar.js +18 -957
  86. package/lib/commonjs/GlassTabBar.js.map +1 -1
  87. package/lib/commonjs/LocalGlassMaterial.js +3 -9
  88. package/lib/commonjs/LocalGlassMaterial.js.map +1 -1
  89. package/lib/commonjs/glassController.js +3 -7
  90. package/lib/commonjs/glassController.js.map +1 -1
  91. package/lib/commonjs/glassRuntime.js +7 -19
  92. package/lib/commonjs/glassRuntime.js.map +1 -1
  93. package/lib/commonjs/localGlassTelemetry.js +4 -13
  94. package/lib/commonjs/localGlassTelemetry.js.map +1 -1
  95. package/lib/commonjs/nativeGlassViews.js +8 -11
  96. package/lib/commonjs/nativeGlassViews.js.map +1 -1
  97. package/lib/commonjs/performanceTelemetry.js +2 -6
  98. package/lib/commonjs/performanceTelemetry.js.map +1 -1
  99. package/lib/commonjs/surface/InlineSurface.js +134 -0
  100. package/lib/commonjs/surface/InlineSurface.js.map +1 -0
  101. package/lib/commonjs/surface/MaterialProvider.js +78 -0
  102. package/lib/commonjs/surface/MaterialProvider.js.map +1 -0
  103. package/lib/commonjs/surface/NativeSurface.js +55 -0
  104. package/lib/commonjs/surface/NativeSurface.js.map +1 -0
  105. package/lib/commonjs/surface/PortalLayers.js +331 -0
  106. package/lib/commonjs/surface/PortalLayers.js.map +1 -0
  107. package/lib/commonjs/surface/contexts.js +108 -0
  108. package/lib/commonjs/surface/contexts.js.map +1 -0
  109. package/lib/commonjs/surface/registry.js +113 -0
  110. package/lib/commonjs/surface/registry.js.map +1 -0
  111. package/lib/commonjs/surface/styles.js +34 -0
  112. package/lib/commonjs/surface/styles.js.map +1 -0
  113. package/lib/commonjs/surface/types.js +3 -0
  114. package/lib/commonjs/surface/types.js.map +1 -0
  115. package/lib/commonjs/tabs/GlassTabItem.js +66 -0
  116. package/lib/commonjs/tabs/GlassTabItem.js.map +1 -0
  117. package/lib/commonjs/tabs/InlineTabBar.js +867 -0
  118. package/lib/commonjs/tabs/InlineTabBar.js.map +1 -0
  119. package/lib/commonjs/tabs/tabConstants.js +22 -0
  120. package/lib/commonjs/tabs/tabConstants.js.map +1 -0
  121. package/lib/commonjs/tabs/tabDebug.js +50 -0
  122. package/lib/commonjs/tabs/tabDebug.js.map +1 -0
  123. package/lib/commonjs/tabs/tabStyles.js +107 -0
  124. package/lib/commonjs/tabs/tabStyles.js.map +1 -0
  125. package/lib/commonjs/tabs/useInlineTabGesture.js +227 -0
  126. package/lib/commonjs/tabs/useInlineTabGesture.js.map +1 -0
  127. package/lib/commonjs/theme/buildTheme.js +1 -1
  128. package/lib/commonjs/theme/buildTheme.js.map +1 -1
  129. package/lib/module/GlassSurface.js +135 -563
  130. package/lib/module/GlassSurface.js.map +1 -1
  131. package/lib/module/GlassTabBar.js +18 -925
  132. package/lib/module/GlassTabBar.js.map +1 -1
  133. package/lib/module/LocalGlassMaterial.js +5 -11
  134. package/lib/module/LocalGlassMaterial.js.map +1 -1
  135. package/lib/module/glassController.js +3 -7
  136. package/lib/module/glassController.js.map +1 -1
  137. package/lib/module/glassRuntime.js +7 -19
  138. package/lib/module/glassRuntime.js.map +1 -1
  139. package/lib/module/localGlassTelemetry.js +4 -13
  140. package/lib/module/localGlassTelemetry.js.map +1 -1
  141. package/lib/module/nativeGlassViews.js +7 -10
  142. package/lib/module/nativeGlassViews.js.map +1 -1
  143. package/lib/module/performanceTelemetry.js +2 -6
  144. package/lib/module/performanceTelemetry.js.map +1 -1
  145. package/lib/module/surface/InlineSurface.js +97 -0
  146. package/lib/module/surface/InlineSurface.js.map +1 -0
  147. package/lib/module/surface/MaterialProvider.js +74 -0
  148. package/lib/module/surface/MaterialProvider.js.map +1 -0
  149. package/lib/module/surface/NativeSurface.js +47 -0
  150. package/lib/module/surface/NativeSurface.js.map +1 -0
  151. package/lib/module/surface/PortalLayers.js +292 -0
  152. package/lib/module/surface/PortalLayers.js.map +1 -0
  153. package/lib/module/surface/contexts.js +96 -0
  154. package/lib/module/surface/contexts.js.map +1 -0
  155. package/lib/module/surface/registry.js +103 -0
  156. package/lib/module/surface/registry.js.map +1 -0
  157. package/lib/module/surface/styles.js +31 -0
  158. package/lib/module/surface/styles.js.map +1 -0
  159. package/lib/module/surface/types.js +2 -0
  160. package/lib/module/surface/types.js.map +1 -0
  161. package/lib/module/tabs/GlassTabItem.js +30 -0
  162. package/lib/module/tabs/GlassTabItem.js.map +1 -0
  163. package/lib/module/tabs/InlineTabBar.js +829 -0
  164. package/lib/module/tabs/InlineTabBar.js.map +1 -0
  165. package/lib/module/tabs/tabConstants.js +19 -0
  166. package/lib/module/tabs/tabConstants.js.map +1 -0
  167. package/lib/module/tabs/tabDebug.js +13 -0
  168. package/lib/module/tabs/tabDebug.js.map +1 -0
  169. package/lib/module/tabs/tabStyles.js +104 -0
  170. package/lib/module/tabs/tabStyles.js.map +1 -0
  171. package/lib/module/tabs/useInlineTabGesture.js +221 -0
  172. package/lib/module/tabs/useInlineTabGesture.js.map +1 -0
  173. package/lib/module/theme/buildTheme.js +1 -1
  174. package/lib/module/theme/buildTheme.js.map +1 -1
  175. package/lib/types/GlassSurface.d.ts +17 -86
  176. package/lib/types/GlassTabBar.d.ts +1 -0
  177. package/lib/types/glassNativeEngine.d.ts +1 -1
  178. package/lib/types/glassRuntime.d.ts +5 -2
  179. package/lib/types/localGlassTelemetry.d.ts +2 -2
  180. package/lib/types/nativeGlassViews.d.ts +2 -4
  181. package/lib/types/surface/InlineSurface.d.ts +42 -0
  182. package/lib/types/surface/MaterialProvider.d.ts +46 -0
  183. package/lib/types/surface/NativeSurface.d.ts +11 -0
  184. package/lib/types/surface/PortalLayers.d.ts +33 -0
  185. package/lib/types/surface/contexts.d.ts +66 -0
  186. package/lib/types/surface/registry.d.ts +6 -0
  187. package/lib/types/surface/styles.d.ts +74 -0
  188. package/lib/types/surface/types.d.ts +118 -0
  189. package/lib/types/tabs/GlassTabItem.d.ts +20 -0
  190. package/lib/types/tabs/InlineTabBar.d.ts +5 -0
  191. package/lib/types/tabs/tabConstants.d.ts +34 -0
  192. package/lib/types/tabs/tabDebug.d.ts +15 -0
  193. package/lib/types/tabs/tabStyles.d.ts +119 -0
  194. package/lib/types/tabs/useInlineTabGesture.d.ts +34 -0
  195. package/package.json +6 -14
  196. package/src/GlassSurface.tsx +227 -1337
  197. package/src/GlassTabBar.tsx +43 -1241
  198. package/src/LocalGlassMaterial.tsx +5 -11
  199. package/src/glassController.ts +3 -7
  200. package/src/glassRuntime.ts +9 -26
  201. package/src/localGlassTelemetry.ts +6 -15
  202. package/src/nativeGlassViews.ts +7 -10
  203. package/src/performanceTelemetry.ts +2 -6
  204. package/src/surface/InlineSurface.tsx +299 -0
  205. package/src/surface/MaterialProvider.tsx +235 -0
  206. package/src/surface/NativeSurface.tsx +115 -0
  207. package/src/surface/PortalLayers.tsx +574 -0
  208. package/src/surface/contexts.tsx +188 -0
  209. package/src/surface/registry.ts +109 -0
  210. package/src/surface/styles.ts +31 -0
  211. package/src/surface/types.ts +139 -0
  212. package/src/tabs/GlassTabItem.tsx +100 -0
  213. package/src/tabs/InlineTabBar.tsx +1193 -0
  214. package/src/tabs/tabConstants.ts +35 -0
  215. package/src/tabs/tabDebug.ts +29 -0
  216. package/src/tabs/tabStyles.ts +104 -0
  217. package/src/tabs/useInlineTabGesture.ts +306 -0
  218. package/src/theme/buildTheme.ts +1 -1
  219. package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassModule.kt +0 -341
  220. package/android/src/main/java/expo/modules/localglass/LocalGlassShader.kt +0 -59
  221. package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassCoreModule.kt +0 -226
  222. package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/GlassViewRenderer.kt +0 -1459
  223. package/android-core/src/main/java/com/newhu/liquidglass/core/shader/HeightFieldGlassShader.kt +0 -7
  224. package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassEngineSelection.kt +0 -30
  225. package/patches/liquid-glass-kit+1.0.0.patch +0 -2015
  226. package/patches/liquid-glass-kit-invalidation-coalescing.diff +0 -249
  227. package/patches/liquid-glass-kit-native-infra.diff +0 -624
  228. package/scripts/apply-legacy-patches.mjs +0 -116
@@ -0,0 +1,574 @@
1
+ import React, { useContext, useMemo } from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import Animated, { useAnimatedProps, useAnimatedStyle } from 'react-native-reanimated';
4
+ import type { SharedValue } from 'react-native-reanimated';
5
+ import type { GlassTokens } from '../types';
6
+ import { GlassRuntimeContext } from './contexts';
7
+ import type { SurfaceEntry, OverlayEntry, EntryRegistry } from './types';
8
+ import { useRegistrySnapshot, selectBalancedShaderSurfaces } from './registry';
9
+ import { NativeBackdropSurface } from './NativeSurface';
10
+ import { styles } from './styles';
11
+
12
+ export function GlassSurfacePortalLayer({
13
+ registry,
14
+ tokens,
15
+ }: {
16
+ registry: EntryRegistry<SurfaceEntry>;
17
+ tokens: GlassTokens;
18
+ }) {
19
+ const entries = useRegistrySnapshot(registry);
20
+ const balancedShaderSurfaces = useMemo(() => selectBalancedShaderSurfaces(entries), [entries]);
21
+ const groups = useMemo(() => {
22
+ const list: {
23
+ key: string;
24
+ zIndex: number;
25
+ offsets: readonly SharedValue<number>[];
26
+ routeTransitionX?: SharedValue<number> | null;
27
+ items: [string, SurfaceEntry][];
28
+ }[] = [];
29
+ const byKey = new Map<string, (typeof list)[number]>();
30
+ for (let i = 0; i < entries.length; i += 1) {
31
+ const pair = entries[i];
32
+ const entry = pair[1];
33
+ const routeId = getSharedValueId(entry.routeTransitionX);
34
+ const key = `${entry.zIndex}::${entry.scrollGroupKey}::${routeId}`;
35
+ let group = byKey.get(key);
36
+ if (!group) {
37
+ group = {
38
+ key,
39
+ zIndex: entry.zIndex,
40
+ offsets: entry.scrollOffsets,
41
+ routeTransitionX: entry.routeTransitionX,
42
+ items: [],
43
+ };
44
+ byKey.set(key, group);
45
+ list.push(group);
46
+ }
47
+ group.items.push(pair);
48
+ }
49
+ return list;
50
+ }, [entries]);
51
+ if (!tokens.enabled) return null;
52
+ return (
53
+ <View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
54
+ {/* The layer itself must not claim the screen, but its portaled
55
+ above-glass content and explicitly interactive native surfaces
56
+ still need to receive touches. Grouping by scroll scope drives
57
+ every scrolled card in lockstep via one Reanimated worklet instead
58
+ of N per-item worklets on every frame. */}
59
+ {groups.map((group) => {
60
+ const content = group.items.map(([id, entry]) => (
61
+ <PortalGlassSurface
62
+ key={id}
63
+ providerId={entry.samplingProviderId}
64
+ entry={entry}
65
+ drawOrder={0}
66
+ shaderEnabled={
67
+ tokens.quality === 'high' ||
68
+ (tokens.quality === 'balanced' && balancedShaderSurfaces.has(id))
69
+ }
70
+ />
71
+ ));
72
+ if (group.offsets.length === 0 && !group.routeTransitionX) {
73
+ return (
74
+ <View
75
+ key={group.key}
76
+ pointerEvents="box-none"
77
+ style={[StyleSheet.absoluteFill, { zIndex: group.zIndex }]}
78
+ >
79
+ {content}
80
+ </View>
81
+ );
82
+ }
83
+ return (
84
+ <PortalScrollGroupContainer
85
+ key={group.key}
86
+ offsets={group.offsets}
87
+ routeTransitionX={group.routeTransitionX}
88
+ zIndex={group.zIndex}
89
+ >
90
+ {content}
91
+ </PortalScrollGroupContainer>
92
+ );
93
+ })}
94
+ </View>
95
+ );
96
+ }
97
+
98
+ export const sharedValueGroupIds = new WeakMap<object, number>();
99
+
100
+ export let nextSharedValueGroupId = 1;
101
+
102
+ export function getSharedValueId(value: SharedValue<number> | null | undefined): number {
103
+ if (!value) return 0;
104
+ let id = sharedValueGroupIds.get(value);
105
+ if (id == null) {
106
+ id = nextSharedValueGroupId++;
107
+ sharedValueGroupIds.set(value, id);
108
+ }
109
+ return id;
110
+ }
111
+
112
+ export const PortalScrollGroupContainer = React.memo(function PortalScrollGroupContainer({
113
+ offsets,
114
+ routeTransitionX,
115
+ zIndex,
116
+ children,
117
+ }: {
118
+ offsets: readonly SharedValue<number>[];
119
+ routeTransitionX?: SharedValue<number> | null;
120
+ zIndex: number;
121
+ children: React.ReactNode;
122
+ }) {
123
+ const groupTransformStyle = useAnimatedStyle(() => {
124
+ let scrollY = 0;
125
+ for (let index = 0; index < offsets.length; index += 1) {
126
+ scrollY += offsets[index].value;
127
+ }
128
+ return {
129
+ transform: [{ translateX: routeTransitionX?.value ?? 0 }, { translateY: -scrollY }],
130
+ };
131
+ }, [offsets, routeTransitionX]);
132
+
133
+ return (
134
+ <Animated.View
135
+ pointerEvents="box-none"
136
+ style={[StyleSheet.absoluteFill, groupTransformStyle, { zIndex }]}
137
+ >
138
+ {children}
139
+ </Animated.View>
140
+ );
141
+ });
142
+
143
+ export function GlassRouteOverlayLayer({
144
+ registry,
145
+ enabled,
146
+ }: {
147
+ registry: EntryRegistry<OverlayEntry>;
148
+ enabled: boolean;
149
+ }) {
150
+ const entries = useRegistrySnapshot(registry);
151
+ if (!enabled) return null;
152
+ return (
153
+ <View pointerEvents="box-none" style={StyleSheet.absoluteFill}>
154
+ {entries.map(([id, entry]) => (
155
+ <RouteOverlayView key={id} entry={entry} />
156
+ ))}
157
+ </View>
158
+ );
159
+ }
160
+
161
+ export const RouteOverlayView = React.memo(function RouteOverlayView({ entry }: { entry: OverlayEntry }) {
162
+ const offsets = entry.scrollOffsets;
163
+ const routeTransitionX = entry.routeTransitionX;
164
+ const scrollTransformStyle = useAnimatedStyle(() => {
165
+ let scrollY = 0;
166
+ if (offsets) {
167
+ for (let index = 0; index < offsets.length; index += 1) {
168
+ scrollY += offsets[index].value;
169
+ }
170
+ }
171
+ return {
172
+ transform: [{ translateX: routeTransitionX?.value ?? 0 }, { translateY: -scrollY }],
173
+ };
174
+ }, [offsets, routeTransitionX]);
175
+ const hasScrollOrRoute = (offsets != null && offsets.length > 0) || routeTransitionX != null;
176
+ return (
177
+ <Animated.View
178
+ pointerEvents="box-none"
179
+ style={[StyleSheet.absoluteFill, entry.style, { zIndex: entry.zIndex }]}
180
+ >
181
+ {entry.frame ? (
182
+ <Animated.View
183
+ pointerEvents="box-none"
184
+ style={[
185
+ {
186
+ position: 'absolute',
187
+ left: entry.frame.x,
188
+ top: entry.frame.y,
189
+ width: entry.frame.width,
190
+ height: entry.frame.height,
191
+ },
192
+ hasScrollOrRoute ? scrollTransformStyle : undefined,
193
+ entry.portalOffsetStyle,
194
+ ]}
195
+ >
196
+ {entry.children}
197
+ </Animated.View>
198
+ ) : (
199
+ entry.children
200
+ )}
201
+ </Animated.View>
202
+ );
203
+ });
204
+
205
+ export const PortalGlassSurface = React.memo(function PortalGlassSurface({
206
+ providerId,
207
+ entry,
208
+ drawOrder,
209
+ shaderEnabled,
210
+ }: {
211
+ providerId: string;
212
+ entry: SurfaceEntry;
213
+ drawOrder: number;
214
+ shaderEnabled: boolean;
215
+ }) {
216
+ const runtime = useContext(GlassRuntimeContext);
217
+ const opticalProgress = entry.opticalProgress;
218
+ const pointerEvent = entry.pointerEvent;
219
+ const pointerEventValue = entry.pointerEventValue;
220
+ const pointerEventSink = entry.pointerEventSink;
221
+ const valueEvent = entry.valueEvent;
222
+ const valueEventSink = entry.valueEventSink;
223
+ const opticalToggleFraction = entry.opticalToggleFraction;
224
+ const opticalProgressValue = entry.opticalProgressValue;
225
+ const opticalPointX = entry.opticalPointX;
226
+ const opticalPointY = entry.opticalPointY;
227
+ const opticalVelocityX = entry.opticalVelocityX;
228
+ const opticalVelocityY = entry.opticalVelocityY;
229
+ const opticalMotionX = entry.opticalMotionX;
230
+ const opticalMotionY = entry.opticalMotionY;
231
+ const hasAnimatedOptics = Boolean(
232
+ opticalPointX ||
233
+ opticalPointY ||
234
+ opticalVelocityX ||
235
+ opticalVelocityY ||
236
+ opticalProgressValue != null ||
237
+ opticalProgress ||
238
+ opticalToggleFraction ||
239
+ opticalMotionX ||
240
+ opticalMotionY,
241
+ );
242
+ const animatedOptics = useAnimatedProps(
243
+ () => ({
244
+ interactionVelocityX: opticalVelocityX?.value,
245
+ interactionVelocityY: opticalVelocityY?.value,
246
+ interactionPointX: opticalPointX?.value,
247
+ interactionPointY: opticalPointY?.value,
248
+ interactionProgress: opticalProgressValue ?? opticalProgress?.value ?? 0,
249
+ toggleFraction: opticalToggleFraction?.value ?? 0,
250
+ motionX: opticalMotionX ? Math.max(-1, Math.min(1, opticalMotionX.value / 1800)) : undefined,
251
+ motionY: opticalMotionY ? Math.max(-1, Math.min(1, opticalMotionY.value / 1800)) : undefined,
252
+ }),
253
+ [
254
+ opticalPointX,
255
+ opticalPointY,
256
+ opticalVelocityX,
257
+ opticalVelocityY,
258
+ opticalProgress,
259
+ pointerEventValue,
260
+ valueEvent,
261
+ opticalToggleFraction,
262
+ opticalProgressValue,
263
+ opticalMotionX,
264
+ opticalMotionY,
265
+ ],
266
+ );
267
+ if (!runtime) return null;
268
+ const { tokens, dark, reducedMotion } = runtime;
269
+ // Backdrop glass is drawn in a sibling overlay, above the actual control.
270
+ // Some native render backends still participate in Android hit testing even
271
+ // with pointerEvents="none" on the native view itself, so make the whole
272
+ // portal subtree untargetable for passive lenses. Keep box-none where its
273
+ // React content or an explicitly interactive surface needs to receive input.
274
+ const portalPointerEvents =
275
+ entry.interactive || entry.portalContent || entry.contentAboveGlass ? 'box-none' : 'none';
276
+ const material = entry.materialOverrides
277
+ ? { ...tokens.materials[entry.variant], ...entry.materialOverrides }
278
+ : tokens.materials[entry.variant];
279
+ const qualityScale =
280
+ material.opticsModel === 'referenceParity'
281
+ ? 1
282
+ : tokens.quality === 'high'
283
+ ? 1.2
284
+ : tokens.quality === 'fallback'
285
+ ? 0.45
286
+ : 1;
287
+
288
+ if (!shaderEnabled) return <PortalFallbackSurface entry={entry} />;
289
+
290
+ const nativeSurface = (
291
+ <NativeBackdropSurface
292
+ providerId={providerId}
293
+ sharedPassZIndex={entry.zIndex}
294
+ sharedPassOrder={drawOrder}
295
+ opticsModel={material.opticsModel}
296
+ shapeMaskText={entry.shapeMaskText}
297
+ shapeMaskFontSize={entry.shapeMaskFontSize}
298
+ shapeMaskFontWeight={entry.shapeMaskFontWeight}
299
+ progressiveBlurIntensity={entry.progressiveBlurIntensity}
300
+ depthEffect={material.referenceDepthEffect ?? false}
301
+ highlightStyle={material.referenceHighlightStyle}
302
+ interactionProfile={material.referenceInteractionProfile}
303
+ contentScaleX={material.referenceContentScaleX}
304
+ contentScaleY={material.referenceContentScaleY}
305
+ sampleOffsetX={material.referenceSampleOffsetX}
306
+ sampleOffsetY={material.referenceSampleOffsetY}
307
+ toggleTrackColorOff={material.referenceToggleTrackColorOff}
308
+ toggleTrackColorOn={material.referenceToggleTrackColorOn}
309
+ toggleTrackWidth={material.referenceToggleTrackWidth}
310
+ toggleTrackHeight={material.referenceToggleTrackHeight}
311
+ toggleSolidBackdropColor={material.referenceToggleSolidBackdropColor}
312
+ brightness={material.brightness ?? 0}
313
+ contrast={material.contrast ?? 1}
314
+ highlightFalloff={material.highlightFalloff ?? 1}
315
+ sdfContrast={material.sdfScaleLens?.contrast}
316
+ sdfBrightness={material.sdfScaleLens?.brightness}
317
+ sdfSaturation={material.sdfScaleLens?.saturation}
318
+ sdfOuterShadowAlpha={material.sdfScaleLens?.outerShadowAlpha}
319
+ sdfOuterShadowBlurRadius={material.sdfScaleLens?.outerShadowBlurRadius}
320
+ sdfOuterShadowOffsetY={material.sdfScaleLens?.outerShadowOffsetY}
321
+ sdfInnerShadowAlpha={material.sdfScaleLens?.innerShadowAlpha}
322
+ sdfInnerShadowExtent={material.sdfScaleLens?.innerShadowExtent}
323
+ cornerRadius={material.radius}
324
+ blurRadius={material.blurRadius * qualityScale}
325
+ refractionHeight={material.refractionHeight * qualityScale}
326
+ refractionAmount={material.refractionAmount * qualityScale}
327
+ bodyRefractionAmount={(material.refractionBodyAmount ?? 2.5) * qualityScale}
328
+ interactionProgress={opticalProgressValue ?? 0}
329
+ // The pointer stream must be a real prop, not only an animated one:
330
+ // Reanimated's animatedProps path does not reach an Expo Modules view's
331
+ // prop setter, so a gesture sent only there is silently dropped and the
332
+ // native driver never sees a single event.
333
+ pointerEvent={entry.pointerEventValue}
334
+ pointerEventSink={pointerEventSink}
335
+ valueEvent={entry.valueEvent}
336
+ valueEventSink={valueEventSink}
337
+ saturation={material.saturation}
338
+ chromaticAberration={
339
+ material.opticsModel === 'referenceParity' ||
340
+ tokens.quality === 'high' ||
341
+ entry.variant === 'tabSelectionLens'
342
+ ? material.chromaticAberration
343
+ : 0
344
+ }
345
+ highlightAlpha={material.highlightAlpha}
346
+ highlightWidth={material.highlightWidth}
347
+ lightAngle={material.highlightAngle ?? 45}
348
+ highlightColor={
349
+ material.highlightColor
350
+ ? dark
351
+ ? material.highlightColor.dark
352
+ : material.highlightColor.light
353
+ : undefined
354
+ }
355
+ tintAlpha={material.tintAlpha ?? 1}
356
+ specularStrength={material.specularStrength ?? 1}
357
+ fresnelStrength={material.fresnelStrength ?? 0.85}
358
+ innerShadowStrength={
359
+ material.innerShadowStrength ?? (material.opticsModel === 'referenceParity' ? 0 : 0.18)
360
+ }
361
+ shadowOpacity={material.shadowOpacity ?? (material.opticsModel === 'referenceParity' ? 0 : 0.1)}
362
+ shadowRadius={material.shadowRadius ?? (material.opticsModel === 'referenceParity' ? 0 : 24)}
363
+ shadowOffsetY={material.shadowOffsetY ?? (material.opticsModel === 'referenceParity' ? 0 : 4)}
364
+ tint={entry.tintColor ?? (dark ? tokens.tint.dark : tokens.tint.light)}
365
+ surfaceColor={
366
+ material.surfaceColor
367
+ ? dark
368
+ ? material.surfaceColor.dark
369
+ : material.surfaceColor.light
370
+ : undefined
371
+ }
372
+ interactive={entry.interactive && tokens.interaction.enabled && !reducedMotion}
373
+ pointerEvents={
374
+ entry.interactive && tokens.interaction.enabled && !reducedMotion ? 'auto' : 'none'
375
+ }
376
+ continuous={entry.continuous}
377
+ sharedSource={entry.sharedSource}
378
+ captureProbe={entry.captureProbe}
379
+ motionX={undefined}
380
+ motionY={undefined}
381
+ displacementOnlyDebug={entry.displacementOnlyDebug}
382
+ syncContentTransform={entry.syncContentTransform}
383
+ animatedProps={hasAnimatedOptics ? animatedOptics : undefined}
384
+ style={[
385
+ styles.nativeSurface,
386
+ entry.placement === 'layout'
387
+ ? StyleSheet.absoluteFill
388
+ : { width: entry.frame.width > 0 ? entry.frame.width : undefined },
389
+ { borderRadius: material.radius },
390
+ ]}
391
+ />
392
+ );
393
+
394
+ if (entry.placement === 'bottom' || entry.placement === 'center') {
395
+ const hasMotion = entry.animatedStyle != null || entry.portalOffsetStyle != null;
396
+ if (!hasMotion) {
397
+ return (
398
+ <View
399
+ pointerEvents={portalPointerEvents}
400
+ style={[
401
+ StyleSheet.absoluteFill,
402
+ entry.placement === 'center' ? styles.centerPlacement : styles.bottomPlacement,
403
+ entry.placement === 'bottom' && entry.bottomInset != null
404
+ ? { paddingBottom: entry.bottomInset }
405
+ : undefined,
406
+ ]}
407
+ >
408
+ {nativeSurface}
409
+ </View>
410
+ );
411
+ }
412
+ return (
413
+ <Animated.View
414
+ pointerEvents={portalPointerEvents}
415
+ style={[
416
+ StyleSheet.absoluteFill,
417
+ entry.placement === 'center' ? styles.centerPlacement : styles.bottomPlacement,
418
+ entry.placement === 'bottom' && entry.bottomInset != null
419
+ ? { paddingBottom: entry.bottomInset }
420
+ : undefined,
421
+ entry.animatedStyle,
422
+ entry.portalOffsetStyle,
423
+ ]}
424
+ >
425
+ {nativeSurface}
426
+ </Animated.View>
427
+ );
428
+ }
429
+
430
+ const portalContent =
431
+ entry.portalContent && entry.placement === 'layout' ? (
432
+ <View
433
+ pointerEvents="box-none"
434
+ accessible={false}
435
+ accessibilityElementsHidden
436
+ importantForAccessibility="no-hide-descendants"
437
+ style={[
438
+ StyleSheet.absoluteFill,
439
+ styles.portalContentOverlay,
440
+ { borderRadius: material.radius },
441
+ ]}
442
+ >
443
+ {entry.portalContent}
444
+ </View>
445
+ ) : null;
446
+
447
+ const innerContent = (
448
+ <>
449
+ {nativeSurface}
450
+ {entry.contentAboveGlass && entry.content ? (
451
+ <View
452
+ pointerEvents="box-none"
453
+ style={[
454
+ StyleSheet.absoluteFill,
455
+ { borderRadius: material.radius },
456
+ styles.contentAboveGlass,
457
+ ]}
458
+ >
459
+ <View style={entry.contentStyle}>{entry.content}</View>
460
+ </View>
461
+ ) : null}
462
+ {portalContent}
463
+ </>
464
+ );
465
+
466
+ const hasMotion =
467
+ (entry.positioning === 'floating' && entry.animatedStyle != null) || entry.portalOffsetStyle != null;
468
+ if (!hasMotion) {
469
+ return (
470
+ <View
471
+ pointerEvents={portalPointerEvents}
472
+ collapsable={!entry.syncContentTransform}
473
+ style={[
474
+ styles.portalSurface,
475
+ {
476
+ left: entry.frame.x,
477
+ top: entry.frame.y,
478
+ width: entry.frame.width,
479
+ height: entry.frame.height,
480
+ },
481
+ ]}
482
+ >
483
+ {innerContent}
484
+ </View>
485
+ );
486
+ }
487
+
488
+ return (
489
+ <Animated.View
490
+ pointerEvents={portalPointerEvents}
491
+ collapsable={!entry.syncContentTransform}
492
+ style={[
493
+ styles.portalSurface,
494
+ {
495
+ left: entry.frame.x,
496
+ top: entry.frame.y,
497
+ width: entry.frame.width,
498
+ height: entry.frame.height,
499
+ },
500
+ entry.positioning === 'floating' ? entry.animatedStyle : undefined,
501
+ entry.portalOffsetStyle,
502
+ ]}
503
+ >
504
+ {innerContent}
505
+ </Animated.View>
506
+ );
507
+ });
508
+
509
+ export const PortalFallbackSurface = React.memo(function PortalFallbackSurface({
510
+ entry,
511
+ }: {
512
+ entry: SurfaceEntry;
513
+ }) {
514
+ const runtime = useContext(GlassRuntimeContext);
515
+ if (!runtime) return null;
516
+ const { tokens, dark } = runtime;
517
+ const portalPointerEvents =
518
+ entry.interactive || entry.portalContent || entry.contentAboveGlass ? 'box-none' : 'none';
519
+ const material = tokens.materials[entry.variant];
520
+ const fallbackSurface = (
521
+ <View
522
+ pointerEvents="none"
523
+ style={[
524
+ styles.fallbackSurface,
525
+ entry.placement === 'layout'
526
+ ? StyleSheet.absoluteFill
527
+ : { width: entry.frame.width > 0 ? entry.frame.width : undefined },
528
+ {
529
+ backgroundColor: dark ? tokens.fallbackTint.dark : tokens.fallbackTint.light,
530
+ borderColor: dark ? tokens.fallbackBorder.dark : tokens.fallbackBorder.light,
531
+ borderRadius: material.radius,
532
+ },
533
+ ]}
534
+ ></View>
535
+ );
536
+
537
+ if (entry.placement === 'bottom' || entry.placement === 'center') {
538
+ return (
539
+ <Animated.View
540
+ pointerEvents={portalPointerEvents}
541
+ style={[
542
+ StyleSheet.absoluteFill,
543
+ entry.placement === 'center' ? styles.centerPlacement : styles.bottomPlacement,
544
+ entry.placement === 'bottom' && entry.bottomInset != null
545
+ ? { paddingBottom: entry.bottomInset }
546
+ : undefined,
547
+ entry.animatedStyle,
548
+ entry.portalOffsetStyle,
549
+ ]}
550
+ >
551
+ {fallbackSurface}
552
+ </Animated.View>
553
+ );
554
+ }
555
+
556
+ return (
557
+ <Animated.View
558
+ pointerEvents={portalPointerEvents}
559
+ style={[
560
+ styles.portalSurface,
561
+ {
562
+ left: entry.frame.x,
563
+ top: entry.frame.y,
564
+ width: entry.frame.width,
565
+ height: entry.frame.height,
566
+ },
567
+ entry.animatedStyle,
568
+ entry.portalOffsetStyle,
569
+ ]}
570
+ >
571
+ {fallbackSurface}
572
+ </Animated.View>
573
+ );
574
+ });