@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.
- package/README.md +20 -33
- package/README.zh-CN.md +20 -33
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/android/build.gradle +4 -4
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/EffectiveScrollInputBridge.kt +2 -2
- package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassProviderCoreView.kt → liquidglass/GlassCaptureView.kt} +39 -39
- package/android/src/main/java/expo/modules/{newhuliquidglass/CoreLiquidGlassRegistry.kt → liquidglass/GlassRegistry.kt} +7 -7
- package/android/src/main/java/expo/modules/{newhuliquidglass/ExpoGlassSurfaceCoreView.kt → liquidglass/GlassSurfaceView.kt} +17 -17
- package/android/src/main/java/expo/modules/liquidglass/LiquidGlassModule.kt +205 -0
- package/android/src/main/java/expo/modules/{localglass/ExpoLocalGlassEngineModule.kt → liquidglass/LocalMaterialView.kt} +24 -27
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/PassSurfaceSuppression.kt +1 -1
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassProbeLog.kt +1 -1
- package/android/src/main/java/expo/modules/{newhuliquidglass → liquidglass}/SharedGlassPassWiring.kt +3 -3
- package/android-core/build.gradle +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/BackdropRecorder.kt +4 -4
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/FrozenBackdrop.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropCoordinator.kt +5 -5
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassBackdropSourceHandle.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassScrollSource.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/GlassViewController.kt +119 -722
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassProviderLayout.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/LiquidGlassView.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/ReferenceSourceWindowPolicy.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/StableSceneTexturePolicy.kt +1 -1
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceFrameBuilder.kt +278 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/SurfaceInteraction.kt +359 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassFrame.kt +110 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/GlassViewRenderer.kt +728 -0
- package/android-core/src/main/java/io/github/luckylca/liquidglass/backdrop/internal/ReferenceParityPasses.kt +705 -0
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/ReferenceTabSampling.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/backdrop/internal/SharedSceneCapture.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassCapabilities.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassEngine.kt +7 -7
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMaterial.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassMath.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassOpticalInsets.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassRenderTier.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassShapePacker.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassSurfaceState.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/GlassUniforms.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/LiquidGlassShaders.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/SharedGlassPass.kt +6 -6
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/G2RoundedRectangle.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/geometry/ReferenceG2MaskTexture.kt +1 -1
- package/android-core/src/main/java/io/github/luckylca/liquidglass/core/shader/HeightFieldGlassShader.kt +7 -0
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceBackdropBlurShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGaussianDiscBackdropBlur.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceGlassUniforms.kt +4 -4
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityGlassShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/ReferenceParityMultiShapeShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/core/shader/SdfScaleLensShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassHardwareLayerExperiment.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassMaterial.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRenderer.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassRuntimeShader.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassShader.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/local/LocalGlassView.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionDriver.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/GlassMotionState.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/PointerVelocityTracker.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/motion/SpringSpec.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/G2Corner.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassMaterial.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassOpticsShader.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassParityProbe.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassShapeGeometry.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/GlassUniformBinder.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/PixelDiff.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/optics/ReferenceOptics.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceHost.kt +17 -17
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/GlassSurfaceRenderer.kt +9 -9
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/rendering/RetainedBackdropLayer.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/scheduler/GlassFrameScheduler.kt +2 -2
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/EffectiveScrollFpsProbe.kt +13 -13
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/GlassTelemetry.kt +1 -1
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassPerfTelemetry.kt +13 -13
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LiquidGlassTrace.kt +3 -3
- package/android-core/src/main/java/{com/newhu → io/github/luckylca}/liquidglass/telemetry/LocalGlassTelemetry.kt +1 -1
- package/docs/architecture.md +61 -0
- package/docs/migration-0.3.md +19 -0
- package/docs/publishing.md +29 -7
- package/expo-module.config.json +4 -4
- package/lib/commonjs/GlassSurface.js +157 -585
- package/lib/commonjs/GlassSurface.js.map +1 -1
- package/lib/commonjs/GlassTabBar.js +18 -957
- package/lib/commonjs/GlassTabBar.js.map +1 -1
- package/lib/commonjs/LocalGlassMaterial.js +3 -9
- package/lib/commonjs/LocalGlassMaterial.js.map +1 -1
- package/lib/commonjs/glassController.js +3 -7
- package/lib/commonjs/glassController.js.map +1 -1
- package/lib/commonjs/glassRuntime.js +7 -19
- package/lib/commonjs/glassRuntime.js.map +1 -1
- package/lib/commonjs/localGlassTelemetry.js +4 -13
- package/lib/commonjs/localGlassTelemetry.js.map +1 -1
- package/lib/commonjs/nativeGlassViews.js +8 -11
- package/lib/commonjs/nativeGlassViews.js.map +1 -1
- package/lib/commonjs/performanceTelemetry.js +2 -6
- package/lib/commonjs/performanceTelemetry.js.map +1 -1
- package/lib/commonjs/surface/InlineSurface.js +134 -0
- package/lib/commonjs/surface/InlineSurface.js.map +1 -0
- package/lib/commonjs/surface/MaterialProvider.js +78 -0
- package/lib/commonjs/surface/MaterialProvider.js.map +1 -0
- package/lib/commonjs/surface/NativeSurface.js +55 -0
- package/lib/commonjs/surface/NativeSurface.js.map +1 -0
- package/lib/commonjs/surface/PortalLayers.js +331 -0
- package/lib/commonjs/surface/PortalLayers.js.map +1 -0
- package/lib/commonjs/surface/contexts.js +108 -0
- package/lib/commonjs/surface/contexts.js.map +1 -0
- package/lib/commonjs/surface/registry.js +113 -0
- package/lib/commonjs/surface/registry.js.map +1 -0
- package/lib/commonjs/surface/styles.js +34 -0
- package/lib/commonjs/surface/styles.js.map +1 -0
- package/lib/commonjs/surface/types.js +3 -0
- package/lib/commonjs/surface/types.js.map +1 -0
- package/lib/commonjs/tabs/GlassTabItem.js +66 -0
- package/lib/commonjs/tabs/GlassTabItem.js.map +1 -0
- package/lib/commonjs/tabs/InlineTabBar.js +867 -0
- package/lib/commonjs/tabs/InlineTabBar.js.map +1 -0
- package/lib/commonjs/tabs/tabConstants.js +22 -0
- package/lib/commonjs/tabs/tabConstants.js.map +1 -0
- package/lib/commonjs/tabs/tabDebug.js +50 -0
- package/lib/commonjs/tabs/tabDebug.js.map +1 -0
- package/lib/commonjs/tabs/tabStyles.js +107 -0
- package/lib/commonjs/tabs/tabStyles.js.map +1 -0
- package/lib/commonjs/tabs/useInlineTabGesture.js +227 -0
- package/lib/commonjs/tabs/useInlineTabGesture.js.map +1 -0
- package/lib/commonjs/theme/buildTheme.js +1 -1
- package/lib/commonjs/theme/buildTheme.js.map +1 -1
- package/lib/module/GlassSurface.js +135 -563
- package/lib/module/GlassSurface.js.map +1 -1
- package/lib/module/GlassTabBar.js +18 -925
- package/lib/module/GlassTabBar.js.map +1 -1
- package/lib/module/LocalGlassMaterial.js +5 -11
- package/lib/module/LocalGlassMaterial.js.map +1 -1
- package/lib/module/glassController.js +3 -7
- package/lib/module/glassController.js.map +1 -1
- package/lib/module/glassRuntime.js +7 -19
- package/lib/module/glassRuntime.js.map +1 -1
- package/lib/module/localGlassTelemetry.js +4 -13
- package/lib/module/localGlassTelemetry.js.map +1 -1
- package/lib/module/nativeGlassViews.js +7 -10
- package/lib/module/nativeGlassViews.js.map +1 -1
- package/lib/module/performanceTelemetry.js +2 -6
- package/lib/module/performanceTelemetry.js.map +1 -1
- package/lib/module/surface/InlineSurface.js +97 -0
- package/lib/module/surface/InlineSurface.js.map +1 -0
- package/lib/module/surface/MaterialProvider.js +74 -0
- package/lib/module/surface/MaterialProvider.js.map +1 -0
- package/lib/module/surface/NativeSurface.js +47 -0
- package/lib/module/surface/NativeSurface.js.map +1 -0
- package/lib/module/surface/PortalLayers.js +292 -0
- package/lib/module/surface/PortalLayers.js.map +1 -0
- package/lib/module/surface/contexts.js +96 -0
- package/lib/module/surface/contexts.js.map +1 -0
- package/lib/module/surface/registry.js +103 -0
- package/lib/module/surface/registry.js.map +1 -0
- package/lib/module/surface/styles.js +31 -0
- package/lib/module/surface/styles.js.map +1 -0
- package/lib/module/surface/types.js +2 -0
- package/lib/module/surface/types.js.map +1 -0
- package/lib/module/tabs/GlassTabItem.js +30 -0
- package/lib/module/tabs/GlassTabItem.js.map +1 -0
- package/lib/module/tabs/InlineTabBar.js +829 -0
- package/lib/module/tabs/InlineTabBar.js.map +1 -0
- package/lib/module/tabs/tabConstants.js +19 -0
- package/lib/module/tabs/tabConstants.js.map +1 -0
- package/lib/module/tabs/tabDebug.js +13 -0
- package/lib/module/tabs/tabDebug.js.map +1 -0
- package/lib/module/tabs/tabStyles.js +104 -0
- package/lib/module/tabs/tabStyles.js.map +1 -0
- package/lib/module/tabs/useInlineTabGesture.js +221 -0
- package/lib/module/tabs/useInlineTabGesture.js.map +1 -0
- package/lib/module/theme/buildTheme.js +1 -1
- package/lib/module/theme/buildTheme.js.map +1 -1
- package/lib/types/GlassSurface.d.ts +17 -86
- package/lib/types/GlassTabBar.d.ts +1 -0
- package/lib/types/glassNativeEngine.d.ts +1 -1
- package/lib/types/glassRuntime.d.ts +5 -2
- package/lib/types/localGlassTelemetry.d.ts +2 -2
- package/lib/types/nativeGlassViews.d.ts +2 -4
- package/lib/types/surface/InlineSurface.d.ts +42 -0
- package/lib/types/surface/MaterialProvider.d.ts +46 -0
- package/lib/types/surface/NativeSurface.d.ts +11 -0
- package/lib/types/surface/PortalLayers.d.ts +33 -0
- package/lib/types/surface/contexts.d.ts +66 -0
- package/lib/types/surface/registry.d.ts +6 -0
- package/lib/types/surface/styles.d.ts +74 -0
- package/lib/types/surface/types.d.ts +118 -0
- package/lib/types/tabs/GlassTabItem.d.ts +20 -0
- package/lib/types/tabs/InlineTabBar.d.ts +5 -0
- package/lib/types/tabs/tabConstants.d.ts +34 -0
- package/lib/types/tabs/tabDebug.d.ts +15 -0
- package/lib/types/tabs/tabStyles.d.ts +119 -0
- package/lib/types/tabs/useInlineTabGesture.d.ts +34 -0
- package/package.json +6 -14
- package/src/GlassSurface.tsx +227 -1337
- package/src/GlassTabBar.tsx +43 -1241
- package/src/LocalGlassMaterial.tsx +5 -11
- package/src/glassController.ts +3 -7
- package/src/glassRuntime.ts +9 -26
- package/src/localGlassTelemetry.ts +6 -15
- package/src/nativeGlassViews.ts +7 -10
- package/src/performanceTelemetry.ts +2 -6
- package/src/surface/InlineSurface.tsx +299 -0
- package/src/surface/MaterialProvider.tsx +235 -0
- package/src/surface/NativeSurface.tsx +115 -0
- package/src/surface/PortalLayers.tsx +574 -0
- package/src/surface/contexts.tsx +188 -0
- package/src/surface/registry.ts +109 -0
- package/src/surface/styles.ts +31 -0
- package/src/surface/types.ts +139 -0
- package/src/tabs/GlassTabItem.tsx +100 -0
- package/src/tabs/InlineTabBar.tsx +1193 -0
- package/src/tabs/tabConstants.ts +35 -0
- package/src/tabs/tabDebug.ts +29 -0
- package/src/tabs/tabStyles.ts +104 -0
- package/src/tabs/useInlineTabGesture.ts +306 -0
- package/src/theme/buildTheme.ts +1 -1
- package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassModule.kt +0 -341
- package/android/src/main/java/expo/modules/localglass/LocalGlassShader.kt +0 -59
- package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassCoreModule.kt +0 -226
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/GlassViewRenderer.kt +0 -1459
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/HeightFieldGlassShader.kt +0 -7
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassEngineSelection.kt +0 -30
- package/patches/liquid-glass-kit+1.0.0.patch +0 -2015
- package/patches/liquid-glass-kit-invalidation-coalescing.diff +0 -249
- package/patches/liquid-glass-kit-native-infra.diff +0 -624
- package/scripts/apply-legacy-patches.mjs +0 -116
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Canvas, Fill, Shader, Skia } from '@shopify/react-native-skia';
|
|
2
2
|
import { requireNativeViewManager } from 'expo-modules-core';
|
|
3
|
-
import React, { memo, useEffect, useMemo, useState
|
|
3
|
+
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { Platform, StyleSheet, View } from 'react-native';
|
|
5
5
|
import type { LayoutChangeEvent, ViewProps } from 'react-native';
|
|
6
6
|
import type { GlassMaterialTokens, GlassTokens } from './types';
|
|
7
|
-
import {
|
|
7
|
+
import { registerLocalGlassMaterial, } from './localGlassTelemetry';
|
|
8
8
|
import { getSurfaceRendererPolicy } from './surfaceRendererPolicy';
|
|
9
9
|
import type { GlassSurfaceRole } from './surfaceRendererPolicy';
|
|
10
10
|
|
|
@@ -86,10 +86,7 @@ export type ResolvedLocalGlassMaterial = {
|
|
|
86
86
|
type NativeLocalGlassMaterialProps = ViewProps & ResolvedLocalGlassMaterial;
|
|
87
87
|
|
|
88
88
|
const NativeLocalGlassView: React.ComponentType<NativeLocalGlassMaterialProps> | null = Platform.OS === 'android'
|
|
89
|
-
? requireNativeViewManager<NativeLocalGlassMaterialProps>('
|
|
90
|
-
: null;
|
|
91
|
-
const NativeLocalGlassEngineView: React.ComponentType<NativeLocalGlassMaterialProps> | null = Platform.OS === 'android'
|
|
92
|
-
? requireNativeViewManager<NativeLocalGlassMaterialProps>('ExpoLocalGlassEngine', 'LocalGlassMaterial')
|
|
89
|
+
? requireNativeViewManager<NativeLocalGlassMaterialProps>('LiquidGlass', 'LocalGlassMaterial')
|
|
93
90
|
: null;
|
|
94
91
|
|
|
95
92
|
const resolvedMaterialCache = new Map<string, ResolvedLocalGlassMaterial>();
|
|
@@ -182,10 +179,7 @@ function NativeLocalGlassRenderer({
|
|
|
182
179
|
dark: boolean;
|
|
183
180
|
resolved: ResolvedLocalGlassMaterial;
|
|
184
181
|
}) {
|
|
185
|
-
const
|
|
186
|
-
const NativeView = engine === 'core'
|
|
187
|
-
? NativeLocalGlassEngineView ?? NativeLocalGlassView
|
|
188
|
-
: NativeLocalGlassView;
|
|
182
|
+
const NativeView = NativeLocalGlassView;
|
|
189
183
|
useEffect(() => NativeView ? registerLocalGlassMaterial('native') : undefined, [NativeView]);
|
|
190
184
|
if (!NativeView) {
|
|
191
185
|
return <SkiaLocalGlassRenderer tokens={tokens} material={material} dark={dark} resolved={resolved} />;
|
|
@@ -253,7 +247,7 @@ export const LocalGlassMaterial = memo(function LocalGlassMaterial({
|
|
|
253
247
|
const renderer = getSurfaceRendererPolicy(surfaceRole);
|
|
254
248
|
const supportsNativeRenderer = Platform.OS === 'android'
|
|
255
249
|
&& Number(Platform.Version) >= 33
|
|
256
|
-
&&
|
|
250
|
+
&& NativeLocalGlassView !== null;
|
|
257
251
|
|
|
258
252
|
if (supportsNativeRenderer && renderer === 'native') {
|
|
259
253
|
return <NativeLocalGlassRenderer tokens={tokens} material={material} dark={dark} resolved={resolved} />;
|
package/src/glassController.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { requireNativeModule } from 'expo-modules-core';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
|
-
import { getGlassNativeEngine } from './glassNativeEngine';
|
|
4
3
|
|
|
5
4
|
type CaptureMode = 'oneShot' | 'frozen' | 'live';
|
|
6
5
|
|
|
@@ -13,16 +12,13 @@ interface LiquidGlassControllerNativeModule {
|
|
|
13
12
|
setSharedPassProbe?(enabled: boolean): void;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
const nativeModule = Platform.OS === 'android'
|
|
17
|
-
? requireNativeModule<LiquidGlassControllerNativeModule>('ExpoLiquidGlassProvider')
|
|
18
|
-
: null;
|
|
19
15
|
const coreNativeModule = Platform.OS === 'android'
|
|
20
|
-
? requireNativeModule<LiquidGlassControllerNativeModule>('
|
|
16
|
+
? requireNativeModule<LiquidGlassControllerNativeModule>('LiquidGlass')
|
|
21
17
|
: null;
|
|
22
18
|
|
|
23
19
|
function setCaptureMode(providerId: string | null, mode: CaptureMode) {
|
|
24
20
|
if (!providerId) return;
|
|
25
|
-
const module =
|
|
21
|
+
const module = coreNativeModule;
|
|
26
22
|
module?.setCaptureMode(providerId, mode);
|
|
27
23
|
}
|
|
28
24
|
|
|
@@ -54,7 +50,7 @@ export function setSharedPassProbe(enabled: boolean) {
|
|
|
54
50
|
|
|
55
51
|
function prepareFrozenBackdrop(providerId: string | null, blurRadiusDp: number) {
|
|
56
52
|
if (!providerId) return;
|
|
57
|
-
const module =
|
|
53
|
+
const module = coreNativeModule;
|
|
58
54
|
module?.prepareFrozenBackdrop(providerId, blurRadiusDp);
|
|
59
55
|
}
|
|
60
56
|
|
package/src/glassRuntime.ts
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface GlassRuntimeConfig {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
// surfaces the core cannot host, so defaulting to it meant every control rendered
|
|
10
|
-
// through a view that has no motion driver at all — the button drew its material
|
|
11
|
-
// and never animated, because nothing was listening.
|
|
12
|
-
let runtime: GlassRuntimeConfig = { engine: 'core' };
|
|
13
|
-
const listeners = new Set<() => void>();
|
|
14
|
-
|
|
15
|
-
export function getGlassRuntime(): GlassRuntimeConfig {
|
|
16
|
-
return runtime;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function subscribeGlassRuntime(listener: () => void) {
|
|
20
|
-
listeners.add(listener);
|
|
21
|
-
return () => listeners.delete(listener);
|
|
22
|
-
}
|
|
23
|
-
|
|
1
|
+
/** Android uses one native renderer; other platforms use local material fallbacks. */
|
|
2
|
+
export type GlassRuntimeEngine = 'core';
|
|
3
|
+
export interface GlassRuntimeConfig { engine: GlassRuntimeEngine }
|
|
4
|
+
const runtime: GlassRuntimeConfig = Object.freeze({ engine: 'core' });
|
|
5
|
+
export function getGlassRuntime(): GlassRuntimeConfig { return runtime; }
|
|
6
|
+
/** @deprecated Renderer selection is automatic. */
|
|
7
|
+
export function subscribeGlassRuntime(_listener: () => void) { return () => {}; }
|
|
8
|
+
/** @deprecated The native renderer is fixed for the lifetime of the process. */
|
|
24
9
|
export function setGlassRuntime(next: GlassRuntimeConfig) {
|
|
25
|
-
if (
|
|
26
|
-
runtime = next;
|
|
27
|
-
for (const listener of listeners) listener();
|
|
10
|
+
if (next.engine !== 'core') throw new Error('Liquid Glass uses its bundled native renderer.');
|
|
28
11
|
}
|
|
@@ -23,19 +23,16 @@ export type LocalGlassTelemetrySnapshot = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
interface NativeLocalGlassTelemetryModule {
|
|
26
|
-
|
|
26
|
+
setLocalPerformanceTelemetryEnabled(enabled: boolean): Promise<void>;
|
|
27
27
|
setHardwareLayerExperimentEnabled(enabled: boolean): Promise<void>;
|
|
28
|
-
|
|
28
|
+
getLocalPerformanceTelemetry(): Promise<Pick<LocalGlassTelemetrySnapshot,
|
|
29
29
|
'mountedNativeViewCount' | 'nativeOnDrawCount' | 'nativeInvalidateCount' | 'materialApplyCount' |
|
|
30
30
|
'runtimeShaderCreateCount' | 'runtimeShaderReuseCount' | 'uniformUpdateCount' |
|
|
31
31
|
'sizeUniformUpdateCount' | 'materialUniformUpdateCount'>>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const nativeTelemetryModule = Platform.OS === 'android'
|
|
35
|
-
? requireNativeModule<NativeLocalGlassTelemetryModule>('
|
|
36
|
-
: null;
|
|
37
|
-
const coreNativeTelemetryModule = Platform.OS === 'android'
|
|
38
|
-
? requireNativeModule<NativeLocalGlassTelemetryModule>('ExpoLocalGlassEngine')
|
|
35
|
+
? requireNativeModule<NativeLocalGlassTelemetryModule>('LiquidGlass')
|
|
39
36
|
: null;
|
|
40
37
|
|
|
41
38
|
export function getLocalGlassNativeEngine() {
|
|
@@ -88,12 +85,9 @@ export function setLocalGlassTelemetryEnabled(next: boolean) {
|
|
|
88
85
|
materialUniformUpdateCount: 0,
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
|
-
void nativeTelemetryModule?.
|
|
88
|
+
void nativeTelemetryModule?.setLocalPerformanceTelemetryEnabled(next).catch((error) => {
|
|
92
89
|
console.warn('[LiquidGlass] Native Local Glass telemetry unavailable.', error);
|
|
93
90
|
});
|
|
94
|
-
void coreNativeTelemetryModule?.setPerformanceTelemetryEnabled(next).catch((error) => {
|
|
95
|
-
console.warn('[LiquidGlass] Core Local Glass telemetry unavailable.', error);
|
|
96
|
-
});
|
|
97
91
|
}
|
|
98
92
|
|
|
99
93
|
/** Debug-only A/B switch. Android applies a hardware layer to LocalGlassMaterial views only. */
|
|
@@ -101,9 +95,6 @@ export function setLocalGlassHardwareLayerExperimentEnabled(next: boolean) {
|
|
|
101
95
|
void nativeTelemetryModule?.setHardwareLayerExperimentEnabled(next).catch((error) => {
|
|
102
96
|
console.warn('[LiquidGlass] Local Glass hardware layer experiment unavailable.', error);
|
|
103
97
|
});
|
|
104
|
-
void coreNativeTelemetryModule?.setHardwareLayerExperimentEnabled(next).catch((error) => {
|
|
105
|
-
console.warn('[LiquidGlass] Core Local Glass hardware layer experiment unavailable.', error);
|
|
106
|
-
});
|
|
107
98
|
}
|
|
108
99
|
|
|
109
100
|
export function registerLocalGlassMaterial(kind: LocalGlassRendererKind): () => void {
|
|
@@ -132,7 +123,7 @@ export function setLocalGlassVisibleItemCount(count: number) {
|
|
|
132
123
|
|
|
133
124
|
export async function getLocalGlassTelemetry(): Promise<LocalGlassTelemetrySnapshot | null> {
|
|
134
125
|
if (!enabled) return null;
|
|
135
|
-
const nativeModule =
|
|
136
|
-
const native = await nativeModule?.
|
|
126
|
+
const nativeModule = nativeTelemetryModule;
|
|
127
|
+
const native = await nativeModule?.getLocalPerformanceTelemetry();
|
|
137
128
|
return { ...snapshot, ...native };
|
|
138
129
|
}
|
package/src/nativeGlassViews.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { requireNativeViewManager } from 'expo-modules-core';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Platform, processColor } from 'react-native';
|
|
4
4
|
import type { ColorValue, View, ViewProps } from 'react-native';
|
|
5
|
-
import { LiquidGlassProvider, LiquidGlassView } from 'liquid-glass-kit';
|
|
6
5
|
import type { GlassOpticsModel } from './types';
|
|
7
6
|
|
|
8
7
|
export interface GlassCaptureSourceProps extends ViewProps {
|
|
@@ -123,17 +122,15 @@ type NativeGlassManagerProps = Omit<NativeGlassSurfaceProps, 'tint' | 'surfaceCo
|
|
|
123
122
|
toggleSolidBackdropColor?: ReturnType<typeof processColor>;
|
|
124
123
|
};
|
|
125
124
|
|
|
126
|
-
export const
|
|
127
|
-
|
|
128
|
-
export const CoreGlassCaptureSource: React.ComponentType<GlassCaptureSourceProps> | null = Platform.OS === 'android'
|
|
129
|
-
? requireNativeViewManager<GlassCaptureSourceProps>('NewHuLiquidGlassCore', 'GlassCaptureSource')
|
|
125
|
+
export const NativeGlassCaptureSource: React.ComponentType<GlassCaptureSourceProps> | null = Platform.OS === 'android'
|
|
126
|
+
? requireNativeViewManager<GlassCaptureSourceProps>('LiquidGlass', 'GlassCaptureSource')
|
|
130
127
|
: null;
|
|
131
|
-
const
|
|
132
|
-
? requireNativeViewManager<NativeGlassManagerProps & React.RefAttributes<View>>('
|
|
128
|
+
const NativeGlassSurfaceManager: React.ComponentType<NativeGlassManagerProps & React.RefAttributes<View>> | null = Platform.OS === 'android'
|
|
129
|
+
? requireNativeViewManager<NativeGlassManagerProps & React.RefAttributes<View>>('LiquidGlass', 'GlassSurface')
|
|
133
130
|
: null;
|
|
134
|
-
export const
|
|
135
|
-
? React.forwardRef<View, NativeGlassSurfaceProps>(function
|
|
136
|
-
return React.createElement(
|
|
131
|
+
export const NativeGlassSurfaceView = NativeGlassSurfaceManager
|
|
132
|
+
? React.forwardRef<View, NativeGlassSurfaceProps>(function NativeGlassSurfaceView({ tint, highlightColor, ...props }, ref) {
|
|
133
|
+
return React.createElement(NativeGlassSurfaceManager, {
|
|
137
134
|
ref,
|
|
138
135
|
...props,
|
|
139
136
|
tint: tint != null ? processColor(tint) ?? undefined : undefined,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { requireNativeModule } from 'expo-modules-core';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
|
-
import { getGlassNativeEngine } from './glassNativeEngine';
|
|
4
3
|
|
|
5
4
|
export interface LiquidGlassPerformanceStats {
|
|
6
5
|
[key: string]: number;
|
|
@@ -70,15 +69,12 @@ interface LiquidGlassPerformanceNativeModule {
|
|
|
70
69
|
getPerformanceStats(): Promise<LiquidGlassPerformanceStats>;
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
const nativeModule = Platform.OS === 'android'
|
|
74
|
-
? requireNativeModule<LiquidGlassPerformanceNativeModule>('ExpoLiquidGlassProvider')
|
|
75
|
-
: null;
|
|
76
72
|
const coreNativeModule = Platform.OS === 'android'
|
|
77
|
-
? requireNativeModule<LiquidGlassPerformanceNativeModule>('
|
|
73
|
+
? requireNativeModule<LiquidGlassPerformanceNativeModule>('LiquidGlass')
|
|
78
74
|
: null;
|
|
79
75
|
|
|
80
76
|
function activeModule() {
|
|
81
|
-
return
|
|
77
|
+
return coreNativeModule;
|
|
82
78
|
}
|
|
83
79
|
|
|
84
80
|
export function setLiquidGlassPerformanceTelemetryEnabled(enabled: boolean) {
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import Animated, { useAnimatedProps } from 'react-native-reanimated';
|
|
5
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
6
|
+
import { LocalGlassMaterial } from '../LocalGlassMaterial';
|
|
7
|
+
import type { GlassMaterialTokens, GlassVariant } from '../types';
|
|
8
|
+
import type { GlassPointerEventSink, GlassValueEventSink } from '../pointerEventBridge';
|
|
9
|
+
import { GlassRuntimeContext } from './contexts';
|
|
10
|
+
import { NativeBackdropSurface } from './NativeSurface';
|
|
11
|
+
import type { GlassSurfaceProps } from '../GlassSurface';
|
|
12
|
+
import { styles } from './styles';
|
|
13
|
+
|
|
14
|
+
export const InlineBackdropSurface = React.memo(function InlineBackdropSurface({
|
|
15
|
+
renderingEnabled,
|
|
16
|
+
providerId,
|
|
17
|
+
variant,
|
|
18
|
+
tintColor,
|
|
19
|
+
interactive,
|
|
20
|
+
continuous,
|
|
21
|
+
sharedSource,
|
|
22
|
+
captureProbe,
|
|
23
|
+
opticalProgress,
|
|
24
|
+
pointerEvent,
|
|
25
|
+
pointerEventValue,
|
|
26
|
+
pointerEventSink,
|
|
27
|
+
valueEventSink,
|
|
28
|
+
valueEvent,
|
|
29
|
+
opticalToggleFraction,
|
|
30
|
+
opticalPointX,
|
|
31
|
+
opticalPointY,
|
|
32
|
+
opticalVelocityX,
|
|
33
|
+
opticalVelocityY,
|
|
34
|
+
opticalMotionX,
|
|
35
|
+
opticalMotionY,
|
|
36
|
+
materialOverrides,
|
|
37
|
+
displacementOnlyDebug,
|
|
38
|
+
syncContentTransform,
|
|
39
|
+
intrinsicLayout,
|
|
40
|
+
contentStyle,
|
|
41
|
+
placement,
|
|
42
|
+
children,
|
|
43
|
+
}: {
|
|
44
|
+
renderingEnabled: boolean;
|
|
45
|
+
providerId: string;
|
|
46
|
+
variant: GlassVariant;
|
|
47
|
+
tintColor?: ColorValue;
|
|
48
|
+
interactive: boolean;
|
|
49
|
+
continuous: boolean;
|
|
50
|
+
opticalProgress?: SharedValue<number>;
|
|
51
|
+
/** Pointer event stream for the native motion driver; it owns the spring. */
|
|
52
|
+
pointerEvent?: SharedValue<string>;
|
|
53
|
+
/** The same stream as plain state; this is what the native prop receives. */
|
|
54
|
+
pointerEventValue?: string;
|
|
55
|
+
/** Direct native path for pointer samples that should not rerender inline surfaces. */
|
|
56
|
+
pointerEventSink?: GlassPointerEventSink;
|
|
57
|
+
/** Knob value stream for value-driven lenses; see useGlassKnobMotion. */
|
|
58
|
+
valueEvent?: string;
|
|
59
|
+
/** Direct native path for knob values that should not rerender portal surfaces. */
|
|
60
|
+
valueEventSink?: GlassValueEventSink;
|
|
61
|
+
opticalToggleFraction?: SharedValue<number>;
|
|
62
|
+
opticalPointX?: SharedValue<number>;
|
|
63
|
+
opticalPointY?: SharedValue<number>;
|
|
64
|
+
opticalVelocityX?: SharedValue<number>;
|
|
65
|
+
opticalVelocityY?: SharedValue<number>;
|
|
66
|
+
opticalMotionX?: SharedValue<number>;
|
|
67
|
+
opticalMotionY?: SharedValue<number>;
|
|
68
|
+
materialOverrides?: Partial<GlassMaterialTokens>;
|
|
69
|
+
displacementOnlyDebug: boolean;
|
|
70
|
+
syncContentTransform?: boolean;
|
|
71
|
+
intrinsicLayout: boolean;
|
|
72
|
+
sharedSource?: boolean;
|
|
73
|
+
captureProbe?: boolean;
|
|
74
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
75
|
+
placement: 'layout' | 'bottom' | 'center';
|
|
76
|
+
children?: React.ReactNode;
|
|
77
|
+
}) {
|
|
78
|
+
const runtime = useContext(GlassRuntimeContext);
|
|
79
|
+
const hasAnimatedOptics = Boolean(
|
|
80
|
+
opticalPointX ||
|
|
81
|
+
opticalPointY ||
|
|
82
|
+
opticalVelocityX ||
|
|
83
|
+
opticalVelocityY ||
|
|
84
|
+
opticalProgress ||
|
|
85
|
+
opticalToggleFraction ||
|
|
86
|
+
opticalMotionX ||
|
|
87
|
+
opticalMotionY,
|
|
88
|
+
);
|
|
89
|
+
const animatedOptics = useAnimatedProps(
|
|
90
|
+
() => ({
|
|
91
|
+
interactionVelocityX: opticalVelocityX?.value,
|
|
92
|
+
interactionVelocityY: opticalVelocityY?.value,
|
|
93
|
+
interactionPointX: opticalPointX?.value,
|
|
94
|
+
interactionPointY: opticalPointY?.value,
|
|
95
|
+
interactionProgress: opticalProgress?.value ?? 0,
|
|
96
|
+
toggleFraction: opticalToggleFraction?.value ?? 0,
|
|
97
|
+
motionX: opticalMotionX ? Math.max(-1, Math.min(1, opticalMotionX.value / 1800)) : undefined,
|
|
98
|
+
motionY: opticalMotionY ? Math.max(-1, Math.min(1, opticalMotionY.value / 1800)) : undefined,
|
|
99
|
+
}),
|
|
100
|
+
[
|
|
101
|
+
opticalPointX,
|
|
102
|
+
opticalPointY,
|
|
103
|
+
opticalVelocityX,
|
|
104
|
+
opticalVelocityY,
|
|
105
|
+
opticalProgress,
|
|
106
|
+
pointerEventValue,
|
|
107
|
+
valueEvent,
|
|
108
|
+
opticalToggleFraction,
|
|
109
|
+
opticalMotionX,
|
|
110
|
+
opticalMotionY,
|
|
111
|
+
],
|
|
112
|
+
);
|
|
113
|
+
if (!runtime) return <>{children}</>;
|
|
114
|
+
const { tokens, dark, reducedMotion } = runtime;
|
|
115
|
+
const material = materialOverrides
|
|
116
|
+
? { ...tokens.materials[variant], ...materialOverrides }
|
|
117
|
+
: tokens.materials[variant];
|
|
118
|
+
const qualityScale =
|
|
119
|
+
material.opticsModel === 'referenceParity'
|
|
120
|
+
? 1
|
|
121
|
+
: tokens.quality === 'high'
|
|
122
|
+
? 1.2
|
|
123
|
+
: tokens.quality === 'fallback'
|
|
124
|
+
? 0.45
|
|
125
|
+
: 1;
|
|
126
|
+
return (
|
|
127
|
+
<View
|
|
128
|
+
collapsable={!syncContentTransform}
|
|
129
|
+
style={intrinsicLayout ? styles.inlineBackdropIntrinsicSurface : styles.inlineBackdropSurface}
|
|
130
|
+
>
|
|
131
|
+
<NativeBackdropSurface
|
|
132
|
+
renderingEnabled={renderingEnabled}
|
|
133
|
+
providerId={providerId}
|
|
134
|
+
opticsModel={material.opticsModel}
|
|
135
|
+
depthEffect={material.referenceDepthEffect ?? false}
|
|
136
|
+
highlightStyle={material.referenceHighlightStyle}
|
|
137
|
+
interactionProfile={material.referenceInteractionProfile}
|
|
138
|
+
contentScaleX={material.referenceContentScaleX}
|
|
139
|
+
contentScaleY={material.referenceContentScaleY}
|
|
140
|
+
sampleOffsetX={material.referenceSampleOffsetX}
|
|
141
|
+
sampleOffsetY={material.referenceSampleOffsetY}
|
|
142
|
+
toggleTrackColorOff={material.referenceToggleTrackColorOff}
|
|
143
|
+
toggleTrackColorOn={material.referenceToggleTrackColorOn}
|
|
144
|
+
toggleTrackWidth={material.referenceToggleTrackWidth}
|
|
145
|
+
toggleTrackHeight={material.referenceToggleTrackHeight}
|
|
146
|
+
toggleSolidBackdropColor={material.referenceToggleSolidBackdropColor}
|
|
147
|
+
brightness={material.brightness ?? 0}
|
|
148
|
+
contrast={material.contrast ?? 1}
|
|
149
|
+
highlightFalloff={material.highlightFalloff ?? 1}
|
|
150
|
+
sdfContrast={material.sdfScaleLens?.contrast}
|
|
151
|
+
sdfBrightness={material.sdfScaleLens?.brightness}
|
|
152
|
+
sdfSaturation={material.sdfScaleLens?.saturation}
|
|
153
|
+
sdfOuterShadowAlpha={material.sdfScaleLens?.outerShadowAlpha}
|
|
154
|
+
sdfOuterShadowBlurRadius={material.sdfScaleLens?.outerShadowBlurRadius}
|
|
155
|
+
sdfOuterShadowOffsetY={material.sdfScaleLens?.outerShadowOffsetY}
|
|
156
|
+
sdfInnerShadowAlpha={material.sdfScaleLens?.innerShadowAlpha}
|
|
157
|
+
sdfInnerShadowExtent={material.sdfScaleLens?.innerShadowExtent}
|
|
158
|
+
cornerRadius={material.radius}
|
|
159
|
+
blurRadius={material.blurRadius * qualityScale}
|
|
160
|
+
refractionHeight={material.refractionHeight * qualityScale}
|
|
161
|
+
refractionAmount={material.refractionAmount * qualityScale}
|
|
162
|
+
bodyRefractionAmount={(material.refractionBodyAmount ?? 2.5) * qualityScale}
|
|
163
|
+
interactionProgress={0}
|
|
164
|
+
pointerEvent={pointerEventValue}
|
|
165
|
+
pointerEventSink={pointerEventSink}
|
|
166
|
+
valueEventSink={valueEventSink}
|
|
167
|
+
valueEvent={valueEvent}
|
|
168
|
+
saturation={material.saturation}
|
|
169
|
+
chromaticAberration={
|
|
170
|
+
material.opticsModel === 'referenceParity' ||
|
|
171
|
+
tokens.quality === 'high' ||
|
|
172
|
+
variant === 'tabSelectionLens'
|
|
173
|
+
? material.chromaticAberration
|
|
174
|
+
: 0
|
|
175
|
+
}
|
|
176
|
+
highlightAlpha={material.highlightAlpha}
|
|
177
|
+
highlightWidth={material.highlightWidth}
|
|
178
|
+
lightAngle={material.highlightAngle ?? 45}
|
|
179
|
+
highlightColor={
|
|
180
|
+
material.highlightColor
|
|
181
|
+
? dark
|
|
182
|
+
? material.highlightColor.dark
|
|
183
|
+
: material.highlightColor.light
|
|
184
|
+
: undefined
|
|
185
|
+
}
|
|
186
|
+
tintAlpha={material.tintAlpha ?? 1}
|
|
187
|
+
specularStrength={material.specularStrength ?? 1}
|
|
188
|
+
fresnelStrength={material.fresnelStrength ?? 0.85}
|
|
189
|
+
innerShadowStrength={
|
|
190
|
+
material.innerShadowStrength ?? (material.opticsModel === 'referenceParity' ? 0 : 0.18)
|
|
191
|
+
}
|
|
192
|
+
shadowOpacity={
|
|
193
|
+
material.shadowOpacity ?? (material.opticsModel === 'referenceParity' ? 0 : 0.1)
|
|
194
|
+
}
|
|
195
|
+
shadowRadius={material.shadowRadius ?? (material.opticsModel === 'referenceParity' ? 0 : 24)}
|
|
196
|
+
shadowOffsetY={material.shadowOffsetY ?? (material.opticsModel === 'referenceParity' ? 0 : 4)}
|
|
197
|
+
tint={tintColor ?? (dark ? tokens.tint.dark : tokens.tint.light)}
|
|
198
|
+
surfaceColor={
|
|
199
|
+
material.surfaceColor
|
|
200
|
+
? dark
|
|
201
|
+
? material.surfaceColor.dark
|
|
202
|
+
: material.surfaceColor.light
|
|
203
|
+
: undefined
|
|
204
|
+
}
|
|
205
|
+
interactive={interactive && tokens.interaction.enabled && !reducedMotion}
|
|
206
|
+
continuous={continuous}
|
|
207
|
+
sharedSource={sharedSource}
|
|
208
|
+
captureProbe={captureProbe}
|
|
209
|
+
displacementOnlyDebug={displacementOnlyDebug}
|
|
210
|
+
syncContentTransform={syncContentTransform}
|
|
211
|
+
animatedProps={hasAnimatedOptics ? animatedOptics : undefined}
|
|
212
|
+
pointerEvents={interactive ? undefined : 'none'}
|
|
213
|
+
style={[StyleSheet.absoluteFill, { borderRadius: material.radius }]}
|
|
214
|
+
/>
|
|
215
|
+
<View
|
|
216
|
+
style={[
|
|
217
|
+
intrinsicLayout
|
|
218
|
+
? styles.portalContentIntrinsic
|
|
219
|
+
: placement === 'layout'
|
|
220
|
+
? styles.portalContentLayout
|
|
221
|
+
: styles.portalContentWrap,
|
|
222
|
+
contentStyle,
|
|
223
|
+
]}
|
|
224
|
+
>
|
|
225
|
+
{children}
|
|
226
|
+
</View>
|
|
227
|
+
</View>
|
|
228
|
+
);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
export function LocalGlassSurface({
|
|
232
|
+
variant,
|
|
233
|
+
surfaceRole,
|
|
234
|
+
style,
|
|
235
|
+
contentStyle,
|
|
236
|
+
animatedStyle,
|
|
237
|
+
fallbackAnimatedStyle,
|
|
238
|
+
pointerEvents,
|
|
239
|
+
onLayout,
|
|
240
|
+
children,
|
|
241
|
+
}: Pick<
|
|
242
|
+
GlassSurfaceProps,
|
|
243
|
+
| 'variant'
|
|
244
|
+
| 'surfaceRole'
|
|
245
|
+
| 'style'
|
|
246
|
+
| 'contentStyle'
|
|
247
|
+
| 'animatedStyle'
|
|
248
|
+
| 'fallbackAnimatedStyle'
|
|
249
|
+
| 'pointerEvents'
|
|
250
|
+
| 'onLayout'
|
|
251
|
+
| 'children'
|
|
252
|
+
>) {
|
|
253
|
+
const runtime = useContext(GlassRuntimeContext);
|
|
254
|
+
if (!runtime?.tokens.enabled)
|
|
255
|
+
return (
|
|
256
|
+
<Animated.View onLayout={onLayout} style={[style, animatedStyle, fallbackAnimatedStyle]}>
|
|
257
|
+
<View style={contentStyle}>{children}</View>
|
|
258
|
+
</Animated.View>
|
|
259
|
+
);
|
|
260
|
+
const { tokens, dark } = runtime;
|
|
261
|
+
const material: GlassMaterialTokens = tokens.materials[variant ?? 'surface'];
|
|
262
|
+
const fallback = tokens.quality === 'fallback';
|
|
263
|
+
return (
|
|
264
|
+
<Animated.View
|
|
265
|
+
pointerEvents={pointerEvents}
|
|
266
|
+
onLayout={onLayout}
|
|
267
|
+
style={[
|
|
268
|
+
styles.localSurface,
|
|
269
|
+
{ borderRadius: material.radius, backgroundColor: 'transparent' },
|
|
270
|
+
style,
|
|
271
|
+
animatedStyle,
|
|
272
|
+
fallbackAnimatedStyle,
|
|
273
|
+
]}
|
|
274
|
+
>
|
|
275
|
+
{fallback ? (
|
|
276
|
+
<View
|
|
277
|
+
pointerEvents="none"
|
|
278
|
+
style={[
|
|
279
|
+
StyleSheet.absoluteFill,
|
|
280
|
+
{
|
|
281
|
+
backgroundColor: dark ? tokens.fallbackTint.dark : tokens.fallbackTint.light,
|
|
282
|
+
borderColor: dark ? tokens.fallbackBorder.dark : tokens.fallbackBorder.light,
|
|
283
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
284
|
+
borderRadius: material.radius,
|
|
285
|
+
},
|
|
286
|
+
]}
|
|
287
|
+
/>
|
|
288
|
+
) : (
|
|
289
|
+
<LocalGlassMaterial
|
|
290
|
+
tokens={tokens}
|
|
291
|
+
material={material}
|
|
292
|
+
dark={dark}
|
|
293
|
+
surfaceRole={surfaceRole}
|
|
294
|
+
/>
|
|
295
|
+
)}
|
|
296
|
+
<View style={[styles.localContent, contentStyle]}>{children}</View>
|
|
297
|
+
</Animated.View>
|
|
298
|
+
);
|
|
299
|
+
}
|