glacia-native 0.5.1 → 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/LICENSE +29 -4
- package/README.md +111 -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 -267
- package/lib/module/Button.js +57 -36
- package/lib/module/Card.js +32 -20
- 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 -124
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +12 -5
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +47 -40
- 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 +74 -58
- 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 +60 -40
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -43
- package/lib/module/TabBar.js +62 -50
- package/lib/module/Tabs.js +3 -2
- 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 +45 -13
- 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 +75 -0
- package/lib/module/internal/fallback.js +110 -20
- package/lib/module/internal/glass-routing.js +154 -30
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +17 -0
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +34 -2
- 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 +39 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +31 -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/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +27 -2
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +13 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +36 -0
- package/package.json +15 -4
- 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 -797
- package/src/Button.tsx +196 -60
- package/src/Card.tsx +106 -33
- 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 +86 -325
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +19 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +143 -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 +147 -90
- 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 +100 -54
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +80 -58
- package/src/TabBar.tsx +118 -84
- package/src/Tabs.tsx +5 -0
- 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 +48 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +70 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +89 -0
- package/src/internal/fallback.tsx +158 -20
- package/src/internal/glass-routing.ts +211 -34
- package/src/internal/glow.tsx +62 -0
- package/src/internal/initials.ts +7 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +26 -0
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +34 -1
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -317
- package/lib/module/Feedback.js +0 -386
- package/lib/module/Form.js +0 -164
- package/lib/module/Forms2.js +0 -454
- package/lib/module/Message.js +0 -88
- package/lib/module/Overlays.js +0 -328
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -99
- package/lib/module/ai.js +0 -280
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -67
- 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 -71
- 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 -778
- package/src/Feedback.tsx +0 -969
- package/src/Form.tsx +0 -425
- package/src/Forms2.tsx +0 -1014
- package/src/Message.tsx +0 -219
- package/src/Overlays.tsx +0 -685
- package/src/Pickers.tsx +0 -590
- package/src/Table.tsx +0 -231
- package/src/ai.tsx +0 -707
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -183
- 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
package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
package expo.modules.liquidglass.glass
|
|
2
|
+
|
|
3
|
+
import android.graphics.HardwareRenderer
|
|
4
|
+
import android.graphics.Matrix
|
|
5
|
+
import android.graphics.PixelFormat
|
|
6
|
+
import android.graphics.RenderNode
|
|
7
|
+
import android.hardware.HardwareBuffer
|
|
8
|
+
import android.media.Image
|
|
9
|
+
import android.media.ImageReader
|
|
10
|
+
import android.os.Build
|
|
11
|
+
import android.os.Handler
|
|
12
|
+
import android.os.Looper
|
|
13
|
+
import androidx.annotation.RequiresApi
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The `adaptive` prop's sensor: the mean luminance of the backdrop under a glass view.
|
|
17
|
+
*
|
|
18
|
+
* The providers' content is drawn — through the same provider-to-local transforms the glass
|
|
19
|
+
* records it with, scaled down to [SIZE] x [SIZE] — into a private surface by a private
|
|
20
|
+
* [HardwareRenderer], and read back through an [ImageReader] on the main looper. That is the
|
|
21
|
+
* pattern Compose's `GraphicsLayer.toImageBitmap` uses for its own live layers, and the one the
|
|
22
|
+
* startup shader probe already uses here; the display list is walked by the RenderThread as
|
|
23
|
+
* usual, the GPU rasterises 64 pixels, and nothing blocks on the readback. Modeled on the
|
|
24
|
+
* AndroidLiquidGlass catalog's adaptive-luminance demo (Apache-2.0, see NOTICE), which scales its
|
|
25
|
+
* layer to a 5x5 bitmap and averages it.
|
|
26
|
+
*
|
|
27
|
+
* `PixelCopy` of the window was the alternative: async too, and it sees `SurfaceView` video —
|
|
28
|
+
* but it captures the glass *itself* and whatever the app draws on it, and a label that flips
|
|
29
|
+
* colour on the very value it feeds back into is a feedback loop. This reads the backdrop alone.
|
|
30
|
+
*
|
|
31
|
+
* One request in flight at a time; the host throttles how often it asks.
|
|
32
|
+
*/
|
|
33
|
+
@RequiresApi(Build.VERSION_CODES.Q)
|
|
34
|
+
internal class GlassLuminanceProbe {
|
|
35
|
+
|
|
36
|
+
private var reader: ImageReader? = null
|
|
37
|
+
private var renderer: HardwareRenderer? = null
|
|
38
|
+
private val node = RenderNode("GlassLuminanceProbe")
|
|
39
|
+
private val handler = Handler(Looper.getMainLooper())
|
|
40
|
+
|
|
41
|
+
private var pending = false
|
|
42
|
+
private var onResult: ((Float) -> Unit)? = null
|
|
43
|
+
private var released = false
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param width the glass view's own size, px — the scale that maps its footprint to the probe
|
|
47
|
+
* @return false when a request is already in flight or the probe could not be set up
|
|
48
|
+
*/
|
|
49
|
+
fun request(
|
|
50
|
+
sources: List<BackdropSource>,
|
|
51
|
+
transforms: List<Matrix>,
|
|
52
|
+
width: Int,
|
|
53
|
+
height: Int,
|
|
54
|
+
onResult: (Float) -> Unit
|
|
55
|
+
): Boolean {
|
|
56
|
+
if (released || pending || width <= 0 || height <= 0) return false
|
|
57
|
+
if (transforms.size < sources.size) return false
|
|
58
|
+
val reader = obtainReader() ?: return false
|
|
59
|
+
val renderer = obtainRenderer(reader) ?: return false
|
|
60
|
+
|
|
61
|
+
node.setPosition(0, 0, SIZE, SIZE)
|
|
62
|
+
val canvas = node.beginRecording(SIZE, SIZE)
|
|
63
|
+
try {
|
|
64
|
+
canvas.scale(SIZE.toFloat() / width, SIZE.toFloat() / height)
|
|
65
|
+
for (i in sources.indices) {
|
|
66
|
+
val content = sources[i].contentNode ?: continue
|
|
67
|
+
val save = canvas.save()
|
|
68
|
+
canvas.concat(transforms[i])
|
|
69
|
+
canvas.drawRenderNode(content)
|
|
70
|
+
canvas.restoreToCount(save)
|
|
71
|
+
}
|
|
72
|
+
} finally {
|
|
73
|
+
node.endRecording()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.onResult = onResult
|
|
77
|
+
pending = true
|
|
78
|
+
return try {
|
|
79
|
+
renderer.setContentRoot(node)
|
|
80
|
+
// No waitForPresent: the sync is what blocks, briefly; the draw lands on the reader's
|
|
81
|
+
// listener whenever the RenderThread gets to it.
|
|
82
|
+
renderer.createRenderRequest().syncAndDraw()
|
|
83
|
+
true
|
|
84
|
+
} catch (t: Throwable) {
|
|
85
|
+
GlassDebug.log("Luminance probe could not draw: $t")
|
|
86
|
+
pending = false
|
|
87
|
+
false
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fun release() {
|
|
92
|
+
released = true
|
|
93
|
+
pending = false
|
|
94
|
+
onResult = null
|
|
95
|
+
try {
|
|
96
|
+
renderer?.destroy()
|
|
97
|
+
} catch (_: Throwable) {
|
|
98
|
+
// Best-effort teardown.
|
|
99
|
+
}
|
|
100
|
+
renderer = null
|
|
101
|
+
reader?.close()
|
|
102
|
+
reader = null
|
|
103
|
+
node.discardDisplayList()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private fun obtainReader(): ImageReader? {
|
|
107
|
+
reader?.let { return it }
|
|
108
|
+
return try {
|
|
109
|
+
ImageReader.newInstance(
|
|
110
|
+
SIZE,
|
|
111
|
+
SIZE,
|
|
112
|
+
PixelFormat.RGBA_8888,
|
|
113
|
+
2,
|
|
114
|
+
HardwareBuffer.USAGE_GPU_COLOR_OUTPUT or
|
|
115
|
+
HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE or
|
|
116
|
+
HardwareBuffer.USAGE_CPU_READ_OFTEN
|
|
117
|
+
).also { created ->
|
|
118
|
+
created.setOnImageAvailableListener({ r -> deliver(r) }, handler)
|
|
119
|
+
reader = created
|
|
120
|
+
}
|
|
121
|
+
} catch (t: Throwable) {
|
|
122
|
+
GlassDebug.log("Luminance probe could not create its reader: $t")
|
|
123
|
+
null
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private fun obtainRenderer(reader: ImageReader): HardwareRenderer? {
|
|
128
|
+
renderer?.let { return it }
|
|
129
|
+
return try {
|
|
130
|
+
HardwareRenderer().also { created ->
|
|
131
|
+
created.setSurface(reader.surface)
|
|
132
|
+
renderer = created
|
|
133
|
+
}
|
|
134
|
+
} catch (t: Throwable) {
|
|
135
|
+
GlassDebug.log("Luminance probe could not create its renderer: $t")
|
|
136
|
+
null
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private fun deliver(reader: ImageReader) {
|
|
141
|
+
val image = try {
|
|
142
|
+
reader.acquireLatestImage()
|
|
143
|
+
} catch (_: Throwable) {
|
|
144
|
+
null
|
|
145
|
+
} ?: return
|
|
146
|
+
val luminance = try {
|
|
147
|
+
readLuminance(image)
|
|
148
|
+
} finally {
|
|
149
|
+
image.close()
|
|
150
|
+
}
|
|
151
|
+
if (released) return
|
|
152
|
+
pending = false
|
|
153
|
+
onResult?.invoke(luminance)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Alpha-weighted mean of Rec.709 luma over the probe, in the sRGB gamma space the shader's own
|
|
158
|
+
* `luma` uses. The surface is premultiplied, so a straight sum of the channels IS the
|
|
159
|
+
* alpha-weighted sum, and dividing by the alpha total leaves the mean of what was actually
|
|
160
|
+
* recorded — a glass overhanging a gap the provider never drew is judged by the content it
|
|
161
|
+
* does cover. Nothing covered at all reads as mid-grey, which flips no polarity.
|
|
162
|
+
*/
|
|
163
|
+
private fun readLuminance(image: Image): Float {
|
|
164
|
+
val plane = image.planes[0]
|
|
165
|
+
val buffer = plane.buffer
|
|
166
|
+
val rowStride = plane.rowStride
|
|
167
|
+
val pixelStride = plane.pixelStride
|
|
168
|
+
var sum = 0f
|
|
169
|
+
var cover = 0f
|
|
170
|
+
for (y in 0 until SIZE) {
|
|
171
|
+
for (x in 0 until SIZE) {
|
|
172
|
+
val i = y * rowStride + x * pixelStride
|
|
173
|
+
if (i + 3 >= buffer.limit()) continue
|
|
174
|
+
val r = (buffer.get(i).toInt() and 0xFF) / 255f
|
|
175
|
+
val g = (buffer.get(i + 1).toInt() and 0xFF) / 255f
|
|
176
|
+
val b = (buffer.get(i + 2).toInt() and 0xFF) / 255f
|
|
177
|
+
val a = (buffer.get(i + 3).toInt() and 0xFF) / 255f
|
|
178
|
+
sum += 0.2126f * r + 0.7152f * g + 0.0722f * b
|
|
179
|
+
cover += a
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return if (cover > 1e-3f) (sum / cover).coerceIn(0f, 1f) else 0.5f
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private companion object {
|
|
186
|
+
/** 64 samples: coarse enough to be free, fine enough that one bright card cannot flip a bar. */
|
|
187
|
+
const val SIZE = 8
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
package expo.modules.liquidglass.glass
|
|
2
|
+
|
|
3
|
+
import android.view.View
|
|
4
|
+
import kotlin.math.abs
|
|
5
|
+
import kotlin.math.max
|
|
6
|
+
import kotlin.math.min
|
|
7
|
+
import kotlin.math.sqrt
|
|
8
|
+
import kotlin.math.tanh
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The spring choreography behind the Android `interactive` flag: a glow that rises on press and
|
|
12
|
+
* chases the finger, a subtle whole-view inflation, and the jelly — a rubber-band translation and
|
|
13
|
+
* an anisotropic stretch, both pure functions of one spring-smoothed drag displacement. Values are
|
|
14
|
+
* read back by the host on every animation frame; this class never touches uniforms or scale
|
|
15
|
+
* itself.
|
|
16
|
+
*
|
|
17
|
+
* Model and constants are Kyant's (InteractiveHighlight / LiquidButton / DampedDragAnimation,
|
|
18
|
+
* Apache-2.0 — see NOTICE): glow ζ 0.5 / k 300; position ζ 1.0 / k 1000 while tracking the finger
|
|
19
|
+
* and ζ 0.5 / k 300 for the release return; scale ζ 0.65 / k 250 (the mean of Kyant's 0.6 / 0.7
|
|
20
|
+
* per-axis pair). The two position modes matter: an earlier round ran ζ 0.5 / 300 during the drag
|
|
21
|
+
* as well — that is Kyant's *release* spec — and the underdamped X and Y springs rang
|
|
22
|
+
* independently on every direction change, which read as the view wobbling through a slow curved
|
|
23
|
+
* drag. Tracking is critically damped (lag, never ring); only the way home is bouncy.
|
|
24
|
+
*
|
|
25
|
+
* The jelly is displacement-based, not velocity-based — LiquidButton's `layerBlock`: translation
|
|
26
|
+
* saturates through tanh (linear for small pulls, asymptoting at the view's min dimension), and
|
|
27
|
+
* stretch grows along the displacement's dominant axis, axis-projected so it turns continuously
|
|
28
|
+
* with the drag and never compresses. A velocity-driven cut of this stretch existed and pulsed:
|
|
29
|
+
* |spring velocity| is a rectified oscillation the moment anything rings. Deriving follow, stretch
|
|
30
|
+
* and hotspot from the single smoothed displacement is what keeps the release coherent — one
|
|
31
|
+
* spring decays and everything settles together.
|
|
32
|
+
*
|
|
33
|
+
* Integration is semi-implicit Euler, unconditionally stable at these stiffnesses with the dt
|
|
34
|
+
* clamp below (the stiff tracking spring has omega_0 = sqrt(1000) ≈ 31.6/s; a 32 ms step puts
|
|
35
|
+
* omega_0·dt ≈ 1.0, inside the method's stability bound of 2, with critical damping on top).
|
|
36
|
+
*
|
|
37
|
+
* The driver is [View.postOnAnimation], re-posted only while a spring is unsettled — the same
|
|
38
|
+
* self-gating standard the geometry pre-draw listener sets: it runs in the Choreographer's
|
|
39
|
+
* animation stage, *before* traversal, so a step's `invalidate()` draws in the same frame, and
|
|
40
|
+
* nothing at all is scheduled once everything has settled. This is deliberately not a persistent
|
|
41
|
+
* `Choreographer.postFrameCallback`, which the geometry watcher's KDoc rejects for burning power
|
|
42
|
+
* at idle. A drag held at a fixed displacement settles and stops posting; the held transform and
|
|
43
|
+
* uniforms simply persist — a pinned rubber band costs no frames.
|
|
44
|
+
*
|
|
45
|
+
* [reset] must call `removeCallbacks`: `postOnAnimation` on a detached view parks the runnable in
|
|
46
|
+
* the view's `HandlerActionQueue`, which executes it on the *next attach* — a stale spring step
|
|
47
|
+
* firing into a recycled view. The host calls [reset] from `release()` (detach and destroy both
|
|
48
|
+
* reach it) and when `interactive` flips off.
|
|
49
|
+
*/
|
|
50
|
+
internal class GlassPressAnimator(
|
|
51
|
+
private val host: View,
|
|
52
|
+
private val onFrame: () -> Unit,
|
|
53
|
+
) {
|
|
54
|
+
|
|
55
|
+
/** 0 at rest — which is what keeps the shader's uniform-coherent glow branch switched off. */
|
|
56
|
+
val glow: Float get() = glowSpring.value.coerceIn(0f, 1f)
|
|
57
|
+
|
|
58
|
+
/** Touch position, view-local px — the same space the shader's `pixels` lives in. */
|
|
59
|
+
val posX: Float get() = xSpring.value
|
|
60
|
+
val posY: Float get() = ySpring.value
|
|
61
|
+
|
|
62
|
+
/** Relative scale for the host to multiply onto its own base; floored away from singularity. */
|
|
63
|
+
val scale: Float get() = max(scaleSpring.value, SCALE_FLOOR)
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The magnetic follow: the drag displacement through a saturating tanh — an initial
|
|
67
|
+
* [FOLLOW_SLOPE] fraction of the pull that asymptotes at the view's min dimension, so a
|
|
68
|
+
* cross-screen drag meets growing rubber-band resistance instead of a hard stop (Kyant's
|
|
69
|
+
* `maxOffset * tanh(slope * offset / maxOffset)`). Springs back to zero on release because
|
|
70
|
+
* [releasePress] retargets the position springs at the origin.
|
|
71
|
+
*/
|
|
72
|
+
val followX: Float get() = followFor(xSpring.value - originX)
|
|
73
|
+
val followY: Float get() = followFor(ySpring.value - originY)
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The jelly stretch, ≥ 1 per axis: [STRETCH_MAX] scaled by the displacement's projection onto
|
|
77
|
+
* the axis (|d·cos θ| = dx²/r — continuous through every drag direction, no axis handoff),
|
|
78
|
+
* normalized by the view's max dimension, with Kyant's aspect correction so a wide view does
|
|
79
|
+
* not stretch further along its long side. The across axis is simply left alone — Kyant's
|
|
80
|
+
* stretch never compresses. Held displacement holds its stretch; release decays it on the same
|
|
81
|
+
* spring as the follow.
|
|
82
|
+
*/
|
|
83
|
+
val stretchX: Float get() = 1f + stretchGain(xSpring.value - originX, ySpring.value - originY, host.width, host.height)
|
|
84
|
+
val stretchY: Float get() = 1f + stretchGain(ySpring.value - originY, xSpring.value - originX, host.height, host.width)
|
|
85
|
+
|
|
86
|
+
private fun followFor(offset: Float): Float {
|
|
87
|
+
val maxOffset = min(host.width, host.height).toFloat()
|
|
88
|
+
if (maxOffset < 1f) return 0f
|
|
89
|
+
return maxOffset * tanh(FOLLOW_SLOPE * offset / maxOffset)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private fun stretchGain(along: Float, across: Float, alongSize: Int, acrossSize: Int): Float {
|
|
93
|
+
if (alongSize < 1 || acrossSize < 1) return 0f
|
|
94
|
+
val r = sqrt(along * along + across * across)
|
|
95
|
+
if (r < 1f) return 0f
|
|
96
|
+
val maxDim = max(alongSize, acrossSize).toFloat()
|
|
97
|
+
val aspect = min(alongSize.toFloat() / acrossSize.toFloat(), 1f)
|
|
98
|
+
return STRETCH_MAX * min((along * along / r) / maxDim, 1f) * aspect
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private val glowSpring = Spring(0f, stiffness = 300f, dampingRatio = 0.5f, eps = 0.001f, epsV = 0.01f)
|
|
102
|
+
private val xSpring = Spring(0f, stiffness = TRACK_STIFFNESS, dampingRatio = TRACK_DAMPING, eps = 0.25f, epsV = 2.5f)
|
|
103
|
+
private val ySpring = Spring(0f, stiffness = TRACK_STIFFNESS, dampingRatio = TRACK_DAMPING, eps = 0.25f, epsV = 2.5f)
|
|
104
|
+
private val scaleSpring = Spring(1f, stiffness = 250f, dampingRatio = 0.65f, eps = 0.001f, epsV = 0.01f)
|
|
105
|
+
|
|
106
|
+
private var originX = 0f
|
|
107
|
+
private var originY = 0f
|
|
108
|
+
|
|
109
|
+
private var posted = false
|
|
110
|
+
private var lastFrameNanos = 0L
|
|
111
|
+
|
|
112
|
+
private val step = object : Runnable {
|
|
113
|
+
override fun run() {
|
|
114
|
+
posted = false
|
|
115
|
+
if (!host.isAttachedToWindow) return
|
|
116
|
+
val now = System.nanoTime()
|
|
117
|
+
// Clamped so a stalled window (app switch, expensive frame) cannot integrate a huge step.
|
|
118
|
+
val dt = min((now - lastFrameNanos) / 1e9f, MAX_DT_SECONDS)
|
|
119
|
+
lastFrameNanos = now
|
|
120
|
+
|
|
121
|
+
glowSpring.step(dt)
|
|
122
|
+
xSpring.step(dt)
|
|
123
|
+
ySpring.step(dt)
|
|
124
|
+
scaleSpring.step(dt)
|
|
125
|
+
|
|
126
|
+
val done = glowSpring.settled && xSpring.settled && ySpring.settled && scaleSpring.settled
|
|
127
|
+
if (done) {
|
|
128
|
+
// Snap and push one final frame so the glow lands at exactly 0 and the branch turns off.
|
|
129
|
+
glowSpring.snap()
|
|
130
|
+
xSpring.snap()
|
|
131
|
+
ySpring.snap()
|
|
132
|
+
scaleSpring.snap()
|
|
133
|
+
}
|
|
134
|
+
onFrame()
|
|
135
|
+
if (!done) schedule()
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Position snaps to the touch — the glow must bloom under the finger, not glide in. */
|
|
140
|
+
fun pressDown(x: Float, y: Float) {
|
|
141
|
+
originX = x
|
|
142
|
+
originY = y
|
|
143
|
+
xSpring.retune(TRACK_STIFFNESS, TRACK_DAMPING)
|
|
144
|
+
ySpring.retune(TRACK_STIFFNESS, TRACK_DAMPING)
|
|
145
|
+
xSpring.snapTo(x)
|
|
146
|
+
ySpring.snapTo(y)
|
|
147
|
+
glowSpring.target = 1f
|
|
148
|
+
scaleSpring.target = PRESS_SCALE
|
|
149
|
+
start()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
fun follow(x: Float, y: Float) {
|
|
153
|
+
xSpring.target = x
|
|
154
|
+
ySpring.target = y
|
|
155
|
+
start()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* UP and CANCEL both land here. The position springs retune to the underdamped return spec and
|
|
160
|
+
* retarget the press origin — the one deliberate bounce, and it is coherent because follow,
|
|
161
|
+
* stretch and hotspot all read this same decaying displacement (Kyant releases to
|
|
162
|
+
* `startPosition` the same way); the glow rides along and fades before the drift could read as
|
|
163
|
+
* the hotspot wandering.
|
|
164
|
+
*/
|
|
165
|
+
fun releasePress() {
|
|
166
|
+
glowSpring.target = 0f
|
|
167
|
+
scaleSpring.target = 1f
|
|
168
|
+
xSpring.retune(HOME_STIFFNESS, HOME_DAMPING)
|
|
169
|
+
ySpring.retune(HOME_STIFFNESS, HOME_DAMPING)
|
|
170
|
+
xSpring.target = originX
|
|
171
|
+
ySpring.target = originY
|
|
172
|
+
start()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Hard stop: everything to rest instantly, and nothing left in any queue. */
|
|
176
|
+
fun reset() {
|
|
177
|
+
host.removeCallbacks(step)
|
|
178
|
+
posted = false
|
|
179
|
+
glowSpring.snapTo(0f)
|
|
180
|
+
scaleSpring.snapTo(1f)
|
|
181
|
+
xSpring.snapTo(xSpring.value)
|
|
182
|
+
ySpring.snapTo(ySpring.value)
|
|
183
|
+
// Follow and stretch read (pos - origin): collapsing the origin onto the position zeroes both.
|
|
184
|
+
originX = xSpring.value
|
|
185
|
+
originY = ySpring.value
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
private fun start() {
|
|
189
|
+
if (posted) return
|
|
190
|
+
lastFrameNanos = System.nanoTime()
|
|
191
|
+
schedule()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private fun schedule() {
|
|
195
|
+
posted = true
|
|
196
|
+
host.postOnAnimation(step)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private class Spring(
|
|
200
|
+
initial: Float,
|
|
201
|
+
stiffness: Float,
|
|
202
|
+
dampingRatio: Float,
|
|
203
|
+
private val eps: Float,
|
|
204
|
+
private val epsV: Float,
|
|
205
|
+
) {
|
|
206
|
+
var value = initial
|
|
207
|
+
var target = initial
|
|
208
|
+
var velocity = 0f
|
|
209
|
+
|
|
210
|
+
private var stiffness = 0f
|
|
211
|
+
private var damping = 0f
|
|
212
|
+
|
|
213
|
+
init {
|
|
214
|
+
retune(stiffness, dampingRatio)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
fun retune(stiffness: Float, dampingRatio: Float) {
|
|
218
|
+
this.stiffness = stiffness
|
|
219
|
+
this.damping = 2f * dampingRatio * sqrt(stiffness)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
fun step(dt: Float) {
|
|
223
|
+
velocity += (-stiffness * (value - target) - damping * velocity) * dt
|
|
224
|
+
value += velocity * dt
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
val settled: Boolean get() = abs(value - target) < eps && abs(velocity) < epsV
|
|
228
|
+
|
|
229
|
+
fun snap() {
|
|
230
|
+
value = target
|
|
231
|
+
velocity = 0f
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
fun snapTo(v: Float) {
|
|
235
|
+
value = v
|
|
236
|
+
target = v
|
|
237
|
+
velocity = 0f
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private companion object {
|
|
242
|
+
/** iOS's press inflation is subtle; the toolkit can layer bigger scales on top later. */
|
|
243
|
+
const val PRESS_SCALE = 1.035f
|
|
244
|
+
|
|
245
|
+
/** Paranoia floor: `computeProviderToLocal` inverts our matrix, and 0 is not invertible. */
|
|
246
|
+
const val SCALE_FLOOR = 0.9f
|
|
247
|
+
|
|
248
|
+
const val MAX_DT_SECONDS = 0.032f
|
|
249
|
+
|
|
250
|
+
/** Tracking the finger: critically damped and stiff — liquid lag, never a ring (Kyant's value spec). */
|
|
251
|
+
const val TRACK_STIFFNESS = 1000f
|
|
252
|
+
const val TRACK_DAMPING = 1f
|
|
253
|
+
|
|
254
|
+
/** The way home after release: Kyant's return spec — underdamped, the one deliberate bounce. */
|
|
255
|
+
const val HOME_STIFFNESS = 300f
|
|
256
|
+
const val HOME_DAMPING = 0.5f
|
|
257
|
+
|
|
258
|
+
/** Initial fraction of the pull the view follows; tanh saturates it at the view's min dimension. */
|
|
259
|
+
const val FOLLOW_SLOPE = 0.12f
|
|
260
|
+
|
|
261
|
+
/** Stretch gain at a full-max-dimension displacement along an axis, before aspect correction. */
|
|
262
|
+
const val STRETCH_MAX = 0.12f
|
|
263
|
+
}
|
|
264
|
+
}
|