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
package/src/Skeleton.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Wave 2 — Skeleton.
|
|
2
|
+
//
|
|
3
|
+
// The donor's placeholder is decorative: it hides its content from screen
|
|
4
|
+
// readers and announces a busy state on the container instead. The shimmer is
|
|
5
|
+
// the family's motion and disappears under Reduce Motion.
|
|
6
|
+
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
9
|
+
|
|
10
|
+
import { colors, radii } from "./internal/tokens";
|
|
11
|
+
import { primitives } from "./internal/primitives";
|
|
12
|
+
import { useIsDark } from "./internal/motion";
|
|
13
|
+
import { useReducedMotion } from "./internal/a11y";
|
|
14
|
+
|
|
15
|
+
export interface SkeletonProps {
|
|
16
|
+
shape?: "rect" | "circle" | "line";
|
|
17
|
+
width?: number | string;
|
|
18
|
+
height?: number;
|
|
19
|
+
isDark?: boolean;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
testID?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Skeleton({
|
|
25
|
+
shape = "rect",
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
isDark: isDarkProp,
|
|
29
|
+
style,
|
|
30
|
+
testID,
|
|
31
|
+
}: SkeletonProps) {
|
|
32
|
+
const isDark = useIsDark(isDarkProp);
|
|
33
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
34
|
+
const reducedMotion = useReducedMotion();
|
|
35
|
+
const { View, Animated, isNative } = primitives();
|
|
36
|
+
|
|
37
|
+
const pulse = useRef<any>(null);
|
|
38
|
+
const animate = Boolean(isNative && Animated?.Value && Animated?.timing) && !reducedMotion;
|
|
39
|
+
if (pulse.current === null) pulse.current = animate ? new Animated.Value(0.55) : { value: 1 };
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!animate) {
|
|
43
|
+
pulse.current.value = 1;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const loop = Animated.loop(
|
|
47
|
+
Animated.sequence([
|
|
48
|
+
Animated.timing(pulse.current, { toValue: 1, duration: 700, useNativeDriver: true }),
|
|
49
|
+
Animated.timing(pulse.current, { toValue: 0.55, duration: 700, useNativeDriver: true }),
|
|
50
|
+
]),
|
|
51
|
+
);
|
|
52
|
+
loop.start();
|
|
53
|
+
return () => loop.stop?.();
|
|
54
|
+
}, [animate]);
|
|
55
|
+
|
|
56
|
+
const resolvedHeight = height ?? (shape === "line" ? 12 : 20);
|
|
57
|
+
|
|
58
|
+
const size = shape === "circle" ? resolvedHeight : undefined;
|
|
59
|
+
return (
|
|
60
|
+
<Animated.View
|
|
61
|
+
testID={testID}
|
|
62
|
+
accessibilityRole="none"
|
|
63
|
+
importantForAccessibility="no"
|
|
64
|
+
accessibilityElementsHidden
|
|
65
|
+
style={[
|
|
66
|
+
{
|
|
67
|
+
width: size ?? (width as any) ?? "100%",
|
|
68
|
+
height: resolvedHeight,
|
|
69
|
+
backgroundColor: theme.skeleton,
|
|
70
|
+
borderRadius: shape === "circle" ? resolvedHeight / 2 : radii.sm,
|
|
71
|
+
opacity: pulse.current,
|
|
72
|
+
},
|
|
73
|
+
style,
|
|
74
|
+
]}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
}
|
package/src/Slider.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import { forwardRef, useMemo, useRef, useState } from "react";
|
|
|
2
2
|
import { measurePreviewWidth } from "./internal/primitives";
|
|
3
3
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
4
4
|
|
|
5
|
+
import { loadEngineControl } from "./internal/glass-routing";
|
|
6
|
+
import { glassCapabilities } from "./internal/GlassView";
|
|
5
7
|
import { Glass } from "./Glass";
|
|
6
8
|
import { colors, material } from "./internal/tokens";
|
|
7
9
|
import { primitives } from "./internal/primitives";
|
|
@@ -9,25 +11,32 @@ import { useIsDark } from "./internal/motion";
|
|
|
9
11
|
import { hapticSelection } from "./internal/haptics";
|
|
10
12
|
|
|
11
13
|
export interface SliderProps {
|
|
14
|
+
/** Controlled value. Omit it and the slider keeps its own. */
|
|
12
15
|
value?: number;
|
|
13
16
|
defaultValue?: number;
|
|
17
|
+
/** Inclusive lower bound. Defaults to 0. */
|
|
14
18
|
min?: number;
|
|
19
|
+
/** Inclusive upper bound. Defaults to 100. */
|
|
15
20
|
max?: number;
|
|
21
|
+
/** Increment per step. Defaults to 1. */
|
|
16
22
|
step?: number;
|
|
23
|
+
/** Fires while dragging and once when the gesture ends (engine order). */
|
|
17
24
|
onValueChange?: (value: number) => void;
|
|
25
|
+
/** Fires once when the gesture ends, after the thumb has been released. */
|
|
26
|
+
onSlidingComplete?: (value: number) => void;
|
|
18
27
|
disabled?: boolean;
|
|
19
28
|
/** One selection tick each time the stepped value changes while dragging. */
|
|
20
29
|
haptics?: boolean;
|
|
21
30
|
accessibilityLabel: string;
|
|
22
31
|
style?: StyleProp<ViewStyle>;
|
|
23
32
|
isDark?: boolean;
|
|
24
|
-
/** Passed
|
|
33
|
+
/** Passed to the draggable track so it is testable. */
|
|
25
34
|
testID?: string;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
// The web slider: a 6pt track and a glass-lens thumb rather than a small dot.
|
|
29
38
|
const TRACK_HEIGHT = 6;
|
|
30
|
-
const THUMB_WIDTH =
|
|
39
|
+
const THUMB_WIDTH = 40;
|
|
31
40
|
const THUMB_HEIGHT = 24;
|
|
32
41
|
const CONTAINER_HEIGHT = 40;
|
|
33
42
|
|
|
@@ -37,19 +46,19 @@ function quantize(value: number, min: number, max: number, step: number): number
|
|
|
37
46
|
const clamped = Math.min(max, Math.max(min, value));
|
|
38
47
|
if (!(step > 0)) return clamped;
|
|
39
48
|
const stepped = min + Math.round((clamped - min) / step) * step;
|
|
40
|
-
// Round away binary float noise introduced by the division above.
|
|
41
49
|
const decimals = (String(step).split(".")[1] ?? "").length;
|
|
42
50
|
return Number(Math.min(max, Math.max(min, stepped)).toFixed(decimals));
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
/**
|
|
46
|
-
* A continuous value chosen by dragging
|
|
54
|
+
* A continuous value chosen by dragging — ported from the engine's
|
|
55
|
+
* `LiquidGlassSlider`, which keeps the approved drag behaviour while the
|
|
56
|
+
* material changes by platform.
|
|
47
57
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* platform; only the glass material changes.
|
|
58
|
+
* With a glass renderer available the engine's own control mounts, carrying the
|
|
59
|
+
* approved geometry and drag behaviour. Without one — Expo Go, below every tier,
|
|
60
|
+
* or Reduce Transparency — the fallback floor renders the same track and lens
|
|
61
|
+
* thumb with the fallback material, so the control is never invisible.
|
|
53
62
|
*/
|
|
54
63
|
export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
55
64
|
{
|
|
@@ -59,6 +68,7 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
59
68
|
max = 100,
|
|
60
69
|
step = 1,
|
|
61
70
|
onValueChange,
|
|
71
|
+
onSlidingComplete,
|
|
62
72
|
disabled = false,
|
|
63
73
|
haptics = true,
|
|
64
74
|
accessibilityLabel,
|
|
@@ -72,6 +82,8 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
72
82
|
const isDark = useIsDark(isDarkProp);
|
|
73
83
|
const themeColors = isDark ? colors.dark : colors.light;
|
|
74
84
|
const { View, Pressable, PanResponder } = primitives();
|
|
85
|
+
const capabilities = glassCapabilities();
|
|
86
|
+
const EngineSlider = loadEngineControl("Slider");
|
|
75
87
|
|
|
76
88
|
const [internalValue, setInternalValue] = useState(() => quantize(defaultValue, min, max, step));
|
|
77
89
|
const value = valueProp !== undefined ? quantize(valueProp, min, max, step) : internalValue;
|
|
@@ -81,9 +93,6 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
81
93
|
// second one starts from it instead of a stale closure.
|
|
82
94
|
const valueRef = useRef(value);
|
|
83
95
|
valueRef.current = value;
|
|
84
|
-
|
|
85
|
-
// Track width as measured on layout. A drag before layout is a no-op rather
|
|
86
|
-
// than a jump: without a width there is no honest mapping from x to value.
|
|
87
96
|
const widthRef = useRef(0);
|
|
88
97
|
|
|
89
98
|
/** Converts an x position relative to the track into a stepped value. */
|
|
@@ -124,10 +133,15 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
124
133
|
const next = valueAtX(event.nativeEvent.locationX);
|
|
125
134
|
if (next !== null) report(next);
|
|
126
135
|
},
|
|
136
|
+
onPanResponderRelease: (event: any) => {
|
|
137
|
+
const next = valueAtX(event.nativeEvent.locationX);
|
|
138
|
+
if (next !== null) {
|
|
139
|
+
report(next);
|
|
140
|
+
onSlidingComplete?.(next);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
127
143
|
onPanResponderTerminationRequest: () => false,
|
|
128
144
|
});
|
|
129
|
-
// `report` reads the value from a ref, so the responder does not need to be
|
|
130
|
-
// rebuilt on every value change and never acts on a stale render.
|
|
131
145
|
}, [disabled, valueAtX]);
|
|
132
146
|
|
|
133
147
|
/** Steps the value for accessibility actions and hardware keys. */
|
|
@@ -171,8 +185,6 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
171
185
|
backgroundColor: themeColors.onTint,
|
|
172
186
|
borderWidth: 0.5,
|
|
173
187
|
borderColor: themeColors.edge,
|
|
174
|
-
// The same lens shadow stack the Switch thumb carries: the web thumb is a
|
|
175
|
-
// lens with real depth, not a white dot painted on the track.
|
|
176
188
|
shadowColor: material.shadowColor,
|
|
177
189
|
shadowOpacity: 0.2,
|
|
178
190
|
shadowRadius: 8,
|
|
@@ -180,38 +192,63 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
|
|
|
180
192
|
elevation: 3,
|
|
181
193
|
};
|
|
182
194
|
|
|
195
|
+
// ------------------------------------------------------------------
|
|
196
|
+
// Fallback floor: the same track and lens thumb, on the fallback material.
|
|
197
|
+
// ------------------------------------------------------------------
|
|
198
|
+
if (!(EngineSlider && capabilities.supported)) {
|
|
199
|
+
const track = (
|
|
200
|
+
<View style={trackStyle}>
|
|
201
|
+
<View style={fillStyle} />
|
|
202
|
+
</View>
|
|
203
|
+
);
|
|
204
|
+
const thumb = <View style={thumbStyle} pointerEvents="none" />;
|
|
205
|
+
return (
|
|
206
|
+
<Pressable
|
|
207
|
+
testID={testID}
|
|
208
|
+
accessibilityRole="adjustable"
|
|
209
|
+
accessibilityLabel={accessibilityLabel}
|
|
210
|
+
accessibilityState={{ disabled }}
|
|
211
|
+
accessibilityValue={{ min, max, now: value }}
|
|
212
|
+
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
|
|
213
|
+
disabled={disabled}
|
|
214
|
+
onAccessibilityAction={(event: any) => {
|
|
215
|
+
if (event?.nativeEvent?.actionName === "increment") nudge(1);
|
|
216
|
+
if (event?.nativeEvent?.actionName === "decrement") nudge(-1);
|
|
217
|
+
}}
|
|
218
|
+
onLayout={(event: any) => {
|
|
219
|
+
const width = event?.nativeEvent?.layout?.width;
|
|
220
|
+
if (typeof width === "number" && width > 0) widthRef.current = width;
|
|
221
|
+
}}
|
|
222
|
+
ref={(node: any) => {
|
|
223
|
+
measurePreviewWidth(node, widthRef);
|
|
224
|
+
if (typeof ref === "function") ref(node);
|
|
225
|
+
else if (ref) ref.current = node;
|
|
226
|
+
}}
|
|
227
|
+
style={containerStyle}
|
|
228
|
+
{...(panResponder ? panResponder.panHandlers : {})}
|
|
229
|
+
{...props}
|
|
230
|
+
>
|
|
231
|
+
<Glass effect="regular" isDark={isDark} style={trackStyle}>
|
|
232
|
+
{track}
|
|
233
|
+
</Glass>
|
|
234
|
+
{thumb}
|
|
235
|
+
</Pressable>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const EngineSliderComponent = EngineSlider;
|
|
183
240
|
return (
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
onAccessibilityAction={(event: any) => {
|
|
192
|
-
if (event?.nativeEvent?.actionName === "increment") nudge(1);
|
|
193
|
-
if (event?.nativeEvent?.actionName === "decrement") nudge(-1);
|
|
194
|
-
}}
|
|
241
|
+
<EngineSliderComponent
|
|
242
|
+
value={value}
|
|
243
|
+
onValueChange={disabled ? undefined : onValueChange ?? report}
|
|
244
|
+
onSlidingComplete={disabled ? undefined : onSlidingComplete}
|
|
245
|
+
minimumValue={min}
|
|
246
|
+
maximumValue={max}
|
|
247
|
+
step={step}
|
|
195
248
|
disabled={disabled}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// The DOM preview has no layout events, so measure on mount there too;
|
|
201
|
-
// on a device this resolves to nothing and onLayout is the source.
|
|
202
|
-
ref={(node: any) => {
|
|
203
|
-
measurePreviewWidth(node, widthRef);
|
|
204
|
-
if (typeof ref === "function") ref(node);
|
|
205
|
-
else if (ref) ref.current = node;
|
|
206
|
-
}}
|
|
207
|
-
style={containerStyle}
|
|
208
|
-
{...(panResponder ? panResponder.panHandlers : {})}
|
|
209
|
-
{...props}
|
|
210
|
-
>
|
|
211
|
-
<Glass effect="regular" isDark={isDark} style={trackStyle}>
|
|
212
|
-
<View style={fillStyle} />
|
|
213
|
-
</Glass>
|
|
214
|
-
<View style={thumbStyle} pointerEvents="none" />
|
|
215
|
-
</Pressable>
|
|
249
|
+
accentColor={themeColors.fill}
|
|
250
|
+
trackColor="rgba(120, 120, 128, 0.2)"
|
|
251
|
+
style={style}
|
|
252
|
+
/>
|
|
216
253
|
);
|
|
217
254
|
});
|
package/src/Stepper.tsx
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
2
|
+
import type { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { loadEngineControl } from "./internal/glass-routing";
|
|
5
|
+
import { glassCapabilities } from "./internal/GlassView";
|
|
6
|
+
import { Glass } from "./Glass";
|
|
7
|
+
import { colors, radii, springs } from "./internal/tokens";
|
|
8
|
+
import { primitives } from "./internal/primitives";
|
|
9
|
+
import { useIsDark } from "./internal/motion";
|
|
10
|
+
import { useReducedMotion } from "./internal/a11y";
|
|
11
|
+
import { hapticSelection } from "./internal/haptics";
|
|
12
|
+
|
|
13
|
+
// The engine's stepper geometry, kept exactly: a 40dp capsule whose `−`/`+`
|
|
14
|
+
// ends are 44dp cells around a 44dp-minimum readout, with the thumb inset by
|
|
15
|
+
// the segmented control's 3dp.
|
|
16
|
+
const STEPPER_HEIGHT = 40;
|
|
17
|
+
const STEPPER_CELL_WIDTH = 44;
|
|
18
|
+
const STEPPER_VALUE_MIN_WIDTH = 44;
|
|
19
|
+
const STEPPER_INSET = 3;
|
|
20
|
+
const STEPPER_REPEAT_DELAY_MS = 400;
|
|
21
|
+
const STEPPER_REPEAT_INTERVAL_MS = 110;
|
|
22
|
+
const STEPPER_VALUE_POP_SCALE = 1.18;
|
|
23
|
+
|
|
24
|
+
export interface StepperProps {
|
|
25
|
+
/** Controlled value. Omit it and the stepper keeps its own. */
|
|
26
|
+
value?: number;
|
|
27
|
+
defaultValue?: number;
|
|
28
|
+
/** Fires with the next value whenever one of the ends steps it. */
|
|
29
|
+
onValueChange?: (value: number) => void;
|
|
30
|
+
/** Inclusive lower bound. Defaults to 0. `minimumValue` is the engine's spelling. */
|
|
31
|
+
min?: number;
|
|
32
|
+
/** Inclusive upper bound. Defaults to 100. `maximumValue` is the engine's spelling. */
|
|
33
|
+
max?: number;
|
|
34
|
+
minimumValue?: number;
|
|
35
|
+
maximumValue?: number;
|
|
36
|
+
/** Increment per press. Defaults to 1. */
|
|
37
|
+
step?: number;
|
|
38
|
+
/** Hold an end and it keeps stepping, the way the system's does. Defaults to true. */
|
|
39
|
+
autoRepeat?: boolean;
|
|
40
|
+
/** One selection tick each time the value changes. `false` opts out. */
|
|
41
|
+
haptics?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/** Capsule height, dp. Defaults to the engine's 40. */
|
|
44
|
+
height?: number;
|
|
45
|
+
/** Formats the middle readout; defaults to the plain number. */
|
|
46
|
+
formatValue?: (value: number) => string;
|
|
47
|
+
/** Announced by screen readers, e.g. "Guests". */
|
|
48
|
+
accessibilityLabel: string;
|
|
49
|
+
/** The track's wash. Defaults to the scheme's glass tint. */
|
|
50
|
+
tint?: string;
|
|
51
|
+
/** The pressed thumb's wash. Defaults to the scheme's glass-active tint. */
|
|
52
|
+
thumbTint?: string;
|
|
53
|
+
/** Pairs the surface with its Android backdrop provider. */
|
|
54
|
+
providerId?: string;
|
|
55
|
+
isDark?: boolean;
|
|
56
|
+
style?: StyleProp<ViewStyle>;
|
|
57
|
+
textStyle?: StyleProp<TextStyle>;
|
|
58
|
+
testID?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Minus / value / plus — ported from the engine's `LiquidGlassStepper`, the
|
|
63
|
+
* design Binyam approved on real devices this week (40dp capsule, 44dp cells,
|
|
64
|
+
* press thumb blooming over the held end, the value popping as it changes, and
|
|
65
|
+
* hold-to-repeat).
|
|
66
|
+
*
|
|
67
|
+
* With a glass renderer available the engine's own control mounts, carrying the
|
|
68
|
+
* approved geometry and behaviour. Without one — Expo Go, below every tier, or
|
|
69
|
+
* Reduce Transparency — the fallback floor renders the same capsule, cells and
|
|
70
|
+
* readout on Glacia's solid material, so the control is never invisible.
|
|
71
|
+
*/
|
|
72
|
+
export const Stepper = forwardRef<any, StepperProps>(function Stepper(
|
|
73
|
+
{
|
|
74
|
+
value: valueProp,
|
|
75
|
+
defaultValue = 0,
|
|
76
|
+
onValueChange,
|
|
77
|
+
min,
|
|
78
|
+
max,
|
|
79
|
+
minimumValue,
|
|
80
|
+
maximumValue,
|
|
81
|
+
step = 1,
|
|
82
|
+
autoRepeat = true,
|
|
83
|
+
haptics = true,
|
|
84
|
+
disabled = false,
|
|
85
|
+
height = STEPPER_HEIGHT,
|
|
86
|
+
formatValue,
|
|
87
|
+
accessibilityLabel,
|
|
88
|
+
tint,
|
|
89
|
+
thumbTint,
|
|
90
|
+
providerId,
|
|
91
|
+
isDark: isDarkProp,
|
|
92
|
+
style,
|
|
93
|
+
textStyle,
|
|
94
|
+
testID,
|
|
95
|
+
...props
|
|
96
|
+
},
|
|
97
|
+
ref,
|
|
98
|
+
) {
|
|
99
|
+
const isDark = useIsDark(isDarkProp);
|
|
100
|
+
const theme = isDark ? colors.dark : colors.light;
|
|
101
|
+
const reducedMotion = useReducedMotion();
|
|
102
|
+
const { Animated, View, Pressable, Text: RNText, isNative } = primitives();
|
|
103
|
+
const capabilities = glassCapabilities();
|
|
104
|
+
const EngineStepper = loadEngineControl("Stepper");
|
|
105
|
+
|
|
106
|
+
const lower = min ?? minimumValue ?? 0;
|
|
107
|
+
const upper = max ?? maximumValue ?? 100;
|
|
108
|
+
|
|
109
|
+
const [internalValue, setInternalValue] = useState(() => clamp(defaultValue, lower, upper));
|
|
110
|
+
const value = clamp(valueProp !== undefined ? valueProp : internalValue, lower, upper);
|
|
111
|
+
|
|
112
|
+
// Two actions can arrive before a re-render (hold-to-repeat, or both ends in
|
|
113
|
+
// one frame). The ref holds the newest value so the next step starts from it.
|
|
114
|
+
const valueRef = useRef(value);
|
|
115
|
+
valueRef.current = value;
|
|
116
|
+
|
|
117
|
+
const [held, setHeld] = useState<-1 | 0 | 1>(0);
|
|
118
|
+
const repeatTimer = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
119
|
+
useEffect(() => () => stopRepeat(), []);
|
|
120
|
+
|
|
121
|
+
// The readout pops on each change, like the engine's: an immediate lift then
|
|
122
|
+
// a spring home. Reduce Motion settles it straight at its resting scale.
|
|
123
|
+
const pop = useRef<any>(null);
|
|
124
|
+
const animate = Boolean(isNative && Animated?.Value && Animated?.spring) && !reducedMotion;
|
|
125
|
+
if (pop.current === null) {
|
|
126
|
+
pop.current = animate ? new Animated.Value(1) : { value: 1 };
|
|
127
|
+
}
|
|
128
|
+
const firstValue = useRef(true);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (firstValue.current) {
|
|
131
|
+
firstValue.current = false;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!animate) return;
|
|
135
|
+
pop.current.setValue(STEPPER_VALUE_POP_SCALE);
|
|
136
|
+
const animation = Animated.spring(pop.current, {
|
|
137
|
+
toValue: 1,
|
|
138
|
+
...springs.snappy,
|
|
139
|
+
useNativeDriver: false,
|
|
140
|
+
});
|
|
141
|
+
animation.start();
|
|
142
|
+
return () => animation.stop?.();
|
|
143
|
+
}, [animate, value]);
|
|
144
|
+
|
|
145
|
+
const atMin = value <= lower;
|
|
146
|
+
const atMax = value >= upper;
|
|
147
|
+
|
|
148
|
+
const apply = (next: number) => {
|
|
149
|
+
const clamped = clamp(next, lower, upper);
|
|
150
|
+
if (clamped === valueRef.current) return;
|
|
151
|
+
if (haptics) hapticSelection();
|
|
152
|
+
valueRef.current = clamped;
|
|
153
|
+
if (valueProp === undefined) setInternalValue(clamped);
|
|
154
|
+
onValueChange?.(clamped);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
function stopRepeat() {
|
|
158
|
+
if (repeatTimer.current != null) {
|
|
159
|
+
clearInterval(repeatTimer.current);
|
|
160
|
+
repeatTimer.current = null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const stepBy = (direction: -1 | 1) => apply(valueRef.current + direction * step);
|
|
165
|
+
|
|
166
|
+
const handlePressIn = (direction: -1 | 1) => {
|
|
167
|
+
setHeld(direction);
|
|
168
|
+
};
|
|
169
|
+
const handlePressOut = () => {
|
|
170
|
+
setHeld(0);
|
|
171
|
+
stopRepeat();
|
|
172
|
+
};
|
|
173
|
+
const handleLongPress = (direction: -1 | 1) => {
|
|
174
|
+
if (!autoRepeat) return;
|
|
175
|
+
stepBy(direction);
|
|
176
|
+
stopRepeat();
|
|
177
|
+
repeatTimer.current = setInterval(() => stepBy(direction), STEPPER_REPEAT_INTERVAL_MS);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const label = formatValue ? formatValue(value) : String(value);
|
|
181
|
+
|
|
182
|
+
const rootStyle: ViewStyle = {
|
|
183
|
+
height,
|
|
184
|
+
borderRadius: radii.pill,
|
|
185
|
+
alignSelf: "flex-start",
|
|
186
|
+
flexDirection: "row",
|
|
187
|
+
alignItems: "stretch",
|
|
188
|
+
opacity: disabled ? 0.5 : 1,
|
|
189
|
+
...(style as ViewStyle),
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const cellStyle: ViewStyle = {
|
|
193
|
+
width: STEPPER_CELL_WIDTH,
|
|
194
|
+
alignItems: "center",
|
|
195
|
+
justifyContent: "center",
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
// ------------------------------------------------------------------
|
|
200
|
+
// Fallback floor: the same capsule, cells and readout, on Glacia's
|
|
201
|
+
// solid-capable material.
|
|
202
|
+
// ------------------------------------------------------------------
|
|
203
|
+
if (!(EngineStepper && capabilities.supported)) {
|
|
204
|
+
const thumbWidth = STEPPER_CELL_WIDTH - STEPPER_INSET;
|
|
205
|
+
const thumb = held !== 0 ? (
|
|
206
|
+
<View
|
|
207
|
+
pointerEvents="none"
|
|
208
|
+
style={{
|
|
209
|
+
position: "absolute",
|
|
210
|
+
top: STEPPER_INSET,
|
|
211
|
+
left: held < 0 ? STEPPER_INSET : undefined,
|
|
212
|
+
right: held > 0 ? STEPPER_INSET : undefined,
|
|
213
|
+
width: thumbWidth,
|
|
214
|
+
height: height - 2 * STEPPER_INSET,
|
|
215
|
+
borderRadius: radii.pill,
|
|
216
|
+
backgroundColor: thumbTint ?? theme.glassActive,
|
|
217
|
+
}}
|
|
218
|
+
/>
|
|
219
|
+
) : null;
|
|
220
|
+
|
|
221
|
+
const cell = (label: string, sign: "\u2212" | "+", direction: -1 | 1, blocked: boolean) => (
|
|
222
|
+
<Pressable
|
|
223
|
+
accessibilityRole="button"
|
|
224
|
+
accessibilityLabel={label}
|
|
225
|
+
accessibilityState={{ disabled: disabled || blocked }}
|
|
226
|
+
disabled={disabled || blocked}
|
|
227
|
+
delayLongPress={STEPPER_REPEAT_DELAY_MS}
|
|
228
|
+
onPressIn={() => handlePressIn(direction)}
|
|
229
|
+
onPressOut={handlePressOut}
|
|
230
|
+
onPress={() => stepBy(direction)}
|
|
231
|
+
onLongPress={() => handleLongPress(direction)}
|
|
232
|
+
style={cellStyle}
|
|
233
|
+
>
|
|
234
|
+
<RNText
|
|
235
|
+
style={{
|
|
236
|
+
fontSize: 20,
|
|
237
|
+
fontWeight: "500",
|
|
238
|
+
color: theme.foreground,
|
|
239
|
+
opacity: disabled || blocked ? 0.35 : 1,
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
{sign}
|
|
243
|
+
</RNText>
|
|
244
|
+
</Pressable>
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<Glass
|
|
249
|
+
ref={ref}
|
|
250
|
+
effect="regular"
|
|
251
|
+
surface="control"
|
|
252
|
+
tintColor={tint}
|
|
253
|
+
isDark={isDark}
|
|
254
|
+
testID={testID}
|
|
255
|
+
accessibilityRole="adjustable"
|
|
256
|
+
accessibilityLabel={accessibilityLabel}
|
|
257
|
+
accessibilityState={{ disabled }}
|
|
258
|
+
accessibilityValue={{ min: lower, max: upper, now: value, text: label }}
|
|
259
|
+
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
|
|
260
|
+
onAccessibilityAction={(event: any) => {
|
|
261
|
+
const action = event?.nativeEvent?.actionName;
|
|
262
|
+
if (action === "increment") apply(valueRef.current + step);
|
|
263
|
+
if (action === "decrement") apply(valueRef.current - step);
|
|
264
|
+
}}
|
|
265
|
+
style={rootStyle}
|
|
266
|
+
{...props}
|
|
267
|
+
>
|
|
268
|
+
{cell(`Decrease ${accessibilityLabel}`, "\u2212", -1, atMin)}
|
|
269
|
+
<View style={{ minWidth: STEPPER_VALUE_MIN_WIDTH, justifyContent: "center", alignItems: "center" }}>
|
|
270
|
+
<Animated.View style={{ transform: [{ scale: pop.current }] }}>
|
|
271
|
+
<RNText
|
|
272
|
+
numberOfLines={1}
|
|
273
|
+
style={[
|
|
274
|
+
{ fontSize: 16, fontWeight: "600", color: theme.foreground },
|
|
275
|
+
textStyle,
|
|
276
|
+
]}
|
|
277
|
+
>
|
|
278
|
+
{label}
|
|
279
|
+
</RNText>
|
|
280
|
+
</Animated.View>
|
|
281
|
+
</View>
|
|
282
|
+
{cell(`Increase ${accessibilityLabel}`, "+", 1, atMax)}
|
|
283
|
+
{thumb}
|
|
284
|
+
</Glass>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const EngineStepperComponent = EngineStepper;
|
|
289
|
+
return (
|
|
290
|
+
<EngineStepperComponent
|
|
291
|
+
value={value}
|
|
292
|
+
onValueChange={disabled ? undefined : (next: number) => apply(next)}
|
|
293
|
+
minimumValue={lower}
|
|
294
|
+
maximumValue={upper}
|
|
295
|
+
step={step}
|
|
296
|
+
disabled={disabled}
|
|
297
|
+
autoRepeat={autoRepeat}
|
|
298
|
+
formatValue={formatValue}
|
|
299
|
+
height={height}
|
|
300
|
+
tint={tint}
|
|
301
|
+
thumbTint={thumbTint}
|
|
302
|
+
providerId={providerId}
|
|
303
|
+
style={style}
|
|
304
|
+
textStyle={textStyle}
|
|
305
|
+
testID={testID}
|
|
306
|
+
accessibilityLabel={accessibilityLabel}
|
|
307
|
+
/>
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
/** Keeps a value inside the stepper's range. */
|
|
312
|
+
function clamp(value: number, min: number, max: number): number {
|
|
313
|
+
if (!Number.isFinite(value)) return min;
|
|
314
|
+
return Math.min(max, Math.max(min, value));
|
|
315
|
+
}
|