glacia-native 0.5.2 → 0.6.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 +84 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +70 -63
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +43 -11
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +6 -9
- package/lib/module/internal/glass-routing.js +154 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +4 -2
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +132 -99
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +211 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -67
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { WithSpringConfig } from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The reference's motion language, ported spec for spec.
|
|
5
|
+
*
|
|
6
|
+
* Compose writes `spring(dampingRatio, stiffness, visibilityThreshold)` and always uses mass 1,
|
|
7
|
+
* so the conversion to Reanimated is exact:
|
|
8
|
+
*
|
|
9
|
+
* damping = dampingRatio * 2 * sqrt(stiffness)
|
|
10
|
+
*
|
|
11
|
+
* Do **not** carry a Compose stiffness across with a hand-picked damping — that is how this kit
|
|
12
|
+
* ended up near-critically damped (zeta 0.75-0.81) against a reference that deliberately
|
|
13
|
+
* overshoots. The bounce is not incidental; it is most of what reads as "liquid".
|
|
14
|
+
*
|
|
15
|
+
* Each spec is exported twice: as a `{stiffness, damping}` pair for the hand-integrated springs in
|
|
16
|
+
* `useDampedDrag`, and as a `WithSpringConfig` for the places a plain `withSpring` will do.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Damping for a unit-mass spring at the given ratio and stiffness. */
|
|
20
|
+
const dampingFor = (dampingRatio: number, stiffness: number): number =>
|
|
21
|
+
dampingRatio * 2 * Math.sqrt(stiffness);
|
|
22
|
+
|
|
23
|
+
interface ISpringSpec {
|
|
24
|
+
stiffness: number;
|
|
25
|
+
damping: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const spec = (dampingRatio: number, stiffness: number): ISpringSpec => ({
|
|
29
|
+
stiffness,
|
|
30
|
+
damping: dampingFor(dampingRatio, stiffness),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const asConfig = (s: ISpringSpec): WithSpringConfig => ({
|
|
34
|
+
mass: 1,
|
|
35
|
+
stiffness: s.stiffness,
|
|
36
|
+
damping: s.damping,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* `spring(1f, 1000f)` — critically damped, no overshoot, ~0.29 s to settle. Drives anything that
|
|
41
|
+
* must land on a definite value: the tab indicator's position, a control's own value, and every
|
|
42
|
+
* dragged control's press progress.
|
|
43
|
+
*/
|
|
44
|
+
const VALUE_SPEC: ISpringSpec = spec(1, 1000);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* `spring(0.6f, 250f)` — 9.5% overshoot. The grab swell on X.
|
|
48
|
+
*
|
|
49
|
+
* X and Y use deliberately different ratios (0.6 vs 0.7); that 0.1 asymmetry is the wobble. Keep
|
|
50
|
+
* them apart.
|
|
51
|
+
*/
|
|
52
|
+
const SCALE_X_SPEC: ISpringSpec = spec(0.6, 250);
|
|
53
|
+
|
|
54
|
+
/** `spring(0.7f, 250f)` — 4.6% overshoot. The grab swell on Y. */
|
|
55
|
+
const SCALE_Y_SPEC: ISpringSpec = spec(0.7, 250);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* `spring(0.5f, 300f)` — 16.3% overshoot, damped period ~0.42 s. Low-passes the velocity that
|
|
59
|
+
* drives the jelly, and springs it back to 0 on release: that decay *is* the settle wobble.
|
|
60
|
+
*/
|
|
61
|
+
const VELOCITY_SPEC: ISpringSpec = spec(0.5, 300);
|
|
62
|
+
|
|
63
|
+
/** `spring(1f, 300f)` — recentres the whole-panel rubber band when a drag stops. */
|
|
64
|
+
const PANEL_SPEC: ISpringSpec = spec(1, 300);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The tab pill's follower: `spring(0.7, 1000)`, 4.6% overshoot, where the reference lands dead
|
|
68
|
+
* (`VALUE_SPEC`, zeta 1). iOS 26's pill overruns its tab and settles back — the "bouncier" the
|
|
69
|
+
* user saw on an iPhone 14 Pro Max (2026-09-07) — while the slider's thumb and the switch's
|
|
70
|
+
* do not, so this is the tab bar's alone, handed to `useDampedDrag` as `valueSpring`. Press
|
|
71
|
+
* progress keeps `VALUE_SPEC` regardless: the inflate must not bounce.
|
|
72
|
+
*/
|
|
73
|
+
const TAB_FOLLOWER_SPEC: ISpringSpec = spec(0.7, 1000);
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* `spring(0.5f, 300f)` — the button's `InteractiveHighlight`: the white grab glow fading in and
|
|
77
|
+
* out, and the rubber-band return to origin.
|
|
78
|
+
*/
|
|
79
|
+
const GLOW_SPEC: ISpringSpec = spec(0.5, 300);
|
|
80
|
+
|
|
81
|
+
const VALUE_SPRING: WithSpringConfig = asConfig(VALUE_SPEC);
|
|
82
|
+
/** The same spec, named for its other job: `pressProgress` 0<->1. */
|
|
83
|
+
const PRESS_SPRING: WithSpringConfig = asConfig(VALUE_SPEC);
|
|
84
|
+
const SCALE_X_SPRING: WithSpringConfig = asConfig(SCALE_X_SPEC);
|
|
85
|
+
const SCALE_Y_SPRING: WithSpringConfig = asConfig(SCALE_Y_SPEC);
|
|
86
|
+
const VELOCITY_SPRING: WithSpringConfig = asConfig(VELOCITY_SPEC);
|
|
87
|
+
const PANEL_SPRING: WithSpringConfig = asConfig(PANEL_SPEC);
|
|
88
|
+
const GLOW_SPRING: WithSpringConfig = asConfig(GLOW_SPEC);
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
dampingFor,
|
|
92
|
+
VALUE_SPEC,
|
|
93
|
+
SCALE_X_SPEC,
|
|
94
|
+
SCALE_Y_SPEC,
|
|
95
|
+
VELOCITY_SPEC,
|
|
96
|
+
PANEL_SPEC,
|
|
97
|
+
GLOW_SPEC,
|
|
98
|
+
TAB_FOLLOWER_SPEC,
|
|
99
|
+
VALUE_SPRING,
|
|
100
|
+
PRESS_SPRING,
|
|
101
|
+
SCALE_X_SPRING,
|
|
102
|
+
SCALE_Y_SPRING,
|
|
103
|
+
VELOCITY_SPRING,
|
|
104
|
+
PANEL_SPRING,
|
|
105
|
+
GLOW_SPRING,
|
|
106
|
+
};
|
|
107
|
+
export type { ISpringSpec };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ViewStyle } from "react-native";
|
|
2
|
+
|
|
3
|
+
/** RN 0.80+'s strict types dropped `StyleSheet.absoluteFillObject`; this is that object. */
|
|
4
|
+
const ABSOLUTE_FILL = {
|
|
5
|
+
position: "absolute",
|
|
6
|
+
top: 0,
|
|
7
|
+
left: 0,
|
|
8
|
+
right: 0,
|
|
9
|
+
bottom: 0,
|
|
10
|
+
} as const satisfies ViewStyle;
|
|
11
|
+
|
|
12
|
+
export { ABSOLUTE_FILL };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
import type { View as RNView } from "react-native";
|
|
4
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
5
|
+
|
|
6
|
+
/** A member's frame in the group's own coordinates, dp — what `onLayout` reports. */
|
|
7
|
+
interface IGlassGroupRect {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What a member hands the group when it joins: the shared values its own press is driven by, so
|
|
16
|
+
* the group's canvas can redraw the member's silhouette — inflated, carried, stretched — from
|
|
17
|
+
* exactly the inputs the member's pane is transformed by, one frame at a time, with no JS.
|
|
18
|
+
*/
|
|
19
|
+
interface IGlassGroupMember {
|
|
20
|
+
/** Press progress, 0 at rest → 1 held. */
|
|
21
|
+
progress: SharedValue<number>;
|
|
22
|
+
/** The finger's travel since it landed, dp — the rubber band's inputs. */
|
|
23
|
+
offsetX: SharedValue<number>;
|
|
24
|
+
offsetY: SharedValue<number>;
|
|
25
|
+
/** Where the finger landed, member-local dp — the press light's hotspot. */
|
|
26
|
+
pressX: SharedValue<number>;
|
|
27
|
+
pressY: SharedValue<number>;
|
|
28
|
+
/** The member's height, which its press growth is expressed as a fraction of. */
|
|
29
|
+
height: number;
|
|
30
|
+
/** How many dp of height the member grows by at full press. */
|
|
31
|
+
growth: number;
|
|
32
|
+
/** The member's press light, 0..1 — the canvas lights the merged pane by the same amount. */
|
|
33
|
+
light: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface IGlassGroupContext {
|
|
37
|
+
/**
|
|
38
|
+
* The system is doing the merging (iOS 26's `UIGlassContainerEffect`): members keep their own
|
|
39
|
+
* panes and there is no canvas to hand them to.
|
|
40
|
+
*/
|
|
41
|
+
native: boolean;
|
|
42
|
+
/** The group's row — what member frames are measured against. */
|
|
43
|
+
hostRef: RefObject<RNView | null>;
|
|
44
|
+
/** Join. Returns the member's slot — its index into the group's rect table. */
|
|
45
|
+
register: (member: IGlassGroupMember) => number;
|
|
46
|
+
unregister: (slot: number) => void;
|
|
47
|
+
/** Report a laid-out frame, group-local dp. UI-thread write; safe from `onLayout`. */
|
|
48
|
+
setRect: (slot: number, rect: IGlassGroupRect) => void;
|
|
49
|
+
/** The pressed member, or -1. */
|
|
50
|
+
activeSlot: SharedValue<number>;
|
|
51
|
+
/** The member the pressed one is fusing with, or -1. */
|
|
52
|
+
targetSlot: SharedValue<number>;
|
|
53
|
+
/** The pressed member's progress — what both involved panes fade out by. */
|
|
54
|
+
activeProgress: SharedValue<number>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Supplied by `LiquidGlassGroup`; read by the kit's controls, which hand their silhouette to the
|
|
59
|
+
* group's canvas while pressed so a press merges into the neighbour like liquid. `null` outside
|
|
60
|
+
* any group — a control on its own draws its own pane and nothing changes.
|
|
61
|
+
*/
|
|
62
|
+
const GlassGroupContext = createContext<IGlassGroupContext | null>(null);
|
|
63
|
+
|
|
64
|
+
export { GlassGroupContext };
|
|
65
|
+
export type { IGlassGroupContext, IGlassGroupMember, IGlassGroupRect };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Platform, View } from "react-native";
|
|
4
|
+
|
|
5
|
+
import { COMPONENT_NAMES } from "../../constants";
|
|
6
|
+
import type { ILiquidGlassContainerProps } from "../../interfaces";
|
|
7
|
+
import { NativeLiquidGlassContainerView } from "../../views";
|
|
8
|
+
|
|
9
|
+
const LiquidGlassContainerBase: React.FC<ILiquidGlassContainerProps> = ({
|
|
10
|
+
children,
|
|
11
|
+
style,
|
|
12
|
+
...nativeProps
|
|
13
|
+
}: ILiquidGlassContainerProps): React.ReactNode & React.ReactElement => {
|
|
14
|
+
if (Platform.OS !== "ios") {
|
|
15
|
+
return <View style={style}>{children}</View>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<NativeLiquidGlassContainerView {...nativeProps} style={style}>
|
|
20
|
+
{children}
|
|
21
|
+
</NativeLiquidGlassContainerView>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
LiquidGlassContainerBase.displayName = `${COMPONENT_NAMES.LIQUID_GLASS_CONTAINER}Base`;
|
|
26
|
+
|
|
27
|
+
const LiquidGlassContainer: React.NamedExoticComponent<ILiquidGlassContainerProps> =
|
|
28
|
+
memo<ILiquidGlassContainerProps>(LiquidGlassContainerBase);
|
|
29
|
+
|
|
30
|
+
LiquidGlassContainer.displayName = COMPONENT_NAMES.LIQUID_GLASS_CONTAINER;
|
|
31
|
+
|
|
32
|
+
export { LiquidGlassContainer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LiquidGlassContainer } from "./LiquidGlassContainer";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Platform, View } from "react-native";
|
|
4
|
+
|
|
5
|
+
import { COMPONENT_NAMES, DEFAULT_PROVIDER_ID } from "../../constants";
|
|
6
|
+
import type { ILiquidGlassProviderProps } from "../../interfaces";
|
|
7
|
+
import { supportsGlass } from "../../utils";
|
|
8
|
+
import { NativeLiquidGlassProviderView } from "../../views";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Marks the content that should show through the glass.
|
|
12
|
+
*
|
|
13
|
+
* **Android only.** On iOS, web, and Android devices with no glass path this renders a plain
|
|
14
|
+
* `View` and nothing else, so it is safe to wrap unconditionally.
|
|
15
|
+
*
|
|
16
|
+
* Android has no primitive that lets a view sample its siblings' pixels, so the backdrop has to be
|
|
17
|
+
* recorded explicitly. This component records it — and because glass views are its *siblings*
|
|
18
|
+
* rather than its descendants, a glass view can never end up inside its own backdrop.
|
|
19
|
+
*
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <View style={{ flex: 1 }}>
|
|
22
|
+
* <LiquidGlassProvider style={StyleSheet.absoluteFill}>
|
|
23
|
+
* <ScrollView>{…}</ScrollView>
|
|
24
|
+
* </LiquidGlassProvider>
|
|
25
|
+
*
|
|
26
|
+
* <LiquidGlassView style={styles.panel} />
|
|
27
|
+
* </View>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* **Put the page background inside.** A provider records what its children draw and nothing else,
|
|
31
|
+
* so anywhere they draw nothing it records nothing, and glass over that region has nothing to
|
|
32
|
+
* transmit: it thins to its own frost and tint. Margins between cards, rounded corners and the
|
|
33
|
+
* padding around a list are all "nothing". If the screen has a background colour or gradient, it
|
|
34
|
+
* belongs in here — putting it on the parent instead is the usual cause of glass that looks
|
|
35
|
+
* unexpectedly see-through near an edge or a gap.
|
|
36
|
+
*
|
|
37
|
+
* A glass view must never sit inside the provider it *reads* — it would refract its own output.
|
|
38
|
+
* Nesting glass inside a **different** provider is the *stacked glass* pattern: the view renders
|
|
39
|
+
* normally, its finished glass is recorded into that provider's backdrop, and glass reading it
|
|
40
|
+
* re-refracts the lower layer. `LiquidGlassStack` builds that topology declaratively — reach for
|
|
41
|
+
* it before wiring nested providers by hand. See the README's "Stacked glass" section.
|
|
42
|
+
*/
|
|
43
|
+
const LiquidGlassProviderBase: React.FC<ILiquidGlassProviderProps> = ({
|
|
44
|
+
children,
|
|
45
|
+
style,
|
|
46
|
+
providerId = DEFAULT_PROVIDER_ID,
|
|
47
|
+
}: ILiquidGlassProviderProps): React.ReactNode & React.ReactElement => {
|
|
48
|
+
if (Platform.OS !== "android" || !supportsGlass) {
|
|
49
|
+
return <View style={style}>{children}</View>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<NativeLiquidGlassProviderView providerId={providerId} style={style}>
|
|
54
|
+
{children}
|
|
55
|
+
</NativeLiquidGlassProviderView>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
LiquidGlassProviderBase.displayName = `${COMPONENT_NAMES.LIQUID_GLASS_PROVIDER}Base`;
|
|
60
|
+
|
|
61
|
+
const LiquidGlassProvider: React.NamedExoticComponent<ILiquidGlassProviderProps> =
|
|
62
|
+
memo<ILiquidGlassProviderProps>(LiquidGlassProviderBase);
|
|
63
|
+
|
|
64
|
+
LiquidGlassProvider.displayName = COMPONENT_NAMES.LIQUID_GLASS_PROVIDER;
|
|
65
|
+
|
|
66
|
+
export { LiquidGlassProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LiquidGlassProvider } from "./LiquidGlassProvider";
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo, useId, useRef } from "react";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
|
|
5
|
+
import { COMPONENT_NAMES } from "../../constants";
|
|
6
|
+
import { GlassStackProviderContext } from "../../context";
|
|
7
|
+
import type {
|
|
8
|
+
ILiquidGlassStackLayerProps,
|
|
9
|
+
ILiquidGlassStackProps,
|
|
10
|
+
} from "../../interfaces";
|
|
11
|
+
import { devWarnOnce } from "../../utils";
|
|
12
|
+
import { LiquidGlassProvider } from "../LiquidGlassProvider";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A marker, not a wrapper: `LiquidGlassStack` reads props straight off its `Layer` elements and
|
|
16
|
+
* builds the real tree itself, so this render body only runs when a `Layer` is mounted somewhere
|
|
17
|
+
* other than directly under a stack — which gets a dev warning and a plain pass-through view.
|
|
18
|
+
*/
|
|
19
|
+
const LiquidGlassStackLayer: React.FC<ILiquidGlassStackLayerProps> = ({
|
|
20
|
+
children,
|
|
21
|
+
style,
|
|
22
|
+
}: ILiquidGlassStackLayerProps): React.ReactNode & React.ReactElement => {
|
|
23
|
+
devWarnOnce(
|
|
24
|
+
"stack-layer-standalone",
|
|
25
|
+
"A <LiquidGlassStack.Layer> rendered outside a <LiquidGlassStack>. Layers only mean " +
|
|
26
|
+
"something as direct children of a stack; this one is a plain view.",
|
|
27
|
+
);
|
|
28
|
+
return (
|
|
29
|
+
<View pointerEvents="box-none" style={style}>
|
|
30
|
+
{children}
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
LiquidGlassStackLayer.displayName = `${COMPONENT_NAMES.LIQUID_GLASS_STACK}.Layer`;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Declarative stacked glass — glass that refracts other glass.
|
|
39
|
+
*
|
|
40
|
+
* Layers go bottom to top. Glass inside layer *k* automatically reads a backdrop containing
|
|
41
|
+
* everything below it, **including lower layers' finished glass** — a sheet over a glass pill
|
|
42
|
+
* shows the pill's frost, rim and refraction re-refracted through its own lens:
|
|
43
|
+
*
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <LiquidGlassStack style={{ flex: 1 }}>
|
|
46
|
+
* <LiquidGlassStack.Layer>
|
|
47
|
+
* <ScrollView>{…}</ScrollView>
|
|
48
|
+
* </LiquidGlassStack.Layer>
|
|
49
|
+
* <LiquidGlassStack.Layer>
|
|
50
|
+
* <GlassPill /> // LiquidGlassView inside — no providerId needed
|
|
51
|
+
* </LiquidGlassStack.Layer>
|
|
52
|
+
* <LiquidGlassStack.Layer>
|
|
53
|
+
* {open && <GlassSheet />} // toggle content INSIDE a layer, not the layer itself
|
|
54
|
+
* </LiquidGlassStack.Layer>
|
|
55
|
+
* </LiquidGlassStack>
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* Each layer boundary expands to a nested `LiquidGlassProvider` with an auto-generated id
|
|
59
|
+
* (internal — do not pair against it by hand), delivered to descendant glass views through
|
|
60
|
+
* context, so reusable glass components need no `providerId` prop. N layers cost N−1 providers,
|
|
61
|
+
* and every level re-records everything below it whenever that content changes — two or three
|
|
62
|
+
* layers is the sane budget.
|
|
63
|
+
*
|
|
64
|
+
* **Keep the layer list static.** Adding or removing a `Layer` changes the nesting depth and
|
|
65
|
+
* remounts every layer below it (scroll positions, video, local state). Mount and unmount
|
|
66
|
+
* *content inside* a layer instead — an empty layer slot is cheap. Dev builds warn when the
|
|
67
|
+
* count changes, and log the stacked topology once at INFO (`Stacked glass: …`) — that line is
|
|
68
|
+
* this component working as designed.
|
|
69
|
+
*
|
|
70
|
+
* On iOS and web this renders plain views and the glass samples the window as always — no
|
|
71
|
+
* platform branches needed.
|
|
72
|
+
*/
|
|
73
|
+
const LiquidGlassStackBase: React.FC<ILiquidGlassStackProps> = ({
|
|
74
|
+
children,
|
|
75
|
+
style,
|
|
76
|
+
}: ILiquidGlassStackProps): React.ReactNode & React.ReactElement => {
|
|
77
|
+
const uid = useId();
|
|
78
|
+
|
|
79
|
+
const layers: ILiquidGlassStackLayerProps[] = [];
|
|
80
|
+
for (const child of React.Children.toArray(children)) {
|
|
81
|
+
if (React.isValidElement(child) && child.type === LiquidGlassStackLayer) {
|
|
82
|
+
layers.push(child.props as ILiquidGlassStackLayerProps);
|
|
83
|
+
} else if (React.isValidElement(child) || child != null) {
|
|
84
|
+
// A bare child is a layer without the marker. It is wrapped rather than
|
|
85
|
+
// dropped: silently losing a layer is what makes a stack look like the
|
|
86
|
+
// bug it is trying to avoid.
|
|
87
|
+
devWarnOnce(
|
|
88
|
+
"stack-non-layer-child",
|
|
89
|
+
"A direct child of <LiquidGlassStack> is not a <LiquidGlassStack.Layer>; it is wrapped " +
|
|
90
|
+
"in one, bottom to top. Prefer an explicit Layer — including conditional ones: put the " +
|
|
91
|
+
"condition inside a Layer that always mounts.",
|
|
92
|
+
);
|
|
93
|
+
layers.push({ children: child as React.ReactNode });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const layerCount = useRef(layers.length);
|
|
98
|
+
if (layerCount.current !== layers.length) {
|
|
99
|
+
devWarnOnce(
|
|
100
|
+
`stack-layer-count:${uid}`,
|
|
101
|
+
`A <LiquidGlassStack> went from ${layerCount.current} to ${layers.length} layers. That ` +
|
|
102
|
+
"changes the nesting depth and remounts every layer below the change — toggle content " +
|
|
103
|
+
"inside a static Layer instead.",
|
|
104
|
+
);
|
|
105
|
+
layerCount.current = layers.length;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const base = layers[0];
|
|
109
|
+
if (base === undefined) {
|
|
110
|
+
return <View style={style} />;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// The provider recording everything below layer k is id(k - 1). Ids are per-instance and
|
|
114
|
+
// internal; the registry only ever string-matches them.
|
|
115
|
+
const providerIdFor = (k: number): string => `stack:${uid}:${k}`;
|
|
116
|
+
|
|
117
|
+
// Built bottom-up. Every level is the *same* absolutely-positioned box inside the stack
|
|
118
|
+
// root, with an explicit z-order, rather than a re-derived flex box:
|
|
119
|
+
//
|
|
120
|
+
// - the base layer used to sit in `flex: 1` flow while every layer above it was an
|
|
121
|
+
// absolute overlay, so the base content was measured in a different box at every
|
|
122
|
+
// nesting depth. Layers with padding, insets or uneven heights (the lab's stack demo)
|
|
123
|
+
// then drew the same text once per depth, each copy at slightly different metrics —
|
|
124
|
+
// the smeared, overlapping layers from the device photos.
|
|
125
|
+
// - the flow box also let a layer overflow its parent, because nothing clipped it.
|
|
126
|
+
//
|
|
127
|
+
// Absolute boxes plus zIndex make each layer occupy the stack's box exactly once, in the
|
|
128
|
+
// order given, so a layer can never be laid out twice. The stack therefore needs its own
|
|
129
|
+
// size (a style with flex: 1 or a fixed height), which the README documents.
|
|
130
|
+
let subtree: React.ReactElement = (
|
|
131
|
+
<View
|
|
132
|
+
pointerEvents="box-none"
|
|
133
|
+
style={[StyleSheet.absoluteFill, styles.layer, base.style, { zIndex: 0 }]}
|
|
134
|
+
>
|
|
135
|
+
{base.children}
|
|
136
|
+
</View>
|
|
137
|
+
);
|
|
138
|
+
for (let k = 1; k < layers.length; k++) {
|
|
139
|
+
const layer = layers[k];
|
|
140
|
+
if (layer === undefined) continue;
|
|
141
|
+
subtree = (
|
|
142
|
+
<View style={[StyleSheet.absoluteFill, styles.layer, { zIndex: k }]}>
|
|
143
|
+
<LiquidGlassProvider
|
|
144
|
+
providerId={providerIdFor(k - 1)}
|
|
145
|
+
style={StyleSheet.absoluteFill}
|
|
146
|
+
>
|
|
147
|
+
{subtree}
|
|
148
|
+
</LiquidGlassProvider>
|
|
149
|
+
<View
|
|
150
|
+
pointerEvents="box-none"
|
|
151
|
+
style={[StyleSheet.absoluteFill, layer.style]}
|
|
152
|
+
>
|
|
153
|
+
<GlassStackProviderContext.Provider value={providerIdFor(k - 1)}>
|
|
154
|
+
{layer.children}
|
|
155
|
+
</GlassStackProviderContext.Provider>
|
|
156
|
+
</View>
|
|
157
|
+
</View>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return <View style={[styles.root, style]}>{subtree}</View>;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
LiquidGlassStackBase.displayName = `${COMPONENT_NAMES.LIQUID_GLASS_STACK}Base`;
|
|
165
|
+
|
|
166
|
+
type TLiquidGlassStackComponent = React.NamedExoticComponent<ILiquidGlassStackProps> & {
|
|
167
|
+
Layer: React.FC<ILiquidGlassStackLayerProps>;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const LiquidGlassStack: TLiquidGlassStackComponent = Object.assign(
|
|
171
|
+
memo<ILiquidGlassStackProps>(LiquidGlassStackBase),
|
|
172
|
+
{ Layer: LiquidGlassStackLayer },
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
LiquidGlassStack.displayName = COMPONENT_NAMES.LIQUID_GLASS_STACK;
|
|
176
|
+
|
|
177
|
+
const styles = StyleSheet.create({
|
|
178
|
+
// The stack must own a box (flex: 1 or a fixed size) now that its layers are absolute;
|
|
179
|
+
// `overflow: hidden` keeps a rounded stack from spilling a layer's glass outside it.
|
|
180
|
+
root: { flex: 1, overflow: "hidden" },
|
|
181
|
+
layer: { overflow: "visible" },
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export { LiquidGlassStack };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LiquidGlassStack } from "./LiquidGlassStack";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { forwardRef, memo, useCallback, useContext } from "react";
|
|
3
|
+
import type { ColorValue, View as RNView } from "react-native";
|
|
4
|
+
import { Platform, processColor, View } from "react-native";
|
|
5
|
+
|
|
6
|
+
import { COMPONENT_NAMES } from "../../constants";
|
|
7
|
+
import { GlassStackProviderContext } from "../../context";
|
|
8
|
+
import type {
|
|
9
|
+
IGlassLuminanceReading,
|
|
10
|
+
ILiquidGlassViewProps,
|
|
11
|
+
} from "../../interfaces";
|
|
12
|
+
import type { TGlassActiveRenderer } from "../../types";
|
|
13
|
+
import { supportsGlass } from "../../utils";
|
|
14
|
+
import { NativeLiquidGlassView } from "../../views";
|
|
15
|
+
|
|
16
|
+
const LiquidGlassViewBase = forwardRef<RNView, ILiquidGlassViewProps>(
|
|
17
|
+
(
|
|
18
|
+
{
|
|
19
|
+
children,
|
|
20
|
+
containerStyle,
|
|
21
|
+
style,
|
|
22
|
+
onRendererChange,
|
|
23
|
+
onBackdropLuminance,
|
|
24
|
+
providerId,
|
|
25
|
+
tint,
|
|
26
|
+
...nativeProps
|
|
27
|
+
}: ILiquidGlassViewProps,
|
|
28
|
+
ref: React.ForwardedRef<RNView>
|
|
29
|
+
): React.ReactElement => {
|
|
30
|
+
// Inside a LiquidGlassStack layer, the stack supplies the id of the provider recording
|
|
31
|
+
// everything below that layer. An explicit prop always wins; `undefined` outside any stack
|
|
32
|
+
// falls through to the native default. An array is a combined backdrop and rides the
|
|
33
|
+
// `providerIds` wire prop instead.
|
|
34
|
+
const stackProviderId = useContext(GlassStackProviderContext);
|
|
35
|
+
const resolvedProviderId = providerId ?? stackProviderId;
|
|
36
|
+
const singleProviderId = Array.isArray(resolvedProviderId)
|
|
37
|
+
? undefined
|
|
38
|
+
: resolvedProviderId;
|
|
39
|
+
const combinedProviderIds = Array.isArray(resolvedProviderId)
|
|
40
|
+
? resolvedProviderId
|
|
41
|
+
: undefined;
|
|
42
|
+
const handleRendererChange = useCallback(
|
|
43
|
+
(event: { nativeEvent: { renderer: TGlassActiveRenderer } }): void =>
|
|
44
|
+
onRendererChange?.(event.nativeEvent.renderer),
|
|
45
|
+
[onRendererChange]
|
|
46
|
+
);
|
|
47
|
+
const handleBackdropLuminance = useCallback(
|
|
48
|
+
(event: { nativeEvent: IGlassLuminanceReading }): void =>
|
|
49
|
+
onBackdropLuminance?.(event.nativeEvent),
|
|
50
|
+
[onBackdropLuminance]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const content: React.ReactNode = children ? (
|
|
54
|
+
<View pointerEvents="box-none" style={containerStyle}>
|
|
55
|
+
{children}
|
|
56
|
+
</View>
|
|
57
|
+
) : null;
|
|
58
|
+
|
|
59
|
+
// No glass renderer of any kind — an unregistered view manager would fail at render, so
|
|
60
|
+
// degrade to a plain view. Deliberately `supportsGlass`, not `supportsNativeGlass`: below
|
|
61
|
+
// iOS 26 the native view mounts the Metal renderer, which is glass all the same.
|
|
62
|
+
if (!supportsGlass) {
|
|
63
|
+
return (
|
|
64
|
+
<View ref={ref} style={style}>
|
|
65
|
+
{content}
|
|
66
|
+
</View>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Android declares `tint` as an Int and expects a processed colour. Expo's `Color` converter,
|
|
71
|
+
// which iOS uses, rejects `rgba()` and `PlatformColor` and mis-reads `#RRGGBBAA` as `#AARRGGBB`
|
|
72
|
+
// — so the platforms genuinely need different wire formats here.
|
|
73
|
+
const nativeTint =
|
|
74
|
+
Platform.OS === "android" ? processColor(tint) ?? undefined : tint;
|
|
75
|
+
// A recipe's own `tint` is processed on BOTH platforms: a colour string of any form becomes
|
|
76
|
+
// the ARGB number both natives take (Android's Int field, Expo's Color converter on iOS),
|
|
77
|
+
// which is also what `lerpMetal` produces on the UI thread — one wire format for the field.
|
|
78
|
+
const { metal, ...restProps } = nativeProps;
|
|
79
|
+
const nativeMetal =
|
|
80
|
+
metal?.tint != null
|
|
81
|
+
? {
|
|
82
|
+
...metal,
|
|
83
|
+
tint: (processColor(metal.tint) ?? undefined) as
|
|
84
|
+
| ColorValue
|
|
85
|
+
| undefined,
|
|
86
|
+
}
|
|
87
|
+
: metal;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<NativeLiquidGlassView
|
|
91
|
+
{...restProps}
|
|
92
|
+
metal={nativeMetal}
|
|
93
|
+
ref={ref}
|
|
94
|
+
providerId={singleProviderId}
|
|
95
|
+
providerIds={combinedProviderIds}
|
|
96
|
+
tint={nativeTint as ILiquidGlassViewProps["tint"]}
|
|
97
|
+
style={style}
|
|
98
|
+
onRendererChange={onRendererChange ? handleRendererChange : undefined}
|
|
99
|
+
onBackdropLuminance={
|
|
100
|
+
onBackdropLuminance ? handleBackdropLuminance : undefined
|
|
101
|
+
}
|
|
102
|
+
>
|
|
103
|
+
{content}
|
|
104
|
+
</NativeLiquidGlassView>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
LiquidGlassViewBase.displayName = `${COMPONENT_NAMES.LIQUID_GLASS_VIEW}Base`;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The ref is forwarded to the native view so this component can be wrapped in Reanimated's
|
|
112
|
+
* `createAnimatedComponent` and driven by `useAnimatedProps` — which is the only way to animate
|
|
113
|
+
* `metal` or `glow` at display rate, since both change every frame of a gesture and neither can
|
|
114
|
+
* wait on a React render.
|
|
115
|
+
*
|
|
116
|
+
* One caveat comes with that: animated props are written straight to the native view, so they skip
|
|
117
|
+
* the `providerId` array handling and the `processColor` above. Animate `metal` and `glow` freely;
|
|
118
|
+
* keep `providerId` and `tint` on the component itself.
|
|
119
|
+
*/
|
|
120
|
+
const LiquidGlassView: React.NamedExoticComponent<
|
|
121
|
+
ILiquidGlassViewProps & React.RefAttributes<RNView>
|
|
122
|
+
> = memo(LiquidGlassViewBase);
|
|
123
|
+
|
|
124
|
+
LiquidGlassView.displayName = COMPONENT_NAMES.LIQUID_GLASS_VIEW;
|
|
125
|
+
|
|
126
|
+
export { LiquidGlassView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LiquidGlassView } from "./LiquidGlassView";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const GLASS_VARIANTS = ["regular", "clear"] as const;
|
|
2
|
+
const GLASS_RENDERERS = ["auto", "native", "metal"] as const;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What `onRendererChange` can report.
|
|
6
|
+
*
|
|
7
|
+
* - `native` — Apple's `UIGlassEffect`. iOS 26+ only; Android has no equivalent.
|
|
8
|
+
* - `metal` — the custom Metal renderer on iOS.
|
|
9
|
+
* - `agsl` — the custom AGSL renderer on Android. API 33+.
|
|
10
|
+
* - `fallback-blur` — blur without refraction (`UIBlurEffect` on iOS, `RenderEffect` on Android 31–32).
|
|
11
|
+
* - `scrim` — Android 29–30: a live backdrop with a translucent scrim, no blur and no shader.
|
|
12
|
+
* - `none` — no hardware path; the component renders as a plain view.
|
|
13
|
+
*/
|
|
14
|
+
const GLASS_ACTIVE_RENDERERS = [
|
|
15
|
+
"native",
|
|
16
|
+
"metal",
|
|
17
|
+
"agsl",
|
|
18
|
+
"fallback-blur",
|
|
19
|
+
"scrim",
|
|
20
|
+
"none",
|
|
21
|
+
] as const;
|
|
22
|
+
const GLASS_CORNER_STYLES = ["continuous", "circular"] as const;
|
|
23
|
+
|
|
24
|
+
const DEFAULT_GLASS_VARIANT = "regular";
|
|
25
|
+
const DEFAULT_GLASS_RENDERER = "auto";
|
|
26
|
+
const DEFAULT_GLASS_CORNER_STYLE = "continuous";
|
|
27
|
+
|
|
28
|
+
const DEFAULT_HIGHLIGHT_ANGLE = 180;
|
|
29
|
+
const DEFAULT_BORDER_WIDTH = 1;
|
|
30
|
+
const DEFAULT_GLASS_OPACITY = 1;
|
|
31
|
+
|
|
32
|
+
const MIN_IOS_VERSION_FOR_NATIVE_GLASS = 26;
|
|
33
|
+
|
|
34
|
+
/** `RenderNode` — the floor for a live backdrop, and so for any glass at all on Android. */
|
|
35
|
+
const MIN_ANDROID_SDK_FOR_NATIVE_GLASS = 29;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Pairs a `LiquidGlassView` with the `LiquidGlassProvider` that supplies its backdrop.
|
|
39
|
+
* Android-only; ignored on iOS, which captures what lies beneath each glass in the window.
|
|
40
|
+
*/
|
|
41
|
+
const DEFAULT_PROVIDER_ID = "default";
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
GLASS_VARIANTS,
|
|
45
|
+
GLASS_RENDERERS,
|
|
46
|
+
GLASS_ACTIVE_RENDERERS,
|
|
47
|
+
GLASS_CORNER_STYLES,
|
|
48
|
+
DEFAULT_GLASS_VARIANT,
|
|
49
|
+
DEFAULT_GLASS_RENDERER,
|
|
50
|
+
DEFAULT_GLASS_CORNER_STYLE,
|
|
51
|
+
DEFAULT_HIGHLIGHT_ANGLE,
|
|
52
|
+
DEFAULT_BORDER_WIDTH,
|
|
53
|
+
DEFAULT_GLASS_OPACITY,
|
|
54
|
+
MIN_IOS_VERSION_FOR_NATIVE_GLASS,
|
|
55
|
+
MIN_ANDROID_SDK_FOR_NATIVE_GLASS,
|
|
56
|
+
DEFAULT_PROVIDER_ID,
|
|
57
|
+
};
|