glacia-native 0.5.2 → 0.6.1
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 +156 -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 +12 -10
- 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 +212 -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,327 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import type { LayoutChangeEvent } from "react-native";
|
|
4
|
+
import { I18nManager, StyleSheet, View } from "react-native";
|
|
5
|
+
import { Gesture, GestureDetector } from "react-native-gesture-handler";
|
|
6
|
+
import Animated, {
|
|
7
|
+
runOnJS,
|
|
8
|
+
useAnimatedProps,
|
|
9
|
+
useAnimatedStyle,
|
|
10
|
+
useSharedValue,
|
|
11
|
+
withSpring,
|
|
12
|
+
} from "react-native-reanimated";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
ABSOLUTE_FILL,
|
|
16
|
+
GLASS_SLIDER_THUMB_METAL,
|
|
17
|
+
GLASS_SLIDER_THUMB_PRESSED_METAL,
|
|
18
|
+
GLOW_SPRING,
|
|
19
|
+
SLIDER_OVERSHOOT_MAX,
|
|
20
|
+
SLIDER_THUMB_HEIGHT,
|
|
21
|
+
SLIDER_THUMB_PRESSED_SCALE,
|
|
22
|
+
SLIDER_THUMB_WIDTH,
|
|
23
|
+
SLIDER_TRACK_HEIGHT,
|
|
24
|
+
SLIDER_VELOCITY_DIVISOR,
|
|
25
|
+
THUMB_SHADOW,
|
|
26
|
+
} from "../../constants";
|
|
27
|
+
import { LiquidGlassProvider, LiquidGlassView } from "../../core";
|
|
28
|
+
import { useDampedDrag, useEchoFilter } from "../../hooks";
|
|
29
|
+
import type { ILiquidGlassSliderProps } from "../../interfaces";
|
|
30
|
+
import { useGlassUITheme } from "../../theme";
|
|
31
|
+
import { lerpMetal } from "../../utils";
|
|
32
|
+
|
|
33
|
+
const AnimatedGlassView = Animated.createAnimatedComponent(LiquidGlassView);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The catalog's `LiquidSlider`: a 6dp track under the same 40x24 glass thumb the toggle uses.
|
|
37
|
+
*
|
|
38
|
+
* Two things separate it from an ordinary slider. Its velocity divisor is **10** rather than the
|
|
39
|
+
* toggle's 50, so the same jelly reads five times stronger — this is the control the effect was
|
|
40
|
+
* tuned on. And a tap on the track does not jump: it routes through the full press/animate/release
|
|
41
|
+
* choreography, so seeking looks exactly like grabbing.
|
|
42
|
+
*/
|
|
43
|
+
const LiquidGlassSliderBase: React.FC<ILiquidGlassSliderProps> = ({
|
|
44
|
+
value = 0,
|
|
45
|
+
onValueChange,
|
|
46
|
+
onSlidingComplete,
|
|
47
|
+
onEdgeReached,
|
|
48
|
+
minimumValue = 0,
|
|
49
|
+
maximumValue = 1,
|
|
50
|
+
disabled = false,
|
|
51
|
+
accentColor,
|
|
52
|
+
trackColor,
|
|
53
|
+
thumbMetal,
|
|
54
|
+
thumbPressedMetal,
|
|
55
|
+
providerId,
|
|
56
|
+
style,
|
|
57
|
+
}: ILiquidGlassSliderProps): React.ReactElement => {
|
|
58
|
+
const layerId = `glass-ui-slider-${useId()}`;
|
|
59
|
+
const { colors } = useGlassUITheme();
|
|
60
|
+
const accent = accentColor ?? colors.accent;
|
|
61
|
+
const track = trackColor ?? colors.switchTrack;
|
|
62
|
+
const direction = I18nManager.isRTL ? -1 : 1;
|
|
63
|
+
|
|
64
|
+
const span = Math.max(maximumValue - minimumValue, 1e-6);
|
|
65
|
+
const [width, setWidth] = useState(0);
|
|
66
|
+
const trackWidth = useSharedValue(0);
|
|
67
|
+
const restMetal = thumbMetal ?? GLASS_SLIDER_THUMB_METAL;
|
|
68
|
+
const heldMetal = thumbPressedMetal ?? GLASS_SLIDER_THUMB_PRESSED_METAL;
|
|
69
|
+
const echo = useEchoFilter<number>();
|
|
70
|
+
const mounted = useRef(false);
|
|
71
|
+
|
|
72
|
+
const drag = useDampedDrag({
|
|
73
|
+
range: [minimumValue, maximumValue],
|
|
74
|
+
initialValue: value,
|
|
75
|
+
pressedScale: SLIDER_THUMB_PRESSED_SCALE,
|
|
76
|
+
velocityDivisor: SLIDER_VELOCITY_DIVISOR,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The rubber band past either stop: the finger's travel beyond the end, accumulated raw and
|
|
81
|
+
* pushed through a saturating tanh so the thumb is carried at most `SLIDER_OVERSHOOT_MAX`
|
|
82
|
+
* further — iOS 26's slider does this and clicks at the stop; the catalog's dead-stops.
|
|
83
|
+
* `edgeArmed` fires `onEdgeReached` once per arrival, re-arming when the thumb leaves the end.
|
|
84
|
+
*/
|
|
85
|
+
const overshootRaw = useSharedValue(0);
|
|
86
|
+
const overshoot = useSharedValue(0);
|
|
87
|
+
const edgeArmed = useSharedValue(true);
|
|
88
|
+
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
trackWidth.value = width;
|
|
91
|
+
}, [trackWidth, width]);
|
|
92
|
+
|
|
93
|
+
// An external `value` plays the full grab choreography. The control's own reports come back
|
|
94
|
+
// through this same prop and must be told apart — see `useEchoFilter` for why "the last one
|
|
95
|
+
// reported" is not enough.
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!mounted.current) {
|
|
98
|
+
mounted.current = true;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (echo.isEcho(value)) return;
|
|
102
|
+
drag.animateTo(value);
|
|
103
|
+
}, [drag, echo, value]);
|
|
104
|
+
|
|
105
|
+
const emit = useCallback(
|
|
106
|
+
(next: number): void => {
|
|
107
|
+
echo.emitted(next);
|
|
108
|
+
onValueChange?.(next);
|
|
109
|
+
},
|
|
110
|
+
[echo, onValueChange]
|
|
111
|
+
);
|
|
112
|
+
const emitComplete = useCallback(
|
|
113
|
+
(next: number): void => {
|
|
114
|
+
onSlidingComplete?.(next);
|
|
115
|
+
},
|
|
116
|
+
[onSlidingComplete]
|
|
117
|
+
);
|
|
118
|
+
const emitEdge = useCallback(
|
|
119
|
+
(edge: "min" | "max"): void => {
|
|
120
|
+
onEdgeReached?.(edge);
|
|
121
|
+
},
|
|
122
|
+
[onEdgeReached]
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const pan = Gesture.Pan()
|
|
126
|
+
.enabled(!disabled)
|
|
127
|
+
.minDistance(0)
|
|
128
|
+
.shouldCancelWhenOutside(false)
|
|
129
|
+
.onBegin(() => {
|
|
130
|
+
drag.press();
|
|
131
|
+
overshootRaw.value = 0;
|
|
132
|
+
edgeArmed.value = true;
|
|
133
|
+
})
|
|
134
|
+
.onChange((event) => {
|
|
135
|
+
if (trackWidth.value <= 0) return;
|
|
136
|
+
const before = drag.targetValue.value;
|
|
137
|
+
// Track width maps 1:1 onto the full range.
|
|
138
|
+
drag.dragBy((direction * event.changeX * span) / trackWidth.value);
|
|
139
|
+
const after = drag.targetValue.value;
|
|
140
|
+
const atMin = after <= minimumValue + 1e-9;
|
|
141
|
+
const atMax = after >= maximumValue - 1e-9;
|
|
142
|
+
|
|
143
|
+
// Past a stop the finger keeps moving and the value cannot: that surplus is the band.
|
|
144
|
+
if (
|
|
145
|
+
(atMin && direction * event.changeX < 0) ||
|
|
146
|
+
(atMax && direction * event.changeX > 0)
|
|
147
|
+
) {
|
|
148
|
+
overshootRaw.value += event.changeX;
|
|
149
|
+
} else {
|
|
150
|
+
overshootRaw.value = 0;
|
|
151
|
+
}
|
|
152
|
+
overshoot.value =
|
|
153
|
+
SLIDER_OVERSHOOT_MAX *
|
|
154
|
+
Math.tanh(overshootRaw.value / (SLIDER_OVERSHOOT_MAX * 4));
|
|
155
|
+
|
|
156
|
+
if ((atMin || atMax) && edgeArmed.value && before !== after) {
|
|
157
|
+
edgeArmed.value = false;
|
|
158
|
+
runOnJS(emitEdge)(atMin ? "min" : "max");
|
|
159
|
+
} else if (!atMin && !atMax) {
|
|
160
|
+
edgeArmed.value = true;
|
|
161
|
+
}
|
|
162
|
+
runOnJS(emit)(after);
|
|
163
|
+
})
|
|
164
|
+
.onFinalize(() => {
|
|
165
|
+
drag.release();
|
|
166
|
+
overshootRaw.value = 0;
|
|
167
|
+
overshoot.value = withSpring(0, GLOW_SPRING);
|
|
168
|
+
runOnJS(emitComplete)(drag.targetValue.value);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// A tap seeks, but plays the whole grab rather than jumping.
|
|
172
|
+
const tap = Gesture.Tap()
|
|
173
|
+
.enabled(!disabled)
|
|
174
|
+
.maxDuration(10000)
|
|
175
|
+
.onEnd((event) => {
|
|
176
|
+
if (trackWidth.value <= 0) return;
|
|
177
|
+
const fraction = Math.min(1, Math.max(0, event.x / trackWidth.value));
|
|
178
|
+
const next =
|
|
179
|
+
minimumValue + (direction > 0 ? fraction : 1 - fraction) * span;
|
|
180
|
+
drag.animateTo(next);
|
|
181
|
+
runOnJS(emit)(next);
|
|
182
|
+
runOnJS(emitComplete)(next);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const gesture = Gesture.Exclusive(pan, tap);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The frost lifting as the lens comes in, on the UI thread — see the toggle. It matters more
|
|
189
|
+
* here: a slider thumb is dragged for seconds at a time, and a material that only arrives on the
|
|
190
|
+
* next React render arrives after the gesture has already told the eye what to expect.
|
|
191
|
+
*/
|
|
192
|
+
const thumbProps = useAnimatedProps(() => ({
|
|
193
|
+
metal: lerpMetal(restMetal, heldMetal, drag.pressProgress.value),
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
const fillStyle = useAnimatedStyle(() => ({
|
|
197
|
+
width:
|
|
198
|
+
trackWidth.value *
|
|
199
|
+
Math.min(1, Math.max(0, (drag.value.value - minimumValue) / span)),
|
|
200
|
+
}));
|
|
201
|
+
const thumbStyle = useAnimatedStyle(() => {
|
|
202
|
+
const { scaleX, scaleY } = drag.jelly();
|
|
203
|
+
const fraction = Math.min(
|
|
204
|
+
1,
|
|
205
|
+
Math.max(0, (drag.value.value - minimumValue) / span)
|
|
206
|
+
);
|
|
207
|
+
const w = SLIDER_THUMB_WIDTH;
|
|
208
|
+
// The reference lets the thumb hang exactly a quarter of its width off each end.
|
|
209
|
+
const x = Math.min(
|
|
210
|
+
trackWidth.value - (3 * w) / 4,
|
|
211
|
+
Math.max(-w / 4, -w / 2 + trackWidth.value * fraction)
|
|
212
|
+
);
|
|
213
|
+
return {
|
|
214
|
+
transform: [
|
|
215
|
+
{
|
|
216
|
+
translateX:
|
|
217
|
+
(direction > 0 ? x : trackWidth.value - w - x) + overshoot.value,
|
|
218
|
+
},
|
|
219
|
+
{ scaleX },
|
|
220
|
+
{ scaleY },
|
|
221
|
+
],
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
const thumbFillStyle = useAnimatedStyle(() => ({
|
|
225
|
+
opacity: 1 - drag.pressProgress.value,
|
|
226
|
+
}));
|
|
227
|
+
|
|
228
|
+
const handleLayout = (event: LayoutChangeEvent): void => {
|
|
229
|
+
setWidth(event.nativeEvent.layout.width);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<GestureDetector gesture={gesture}>
|
|
234
|
+
<View
|
|
235
|
+
accessible
|
|
236
|
+
accessibilityRole="adjustable"
|
|
237
|
+
accessibilityState={{ disabled }}
|
|
238
|
+
accessibilityValue={{
|
|
239
|
+
min: minimumValue,
|
|
240
|
+
max: maximumValue,
|
|
241
|
+
now: value,
|
|
242
|
+
}}
|
|
243
|
+
onLayout={handleLayout}
|
|
244
|
+
style={[styles.root, disabled && styles.disabled, style]}
|
|
245
|
+
>
|
|
246
|
+
{/* One direct child — the provider lays out only its first. */}
|
|
247
|
+
<LiquidGlassProvider
|
|
248
|
+
providerId={layerId}
|
|
249
|
+
style={StyleSheet.absoluteFill}
|
|
250
|
+
>
|
|
251
|
+
<View style={styles.trackRow}>
|
|
252
|
+
<View style={[styles.track, { backgroundColor: track }]} />
|
|
253
|
+
<Animated.View
|
|
254
|
+
style={[styles.fill, { backgroundColor: accent }, fillStyle]}
|
|
255
|
+
/>
|
|
256
|
+
</View>
|
|
257
|
+
</LiquidGlassProvider>
|
|
258
|
+
{width > 0 ? (
|
|
259
|
+
<Animated.View style={[styles.thumb, thumbStyle]}>
|
|
260
|
+
<AnimatedGlassView
|
|
261
|
+
providerId={[providerId ?? "default", layerId]}
|
|
262
|
+
cornerRadius={SLIDER_THUMB_HEIGHT / 2}
|
|
263
|
+
cornerStyle="continuous"
|
|
264
|
+
animatedProps={thumbProps}
|
|
265
|
+
style={styles.thumbGlass}
|
|
266
|
+
containerStyle={styles.thumbContent}
|
|
267
|
+
>
|
|
268
|
+
<Animated.View style={[styles.thumbFill, thumbFillStyle]} />
|
|
269
|
+
</AnimatedGlassView>
|
|
270
|
+
</Animated.View>
|
|
271
|
+
) : null}
|
|
272
|
+
</View>
|
|
273
|
+
</GestureDetector>
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const styles = StyleSheet.create({
|
|
278
|
+
root: {
|
|
279
|
+
height: SLIDER_THUMB_HEIGHT,
|
|
280
|
+
justifyContent: "center",
|
|
281
|
+
},
|
|
282
|
+
disabled: {
|
|
283
|
+
opacity: 0.5,
|
|
284
|
+
},
|
|
285
|
+
trackRow: {
|
|
286
|
+
...ABSOLUTE_FILL,
|
|
287
|
+
justifyContent: "center",
|
|
288
|
+
},
|
|
289
|
+
track: {
|
|
290
|
+
height: SLIDER_TRACK_HEIGHT,
|
|
291
|
+
borderRadius: SLIDER_TRACK_HEIGHT / 2,
|
|
292
|
+
},
|
|
293
|
+
fill: {
|
|
294
|
+
position: "absolute",
|
|
295
|
+
left: 0,
|
|
296
|
+
height: SLIDER_TRACK_HEIGHT,
|
|
297
|
+
borderRadius: SLIDER_TRACK_HEIGHT / 2,
|
|
298
|
+
},
|
|
299
|
+
thumb: {
|
|
300
|
+
position: "absolute",
|
|
301
|
+
left: 0,
|
|
302
|
+
width: SLIDER_THUMB_WIDTH,
|
|
303
|
+
height: SLIDER_THUMB_HEIGHT,
|
|
304
|
+
// `boxShadow` draws on both platforms (the old `shadow*` quartet was iOS-only), and outside
|
|
305
|
+
// the capsule only, so the glass keeps refracting a clean backdrop.
|
|
306
|
+
borderRadius: SLIDER_THUMB_HEIGHT / 2,
|
|
307
|
+
boxShadow: THUMB_SHADOW,
|
|
308
|
+
},
|
|
309
|
+
thumbGlass: {
|
|
310
|
+
width: SLIDER_THUMB_WIDTH,
|
|
311
|
+
height: SLIDER_THUMB_HEIGHT,
|
|
312
|
+
},
|
|
313
|
+
thumbContent: {
|
|
314
|
+
...ABSOLUTE_FILL,
|
|
315
|
+
},
|
|
316
|
+
thumbFill: {
|
|
317
|
+
...ABSOLUTE_FILL,
|
|
318
|
+
borderRadius: SLIDER_THUMB_HEIGHT / 2,
|
|
319
|
+
backgroundColor: "#FFFFFF",
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
const LiquidGlassSlider: React.NamedExoticComponent<ILiquidGlassSliderProps> =
|
|
324
|
+
memo<ILiquidGlassSliderProps>(LiquidGlassSliderBase);
|
|
325
|
+
LiquidGlassSlider.displayName = "LiquidGlassSlider";
|
|
326
|
+
|
|
327
|
+
export { LiquidGlassSlider };
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import type { LayoutChangeEvent } from "react-native";
|
|
4
|
+
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
5
|
+
import Animated, {
|
|
6
|
+
useAnimatedProps,
|
|
7
|
+
useAnimatedStyle,
|
|
8
|
+
useSharedValue,
|
|
9
|
+
withSpring,
|
|
10
|
+
} from "react-native-reanimated";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
GLASS_BAR_METAL,
|
|
14
|
+
GLASS_THUMB_METAL,
|
|
15
|
+
GLOW_SPRING,
|
|
16
|
+
SEGMENTED_INSET,
|
|
17
|
+
STEPPER_CELL_WIDTH,
|
|
18
|
+
STEPPER_HEIGHT,
|
|
19
|
+
STEPPER_REPEAT_DELAY_MS,
|
|
20
|
+
STEPPER_REPEAT_INTERVAL_MS,
|
|
21
|
+
STEPPER_VALUE_MIN_WIDTH,
|
|
22
|
+
STEPPER_VALUE_POP_SCALE,
|
|
23
|
+
} from "../../constants";
|
|
24
|
+
import type { GlassMetalOptions } from "../../core";
|
|
25
|
+
import { LiquidGlassView } from "../../core";
|
|
26
|
+
import { usePressProgress } from "../../hooks";
|
|
27
|
+
import type { ILiquidGlassStepperProps } from "../../interfaces";
|
|
28
|
+
import { useGlassUITheme } from "../../theme";
|
|
29
|
+
|
|
30
|
+
const AnimatedGlassView = Animated.createAnimatedComponent(LiquidGlassView);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The system stepper in glass: a capsule track with `−` and `+` ends around the value. Pressing
|
|
34
|
+
* an end blooms a glass thumb over it — the segmented control's canvas thumb, lit by the press —
|
|
35
|
+
* and the value pops as it changes. Hold an end and it keeps stepping, the way the system's
|
|
36
|
+
* does. The track samples the backdrop; the thumb is the wash-lifted chip over it.
|
|
37
|
+
*/
|
|
38
|
+
const LiquidGlassStepperBase: React.FC<ILiquidGlassStepperProps> = ({
|
|
39
|
+
value,
|
|
40
|
+
onValueChange,
|
|
41
|
+
minimumValue = 0,
|
|
42
|
+
maximumValue = 100,
|
|
43
|
+
step = 1,
|
|
44
|
+
disabled = false,
|
|
45
|
+
autoRepeat = true,
|
|
46
|
+
formatValue,
|
|
47
|
+
height = STEPPER_HEIGHT,
|
|
48
|
+
tint,
|
|
49
|
+
thumbTint,
|
|
50
|
+
thumbMetal,
|
|
51
|
+
providerId,
|
|
52
|
+
style,
|
|
53
|
+
textStyle,
|
|
54
|
+
}: ILiquidGlassStepperProps): React.ReactElement => {
|
|
55
|
+
const { colors } = useGlassUITheme();
|
|
56
|
+
const press = usePressProgress(GLOW_SPRING);
|
|
57
|
+
/** -1 while the minus end is held, +1 for plus, 0 at rest. */
|
|
58
|
+
const side = useSharedValue(0);
|
|
59
|
+
const pop = useSharedValue(1);
|
|
60
|
+
const trackWidth = useSharedValue(0);
|
|
61
|
+
|
|
62
|
+
const valueRef = useRef(value);
|
|
63
|
+
const repeatTimer = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
64
|
+
const firstValue = useRef(true);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
valueRef.current = value;
|
|
68
|
+
if (firstValue.current) {
|
|
69
|
+
firstValue.current = false;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// A change pops the number: an immediate lift, then the bouncy spring home.
|
|
73
|
+
pop.value = STEPPER_VALUE_POP_SCALE;
|
|
74
|
+
pop.value = withSpring(1, GLOW_SPRING);
|
|
75
|
+
}, [pop, value]);
|
|
76
|
+
|
|
77
|
+
const atMin = value <= minimumValue;
|
|
78
|
+
const atMax = value >= maximumValue;
|
|
79
|
+
|
|
80
|
+
const stepBy = useCallback(
|
|
81
|
+
(direction: -1 | 1): void => {
|
|
82
|
+
const next = Math.min(
|
|
83
|
+
maximumValue,
|
|
84
|
+
Math.max(minimumValue, valueRef.current + direction * step)
|
|
85
|
+
);
|
|
86
|
+
if (next === valueRef.current) return;
|
|
87
|
+
valueRef.current = next;
|
|
88
|
+
onValueChange(next);
|
|
89
|
+
},
|
|
90
|
+
[maximumValue, minimumValue, onValueChange, step]
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
const stopRepeat = useCallback((): void => {
|
|
94
|
+
if (repeatTimer.current != null) {
|
|
95
|
+
clearInterval(repeatTimer.current);
|
|
96
|
+
repeatTimer.current = null;
|
|
97
|
+
}
|
|
98
|
+
}, []);
|
|
99
|
+
|
|
100
|
+
useEffect(() => stopRepeat, [stopRepeat]);
|
|
101
|
+
|
|
102
|
+
const handlePressIn = useCallback(
|
|
103
|
+
(direction: -1 | 1): void => {
|
|
104
|
+
side.value = direction;
|
|
105
|
+
press.pressIn();
|
|
106
|
+
},
|
|
107
|
+
[press, side]
|
|
108
|
+
);
|
|
109
|
+
const handlePressOut = useCallback((): void => {
|
|
110
|
+
press.pressOut();
|
|
111
|
+
stopRepeat();
|
|
112
|
+
}, [press, stopRepeat]);
|
|
113
|
+
const handleLongPress = useCallback(
|
|
114
|
+
(direction: -1 | 1): void => {
|
|
115
|
+
if (!autoRepeat) return;
|
|
116
|
+
stepBy(direction);
|
|
117
|
+
stopRepeat();
|
|
118
|
+
repeatTimer.current = setInterval(
|
|
119
|
+
() => stepBy(direction),
|
|
120
|
+
STEPPER_REPEAT_INTERVAL_MS
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
[autoRepeat, stepBy, stopRepeat]
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const handleLayout = useCallback(
|
|
127
|
+
(event: LayoutChangeEvent): void => {
|
|
128
|
+
trackWidth.value = event.nativeEvent.layout.width;
|
|
129
|
+
},
|
|
130
|
+
[trackWidth]
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const baseThumbMetal = useMemo<GlassMetalOptions>(
|
|
134
|
+
() => ({
|
|
135
|
+
...(thumbMetal ?? GLASS_THUMB_METAL),
|
|
136
|
+
border: { width: 0, opacity: 0 },
|
|
137
|
+
}),
|
|
138
|
+
[thumbMetal]
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// The thumb over the held end: the cell, inset by the segmented control's 3dp from the track's
|
|
142
|
+
// edge, and lit by the press at the cell's centre.
|
|
143
|
+
const thumbProps = useAnimatedProps(() => {
|
|
144
|
+
const w = trackWidth.value;
|
|
145
|
+
const s = side.value;
|
|
146
|
+
if (w <= 0 || s === 0) {
|
|
147
|
+
return {
|
|
148
|
+
metal: {
|
|
149
|
+
...baseThumbMetal,
|
|
150
|
+
shape: { x: 0, y: 0, width: 0.01, height: 0.01 },
|
|
151
|
+
},
|
|
152
|
+
glow: { progress: 0, x: 0, y: 0, lens: false },
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
const cellW = STEPPER_CELL_WIDTH - SEGMENTED_INSET;
|
|
156
|
+
const x = s < 0 ? SEGMENTED_INSET : w - SEGMENTED_INSET - cellW;
|
|
157
|
+
const shape = {
|
|
158
|
+
x,
|
|
159
|
+
y: SEGMENTED_INSET,
|
|
160
|
+
width: cellW,
|
|
161
|
+
height: height - 2 * SEGMENTED_INSET,
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
metal: { ...baseThumbMetal, shape },
|
|
165
|
+
glow: {
|
|
166
|
+
progress: Math.min(1, Math.max(0, press.progress.value)),
|
|
167
|
+
x: x + cellW / 2,
|
|
168
|
+
y: height / 2,
|
|
169
|
+
lens: false,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const thumbFade = useAnimatedStyle(() => ({
|
|
175
|
+
opacity: Math.min(1, Math.max(0, press.progress.value)),
|
|
176
|
+
}));
|
|
177
|
+
const popStyle = useAnimatedStyle(() => ({
|
|
178
|
+
transform: [{ scale: pop.value }],
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
const label = formatValue != null ? formatValue(value) : String(value);
|
|
182
|
+
const glyphColor = colors.label;
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<View
|
|
186
|
+
accessible
|
|
187
|
+
accessibilityRole="adjustable"
|
|
188
|
+
accessibilityValue={{
|
|
189
|
+
min: minimumValue,
|
|
190
|
+
max: maximumValue,
|
|
191
|
+
now: value,
|
|
192
|
+
text: label,
|
|
193
|
+
}}
|
|
194
|
+
accessibilityState={{ disabled }}
|
|
195
|
+
onLayout={handleLayout}
|
|
196
|
+
style={[
|
|
197
|
+
styles.root,
|
|
198
|
+
{ height },
|
|
199
|
+
disabled ? styles.disabled : null,
|
|
200
|
+
style,
|
|
201
|
+
]}
|
|
202
|
+
>
|
|
203
|
+
<LiquidGlassView
|
|
204
|
+
providerId={providerId}
|
|
205
|
+
cornerRadius={height / 2}
|
|
206
|
+
cornerStyle="continuous"
|
|
207
|
+
tint={tint ?? colors.tabBarSurface}
|
|
208
|
+
metal={GLASS_BAR_METAL}
|
|
209
|
+
style={StyleSheet.absoluteFill}
|
|
210
|
+
/>
|
|
211
|
+
<Animated.View
|
|
212
|
+
pointerEvents="none"
|
|
213
|
+
style={[StyleSheet.absoluteFill, thumbFade]}
|
|
214
|
+
>
|
|
215
|
+
<AnimatedGlassView
|
|
216
|
+
renderer="metal"
|
|
217
|
+
providerId={providerId}
|
|
218
|
+
cornerRadius={(height - 2 * SEGMENTED_INSET) / 2}
|
|
219
|
+
cornerStyle="continuous"
|
|
220
|
+
tint={thumbTint ?? colors.tabIndicatorSurface}
|
|
221
|
+
animatedProps={thumbProps}
|
|
222
|
+
style={StyleSheet.absoluteFill}
|
|
223
|
+
/>
|
|
224
|
+
</Animated.View>
|
|
225
|
+
<Pressable
|
|
226
|
+
accessibilityRole="button"
|
|
227
|
+
accessibilityLabel="Decrement"
|
|
228
|
+
disabled={disabled || atMin}
|
|
229
|
+
delayLongPress={STEPPER_REPEAT_DELAY_MS}
|
|
230
|
+
onPressIn={() => handlePressIn(-1)}
|
|
231
|
+
onPressOut={handlePressOut}
|
|
232
|
+
onPress={() => stepBy(-1)}
|
|
233
|
+
onLongPress={() => handleLongPress(-1)}
|
|
234
|
+
style={styles.cell}
|
|
235
|
+
>
|
|
236
|
+
<Text
|
|
237
|
+
style={[
|
|
238
|
+
styles.glyph,
|
|
239
|
+
{ color: glyphColor },
|
|
240
|
+
atMin ? styles.glyphDim : null,
|
|
241
|
+
]}
|
|
242
|
+
>
|
|
243
|
+
−
|
|
244
|
+
</Text>
|
|
245
|
+
</Pressable>
|
|
246
|
+
<Animated.View style={[styles.value, popStyle]}>
|
|
247
|
+
<Text
|
|
248
|
+
numberOfLines={1}
|
|
249
|
+
style={[styles.valueText, { color: colors.label }, textStyle]}
|
|
250
|
+
>
|
|
251
|
+
{label}
|
|
252
|
+
</Text>
|
|
253
|
+
</Animated.View>
|
|
254
|
+
<Pressable
|
|
255
|
+
accessibilityRole="button"
|
|
256
|
+
accessibilityLabel="Increment"
|
|
257
|
+
disabled={disabled || atMax}
|
|
258
|
+
delayLongPress={STEPPER_REPEAT_DELAY_MS}
|
|
259
|
+
onPressIn={() => handlePressIn(1)}
|
|
260
|
+
onPressOut={handlePressOut}
|
|
261
|
+
onPress={() => stepBy(1)}
|
|
262
|
+
onLongPress={() => handleLongPress(1)}
|
|
263
|
+
style={styles.cell}
|
|
264
|
+
>
|
|
265
|
+
<Text
|
|
266
|
+
style={[
|
|
267
|
+
styles.glyph,
|
|
268
|
+
{ color: glyphColor },
|
|
269
|
+
atMax ? styles.glyphDim : null,
|
|
270
|
+
]}
|
|
271
|
+
>
|
|
272
|
+
+
|
|
273
|
+
</Text>
|
|
274
|
+
</Pressable>
|
|
275
|
+
</View>
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const styles = StyleSheet.create({
|
|
280
|
+
// The cells lay out in normal flow so the capsule takes its width from them; the glass
|
|
281
|
+
// layers are absolute underneath. (Absolute cells left the root 0 wide and the track invisible.)
|
|
282
|
+
root: {
|
|
283
|
+
alignSelf: "flex-start",
|
|
284
|
+
flexDirection: "row",
|
|
285
|
+
alignItems: "stretch",
|
|
286
|
+
},
|
|
287
|
+
disabled: {
|
|
288
|
+
opacity: 0.5,
|
|
289
|
+
},
|
|
290
|
+
cell: {
|
|
291
|
+
width: STEPPER_CELL_WIDTH,
|
|
292
|
+
alignItems: "center",
|
|
293
|
+
justifyContent: "center",
|
|
294
|
+
},
|
|
295
|
+
glyph: {
|
|
296
|
+
fontSize: 20,
|
|
297
|
+
fontWeight: "500",
|
|
298
|
+
includeFontPadding: false,
|
|
299
|
+
},
|
|
300
|
+
glyphDim: {
|
|
301
|
+
opacity: 0.35,
|
|
302
|
+
},
|
|
303
|
+
value: {
|
|
304
|
+
minWidth: STEPPER_VALUE_MIN_WIDTH,
|
|
305
|
+
paddingHorizontal: 6,
|
|
306
|
+
alignItems: "center",
|
|
307
|
+
justifyContent: "center",
|
|
308
|
+
},
|
|
309
|
+
valueText: {
|
|
310
|
+
fontSize: 16,
|
|
311
|
+
fontWeight: "600",
|
|
312
|
+
fontVariant: ["tabular-nums"],
|
|
313
|
+
includeFontPadding: false,
|
|
314
|
+
},
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
const LiquidGlassStepper: React.NamedExoticComponent<ILiquidGlassStepperProps> =
|
|
318
|
+
memo<ILiquidGlassStepperProps>(LiquidGlassStepperBase);
|
|
319
|
+
LiquidGlassStepper.displayName = "LiquidGlassStepper";
|
|
320
|
+
|
|
321
|
+
export { LiquidGlassStepper };
|