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,171 @@
|
|
|
1
|
+
package expo.modules.liquidglass.enums
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.types.Enumerable
|
|
4
|
+
import expo.modules.liquidglass.glass.GlassTier
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Entry names are matched against the JS string literals verbatim, so they are lowercase and
|
|
8
|
+
* intentionally do not follow Kotlin enum-naming convention. 1:1 with `ios/Enums/GlassVariant.swift`.
|
|
9
|
+
*/
|
|
10
|
+
@Suppress("EnumEntryName")
|
|
11
|
+
enum class GlassVariant : Enumerable {
|
|
12
|
+
regular,
|
|
13
|
+
clear;
|
|
14
|
+
|
|
15
|
+
val metalDefaults: MetalDefaults
|
|
16
|
+
get() = when (this) {
|
|
17
|
+
regular -> REGULAR_DEFAULTS
|
|
18
|
+
clear -> CLEAR_DEFAULTS
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private companion object {
|
|
22
|
+
// ios/Enums/GlassVariant.swift:32-67. Do NOT copy the stored-property defaults in
|
|
23
|
+
// GlassSurfaceView.swift:16-42 — those are dead code, overwritten by applyAppearance() in
|
|
24
|
+
// init before any frame is drawn, and they differ from these.
|
|
25
|
+
val REGULAR_DEFAULTS = MetalDefaults(
|
|
26
|
+
blurRadius = 0f,
|
|
27
|
+
refractionWidth = 20f,
|
|
28
|
+
refractionHeight = 20f,
|
|
29
|
+
refractionAmount = 60f,
|
|
30
|
+
refractionDepth = 1f,
|
|
31
|
+
curvePower = 1f,
|
|
32
|
+
curveBias = 0f,
|
|
33
|
+
dispersionAmount = 6f,
|
|
34
|
+
light = 0f,
|
|
35
|
+
frost = 0.36f,
|
|
36
|
+
saturation = 1.8f,
|
|
37
|
+
highlightIntensity = 0.25f,
|
|
38
|
+
noise = 0.05f,
|
|
39
|
+
borderOpacity = 0.28f
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
val CLEAR_DEFAULTS = MetalDefaults(
|
|
43
|
+
blurRadius = 0f,
|
|
44
|
+
refractionWidth = 10f,
|
|
45
|
+
refractionHeight = 10f,
|
|
46
|
+
refractionAmount = 30f,
|
|
47
|
+
refractionDepth = 0f,
|
|
48
|
+
curvePower = 1f,
|
|
49
|
+
curveBias = 0f,
|
|
50
|
+
dispersionAmount = 10f,
|
|
51
|
+
light = 0f,
|
|
52
|
+
frost = 0.06f,
|
|
53
|
+
saturation = 1.15f,
|
|
54
|
+
highlightIntensity = 0.35f,
|
|
55
|
+
noise = 0.06f,
|
|
56
|
+
borderOpacity = 0.4f
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Per-variant fallbacks for every `metal` field that has one. Lengths are in **dp**, matching iOS
|
|
63
|
+
* points; they are converted to pixels during resolution.
|
|
64
|
+
*
|
|
65
|
+
* Note there is no `dispersionReach`: iOS falls back to [refractionHeight] for it. See
|
|
66
|
+
* `GlassAppearance.resolve`.
|
|
67
|
+
*/
|
|
68
|
+
data class MetalDefaults(
|
|
69
|
+
val blurRadius: Float,
|
|
70
|
+
val refractionWidth: Float,
|
|
71
|
+
val refractionHeight: Float,
|
|
72
|
+
val refractionAmount: Float,
|
|
73
|
+
val refractionDepth: Float,
|
|
74
|
+
val curvePower: Float,
|
|
75
|
+
val curveBias: Float,
|
|
76
|
+
val dispersionAmount: Float,
|
|
77
|
+
val light: Float,
|
|
78
|
+
val frost: Float,
|
|
79
|
+
val saturation: Float,
|
|
80
|
+
val highlightIntensity: Float,
|
|
81
|
+
val noise: Float,
|
|
82
|
+
val borderOpacity: Float
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The `renderer` prop. `native` has no Android meaning — there is no Apple material to ask for —
|
|
87
|
+
* so it resolves to the shader path exactly as it does on iOS below 26.
|
|
88
|
+
*/
|
|
89
|
+
@Suppress("EnumEntryName")
|
|
90
|
+
enum class GlassBackend : Enumerable {
|
|
91
|
+
auto,
|
|
92
|
+
native,
|
|
93
|
+
metal
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* iOS's `CALayerCornerCurve`, honoured since the squircle port. `continuous` renders the Apple
|
|
98
|
+
* corner family calibrated in research/05 — shader SDF, clip path and border all on one curve via
|
|
99
|
+
* [expo.modules.liquidglass.glass.ContinuousCorners]. This deliberately *exceeds* the iOS Metal
|
|
100
|
+
* renderer (which is circular-only; `cornerStyle` there only reaches `CALayerCornerCurve` for
|
|
101
|
+
* content clipping) and matches the iOS 26 native renderer instead.
|
|
102
|
+
*/
|
|
103
|
+
@Suppress("EnumEntryName")
|
|
104
|
+
enum class GlassCornerStyle : Enumerable {
|
|
105
|
+
continuous,
|
|
106
|
+
circular
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* `metal.progressiveBlur.direction` — the axis the blur ramp travels along, named for where the
|
|
111
|
+
* blur *increases* toward. `down` is the classic bottom-bar scrim: sharp at the top of the view,
|
|
112
|
+
* melting into blur at its bottom edge.
|
|
113
|
+
*/
|
|
114
|
+
@Suppress("EnumEntryName")
|
|
115
|
+
enum class GlassBlurDirection : Enumerable {
|
|
116
|
+
down,
|
|
117
|
+
up,
|
|
118
|
+
left,
|
|
119
|
+
right;
|
|
120
|
+
|
|
121
|
+
/** Whether the ramp runs along y. */
|
|
122
|
+
val vertical: Boolean get() = this == down || this == up
|
|
123
|
+
|
|
124
|
+
/** Whether the ramp starts from the far edge of its axis (bottom or right). */
|
|
125
|
+
val reversed: Boolean get() = this == up || this == left
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* `metal.android.quality`. Android-only; iOS silently drops the key.
|
|
130
|
+
*
|
|
131
|
+
* Selects which compiled AGSL variant the view draws with. The dispersion loop needs a
|
|
132
|
+
* compile-time-constant bound to unroll, so the tiers cannot be one shader driven by a uniform.
|
|
133
|
+
*/
|
|
134
|
+
@Suppress("EnumEntryName")
|
|
135
|
+
enum class GlassQuality : Enumerable {
|
|
136
|
+
low,
|
|
137
|
+
medium,
|
|
138
|
+
high
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* `metal.android.maxTier`. Android-only; iOS silently drops the key.
|
|
143
|
+
*
|
|
144
|
+
* Caps how far up [expo.modules.liquidglass.glass.GlassTier] a view is allowed to go. It can only
|
|
145
|
+
* ever *lower* the tier — asking for `agsl` on an API-31 device still gets `fallback-blur`, because
|
|
146
|
+
* this is a ceiling and not an override.
|
|
147
|
+
*
|
|
148
|
+
* The entry names are the same strings `onRendererChange` reports, so a caller can compare what it
|
|
149
|
+
* asked for against what it got without a second vocabulary. That is why `fallback-blur` is
|
|
150
|
+
* backtick-quoted rather than renamed: [expo.modules.kotlin.types.EnumTypeConverter] matches the JS
|
|
151
|
+
* string against `Enum.name` verbatim.
|
|
152
|
+
*
|
|
153
|
+
* **Do not give this enum a constructor parameter or a backing field.** The converter switches to
|
|
154
|
+
* matching on the single declared field the moment one exists, and the name matching above would
|
|
155
|
+
* stop working. [tier] is a getter, so it has no backing field.
|
|
156
|
+
*/
|
|
157
|
+
@Suppress("EnumEntryName")
|
|
158
|
+
enum class GlassTierCeiling : Enumerable {
|
|
159
|
+
agsl,
|
|
160
|
+
`fallback-blur`,
|
|
161
|
+
scrim,
|
|
162
|
+
none;
|
|
163
|
+
|
|
164
|
+
val tier: GlassTier
|
|
165
|
+
get() = when (this) {
|
|
166
|
+
agsl -> GlassTier.FULL
|
|
167
|
+
`fallback-blur` -> GlassTier.BLUR
|
|
168
|
+
scrim -> GlassTier.SCRIM
|
|
169
|
+
none -> GlassTier.NONE
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
package expo.modules.liquidglass.glass
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import android.view.ViewGroup
|
|
5
|
+
import expo.modules.liquidglass.LiquidGlassView
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The check that keeps a mis-wired backdrop from taking the process down.
|
|
9
|
+
*
|
|
10
|
+
* Sampling a provider is not a read — it is a `RenderNode` reference. `recordBackdrop` puts the
|
|
11
|
+
* provider's node *inside* the glass view's own node, while the provider's recording already
|
|
12
|
+
* contains the node of every view in its subtree. Two edges, opposite directions:
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* provider.node -> glass.node for every glass view in the provider's subtree
|
|
16
|
+
* glass.node -> provider.node for every provider that glass view samples
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Close a loop between them and `hwui` has a cyclic render tree. Nothing in the framework checks
|
|
20
|
+
* for that: `RenderNode::prepareTreeImpl` walks children depth-first and recurses until the
|
|
21
|
+
* RenderThread's stack hits its guard page — `SIGSEGV`, `SEGV_ACCERR`, a tombstone whose backtrace
|
|
22
|
+
* is 256 identical frames. It is not recoverable and it is not reported as anything to do with
|
|
23
|
+
* glass.
|
|
24
|
+
*
|
|
25
|
+
* The loop is easy to build by accident. A provider around a screen and a glass view *inside* that
|
|
26
|
+
* screen sharing the default id is enough, and that pairing happens silently — the view resolves an
|
|
27
|
+
* id, not a relationship. So this runs on every resolve, in every build, and a view that would form
|
|
28
|
+
* a loop draws as a plain scrim with one line in logcat instead.
|
|
29
|
+
*
|
|
30
|
+
* Cheap because it is bounded twice: [MAX_DEPTH] on the chain, and a visited set so a diamond is
|
|
31
|
+
* walked once. It runs once per attach — [LiquidGlassView.resolveProviders] latches the verdict.
|
|
32
|
+
*
|
|
33
|
+
* Stacked glass is unaffected: `LiquidGlassStack` puts each layer's glass as a **sibling** of the
|
|
34
|
+
* provider it reads, never a descendant, so no edge ever points back.
|
|
35
|
+
*/
|
|
36
|
+
internal object BackdropGraph {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* How many provider hops one glass view's backdrop may traverse.
|
|
40
|
+
*
|
|
41
|
+
* Every hop is a real nesting level in the render tree, and the depth a *correct* topology needs
|
|
42
|
+
* is small: `LiquidGlassStack` spends one hop per layer boundary, so 8 is roughly twice the
|
|
43
|
+
* deepest stack anyone has reason to build. The cap is not a tuning knob — it is the backstop for
|
|
44
|
+
* loops this walk cannot see, which is why it is deliberately far above real use. A chain that
|
|
45
|
+
* reaches it is a mistake whatever its shape.
|
|
46
|
+
*/
|
|
47
|
+
const val MAX_DEPTH = 8
|
|
48
|
+
|
|
49
|
+
enum class Kind {
|
|
50
|
+
/** The view sits inside a provider it samples — the one-hop loop, and the common mistake. */
|
|
51
|
+
INSIDE_ITS_OWN_PROVIDER,
|
|
52
|
+
|
|
53
|
+
/** A longer loop: two or more providers whose subtrees sample each other. */
|
|
54
|
+
LOOP,
|
|
55
|
+
|
|
56
|
+
/** No loop found, but the chain is deeper than [MAX_DEPTH]. */
|
|
57
|
+
TOO_DEEP,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class Fault(val kind: Kind, val providerId: String)
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param view the view about to record
|
|
64
|
+
* @param sources what it resolved, in the order it would composite them
|
|
65
|
+
* @return null when the graph is safe to record
|
|
66
|
+
*/
|
|
67
|
+
fun inspect(view: LiquidGlassView, sources: List<BackdropSource>): Fault? {
|
|
68
|
+
if (sources.isEmpty()) return null
|
|
69
|
+
val path = ArrayList<LiquidGlassView>(MAX_DEPTH + 1)
|
|
70
|
+
path.add(view)
|
|
71
|
+
return walk(sources, path, HashSet(), 0)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Depth-first over glass-view -> provider -> glass-view edges.
|
|
76
|
+
*
|
|
77
|
+
* [path] is the current chain, root first; a node already on it closes a loop. [settled] is every
|
|
78
|
+
* node whose own subgraph came back clean — reaching one again cannot reveal a loop the first
|
|
79
|
+
* visit missed, so it is skipped, which is what keeps a wide tree linear.
|
|
80
|
+
*/
|
|
81
|
+
private fun walk(
|
|
82
|
+
sources: List<BackdropSource>,
|
|
83
|
+
path: MutableList<LiquidGlassView>,
|
|
84
|
+
settled: MutableSet<LiquidGlassView>,
|
|
85
|
+
depth: Int,
|
|
86
|
+
): Fault? {
|
|
87
|
+
if (depth >= MAX_DEPTH) {
|
|
88
|
+
return Fault(Kind.TOO_DEEP, sources.first().providerId)
|
|
89
|
+
}
|
|
90
|
+
val reachable = ArrayList<LiquidGlassView>()
|
|
91
|
+
for (source in sources) {
|
|
92
|
+
reachable.clear()
|
|
93
|
+
collectGlass(source.sourceView, reachable)
|
|
94
|
+
for (next in reachable) {
|
|
95
|
+
if (path.contains(next)) {
|
|
96
|
+
// Closing on the root at the first hop is the "glass inside its own provider" case, and
|
|
97
|
+
// it gets its own message because the fix is a different one.
|
|
98
|
+
val kind =
|
|
99
|
+
if (depth == 0 && next === path[0]) Kind.INSIDE_ITS_OWN_PROVIDER else Kind.LOOP
|
|
100
|
+
return Fault(kind, source.providerId)
|
|
101
|
+
}
|
|
102
|
+
if (!settled.add(next)) continue
|
|
103
|
+
val onward = next.peekSampledSources()
|
|
104
|
+
if (onward.isEmpty()) continue
|
|
105
|
+
path.add(next)
|
|
106
|
+
walk(onward, path, settled, depth + 1)?.let { return it }
|
|
107
|
+
path.removeAt(path.size - 1)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return null
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Every glass view in [root]'s subtree — all of them, not just the topmost.
|
|
115
|
+
*
|
|
116
|
+
* The walk does not stop at a glass view or at a nested provider: both keep drawing their
|
|
117
|
+
* children into the same recording, so anything below them is still reachable from [root]'s node
|
|
118
|
+
* and can still close a loop.
|
|
119
|
+
*/
|
|
120
|
+
private fun collectGlass(root: View, out: MutableList<LiquidGlassView>) {
|
|
121
|
+
if (root is LiquidGlassView) out.add(root)
|
|
122
|
+
if (root !is ViewGroup) return
|
|
123
|
+
for (i in 0 until root.childCount) collectGlass(root.getChildAt(i), out)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
fun describe(fault: Fault): String = when (fault.kind) {
|
|
127
|
+
Kind.INSIDE_ITS_OWN_PROVIDER ->
|
|
128
|
+
"A <LiquidGlassView> is INSIDE the <LiquidGlassProvider providerId=\"${fault.providerId}\"> " +
|
|
129
|
+
"it samples. That is a cycle in the render tree and it crashes the RenderThread, so this " +
|
|
130
|
+
"view is drawing as a plain scrim instead. Make it a SIBLING of the provider — or, if it " +
|
|
131
|
+
"never meant to pair with that provider at all, give one of them an id of its own. A " +
|
|
132
|
+
"provider wrapped around a whole screen shares the default id with every glass view on it."
|
|
133
|
+
|
|
134
|
+
Kind.LOOP ->
|
|
135
|
+
"A <LiquidGlassProvider providerId=\"${fault.providerId}\"> is part of a loop: providers " +
|
|
136
|
+
"whose subtrees sample each other. That is a cycle in the render tree and it crashes the " +
|
|
137
|
+
"RenderThread, so this view is drawing as a plain scrim instead. Backdrops have to flow " +
|
|
138
|
+
"one way — pick which layer is underneath and let only the other one sample it."
|
|
139
|
+
|
|
140
|
+
Kind.TOO_DEEP ->
|
|
141
|
+
"A <LiquidGlassView> reading <LiquidGlassProvider providerId=\"${fault.providerId}\"> is " +
|
|
142
|
+
"more than $MAX_DEPTH providers deep. Each level is real nesting in the render tree, so " +
|
|
143
|
+
"this view is drawing as a plain scrim instead. Stacked glass needs one level per layer " +
|
|
144
|
+
"boundary; if you are not stacking that many, something is sampling in a loop."
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package expo.modules.liquidglass.glass
|
|
2
|
+
|
|
3
|
+
import android.graphics.RenderNode
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import android.view.View
|
|
6
|
+
import androidx.annotation.RequiresApi
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The seam between a `LiquidGlassProviderView` and the glass views that sample it.
|
|
10
|
+
*
|
|
11
|
+
* `ExpoView` extends `LinearLayout` rather than `FrameLayout`, so this is an interface rather than
|
|
12
|
+
* a base class in the style of Dimezis' `BlurTarget`.
|
|
13
|
+
*/
|
|
14
|
+
internal interface BackdropSource {
|
|
15
|
+
val providerId: String
|
|
16
|
+
|
|
17
|
+
/** The provider itself — glass views need it to work out where they sit inside the recording. */
|
|
18
|
+
val sourceView: View
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Bumped whenever the recorded content may have changed.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately **not** bumped from `dispatchDraw`: consumers redraw in response to a change, and
|
|
24
|
+
* a counter that ticks on every draw would make every redraw look like a change, which is the
|
|
25
|
+
* shape of an invalidation loop.
|
|
26
|
+
*/
|
|
27
|
+
val contentGeneration: Int
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The recorded display list of everything that should show through the glass, or `null` below
|
|
31
|
+
* API 29 / before the provider's first draw.
|
|
32
|
+
*
|
|
33
|
+
* This is a **live reference**, not a snapshot: unchanged children keep re-referencing their own
|
|
34
|
+
* `RenderNode`s, so the content stays current without re-recording.
|
|
35
|
+
*/
|
|
36
|
+
@get:RequiresApi(Build.VERSION_CODES.Q)
|
|
37
|
+
val contentNode: RenderNode?
|
|
38
|
+
|
|
39
|
+
fun addConsumer(consumer: BackdropConsumer)
|
|
40
|
+
|
|
41
|
+
fun removeConsumer(consumer: BackdropConsumer)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Called after the provider has finished a recording pass.
|
|
46
|
+
*
|
|
47
|
+
* Public only because `LiquidGlassProviderView` has to be public for Expo to instantiate it, and
|
|
48
|
+
* Kotlin will not let a public class narrow an override to `internal`. Not part of this package's
|
|
49
|
+
* API — do not implement it outside the module.
|
|
50
|
+
*/
|
|
51
|
+
fun interface BackdropConsumer {
|
|
52
|
+
fun onBackdropChanged()
|
|
53
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
package expo.modules.liquidglass.glass
|
|
2
|
+
|
|
3
|
+
import android.graphics.Path
|
|
4
|
+
import android.graphics.RectF
|
|
5
|
+
import kotlin.math.cos
|
|
6
|
+
import kotlin.math.min
|
|
7
|
+
import kotlin.math.pow
|
|
8
|
+
import kotlin.math.sin
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The continuous-corner ("squircle") curve family, shared by the Kotlin `Path`s and the AGSL SDF.
|
|
12
|
+
*
|
|
13
|
+
* One curve, two renderers: a corner is a superellipse quadrant in an E x E cell,
|
|
14
|
+
* `((E-x)/E)^n + ((E-y)/E)^n = 1`, with the circular corner as its exact (E = r, n = 2) member.
|
|
15
|
+
* The constants are calibrated against the PaintCode reverse-engineering of Apple's continuous
|
|
16
|
+
* rounded rect — max deviation 7.3e-3 r, sub-pixel at every UI radius. Method, ground-truth
|
|
17
|
+
* provenance and error tables: `docs/android-port/research/05-continuous-corner-calibration.md`.
|
|
18
|
+
*
|
|
19
|
+
* The resolver and the path builder must stay in lock-step with the shader's `sdGlassRect` /
|
|
20
|
+
* `gradGlassRect` (GlassShaderSource.FUNCTIONS): the border stroke is drawn on these paths *over*
|
|
21
|
+
* the shader's rim, and at a 1 px border against a 0.75 dp rim, sub-pixel disagreement reads as a
|
|
22
|
+
* double edge.
|
|
23
|
+
*/
|
|
24
|
+
internal object ContinuousCorners {
|
|
25
|
+
|
|
26
|
+
/** Apple's corner extent per unit radius — where the curve departs the straight edge. Exact. */
|
|
27
|
+
const val EXTENT = 1.52866483f
|
|
28
|
+
|
|
29
|
+
/** Fitted superellipse exponent at full extent (research/05, fit 1). */
|
|
30
|
+
const val N_FULL = 3.3418f
|
|
31
|
+
|
|
32
|
+
/** Below this, an exponent is treated as circular — must match the shader's `n > 2.001` test. */
|
|
33
|
+
const val CIRCULAR_N = 2f
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Resolves per-corner cell extents and exponents, in the field order of [CornerRadii]
|
|
37
|
+
* (TL, TR, BR, BL — index via [IDX_TL] etc).
|
|
38
|
+
*
|
|
39
|
+
* Rules (research/05): desired `E = EXTENT * r`; if the two desired extents on an edge overflow
|
|
40
|
+
* the side, both scale by `side / sum` and a corner takes the min of its two edges' scales; then
|
|
41
|
+
* a hard cap at `min(halfW, halfH)` keeps every cell inside its quadrant. `clampedTo` guarantees
|
|
42
|
+
* `r_a + r_b <= side`, so the scale never pushes E below r — `E/r` stays in `[1, EXTENT]` and
|
|
43
|
+
* the exponent blend never extrapolates. At the capsule limit (E = r) the exponent lands on
|
|
44
|
+
* exactly 2, which is what makes pills keep true circular ends.
|
|
45
|
+
*/
|
|
46
|
+
fun resolve(
|
|
47
|
+
radii: CornerRadii,
|
|
48
|
+
continuous: Boolean,
|
|
49
|
+
width: Float,
|
|
50
|
+
height: Float,
|
|
51
|
+
outExtents: FloatArray,
|
|
52
|
+
outShapes: FloatArray
|
|
53
|
+
) {
|
|
54
|
+
val r = floatArrayOf(radii.topLeft, radii.topRight, radii.bottomRight, radii.bottomLeft)
|
|
55
|
+
if (!continuous || radii.isZero) {
|
|
56
|
+
for (i in 0..3) {
|
|
57
|
+
outExtents[i] = r[i]
|
|
58
|
+
outShapes[i] = CIRCULAR_N
|
|
59
|
+
}
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fun edgeScale(a: Float, b: Float, side: Float): Float {
|
|
64
|
+
val sum = (a + b) * EXTENT
|
|
65
|
+
return if (sum > side && sum > 0f) side / sum else 1f
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
val top = edgeScale(r[IDX_TL], r[IDX_TR], width)
|
|
69
|
+
val bottom = edgeScale(r[IDX_BL], r[IDX_BR], width)
|
|
70
|
+
val left = edgeScale(r[IDX_TL], r[IDX_BL], height)
|
|
71
|
+
val right = edgeScale(r[IDX_TR], r[IDX_BR], height)
|
|
72
|
+
|
|
73
|
+
val scale = floatArrayOf(
|
|
74
|
+
min(top, left), // TL
|
|
75
|
+
min(top, right), // TR
|
|
76
|
+
min(bottom, right), // BR
|
|
77
|
+
min(bottom, left) // BL
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
val cap = min(width, height) / 2f
|
|
81
|
+
for (i in 0..3) {
|
|
82
|
+
val radius = r[i]
|
|
83
|
+
if (radius <= 0f) {
|
|
84
|
+
outExtents[i] = 0f
|
|
85
|
+
outShapes[i] = CIRCULAR_N
|
|
86
|
+
continue
|
|
87
|
+
}
|
|
88
|
+
val extent = min(radius * EXTENT * scale[i], cap)
|
|
89
|
+
val blend = ((extent / radius - 1f) / (EXTENT - 1f)).coerceIn(0f, 1f)
|
|
90
|
+
outExtents[i] = extent
|
|
91
|
+
outShapes[i] = CIRCULAR_N + (N_FULL - CIRCULAR_N) * blend
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Appends the continuous rounded rect to [path] as a clockwise contour.
|
|
97
|
+
*
|
|
98
|
+
* Corners are sampled from the same superellipse the shader evaluates — a polyline, not the
|
|
99
|
+
* PaintCode beziers — so Path and SDF agree exactly by construction (research/05). At
|
|
100
|
+
* [SEGMENTS_PER_CORNER] steps the chord sagitta stays under ~0.1 px for any extent that fits a
|
|
101
|
+
* phone screen; the paths are rebuilt only on geometry change, so the vertex count is free.
|
|
102
|
+
*
|
|
103
|
+
* `P(theta) = C + a*E*cos(theta)^(2/n) + b*E*sin(theta)^(2/n)` for corner point C and unit
|
|
104
|
+
* edge vectors a (incoming, clockwise) and b (outgoing) — at n = 2 this is the circular arc.
|
|
105
|
+
*/
|
|
106
|
+
fun addContinuousRoundRect(
|
|
107
|
+
path: Path,
|
|
108
|
+
bounds: RectF,
|
|
109
|
+
extents: FloatArray,
|
|
110
|
+
shapes: FloatArray
|
|
111
|
+
) {
|
|
112
|
+
val l = bounds.left
|
|
113
|
+
val t = bounds.top
|
|
114
|
+
val rr = bounds.right
|
|
115
|
+
val bb = bounds.bottom
|
|
116
|
+
|
|
117
|
+
// Start on the top edge, at the TL corner's exit point.
|
|
118
|
+
path.moveTo(l + extents[IDX_TL], t)
|
|
119
|
+
path.lineTo(rr - extents[IDX_TR], t)
|
|
120
|
+
corner(path, rr, t, -1f, 0f, 0f, 1f, extents[IDX_TR], shapes[IDX_TR]) // TR
|
|
121
|
+
path.lineTo(rr, bb - extents[IDX_BR])
|
|
122
|
+
corner(path, rr, bb, 0f, -1f, -1f, 0f, extents[IDX_BR], shapes[IDX_BR]) // BR
|
|
123
|
+
path.lineTo(l + extents[IDX_BL], bb)
|
|
124
|
+
corner(path, l, bb, 1f, 0f, 0f, -1f, extents[IDX_BL], shapes[IDX_BL]) // BL
|
|
125
|
+
path.lineTo(l, t + extents[IDX_TL])
|
|
126
|
+
corner(path, l, t, 0f, 1f, 1f, 0f, extents[IDX_TL], shapes[IDX_TL]) // TL
|
|
127
|
+
path.close()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* One corner: from `C + a*E` to `C + b*E`. `(ax, ay)` points from the corner back along the
|
|
132
|
+
* incoming edge, `(bx, by)` forward along the outgoing edge, both unit.
|
|
133
|
+
*
|
|
134
|
+
* The curve is the superellipse about the corner cell's INNER point `C + a*E + b*E`:
|
|
135
|
+
* `P(theta) = C + a*E*(1 - sin^(2/n) theta) + b*E*(1 - cos^(2/n) theta)` — at n = 2 the
|
|
136
|
+
* circular arc. The tempting "polar" form `C + a*E*cos^p + b*E*sin^p` has the same endpoints
|
|
137
|
+
* but is the superellipse about the CORNER — the corner curve mirrored through its chord,
|
|
138
|
+
* bulging into the shape. It shipped for one build: the border stroked an "inverse squircle"
|
|
139
|
+
* hairline inside the glass, measured on device as exactly `nnorm(p - corner) = 0.99*E`
|
|
140
|
+
* (PLAN F53). The SDF was never wrong — only this path.
|
|
141
|
+
*/
|
|
142
|
+
private fun corner(
|
|
143
|
+
path: Path,
|
|
144
|
+
cx: Float,
|
|
145
|
+
cy: Float,
|
|
146
|
+
ax: Float,
|
|
147
|
+
ay: Float,
|
|
148
|
+
bx: Float,
|
|
149
|
+
by: Float,
|
|
150
|
+
extent: Float,
|
|
151
|
+
n: Float
|
|
152
|
+
) {
|
|
153
|
+
if (extent < MIN_EXTENT_PX) {
|
|
154
|
+
path.lineTo(cx, cy)
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
val exponent = 2.0 / n
|
|
158
|
+
for (i in 1..SEGMENTS_PER_CORNER) {
|
|
159
|
+
val theta = (i.toDouble() / SEGMENTS_PER_CORNER) * (Math.PI / 2.0)
|
|
160
|
+
val ca = 1.0 - sin(theta).pow(exponent)
|
|
161
|
+
val sb = 1.0 - cos(theta).pow(exponent)
|
|
162
|
+
path.lineTo(
|
|
163
|
+
cx + (ax * ca.toFloat() + bx * sb.toFloat()) * extent,
|
|
164
|
+
cy + (ay * ca.toFloat() + by * sb.toFloat()) * extent
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// CornerRadii field order.
|
|
170
|
+
const val IDX_TL = 0
|
|
171
|
+
const val IDX_TR = 1
|
|
172
|
+
const val IDX_BR = 2
|
|
173
|
+
const val IDX_BL = 3
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The shader's `float4` packing, which is **not** the field order:
|
|
177
|
+
* `.x` = bottom-left, `.y` = bottom-right, `.z` = top-right, `.w` = top-left.
|
|
178
|
+
*/
|
|
179
|
+
fun writeShaderVec(values: FloatArray, out: FloatArray) {
|
|
180
|
+
out[0] = values[IDX_BL]
|
|
181
|
+
out[1] = values[IDX_BR]
|
|
182
|
+
out[2] = values[IDX_TR]
|
|
183
|
+
out[3] = values[IDX_TL]
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private const val SEGMENTS_PER_CORNER = 32
|
|
187
|
+
private const val MIN_EXTENT_PX = 0.5f
|
|
188
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package expo.modules.liquidglass.glass
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.types.Either
|
|
4
|
+
import expo.modules.liquidglass.records.GlassCornerRadii
|
|
5
|
+
import kotlin.math.min
|
|
6
|
+
|
|
7
|
+
/** Per-corner radii in pixels. */
|
|
8
|
+
internal data class CornerRadii(
|
|
9
|
+
val topLeft: Float,
|
|
10
|
+
val topRight: Float,
|
|
11
|
+
val bottomRight: Float,
|
|
12
|
+
val bottomLeft: Float
|
|
13
|
+
) {
|
|
14
|
+
val isZero: Boolean
|
|
15
|
+
get() = topLeft == 0f && topRight == 0f && bottomRight == 0f && bottomLeft == 0f
|
|
16
|
+
|
|
17
|
+
/** A radius larger than half the shorter side is not representable; iOS clamps the same way. */
|
|
18
|
+
fun clampedTo(width: Float, height: Float): CornerRadii {
|
|
19
|
+
val limit = min(width, height) / 2f
|
|
20
|
+
return CornerRadii(
|
|
21
|
+
min(topLeft, limit),
|
|
22
|
+
min(topRight, limit),
|
|
23
|
+
min(bottomRight, limit),
|
|
24
|
+
min(bottomLeft, limit)
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** `Path.addRoundRect` wants eight floats: TL-x, TL-y, TR-x, TR-y, BR-x, BR-y, BL-x, BL-y. */
|
|
29
|
+
fun writePathRadii(out: FloatArray) {
|
|
30
|
+
out[0] = topLeft; out[1] = topLeft
|
|
31
|
+
out[2] = topRight; out[3] = topRight
|
|
32
|
+
out[4] = bottomRight; out[5] = bottomRight
|
|
33
|
+
out[6] = bottomLeft; out[7] = bottomLeft
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Each radius reduced by [amount], floored at zero — the border path's half-stroke shrink. */
|
|
37
|
+
fun insetBy(amount: Float): CornerRadii = CornerRadii(
|
|
38
|
+
(topLeft - amount).coerceAtLeast(0f),
|
|
39
|
+
(topRight - amount).coerceAtLeast(0f),
|
|
40
|
+
(bottomRight - amount).coerceAtLeast(0f),
|
|
41
|
+
(bottomLeft - amount).coerceAtLeast(0f)
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
val ZERO = CornerRadii(0f, 0f, 0f, 0f)
|
|
46
|
+
|
|
47
|
+
fun from(value: Either<Double, GlassCornerRadii>?, density: Float): CornerRadii {
|
|
48
|
+
if (value == null) return ZERO
|
|
49
|
+
if (value.`is`(Double::class)) {
|
|
50
|
+
val radius = value.first().toFloat() * density
|
|
51
|
+
return CornerRadii(radius, radius, radius, radius)
|
|
52
|
+
}
|
|
53
|
+
val radii = value.second()
|
|
54
|
+
return CornerRadii(
|
|
55
|
+
(radii.topLeft * density).toFloat(),
|
|
56
|
+
(radii.topRight * density).toFloat(),
|
|
57
|
+
(radii.bottomRight * density).toFloat(),
|
|
58
|
+
(radii.bottomLeft * density).toFloat()
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|