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/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
|
+
}
|
package/src/Switch.tsx
CHANGED
|
@@ -1,109 +1,131 @@
|
|
|
1
1
|
import { forwardRef, useState } from "react";
|
|
2
2
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
|
|
4
|
+
import { loadEngineControl } from "./internal/glass-routing";
|
|
5
|
+
import { glassCapabilities } from "./internal/GlassView";
|
|
4
6
|
import { Glass } from "./Glass";
|
|
5
7
|
import { colors } from "./internal/tokens";
|
|
6
8
|
import { primitives } from "./internal/primitives";
|
|
7
|
-
import { useIsDark, useSpring } from "./internal/motion";
|
|
8
9
|
import { hapticSelection } from "./internal/haptics";
|
|
10
|
+
import { useIsDark } from "./internal/motion";
|
|
9
11
|
|
|
10
12
|
export interface SwitchProps {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/** Controlled on/off value. Omit it and the switch keeps its own. */
|
|
14
|
+
value?: boolean;
|
|
15
|
+
defaultValue?: boolean;
|
|
16
|
+
/** Fires with the next value. The engine's controlled contract. */
|
|
17
|
+
onValueChange?: (value: boolean) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** Track colour while on. A parseable colour string. Defaults to the scheme's system blue. */
|
|
20
|
+
accentColor?: string;
|
|
21
|
+
/** Track colour while off. */
|
|
22
|
+
trackColor?: string;
|
|
23
|
+
accessibilityLabel?: string;
|
|
14
24
|
/** One selection tick when it toggles. `false` opts out. */
|
|
15
25
|
haptics?: boolean;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
accessibilityLabel: string;
|
|
18
|
-
style?: StyleProp<ViewStyle>;
|
|
19
26
|
isDark?: boolean;
|
|
20
|
-
/** Passed
|
|
27
|
+
/** Passed to the control so it is testable. */
|
|
21
28
|
testID?: string;
|
|
29
|
+
style?: StyleProp<ViewStyle>;
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
const TRACK_WIDTH = 51;
|
|
25
|
-
const TRACK_HEIGHT = 31;
|
|
26
|
-
const THUMB = 27;
|
|
27
|
-
const TRAVEL = TRACK_WIDTH - THUMB - 4;
|
|
28
|
-
|
|
29
32
|
/**
|
|
30
|
-
* An on/off switch
|
|
33
|
+
* An on/off switch — ported from the engine's `LiquidGlassSwitch`, the design
|
|
34
|
+
* Binyam approved on real devices this week (64x28 track, 40x24 lens thumb).
|
|
31
35
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
+
* With a glass renderer available the engine's own control mounts, carrying the
|
|
37
|
+
* approved geometry and interaction. Without one — Expo Go, below every tier, or
|
|
38
|
+
* Reduce Transparency — the fallback floor renders the same geometry with a solid
|
|
39
|
+
* track and lens thumb, so the control is never invisible.
|
|
36
40
|
*/
|
|
37
41
|
export const Switch = forwardRef<any, SwitchProps>(function Switch(
|
|
38
42
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
value: valueProp,
|
|
44
|
+
defaultValue = false,
|
|
45
|
+
onValueChange,
|
|
42
46
|
disabled = false,
|
|
43
|
-
|
|
47
|
+
accentColor,
|
|
48
|
+
trackColor,
|
|
44
49
|
accessibilityLabel,
|
|
45
|
-
|
|
50
|
+
haptics = true,
|
|
46
51
|
isDark: isDarkProp,
|
|
47
52
|
testID,
|
|
53
|
+
style,
|
|
48
54
|
...props
|
|
49
55
|
},
|
|
50
56
|
ref,
|
|
51
57
|
) {
|
|
52
58
|
const isDark = useIsDark(isDarkProp);
|
|
53
59
|
const themeColors = isDark ? colors.dark : colors.light;
|
|
54
|
-
const { View, Pressable
|
|
55
|
-
const
|
|
56
|
-
const
|
|
60
|
+
const { View, Pressable } = primitives();
|
|
61
|
+
const capabilities = glassCapabilities();
|
|
62
|
+
const EngineSwitch = loadEngineControl("Switch");
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
const
|
|
64
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
65
|
+
const value = valueProp ?? internalValue;
|
|
60
66
|
|
|
61
67
|
const toggle = () => {
|
|
62
68
|
if (disabled) return;
|
|
63
|
-
const next = !
|
|
69
|
+
const next = !value;
|
|
64
70
|
if (haptics) hapticSelection();
|
|
65
|
-
if (
|
|
66
|
-
|
|
71
|
+
if (valueProp === undefined) setInternalValue(next);
|
|
72
|
+
onValueChange?.(next);
|
|
67
73
|
};
|
|
68
74
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
height: THUMB,
|
|
83
|
-
borderRadius: THUMB / 2,
|
|
84
|
-
backgroundColor: "#FFFFFF",
|
|
85
|
-
// A hairline edge instead of a drop shadow: RN shadows need per-platform
|
|
86
|
-
// props, and the edge reads correctly on a translucent track.
|
|
87
|
-
borderWidth: 0.5,
|
|
88
|
-
borderColor: "rgba(0, 0, 0, 0.12)",
|
|
89
|
-
transform: [{ translateX: animated ? offset : isChecked ? TRAVEL : 0 }],
|
|
90
|
-
};
|
|
75
|
+
if (EngineSwitch && capabilities.supported) {
|
|
76
|
+
const EngineSwitchComponent = EngineSwitch;
|
|
77
|
+
return (
|
|
78
|
+
<EngineSwitchComponent
|
|
79
|
+
value={value}
|
|
80
|
+
onValueChange={disabled ? undefined : toggle}
|
|
81
|
+
disabled={disabled}
|
|
82
|
+
accentColor={accentColor}
|
|
83
|
+
trackColor={trackColor}
|
|
84
|
+
style={style}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
91
88
|
|
|
89
|
+
// Fallback floor: solid track + lens thumb, full geometry, full states.
|
|
90
|
+
const trackHeight = 28;
|
|
91
|
+
const thumbHeight = 24;
|
|
92
|
+
const thumbInset = 2;
|
|
93
|
+
const travel = 64 - 40 - thumbInset * 2;
|
|
92
94
|
return (
|
|
93
95
|
<Pressable
|
|
94
96
|
ref={ref}
|
|
95
97
|
testID={testID}
|
|
96
98
|
accessibilityRole="switch"
|
|
97
99
|
accessibilityLabel={accessibilityLabel}
|
|
98
|
-
accessibilityState={{ checked:
|
|
100
|
+
accessibilityState={{ checked: value, disabled }}
|
|
99
101
|
disabled={disabled}
|
|
100
|
-
onPress={toggle}
|
|
102
|
+
onPress={disabled ? undefined : toggle}
|
|
101
103
|
style={{ alignSelf: "flex-start" }}
|
|
102
104
|
{...props}
|
|
103
105
|
>
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
<View
|
|
107
|
+
style={{
|
|
108
|
+
width: 64,
|
|
109
|
+
height: trackHeight,
|
|
110
|
+
borderRadius: trackHeight / 2,
|
|
111
|
+
backgroundColor: value ? accentColor ?? themeColors.fill : themeColors.fieldWash,
|
|
112
|
+
overflow: "hidden",
|
|
113
|
+
opacity: disabled ? 0.38 : 1,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<View
|
|
117
|
+
style={{
|
|
118
|
+
position: "absolute",
|
|
119
|
+
left: thumbInset,
|
|
120
|
+
top: (trackHeight - thumbHeight) / 2,
|
|
121
|
+
width: 40,
|
|
122
|
+
height: thumbHeight,
|
|
123
|
+
borderRadius: thumbHeight / 2,
|
|
124
|
+
backgroundColor: themeColors.onTint,
|
|
125
|
+
transform: [{ translateX: value ? travel : 0 }],
|
|
126
|
+
}}
|
|
127
|
+
/>
|
|
128
|
+
</View>
|
|
107
129
|
</Pressable>
|
|
108
130
|
);
|
|
109
131
|
});
|