glacia-native 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -17
- package/lib/module/Accordion.js +58 -0
- package/lib/module/ActionSheet.js +38 -0
- package/lib/module/Alert.js +23 -0
- package/lib/module/AlertDialog.js +47 -0
- package/lib/module/Avatar.js +48 -0
- package/lib/module/Badge.js +36 -0
- package/lib/module/Bars.js +13 -268
- package/lib/module/Button.js +57 -39
- package/lib/module/Card.js +31 -19
- package/lib/module/Checkbox.js +42 -0
- package/lib/module/Chip.js +80 -0
- package/lib/module/Collapsible.js +26 -0
- package/lib/module/ContextMenu.js +33 -0
- package/lib/module/Dialog.js +39 -123
- package/lib/module/DropdownMenu.js +33 -0
- package/lib/module/Field.js +22 -0
- package/lib/module/Glass.js +10 -3
- package/lib/module/Group.js +36 -0
- package/lib/module/IconButton.js +40 -0
- package/lib/module/Input.js +43 -38
- package/lib/module/Label.js +17 -0
- package/lib/module/MorphGroup.js +47 -0
- package/lib/module/Popover.js +29 -0
- package/lib/module/Progress.js +32 -0
- package/lib/module/RadioGroup.js +51 -0
- package/lib/module/Scrim.js +44 -0
- package/lib/module/SegmentedControl.js +70 -63
- package/lib/module/Select.js +51 -0
- package/lib/module/Separator.js +25 -0
- package/lib/module/Sheet.js +51 -0
- package/lib/module/Skeleton.js +48 -0
- package/lib/module/Slider.js +45 -34
- package/lib/module/Stepper.js +167 -0
- package/lib/module/Switch.js +45 -55
- package/lib/module/TabBar.js +50 -44
- package/lib/module/Textarea.js +18 -0
- package/lib/module/Toast.js +55 -0
- package/lib/module/Toggle.js +47 -0
- package/lib/module/ToggleGroup.js +56 -0
- package/lib/module/Toolbar.js +37 -0
- package/lib/module/Tooltip.js +31 -0
- package/lib/module/glass-provider.js +28 -0
- package/lib/module/glass-stack.js +61 -0
- package/lib/module/index.js +78 -109
- package/lib/module/internal/GlassBackdrop.js +36 -0
- package/lib/module/internal/GlassView.js +43 -11
- package/lib/module/internal/blur-community.js +20 -0
- package/lib/module/internal/blur-community.web.js +9 -0
- package/lib/module/internal/blur.js +6 -9
- package/lib/module/internal/glass-routing.js +154 -30
- package/lib/module/internal/initials.js +12 -0
- package/lib/module/internal/overlay.js +147 -0
- package/lib/module/internal/primitives.js +16 -0
- package/lib/typescript/Accordion.d.ts +22 -0
- package/lib/typescript/ActionSheet.d.ts +24 -0
- package/lib/typescript/Alert.d.ts +15 -0
- package/lib/typescript/AlertDialog.d.ts +17 -0
- package/lib/typescript/Avatar.d.ts +22 -0
- package/lib/typescript/Badge.d.ts +12 -0
- package/lib/typescript/Bars.d.ts +3 -188
- package/lib/typescript/Button.d.ts +44 -10
- package/lib/typescript/Card.d.ts +30 -3
- package/lib/typescript/Checkbox.d.ts +14 -0
- package/lib/typescript/Chip.d.ts +19 -0
- package/lib/typescript/Collapsible.d.ts +17 -0
- package/lib/typescript/ContextMenu.d.ts +23 -0
- package/lib/typescript/Dialog.d.ts +8 -68
- package/lib/typescript/DropdownMenu.d.ts +23 -0
- package/lib/typescript/Field.d.ts +19 -0
- package/lib/typescript/Glass.d.ts +11 -2
- package/lib/typescript/Group.d.ts +35 -0
- package/lib/typescript/IconButton.d.ts +21 -0
- package/lib/typescript/Input.d.ts +17 -18
- package/lib/typescript/Label.d.ts +14 -0
- package/lib/typescript/MorphGroup.d.ts +46 -0
- package/lib/typescript/Popover.d.ts +17 -0
- package/lib/typescript/Progress.d.ts +13 -0
- package/lib/typescript/RadioGroup.d.ts +21 -0
- package/lib/typescript/Scrim.d.ts +33 -0
- package/lib/typescript/SegmentedControl.d.ts +24 -13
- package/lib/typescript/Select.d.ts +19 -0
- package/lib/typescript/Separator.d.ts +10 -0
- package/lib/typescript/Sheet.d.ts +45 -0
- package/lib/typescript/Skeleton.d.ts +10 -0
- package/lib/typescript/Slider.d.ts +15 -7
- package/lib/typescript/Stepper.d.ts +49 -0
- package/lib/typescript/Switch.d.ts +19 -12
- package/lib/typescript/TabBar.d.ts +18 -6
- package/lib/typescript/Textarea.d.ts +6 -0
- package/lib/typescript/Toast.d.ts +40 -0
- package/lib/typescript/Toggle.d.ts +21 -0
- package/lib/typescript/ToggleGroup.d.ts +22 -0
- package/lib/typescript/Toolbar.d.ts +35 -0
- package/lib/typescript/Tooltip.d.ts +16 -0
- package/lib/typescript/glass-provider.d.ts +34 -0
- package/lib/typescript/glass-stack.d.ts +54 -0
- package/lib/typescript/index.d.ts +38 -17
- package/lib/typescript/internal/GlassBackdrop.d.ts +33 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -2
- package/lib/typescript/internal/blur-community.d.ts +2 -0
- package/lib/typescript/internal/blur-community.web.d.ts +2 -0
- package/lib/typescript/internal/glass-routing.d.ts +83 -15
- package/lib/typescript/internal/initials.d.ts +2 -0
- package/lib/typescript/internal/overlay.d.ts +74 -0
- package/lib/typescript/internal/primitives.d.ts +11 -0
- package/package.json +4 -2
- package/src/Accordion.tsx +165 -0
- package/src/ActionSheet.tsx +149 -0
- package/src/Alert.tsx +85 -0
- package/src/AlertDialog.tsx +124 -0
- package/src/Avatar.tsx +102 -0
- package/src/Badge.tsx +80 -0
- package/src/Bars.tsx +10 -807
- package/src/Button.tsx +196 -67
- package/src/Card.tsx +105 -32
- package/src/Checkbox.tsx +98 -0
- package/src/Chip.tsx +149 -0
- package/src/Collapsible.tsx +66 -0
- package/src/ContextMenu.tsx +103 -0
- package/src/Dialog.tsx +85 -335
- package/src/DropdownMenu.tsx +103 -0
- package/src/Field.tsx +65 -0
- package/src/Glass.tsx +15 -5
- package/src/Group.tsx +98 -0
- package/src/IconButton.tsx +110 -0
- package/src/Input.tsx +139 -87
- package/src/Label.tsx +56 -0
- package/src/MorphGroup.tsx +134 -0
- package/src/Popover.tsx +81 -0
- package/src/Progress.tsx +83 -0
- package/src/RadioGroup.tsx +122 -0
- package/src/Scrim.tsx +94 -0
- package/src/SegmentedControl.tsx +132 -99
- package/src/Select.tsx +136 -0
- package/src/Separator.tsx +52 -0
- package/src/Sheet.tsx +139 -0
- package/src/Skeleton.tsx +77 -0
- package/src/Slider.tsx +84 -47
- package/src/Stepper.tsx +315 -0
- package/src/Switch.tsx +81 -73
- package/src/TabBar.tsx +106 -93
- package/src/Textarea.tsx +34 -0
- package/src/Toast.tsx +131 -0
- package/src/Toggle.tsx +113 -0
- package/src/ToggleGroup.tsx +129 -0
- package/src/Toolbar.tsx +111 -0
- package/src/Tooltip.tsx +79 -0
- package/src/engine/CHANGELOG.md +430 -0
- package/src/engine/NOTICE +54 -0
- package/src/engine/README.md +975 -0
- package/src/engine/android/build.gradle +18 -0
- package/src/engine/android/src/main/AndroidManifest.xml +2 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/ExpoLiquidGlassModule.kt +174 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/GlassConstants.kt +7 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassContainerView.kt +16 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassProviderView.kt +165 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/LiquidGlassView.kt +1731 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/enums/GlassEnums.kt +171 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropGraph.kt +146 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/BackdropSource.kt +53 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ContinuousCorners.kt +188 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/CornerRadii.kt +62 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassAppearance.kt +352 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassDebug.kt +109 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassEnvironment.kt +139 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassHdr.kt +85 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassLuminanceProbe.kt +189 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassPressAnimator.kt +264 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassProgressiveBlur.kt +249 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderCache.kt +256 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassShaderSource.kt +845 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/GlassTier.kt +63 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/glass/ProviderRegistry.kt +71 -0
- package/src/engine/android/src/main/java/expo/modules/liquidglass/records/GlassRecords.kt +288 -0
- package/src/engine/index.ts +24 -0
- package/src/engine/ios/Enums/GlassBlurDirection.swift +21 -0
- package/src/engine/ios/Enums/GlassVariant.swift +86 -0
- package/src/engine/ios/ExpoLiquidGlass.podspec +93 -0
- package/src/engine/ios/ExpoLiquidGlassModule.swift +77 -0
- package/src/engine/ios/Glass/BackdropCapturer.swift +811 -0
- package/src/engine/ios/Glass/ContinuousCorners.swift +165 -0
- package/src/engine/ios/Glass/GlassBackdrop.swift +176 -0
- package/src/engine/ios/Glass/GlassFramePhase.swift +126 -0
- package/src/engine/ios/Glass/GlassFrameScheduler.swift +261 -0
- package/src/engine/ios/Glass/GlassPressAnimator.swift +250 -0
- package/src/engine/ios/Glass/GlassRenderContext.swift +168 -0
- package/src/engine/ios/Glass/GlassRenderer.swift +186 -0
- package/src/engine/ios/Glass/GlassSurfaceView.swift +452 -0
- package/src/engine/ios/Glass/NonRenderableView.swift +54 -0
- package/src/engine/ios/Glass/StripCache.swift +545 -0
- package/src/engine/ios/Records/GlassCornerRadii.swift +79 -0
- package/src/engine/ios/Records/GlassMetalOptions.swift +180 -0
- package/src/engine/ios/Records/GlassRefractionCurve.swift +14 -0
- package/src/engine/ios/Shaders/LiquidGlass.metal +480 -0
- package/src/engine/ios/Shaders/bundle-marker.txt +6 -0
- package/src/engine/ios/Views/LiquidGlassContainerView.swift +99 -0
- package/src/engine/ios/Views/LiquidGlassView.swift +859 -0
- package/src/engine/package.json +70 -0
- package/src/engine/src/components/LiquidGlassButton/LiquidGlassButton.tsx +424 -0
- package/src/engine/src/components/LiquidGlassCard/LiquidGlassCard.tsx +98 -0
- package/src/engine/src/components/LiquidGlassChip/LiquidGlassChip.tsx +65 -0
- package/src/engine/src/components/LiquidGlassGroup/LiquidGlassGroup.tsx +350 -0
- package/src/engine/src/components/LiquidGlassIconButton/LiquidGlassIconButton.tsx +24 -0
- package/src/engine/src/components/LiquidGlassMorphGroup/LiquidGlassMorphGroup.tsx +434 -0
- package/src/engine/src/components/LiquidGlassScrim/LiquidGlassScrim.tsx +100 -0
- package/src/engine/src/components/LiquidGlassSegmentedControl/LiquidGlassSegmentedControl.tsx +213 -0
- package/src/engine/src/components/LiquidGlassSheet/LiquidGlassSheet.tsx +218 -0
- package/src/engine/src/components/LiquidGlassSlider/LiquidGlassSlider.tsx +327 -0
- package/src/engine/src/components/LiquidGlassStepper/LiquidGlassStepper.tsx +321 -0
- package/src/engine/src/components/LiquidGlassSwitch/LiquidGlassSwitch.tsx +296 -0
- package/src/engine/src/components/LiquidGlassTabBar/LiquidGlassTabBar.tsx +952 -0
- package/src/engine/src/components/LiquidGlassTextInput/LiquidGlassTextInput.tsx +151 -0
- package/src/engine/src/components/LiquidGlassToast/LiquidGlassToast.tsx +169 -0
- package/src/engine/src/components/LiquidGlassToolbar/LiquidGlassToolbar.tsx +124 -0
- package/src/engine/src/components/index.ts +16 -0
- package/src/engine/src/constants/index.ts +4 -0
- package/src/engine/src/constants/metal.constants.ts +327 -0
- package/src/engine/src/constants/metrics.constants.ts +325 -0
- package/src/engine/src/constants/springs.constants.ts +107 -0
- package/src/engine/src/constants/styles.constants.ts +12 -0
- package/src/engine/src/context/glass-group.context.ts +65 -0
- package/src/engine/src/context/index.ts +6 -0
- package/src/engine/src/core/components/LiquidGlassContainer/LiquidGlassContainer.tsx +32 -0
- package/src/engine/src/core/components/LiquidGlassContainer/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassProvider/LiquidGlassProvider.tsx +66 -0
- package/src/engine/src/core/components/LiquidGlassProvider/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassStack/LiquidGlassStack.tsx +184 -0
- package/src/engine/src/core/components/LiquidGlassStack/index.ts +1 -0
- package/src/engine/src/core/components/LiquidGlassView/LiquidGlassView.tsx +126 -0
- package/src/engine/src/core/components/LiquidGlassView/index.ts +1 -0
- package/src/engine/src/core/components/index.ts +4 -0
- package/src/engine/src/core/constants/glass.constants.ts +57 -0
- package/src/engine/src/core/constants/index.ts +20 -0
- package/src/engine/src/core/constants/native.constants.ts +16 -0
- package/src/engine/src/core/context/glass-stack.context.ts +30 -0
- package/src/engine/src/core/context/index.ts +4 -0
- package/src/engine/src/core/enum/index.ts +12 -0
- package/src/engine/src/core/index.ts +1 -0
- package/src/engine/src/core/interfaces/glass-hdr.interface.ts +15 -0
- package/src/engine/src/core/interfaces/glass-metal.interface.ts +248 -0
- package/src/engine/src/core/interfaces/glass-surface.interface.ts +9 -0
- package/src/engine/src/core/interfaces/index.ts +31 -0
- package/src/engine/src/core/interfaces/liquid-glass-container.interface.ts +6 -0
- package/src/engine/src/core/interfaces/liquid-glass-provider.interface.ts +14 -0
- package/src/engine/src/core/interfaces/liquid-glass-stack.interface.ts +21 -0
- package/src/engine/src/core/interfaces/liquid-glass-view.interface.ts +129 -0
- package/src/engine/src/core/interfaces/native-liquid-glass-view.interface.ts +19 -0
- package/src/engine/src/core/modules/ExpoLiquidGlassModule.ts +26 -0
- package/src/engine/src/core/modules/index.ts +2 -0
- package/src/engine/src/core/root/index.ts +51 -0
- package/src/engine/src/core/types/glass.types.ts +25 -0
- package/src/engine/src/core/types/index.ts +8 -0
- package/src/engine/src/core/utils/debug.utils.ts +17 -0
- package/src/engine/src/core/utils/dev-warn.utils.ts +17 -0
- package/src/engine/src/core/utils/hdr.utils.ts +37 -0
- package/src/engine/src/core/utils/index.ts +5 -0
- package/src/engine/src/core/utils/native-view.utils.ts +33 -0
- package/src/engine/src/core/utils/platform.utils.ts +34 -0
- package/src/engine/src/core/views/NativeGlassBackdropView.ts +24 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassContainerView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.ts +13 -0
- package/src/engine/src/core/views/NativeLiquidGlassProviderView.web.ts +10 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.ts +19 -0
- package/src/engine/src/core/views/NativeLiquidGlassView.web.ts +14 -0
- package/src/engine/src/core/views/index.ts +4 -0
- package/src/engine/src/hooks/index.ts +18 -0
- package/src/engine/src/hooks/use-adaptive-glass.ts +91 -0
- package/src/engine/src/hooks/use-damped-drag.ts +332 -0
- package/src/engine/src/hooks/use-echo-filter.ts +55 -0
- package/src/engine/src/hooks/use-glass-group-member.ts +169 -0
- package/src/engine/src/hooks/use-gravity-highlight.ts +79 -0
- package/src/engine/src/hooks/use-press-progress.ts +44 -0
- package/src/engine/src/index.ts +120 -0
- package/src/engine/src/interfaces/index.ts +28 -0
- package/src/engine/src/interfaces/liquid-glass-button.interface.ts +94 -0
- package/src/engine/src/interfaces/liquid-glass-card.interface.ts +40 -0
- package/src/engine/src/interfaces/liquid-glass-chip.interface.ts +29 -0
- package/src/engine/src/interfaces/liquid-glass-group.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-icon-button.interface.ts +19 -0
- package/src/engine/src/interfaces/liquid-glass-morph-group.interface.ts +59 -0
- package/src/engine/src/interfaces/liquid-glass-scrim.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-segmented-control.interface.ts +32 -0
- package/src/engine/src/interfaces/liquid-glass-sheet.interface.ts +38 -0
- package/src/engine/src/interfaces/liquid-glass-slider.interface.ts +37 -0
- package/src/engine/src/interfaces/liquid-glass-stepper.interface.ts +35 -0
- package/src/engine/src/interfaces/liquid-glass-switch.interface.ts +27 -0
- package/src/engine/src/interfaces/liquid-glass-tab-bar.interface.ts +116 -0
- package/src/engine/src/interfaces/liquid-glass-text-input.interface.ts +42 -0
- package/src/engine/src/interfaces/liquid-glass-toast.interface.ts +36 -0
- package/src/engine/src/interfaces/liquid-glass-toolbar.interface.ts +33 -0
- package/src/engine/src/theme/glass-ui-theme.ts +100 -0
- package/src/engine/src/theme/index.ts +2 -0
- package/src/engine/src/utils/button-press.utils.ts +63 -0
- package/src/engine/src/utils/index.ts +3 -0
- package/src/engine/src/utils/metal.utils.ts +164 -0
- package/src/glass-provider.tsx +60 -0
- package/src/glass-stack.tsx +115 -0
- package/src/index.ts +47 -190
- package/src/internal/GlassBackdrop.tsx +60 -0
- package/src/internal/GlassView.tsx +53 -18
- package/src/internal/blur-community.ts +19 -0
- package/src/internal/blur-community.web.ts +7 -0
- package/src/internal/blur.ts +7 -8
- package/src/internal/glass-routing.ts +211 -34
- package/src/internal/initials.ts +7 -0
- package/src/internal/overlay.tsx +258 -0
- package/src/internal/primitives.ts +23 -0
- package/lib/module/Carousel.js +0 -103
- package/lib/module/Display.js +0 -318
- package/lib/module/Feedback.js +0 -395
- package/lib/module/Form.js +0 -160
- package/lib/module/Forms2.js +0 -471
- package/lib/module/Message.js +0 -84
- package/lib/module/Overlays.js +0 -344
- package/lib/module/Pickers.js +0 -243
- package/lib/module/Table.js +0 -100
- package/lib/module/ai.js +0 -283
- package/lib/module/charts/AreaChart.js +0 -32
- package/lib/module/charts/BarChart.js +0 -75
- package/lib/module/charts/FunnelChart.js +0 -50
- package/lib/module/charts/HeatmapChart.js +0 -71
- package/lib/module/charts/LineChart.js +0 -81
- package/lib/module/charts/PlotChart.js +0 -52
- package/lib/module/charts/RadarChart.js +0 -78
- package/lib/module/charts/RingChart.js +0 -52
- package/lib/module/charts/ScatterChart.js +0 -95
- package/lib/module/charts/WaterfallChart.js +0 -85
- package/lib/module/charts/advanced.js +0 -313
- package/lib/module/charts/extra.js +0 -108
- package/lib/module/charts/index.js +0 -50
- package/lib/module/charts/scales.js +0 -140
- package/lib/typescript/Carousel.d.ts +0 -47
- package/lib/typescript/Display.d.ts +0 -178
- package/lib/typescript/Feedback.d.ts +0 -196
- package/lib/typescript/Form.d.ts +0 -97
- package/lib/typescript/Forms2.d.ts +0 -209
- package/lib/typescript/Message.d.ts +0 -67
- package/lib/typescript/Overlays.d.ts +0 -146
- package/lib/typescript/Pickers.d.ts +0 -105
- package/lib/typescript/Table.d.ts +0 -64
- package/lib/typescript/ai.d.ts +0 -166
- package/lib/typescript/charts/AreaChart.d.ts +0 -44
- package/lib/typescript/charts/BarChart.d.ts +0 -19
- package/lib/typescript/charts/FunnelChart.d.ts +0 -25
- package/lib/typescript/charts/HeatmapChart.d.ts +0 -23
- package/lib/typescript/charts/LineChart.d.ts +0 -30
- package/lib/typescript/charts/PlotChart.d.ts +0 -31
- package/lib/typescript/charts/RadarChart.d.ts +0 -27
- package/lib/typescript/charts/RingChart.d.ts +0 -28
- package/lib/typescript/charts/ScatterChart.d.ts +0 -34
- package/lib/typescript/charts/WaterfallChart.d.ts +0 -22
- package/lib/typescript/charts/advanced.d.ts +0 -107
- package/lib/typescript/charts/extra.d.ts +0 -63
- package/lib/typescript/charts/index.d.ts +0 -13
- package/lib/typescript/charts/scales.d.ts +0 -35
- package/src/Carousel.tsx +0 -233
- package/src/Display.tsx +0 -781
- package/src/Feedback.tsx +0 -992
- package/src/Form.tsx +0 -445
- package/src/Forms2.tsx +0 -1055
- package/src/Message.tsx +0 -218
- package/src/Overlays.tsx +0 -704
- package/src/Pickers.tsx +0 -595
- package/src/Table.tsx +0 -232
- package/src/ai.tsx +0 -715
- package/src/charts/AreaChart.tsx +0 -73
- package/src/charts/BarChart.tsx +0 -221
- package/src/charts/FunnelChart.tsx +0 -125
- package/src/charts/HeatmapChart.tsx +0 -155
- package/src/charts/LineChart.tsx +0 -247
- package/src/charts/PlotChart.tsx +0 -168
- package/src/charts/RadarChart.tsx +0 -208
- package/src/charts/RingChart.tsx +0 -133
- package/src/charts/ScatterChart.tsx +0 -223
- package/src/charts/WaterfallChart.tsx +0 -201
- package/src/charts/advanced.tsx +0 -676
- package/src/charts/extra.tsx +0 -242
- package/src/charts/index.ts +0 -86
- package/src/charts/scales.ts +0 -163
|
@@ -0,0 +1,859 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
class LiquidGlassView: ExpoView {
|
|
5
|
+
|
|
6
|
+
override class var layerClass: AnyClass { NonRenderableLayer.self }
|
|
7
|
+
|
|
8
|
+
private var glassLayerView: UIView?
|
|
9
|
+
private let surface = GlassSurfaceView()
|
|
10
|
+
private var visualEffectView: UIVisualEffectView?
|
|
11
|
+
|
|
12
|
+
private let contentContainer = NonRenderableView()
|
|
13
|
+
|
|
14
|
+
private let borderLayer = CAGradientLayer()
|
|
15
|
+
private let borderMask = CAShapeLayer()
|
|
16
|
+
|
|
17
|
+
private let contentMask = CAShapeLayer()
|
|
18
|
+
private let effectMask = CAShapeLayer()
|
|
19
|
+
|
|
20
|
+
var variant: GlassVariant = .regular {
|
|
21
|
+
didSet {
|
|
22
|
+
guard variant != oldValue else { return }
|
|
23
|
+
setNeedsAppearanceUpdate()
|
|
24
|
+
refreshBackend()
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var backend: GlassBackend = .auto {
|
|
29
|
+
didSet {
|
|
30
|
+
guard backend != oldValue else { return }
|
|
31
|
+
refreshBackend()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// `CALayerCornerCurve`, honoured by every renderer since the parity pass: `continuous`
|
|
36
|
+
/// renders the calibrated Apple corner family in the Metal SDF, the content mask, the border
|
|
37
|
+
/// and the backdrop fill (`ContinuousCorners`), and the native path hands it to Core
|
|
38
|
+
/// Animation. Before, the Metal SDF was circular under a continuous content clip, and the
|
|
39
|
+
/// border — circular too — sat up to 0.12 r inside the glass at every corner apex.
|
|
40
|
+
var cornerStyle: GlassCornerStyle = .continuous {
|
|
41
|
+
didSet {
|
|
42
|
+
guard cornerStyle != oldValue else { return }
|
|
43
|
+
invalidateShape()
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var cornerRadii: CornerRadiiValues = .uniform(0) {
|
|
48
|
+
didSet {
|
|
49
|
+
guard cornerRadii != oldValue else { return }
|
|
50
|
+
invalidateShape()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var tint: UIColor = .clear {
|
|
55
|
+
didSet {
|
|
56
|
+
guard tint != oldValue else { return }
|
|
57
|
+
setNeedsAppearanceUpdate()
|
|
58
|
+
applyNativeTint()
|
|
59
|
+
invalidateShape()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// The wash that draws: the recipe's own `metal.tint` when it carries one, else the prop.
|
|
64
|
+
private var effectiveTint: UIColor { metal.tint ?? tint }
|
|
65
|
+
|
|
66
|
+
/// iOS 26's `isInteractive`, and below 26 the Metal path's port of it: a spring-driven
|
|
67
|
+
/// specular that blooms under the finger and follows it, the refraction denting and deepening
|
|
68
|
+
/// around it, and a subtle whole-glass inflation, follow and stretch — `GlassPressAnimator`,
|
|
69
|
+
/// the same springs as Android. Touches reach this view whenever it, or a child that does not
|
|
70
|
+
/// consume them, is the hit-test target; an ancestor gesture taking over (a scroll view) lands
|
|
71
|
+
/// as `touchesCancelled`, which releases like a lift.
|
|
72
|
+
var isInteractive: Bool = false {
|
|
73
|
+
didSet {
|
|
74
|
+
guard isInteractive != oldValue else { return }
|
|
75
|
+
|
|
76
|
+
if shouldUseNativeGlass {
|
|
77
|
+
visualEffectView?.effect = UIVisualEffect()
|
|
78
|
+
}
|
|
79
|
+
applyNativeTint()
|
|
80
|
+
|
|
81
|
+
if !isInteractive {
|
|
82
|
+
// Mid-press prop flip: stop dead and restore rest state.
|
|
83
|
+
pressAnimator?.reset()
|
|
84
|
+
applyPressTransform(.identity)
|
|
85
|
+
pushPressUniforms()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// A press choreographed by the app, usually one happening on some *other* view — see
|
|
91
|
+
/// `GlassGlowOptions`. Non-nil takes over the press uniforms entirely; nil hands them straight
|
|
92
|
+
/// back to `interactive`'s animator. Cheap to animate per frame: the uniforms are re-uploaded
|
|
93
|
+
/// and the surface redrawn, nothing else moves. Ignored by the native UIGlassEffect path.
|
|
94
|
+
var glow: GlassGlowOptions? {
|
|
95
|
+
didSet { pushPressUniforms() }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// The `adaptive` prop: the Metal path reads the mean luminance of the backdrop under the
|
|
99
|
+
/// view off the capture (every 250 ms at most, only when the backdrop or the geometry moved),
|
|
100
|
+
/// reports it through `onBackdropLuminance`, and lets the frost's polarity follow the
|
|
101
|
+
/// backdrop instead of the colour scheme — dark content under a dark frost, light under a
|
|
102
|
+
/// light one — with hysteresis and a 350 ms crossfade. The native UIGlassEffect adapts on its
|
|
103
|
+
/// own and ignores this.
|
|
104
|
+
var isAdaptive = false {
|
|
105
|
+
didSet {
|
|
106
|
+
guard isAdaptive != oldValue else { return }
|
|
107
|
+
frostPolarityDark = traitCollection.userInterfaceStyle == .dark
|
|
108
|
+
lastEmittedLuminance = nil
|
|
109
|
+
surface.snapFrost(dark: frostPolarityDark)
|
|
110
|
+
surface.isAdaptive = isAdaptive && !isUsingNativeGlass
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let onBackdropLuminance = EventDispatcher()
|
|
115
|
+
|
|
116
|
+
private var frostPolarityDark = false
|
|
117
|
+
private var lastEmittedLuminance: Float?
|
|
118
|
+
|
|
119
|
+
/// The sensor's result: hysteresis for the polarity, a delta gate for the event.
|
|
120
|
+
private func handleLuminance(_ luminance: Float) {
|
|
121
|
+
let dark = frostPolarityDark
|
|
122
|
+
? luminance < Self.adaptiveLightAbove
|
|
123
|
+
: luminance < Self.adaptiveDarkBelow
|
|
124
|
+
let flipped = dark != frostPolarityDark
|
|
125
|
+
if flipped {
|
|
126
|
+
frostPolarityDark = dark
|
|
127
|
+
surface.frostDarkTarget = dark ? 1 : 0
|
|
128
|
+
}
|
|
129
|
+
let moved = lastEmittedLuminance.map { abs(luminance - $0) >= Self.luminanceEmitDelta } ?? true
|
|
130
|
+
if moved || flipped {
|
|
131
|
+
lastEmittedLuminance = luminance
|
|
132
|
+
onBackdropLuminance(["luminance": Double(luminance), "dark": dark])
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private static let adaptiveDarkBelow: Float = 0.45
|
|
137
|
+
private static let adaptiveLightAbove: Float = 0.55
|
|
138
|
+
private static let luminanceEmitDelta: Float = 0.02
|
|
139
|
+
|
|
140
|
+
var metal = GlassMetalOptions() {
|
|
141
|
+
didSet {
|
|
142
|
+
setNeedsAppearanceUpdate()
|
|
143
|
+
if borderWidth != cachedBorderWidth { invalidateShape() }
|
|
144
|
+
// A recipe's own tint reaches the native effect and the backdrop fill the same way
|
|
145
|
+
// the prop does.
|
|
146
|
+
if oldValue.tint != metal.tint {
|
|
147
|
+
applyNativeTint()
|
|
148
|
+
invalidateShape()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// `metal.shape` moves the SDF's rect, so the radii must re-resolve against it.
|
|
152
|
+
// Written synchronously (unlike the async appearance pass) because layoutSubviews
|
|
153
|
+
// reads it — an async write would leave one frame on the old geometry.
|
|
154
|
+
let newShape = Self.shapeRect(from: metal)
|
|
155
|
+
if newShape != surface.shapeRect {
|
|
156
|
+
surface.shapeRect = newShape
|
|
157
|
+
invalidateShape()
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private static func shapeRect(from metal: GlassMetalOptions) -> CGRect {
|
|
163
|
+
guard let shape = metal.shape,
|
|
164
|
+
let width = shape.width, let height = shape.height,
|
|
165
|
+
width > 0, height > 0
|
|
166
|
+
else { return .zero }
|
|
167
|
+
return CGRect(x: shape.x ?? 0, y: shape.y ?? 0, width: width, height: height)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private var borderWidth: CGFloat {
|
|
171
|
+
CGFloat(metal.border?.width ?? 1)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let onRendererChange = EventDispatcher()
|
|
175
|
+
|
|
176
|
+
private var isUsingNativeGlass = false
|
|
177
|
+
private var didReportRenderer = false
|
|
178
|
+
private var lastReportedRenderer = ""
|
|
179
|
+
|
|
180
|
+
private var hasPendingAppearanceUpdate = false
|
|
181
|
+
|
|
182
|
+
private var resolvedFrostColor = SIMD4<Float>(1, 1, 1, 1)
|
|
183
|
+
|
|
184
|
+
private var mountedChildren: [UIView] = []
|
|
185
|
+
|
|
186
|
+
private var hasAppliedEffectAfterLayout = false
|
|
187
|
+
|
|
188
|
+
private var shapeIsValid = false
|
|
189
|
+
private var cachedRadii = CornerRadiiValues()
|
|
190
|
+
private var cachedShapeSize: CGSize = .zero
|
|
191
|
+
private var cachedBorderWidth: CGFloat = -1
|
|
192
|
+
|
|
193
|
+
/// The highlight's light angle, radians — the border gradient's axis follows it.
|
|
194
|
+
private var highlightAngle: CGFloat =
|
|
195
|
+
CGFloat(LiquidGlassView.defaultHighlightAngleDegrees) * .pi / 180
|
|
196
|
+
|
|
197
|
+
/// Lazily created on the first interactive press; nil means no press has ever happened.
|
|
198
|
+
private var pressAnimator: GlassPressAnimator?
|
|
199
|
+
|
|
200
|
+
required init(appContext: AppContext? = nil) {
|
|
201
|
+
super.init(appContext: appContext)
|
|
202
|
+
|
|
203
|
+
clipsToBounds = false
|
|
204
|
+
backgroundColor = .clear
|
|
205
|
+
|
|
206
|
+
contentContainer.isUserInteractionEnabled = true
|
|
207
|
+
addSubview(contentContainer)
|
|
208
|
+
|
|
209
|
+
borderLayer.mask = borderMask
|
|
210
|
+
|
|
211
|
+
borderLayer.opacity = 0
|
|
212
|
+
|
|
213
|
+
// Pure white light with transparent-white tails: real iOS 26 glass has no dark edge
|
|
214
|
+
// component, so the black end stops this layer used to carry are gone. The axis follows
|
|
215
|
+
// `highlight.angle` — see updateBorderAxis — so one prop steers the shader's rim lobes
|
|
216
|
+
// and this stroke together.
|
|
217
|
+
borderLayer.colors = [
|
|
218
|
+
UIColor.white.withAlphaComponent(0).cgColor,
|
|
219
|
+
UIColor.white.cgColor,
|
|
220
|
+
UIColor.white.cgColor,
|
|
221
|
+
UIColor.white.withAlphaComponent(0).cgColor,
|
|
222
|
+
]
|
|
223
|
+
borderLayer.locations = [0, 0.25, 0.75, 1]
|
|
224
|
+
borderLayer.startPoint = CGPoint(x: 0.5, y: 1)
|
|
225
|
+
borderLayer.endPoint = CGPoint(x: 0.5, y: 0)
|
|
226
|
+
borderMask.fillColor = UIColor.clear.cgColor
|
|
227
|
+
borderMask.strokeColor = UIColor.white.cgColor
|
|
228
|
+
layer.addSublayer(borderLayer)
|
|
229
|
+
|
|
230
|
+
contentMask.fillColor = UIColor.white.cgColor
|
|
231
|
+
effectMask.fillColor = UIColor.white.cgColor
|
|
232
|
+
|
|
233
|
+
surface.onLuminance = { [weak self] luminance in self?.handleLuminance(luminance) }
|
|
234
|
+
|
|
235
|
+
updateResolvedFrostColor()
|
|
236
|
+
applyAppearance()
|
|
237
|
+
refreshBackend()
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
private var shouldUseNativeGlass: Bool {
|
|
241
|
+
switch backend {
|
|
242
|
+
case .metal:
|
|
243
|
+
return false
|
|
244
|
+
case .native, .auto:
|
|
245
|
+
if #available(iOS 26.0, *) { return Self.isGlassEffectAvailable }
|
|
246
|
+
return false
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
private static let isGlassEffectAvailable: Bool = {
|
|
251
|
+
if #available(iOS 26.0, *) {
|
|
252
|
+
guard let glassEffectClass = NSClassFromString("UIGlassEffect") as? NSObject.Type else {
|
|
253
|
+
return false
|
|
254
|
+
}
|
|
255
|
+
return glassEffectClass.responds(to: NSSelectorFromString("effectWithStyle:"))
|
|
256
|
+
}
|
|
257
|
+
return false
|
|
258
|
+
}()
|
|
259
|
+
|
|
260
|
+
private func refreshBackend() {
|
|
261
|
+
let wantsNative = shouldUseNativeGlass
|
|
262
|
+
|
|
263
|
+
let useNative = wantsNative || !surface.isOperational
|
|
264
|
+
|
|
265
|
+
isUsingNativeGlass = useNative
|
|
266
|
+
|
|
267
|
+
if useNative {
|
|
268
|
+
// The press choreography is the Metal path's; Apple's material owns its own.
|
|
269
|
+
pressAnimator?.reset()
|
|
270
|
+
applyPressTransform(.identity)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if useNative, !wantsNative {
|
|
274
|
+
installFallbackBlur()
|
|
275
|
+
} else if useNative {
|
|
276
|
+
installNativeGlass()
|
|
277
|
+
} else {
|
|
278
|
+
installMetalGlass()
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
surface.isAdaptive = isAdaptive && !isUsingNativeGlass
|
|
282
|
+
|
|
283
|
+
updateBackdropExclusion()
|
|
284
|
+
restoreChildren()
|
|
285
|
+
reportRenderer()
|
|
286
|
+
invalidateShape()
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private func updateBackdropExclusion() {
|
|
290
|
+
let excluded = !isUsingNativeGlass
|
|
291
|
+
(layer as? NonRenderableLayer)?.isExcludedFromBackdrop = excluded
|
|
292
|
+
contentContainer.isExcludedFromBackdrop = excluded
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private func installNativeGlass() {
|
|
296
|
+
surface.removeFromSuperview()
|
|
297
|
+
|
|
298
|
+
let effectView = existingOrNewEffectView()
|
|
299
|
+
applyNativeTint()
|
|
300
|
+
setGlassLayerView(effectView)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private func installFallbackBlur() {
|
|
304
|
+
surface.removeFromSuperview()
|
|
305
|
+
|
|
306
|
+
let effectView = existingOrNewEffectView()
|
|
307
|
+
effectView.effect = UIBlurEffect(style: .systemThinMaterial)
|
|
308
|
+
setGlassLayerView(effectView)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private func existingOrNewEffectView() -> UIVisualEffectView {
|
|
312
|
+
if let visualEffectView { return visualEffectView }
|
|
313
|
+
let effectView = UIVisualEffectView(effect: nil)
|
|
314
|
+
|
|
315
|
+
effectView.isUserInteractionEnabled = true
|
|
316
|
+
visualEffectView = effectView
|
|
317
|
+
return effectView
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
private func installMetalGlass() {
|
|
321
|
+
visualEffectView?.removeFromSuperview()
|
|
322
|
+
visualEffectView = nil
|
|
323
|
+
setGlassLayerView(surface)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private func setGlassLayerView(_ view: UIView) {
|
|
327
|
+
// Identity alone is not proof that the layer is installed. Fabric
|
|
328
|
+
// recycles component views, and a view coming back from the pool still
|
|
329
|
+
// holds its `glassLayerView` reference while the layer itself is no
|
|
330
|
+
// longer in the hierarchy. The old guard read that as "already done"
|
|
331
|
+
// and returned, leaving the view with a glass layer it believes it has
|
|
332
|
+
// and does not.
|
|
333
|
+
guard glassLayerView !== view || view.superview !== self else { return }
|
|
334
|
+
if glassLayerView !== view {
|
|
335
|
+
glassLayerView?.removeFromSuperview()
|
|
336
|
+
}
|
|
337
|
+
insertSubview(view, at: 0)
|
|
338
|
+
glassLayerView = view
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
private func applyNativeTint() {
|
|
342
|
+
guard #available(iOS 26.0, *),
|
|
343
|
+
let visualEffectView,
|
|
344
|
+
isUsingNativeGlass,
|
|
345
|
+
shouldUseNativeGlass
|
|
346
|
+
else { return }
|
|
347
|
+
let effect = UIGlassEffect(style: variant == .clear ? .clear : .regular)
|
|
348
|
+
effect.isInteractive = isInteractive
|
|
349
|
+
let wash = effectiveTint
|
|
350
|
+
effect.tintColor = wash.cgColor.alpha > 0 ? wash : nil
|
|
351
|
+
visualEffectView.effect = effect
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
private func setNeedsAppearanceUpdate() {
|
|
355
|
+
guard !hasPendingAppearanceUpdate else { return }
|
|
356
|
+
hasPendingAppearanceUpdate = true
|
|
357
|
+
DispatchQueue.main.async { [weak self] in
|
|
358
|
+
guard let self, self.hasPendingAppearanceUpdate else { return }
|
|
359
|
+
self.hasPendingAppearanceUpdate = false
|
|
360
|
+
self.applyAppearance()
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
private func applyAppearance() {
|
|
365
|
+
let defaults = variant.metalDefaults
|
|
366
|
+
|
|
367
|
+
let refraction = metal.refraction
|
|
368
|
+
let dispersion = metal.dispersion
|
|
369
|
+
let highlight = metal.highlight
|
|
370
|
+
let innerShadow = metal.innerShadow
|
|
371
|
+
|
|
372
|
+
surface.blurRadius = resolve(metal.blurRadius, defaults.blur)
|
|
373
|
+
surface.captureQuality = max(CGFloat(metal.captureQuality ?? 1), 0.25)
|
|
374
|
+
|
|
375
|
+
// Metal-renderer only, like the rest of `metal`. Two zero radii are off; the surface
|
|
376
|
+
// treats an active ramp as replacing the uniform blur stage.
|
|
377
|
+
if let progressive = metal.progressiveBlur,
|
|
378
|
+
max(progressive.startRadius ?? 0, progressive.endRadius ?? 0) > 0 {
|
|
379
|
+
surface.progressiveBlurStart = CGFloat(progressive.startRadius ?? 0)
|
|
380
|
+
surface.progressiveBlurEnd = CGFloat(progressive.endRadius ?? 0)
|
|
381
|
+
surface.progressiveBlurDirection = progressive.direction ?? .down
|
|
382
|
+
surface.progressiveBlurRampStart = CGFloat(progressive.start ?? 0)
|
|
383
|
+
surface.progressiveBlurRampEnd = CGFloat(progressive.end ?? 1)
|
|
384
|
+
} else {
|
|
385
|
+
surface.progressiveBlurStart = 0
|
|
386
|
+
surface.progressiveBlurEnd = 0
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
surface.refractionScale = CGSize(
|
|
390
|
+
width: resolve(refraction?.width, defaults.width),
|
|
391
|
+
height: resolve(refraction?.height, defaults.height)
|
|
392
|
+
)
|
|
393
|
+
surface.refractionAmount = resolve(refraction?.amount, defaults.amount)
|
|
394
|
+
surface.depthEffect = resolve(refraction?.depth, defaults.depthEffect)
|
|
395
|
+
surface.refractionProfile = refraction?.curve?.simd ?? defaults.profile
|
|
396
|
+
// Clamped: the padding budget's outward-excursion bound needs |swirl| <= 1.
|
|
397
|
+
surface.refractionSwirl = min(max(CGFloat(refraction?.swirl ?? 0), -1), 1)
|
|
398
|
+
|
|
399
|
+
surface.dispersionAmount = resolve(dispersion?.amount, defaults.dispersion)
|
|
400
|
+
surface.dispersionHeight = resolve(dispersion?.reach, defaults.height)
|
|
401
|
+
// Clamped: the shader's `mix(1, q, t)` is only a blend for t in [0, 1].
|
|
402
|
+
surface.dispersionQuadrant = min(max(CGFloat(dispersion?.quadrant ?? 0), 0), 1)
|
|
403
|
+
|
|
404
|
+
surface.highlightIntensity = resolve(highlight?.intensity, defaults.highlight)
|
|
405
|
+
highlightAngle = CGFloat(highlight?.angle ?? Self.defaultHighlightAngleDegrees) * .pi / 180
|
|
406
|
+
surface.highlightAngle = highlightAngle
|
|
407
|
+
surface.highlightWidth = max(resolve(highlight?.width, Self.defaultHighlightWidth), 0)
|
|
408
|
+
// Floored here, not per pixel: pow(0, 0) in the shader is the alternative.
|
|
409
|
+
surface.highlightFalloff = max(CGFloat(highlight?.falloff ?? 1), 0.01)
|
|
410
|
+
|
|
411
|
+
surface.frostAmount = resolve(metal.frost, defaults.frost)
|
|
412
|
+
surface.saturation = resolve(metal.saturation, defaults.saturation)
|
|
413
|
+
surface.noiseAmount = resolve(metal.noise, defaults.noise)
|
|
414
|
+
surface.lightIntensity = resolve(metal.light, defaults.light)
|
|
415
|
+
|
|
416
|
+
surface.glassOpacity = CGFloat(metal.opacity ?? 1)
|
|
417
|
+
surface.tintRGBA = effectiveTint.simdRGBA
|
|
418
|
+
surface.frostRGB = resolvedFrostColor
|
|
419
|
+
|
|
420
|
+
// >= 1 only: a magnification below 1 would sample outside the padded capture.
|
|
421
|
+
surface.magnification = min(max(CGFloat(metal.magnification ?? 1), 1), 4)
|
|
422
|
+
|
|
423
|
+
// The cast defaults to straight down by one radius — lit from above, the top inner
|
|
424
|
+
// edge shades — which is Kyant's default and what the kit's pressed controls use.
|
|
425
|
+
let shadowRadius = max(CGFloat(innerShadow?.radius ?? 0), 0)
|
|
426
|
+
surface.innerShadowRadius = shadowRadius
|
|
427
|
+
surface.innerShadowOffset = CGPoint(
|
|
428
|
+
x: CGFloat(innerShadow?.offsetX ?? 0),
|
|
429
|
+
y: innerShadow?.offsetY.map { CGFloat($0) } ?? shadowRadius
|
|
430
|
+
)
|
|
431
|
+
surface.innerShadowOpacity = min(
|
|
432
|
+
max(innerShadow?.opacity.map { CGFloat($0) } ?? Self.defaultInnerShadowOpacity, 0), 1
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
// Metal-renderer only, like the rest of `metal` — the native UIGlassEffect path has no
|
|
436
|
+
// morph to drive. All-or-nothing: width, height and a positive smoothing make it live.
|
|
437
|
+
if let morph = metal.morph,
|
|
438
|
+
let morphWidth = morph.width, let morphHeight = morph.height,
|
|
439
|
+
(morph.smoothing ?? 0) > 0 {
|
|
440
|
+
surface.morphRect = CGRect(
|
|
441
|
+
x: morph.x ?? 0, y: morph.y ?? 0, width: morphWidth, height: morphHeight
|
|
442
|
+
)
|
|
443
|
+
surface.morphCornerRadius = CGFloat(morph.cornerRadius ?? 0)
|
|
444
|
+
surface.morphSmoothing = CGFloat(morph.smoothing ?? 0)
|
|
445
|
+
} else {
|
|
446
|
+
surface.morphRect = .zero
|
|
447
|
+
surface.morphCornerRadius = 0
|
|
448
|
+
surface.morphSmoothing = 0
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
borderLayer.opacity = Float(metal.border?.opacity ?? Double(defaults.borderOpacity))
|
|
452
|
+
updateBorderAxis()
|
|
453
|
+
|
|
454
|
+
// The capture keeps everything painted over this pane out of its padded rect
|
|
455
|
+
// (`BackdropCapturer.drawTree`); the reach is the surface's own padding, which the
|
|
456
|
+
// lines above have just resolved.
|
|
457
|
+
(layer as? NonRenderableLayer)?.backdropHolePadding = surface.glassBackdropPadding
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
private func resolve(_ override: Double?, _ fallback: CGFloat) -> CGFloat {
|
|
461
|
+
guard let override else { return fallback }
|
|
462
|
+
return CGFloat(override)
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
private func updateResolvedFrostColor() {
|
|
466
|
+
resolvedFrostColor = UIColor.systemBackground
|
|
467
|
+
.resolvedColor(with: traitCollection)
|
|
468
|
+
.simdRGBA
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
override func traitCollectionDidChange(_ previous: UITraitCollection?) {
|
|
472
|
+
super.traitCollectionDidChange(previous)
|
|
473
|
+
guard traitCollection.userInterfaceStyle != previous?.userInterfaceStyle else { return }
|
|
474
|
+
updateResolvedFrostColor()
|
|
475
|
+
applyAppearance()
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
private func reportRenderer() {
|
|
479
|
+
|
|
480
|
+
guard window != nil else { return }
|
|
481
|
+
|
|
482
|
+
let name = isUsingNativeGlass
|
|
483
|
+
? (shouldUseNativeGlass ? "native" : "fallback-blur")
|
|
484
|
+
: "metal"
|
|
485
|
+
guard !didReportRenderer || name != lastReportedRenderer else { return }
|
|
486
|
+
didReportRenderer = true
|
|
487
|
+
lastReportedRenderer = name
|
|
488
|
+
onRendererChange(["renderer": name])
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
override func didMoveToWindow() {
|
|
492
|
+
super.didMoveToWindow()
|
|
493
|
+
|
|
494
|
+
guard window != nil else {
|
|
495
|
+
hasAppliedEffectAfterLayout = false
|
|
496
|
+
pressAnimator?.reset()
|
|
497
|
+
applyPressTransform(.identity)
|
|
498
|
+
return
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Re-resolve the backend if the glass layer is not actually ours.
|
|
502
|
+
//
|
|
503
|
+
// `refreshBackend()` — the only thing that installs a glass layer — has
|
|
504
|
+
// exactly three callers: `init`, and the `didSet` on `variant` and on
|
|
505
|
+
// `backend`. Both `didSet`s guard on `!= oldValue`.
|
|
506
|
+
//
|
|
507
|
+
// A RECYCLED view runs none of them. `init` is long past, and Fabric
|
|
508
|
+
// re-applies the same props the view already carried from its previous
|
|
509
|
+
// life, so neither `didSet` fires. The view therefore mounts with
|
|
510
|
+
// whatever hierarchy recycling left it — and `layoutSubviews` goes on
|
|
511
|
+
// to set a perfectly good `UIGlassEffect` on a `UIVisualEffectView`
|
|
512
|
+
// that is no longer in the tree. Nothing paints, and the surface reads
|
|
513
|
+
// as though it never mounted.
|
|
514
|
+
//
|
|
515
|
+
// Reported on iOS 26 as "the glass is unmounting when i view the stream
|
|
516
|
+
// view again": a screen's chrome unmounts wholesale between visits,
|
|
517
|
+
// which is exactly the path that puts these views through the recycle
|
|
518
|
+
// pool. Ported from mine-app's `ios-glass-recycle` patch (2026-08-26).
|
|
519
|
+
//
|
|
520
|
+
// The condition makes this a no-op on an ordinary re-attach, where the
|
|
521
|
+
// layer is still installed.
|
|
522
|
+
if glassLayerView?.superview !== self {
|
|
523
|
+
refreshBackend()
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
setNeedsLayout()
|
|
527
|
+
reportRenderer()
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
private var contentHost: UIView {
|
|
531
|
+
if isUsingNativeGlass, let visualEffectView {
|
|
532
|
+
return visualEffectView.contentView
|
|
533
|
+
}
|
|
534
|
+
return contentContainer
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
private func restoreChildren() {
|
|
538
|
+
guard !mountedChildren.isEmpty else { return }
|
|
539
|
+
let host = contentHost
|
|
540
|
+
for (index, child) in mountedChildren.enumerated() {
|
|
541
|
+
host.insertSubview(child, at: min(index, host.subviews.count))
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
override func mountChildComponentView(_ childComponentView: UIView, index: Int) {
|
|
546
|
+
mountedChildren.insert(childComponentView, at: min(index, mountedChildren.count))
|
|
547
|
+
let host = contentHost
|
|
548
|
+
host.insertSubview(childComponentView, at: min(index, host.subviews.count))
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
override func unmountChildComponentView(_ childComponentView: UIView, index: Int) {
|
|
552
|
+
mountedChildren.removeAll { $0 === childComponentView }
|
|
553
|
+
childComponentView.removeFromSuperview()
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// MARK: - Interactive presses (Metal path)
|
|
557
|
+
|
|
558
|
+
/// Whether a touch on this view should drive the press animator: the Metal path only —
|
|
559
|
+
/// Apple's material choreographs its own `isInteractive`.
|
|
560
|
+
private var pressResponds: Bool {
|
|
561
|
+
isInteractive && !isUsingNativeGlass
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
|
565
|
+
super.touchesBegan(touches, with: event)
|
|
566
|
+
guard pressResponds, let touch = touches.first else { return }
|
|
567
|
+
let point = touch.location(in: self)
|
|
568
|
+
obtainPressAnimator().pressDown(x: point.x, y: point.y)
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
|
572
|
+
super.touchesMoved(touches, with: event)
|
|
573
|
+
guard pressResponds, let touch = touches.first else { return }
|
|
574
|
+
let point = touch.location(in: self)
|
|
575
|
+
pressAnimator?.follow(x: point.x, y: point.y)
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
|
579
|
+
super.touchesEnded(touches, with: event)
|
|
580
|
+
pressAnimator?.releasePress()
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/// An ancestor recogniser taking the gesture (a scroll view's pan) lands here — released
|
|
584
|
+
/// exactly like a lift, so the glass never sticks inflated.
|
|
585
|
+
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
|
|
586
|
+
super.touchesCancelled(touches, with: event)
|
|
587
|
+
pressAnimator?.releasePress()
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
private func obtainPressAnimator() -> GlassPressAnimator {
|
|
591
|
+
if let pressAnimator { return pressAnimator }
|
|
592
|
+
let created = GlassPressAnimator(host: self) { [weak self] in self?.onPressFrame() }
|
|
593
|
+
pressAnimator = created
|
|
594
|
+
return created
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/// Animation-stage write-through: fresh uniforms and a fresh transform, drawn by the frame
|
|
598
|
+
/// scheduler's next tick.
|
|
599
|
+
private func onPressFrame() {
|
|
600
|
+
guard let animator = pressAnimator, pressResponds else { return }
|
|
601
|
+
let transform = CGAffineTransform(translationX: animator.followX, y: animator.followY)
|
|
602
|
+
.scaledBy(x: animator.scale * animator.stretchX, y: animator.scale * animator.stretchY)
|
|
603
|
+
applyPressTransform(transform)
|
|
604
|
+
pushPressUniforms()
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/// The inflation, follow and stretch go on this view's own subviews — the glass surface, the
|
|
608
|
+
/// content host and the border — never on this view itself, whose `layer.transform` React
|
|
609
|
+
/// Native owns through the `transform` style. Children ride along inside the content host, so
|
|
610
|
+
/// hit-testing stays correct through the press.
|
|
611
|
+
private func applyPressTransform(_ transform: CGAffineTransform) {
|
|
612
|
+
CATransaction.begin()
|
|
613
|
+
CATransaction.setDisableActions(true)
|
|
614
|
+
glassLayerView?.transform = transform
|
|
615
|
+
contentContainer.transform = transform
|
|
616
|
+
borderLayer.setAffineTransform(transform)
|
|
617
|
+
CATransaction.commit()
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/// Two sources feed the same press uniforms: this view's own `interactive` animator, and a
|
|
621
|
+
/// `glow` record the app drives. An explicit record wins — it is the caller saying "I am
|
|
622
|
+
/// choreographing this".
|
|
623
|
+
private func pushPressUniforms() {
|
|
624
|
+
if let glow {
|
|
625
|
+
surface.glowProgress = CGFloat(min(max(glow.progress, 0), 1))
|
|
626
|
+
surface.glowPoint = CGPoint(
|
|
627
|
+
x: glow.x.map { CGFloat($0) } ?? bounds.midX,
|
|
628
|
+
y: glow.y.map { CGFloat($0) } ?? bounds.midY
|
|
629
|
+
)
|
|
630
|
+
surface.glowLens = glow.lens ? 1 : 0
|
|
631
|
+
} else if pressResponds, let animator = pressAnimator {
|
|
632
|
+
surface.glowProgress = animator.glow
|
|
633
|
+
surface.glowPoint = CGPoint(x: animator.posX, y: animator.posY)
|
|
634
|
+
surface.glowLens = 1
|
|
635
|
+
} else {
|
|
636
|
+
surface.glowProgress = 0
|
|
637
|
+
surface.glowLens = 1
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// MARK: - Shape
|
|
642
|
+
|
|
643
|
+
private func invalidateShape() {
|
|
644
|
+
shapeIsValid = false
|
|
645
|
+
setNeedsLayout()
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
override func layoutSubviews() {
|
|
649
|
+
super.layoutSubviews()
|
|
650
|
+
|
|
651
|
+
// The latch may only close on a SUCCESSFUL application. `applyNativeTint()`
|
|
652
|
+
// guards on `visualEffectView != nil` and `isUsingNativeGlass`; setting
|
|
653
|
+
// the flag before calling it meant a bail left the view holding the
|
|
654
|
+
// blank `UIVisualEffect()` assigned below, with no retry until it next
|
|
655
|
+
// left the window. Hoisting both conditions makes the bail unreachable.
|
|
656
|
+
if !hasAppliedEffectAfterLayout, window != nil, shouldUseNativeGlass,
|
|
657
|
+
isUsingNativeGlass, let visualEffectView {
|
|
658
|
+
hasAppliedEffectAfterLayout = true
|
|
659
|
+
|
|
660
|
+
visualEffectView.effect = UIVisualEffect()
|
|
661
|
+
applyNativeTint()
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
let center = CGPoint(x: bounds.midX, y: bounds.midY)
|
|
665
|
+
for child in [glassLayerView, contentContainer].compactMap({ $0 }) {
|
|
666
|
+
child.bounds = CGRect(origin: .zero, size: bounds.size)
|
|
667
|
+
child.center = center
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// The glow's default hotspot is the view's centre, so it re-resolves with the size.
|
|
671
|
+
pushPressUniforms()
|
|
672
|
+
|
|
673
|
+
let radii = cornerRadii
|
|
674
|
+
|
|
675
|
+
guard !shapeIsValid
|
|
676
|
+
|| cachedShapeSize != bounds.size
|
|
677
|
+
|| cachedRadii != radii
|
|
678
|
+
|| cachedBorderWidth != borderWidth
|
|
679
|
+
else { return }
|
|
680
|
+
|
|
681
|
+
shapeIsValid = true
|
|
682
|
+
cachedShapeSize = bounds.size
|
|
683
|
+
cachedRadii = radii
|
|
684
|
+
cachedBorderWidth = borderWidth
|
|
685
|
+
|
|
686
|
+
let clamped = radii.clamped(to: bounds.size)
|
|
687
|
+
// With `metal.shape` the SDF's rect is smaller than the view, and the radii must clamp
|
|
688
|
+
// against IT — the border layer and content masks below still track the view, which is
|
|
689
|
+
// documented as the shape-inset limitation (canvas views host their own chrome).
|
|
690
|
+
let radiiBasis = surface.shapeRect == .zero ? bounds.size : surface.shapeRect.size
|
|
691
|
+
let resolved = ContinuousCorners.resolve(
|
|
692
|
+
radii.clamped(to: radiiBasis),
|
|
693
|
+
continuous: cornerStyle == .continuous,
|
|
694
|
+
size: radiiBasis
|
|
695
|
+
)
|
|
696
|
+
surface.cornerExtents = resolved.extentsSIMD
|
|
697
|
+
surface.cornerShapes = resolved.shapesSIMD
|
|
698
|
+
|
|
699
|
+
applyCornerShaping(clamped)
|
|
700
|
+
applyBorder(clamped)
|
|
701
|
+
updateBackdropFill(clamped)
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
private func updateBackdropFill(_ radii: CornerRadiiValues) {
|
|
705
|
+
guard let layer = layer as? NonRenderableLayer else { return }
|
|
706
|
+
let wash = effectiveTint
|
|
707
|
+
guard isUsingNativeGlass, wash.cgColor.alpha > 0 else {
|
|
708
|
+
layer.backdropFillColor = nil
|
|
709
|
+
layer.backdropFillPath = nil
|
|
710
|
+
return
|
|
711
|
+
}
|
|
712
|
+
layer.backdropFillColor = wash.cgColor
|
|
713
|
+
layer.backdropFillPath = path(for: radii).cgPath
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
private func applyCornerShaping(_ radii: CornerRadiiValues) {
|
|
717
|
+
contentContainer.layer.cornerCurve = cornerStyle.layerCurve
|
|
718
|
+
|
|
719
|
+
// Uniform radii ride Core Animation's own corner curve — for `continuous` that is Apple's
|
|
720
|
+
// exact curve, within 0.8 px of the shader's family at any UI radius. Per-corner radii
|
|
721
|
+
// take the path, which is that family verbatim.
|
|
722
|
+
if radii.isUniform {
|
|
723
|
+
contentContainer.layer.mask = nil
|
|
724
|
+
contentContainer.layer.cornerRadius = radii.topLeft
|
|
725
|
+
contentContainer.clipsToBounds = radii.topLeft > 0
|
|
726
|
+
} else {
|
|
727
|
+
contentContainer.layer.cornerRadius = 0
|
|
728
|
+
contentMask.frame = bounds
|
|
729
|
+
contentMask.path = path(for: radii).cgPath
|
|
730
|
+
contentContainer.layer.mask = contentMask
|
|
731
|
+
contentContainer.clipsToBounds = true
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
guard let visualEffectView else { return }
|
|
735
|
+
visualEffectView.layer.cornerCurve = cornerStyle.layerCurve
|
|
736
|
+
if radii.isUniform {
|
|
737
|
+
visualEffectView.layer.mask = nil
|
|
738
|
+
visualEffectView.layer.cornerRadius = radii.topLeft
|
|
739
|
+
visualEffectView.clipsToBounds = true
|
|
740
|
+
} else {
|
|
741
|
+
visualEffectView.layer.cornerRadius = 0
|
|
742
|
+
effectMask.frame = bounds
|
|
743
|
+
effectMask.path = path(for: radii).cgPath
|
|
744
|
+
visualEffectView.layer.mask = effectMask
|
|
745
|
+
visualEffectView.clipsToBounds = true
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
private func applyBorder(_ radii: CornerRadiiValues) {
|
|
750
|
+
|
|
751
|
+
let visible = !isUsingNativeGlass && borderWidth > 0
|
|
752
|
+
borderLayer.isHidden = !visible
|
|
753
|
+
guard visible else { return }
|
|
754
|
+
|
|
755
|
+
CATransaction.begin()
|
|
756
|
+
CATransaction.setDisableActions(true)
|
|
757
|
+
// Bounds and position rather than frame: the layer carries the press transform, and a
|
|
758
|
+
// frame written through a transform is not the geometry it looks like.
|
|
759
|
+
borderLayer.bounds = CGRect(origin: .zero, size: bounds.size)
|
|
760
|
+
borderLayer.position = CGPoint(x: bounds.midX, y: bounds.midY)
|
|
761
|
+
borderMask.frame = CGRect(origin: .zero, size: bounds.size)
|
|
762
|
+
borderMask.lineWidth = borderWidth
|
|
763
|
+
|
|
764
|
+
borderMask.path = path(for: radii, inset: borderWidth / 2).cgPath
|
|
765
|
+
updateBorderAxis()
|
|
766
|
+
CATransaction.commit()
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/// Lays the border gradient along the highlight axis. `reach` is half the view's footprint
|
|
770
|
+
/// projected onto that axis, so the extreme corners project exactly onto stops 0 and 1 at
|
|
771
|
+
/// any angle — the geometry the old corner-to-corner diagonal had for its one fixed angle.
|
|
772
|
+
/// Expressed in the layer's unit square, which is what CAGradientLayer's points are.
|
|
773
|
+
private func updateBorderAxis() {
|
|
774
|
+
let w = max(bounds.width, 1)
|
|
775
|
+
let h = max(bounds.height, 1)
|
|
776
|
+
let dx = cos(highlightAngle)
|
|
777
|
+
let dy = sin(highlightAngle)
|
|
778
|
+
let reach = 0.5 * (abs(w * dx) + abs(h * dy))
|
|
779
|
+
borderLayer.startPoint = CGPoint(x: 0.5 - reach * dx / w, y: 0.5 - reach * dy / h)
|
|
780
|
+
borderLayer.endPoint = CGPoint(x: 0.5 + reach * dx / w, y: 0.5 + reach * dy / h)
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/// The clip and border outline. Continuous corners take the calibrated superellipse family —
|
|
784
|
+
/// the same curve the Metal SDF evaluates — so the stroke sits on the refraction fold;
|
|
785
|
+
/// circular corners take arcs.
|
|
786
|
+
private func path(for radii: CornerRadiiValues, inset: CGFloat = 0) -> UIBezierPath {
|
|
787
|
+
let rect = bounds.insetBy(dx: inset, dy: inset)
|
|
788
|
+
guard rect.width > 0, rect.height > 0 else { return UIBezierPath() }
|
|
789
|
+
|
|
790
|
+
let adjusted = CornerRadiiValues(
|
|
791
|
+
topLeft: max(0, radii.topLeft - inset),
|
|
792
|
+
topRight: max(0, radii.topRight - inset),
|
|
793
|
+
bottomRight: max(0, radii.bottomRight - inset),
|
|
794
|
+
bottomLeft: max(0, radii.bottomLeft - inset)
|
|
795
|
+
).clamped(to: rect.size)
|
|
796
|
+
|
|
797
|
+
if cornerStyle == .continuous, !adjusted.isZero {
|
|
798
|
+
let resolved = ContinuousCorners.resolve(adjusted, continuous: true, size: rect.size)
|
|
799
|
+
return ContinuousCorners.path(in: rect, resolved: resolved)
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if adjusted.isUniform {
|
|
803
|
+
return UIBezierPath(
|
|
804
|
+
roundedRect: rect,
|
|
805
|
+
cornerRadius: adjusted.topLeft
|
|
806
|
+
)
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
let path = UIBezierPath()
|
|
810
|
+
path.move(to: CGPoint(x: rect.minX + adjusted.topLeft, y: rect.minY))
|
|
811
|
+
path.addLine(to: CGPoint(x: rect.maxX - adjusted.topRight, y: rect.minY))
|
|
812
|
+
path.addArc(
|
|
813
|
+
withCenter: CGPoint(x: rect.maxX - adjusted.topRight, y: rect.minY + adjusted.topRight),
|
|
814
|
+
radius: adjusted.topRight, startAngle: -.pi / 2, endAngle: 0, clockwise: true
|
|
815
|
+
)
|
|
816
|
+
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY - adjusted.bottomRight))
|
|
817
|
+
path.addArc(
|
|
818
|
+
withCenter: CGPoint(x: rect.maxX - adjusted.bottomRight, y: rect.maxY - adjusted.bottomRight),
|
|
819
|
+
radius: adjusted.bottomRight, startAngle: 0, endAngle: .pi / 2, clockwise: true
|
|
820
|
+
)
|
|
821
|
+
path.addLine(to: CGPoint(x: rect.minX + adjusted.bottomLeft, y: rect.maxY))
|
|
822
|
+
path.addArc(
|
|
823
|
+
withCenter: CGPoint(x: rect.minX + adjusted.bottomLeft, y: rect.maxY - adjusted.bottomLeft),
|
|
824
|
+
radius: adjusted.bottomLeft, startAngle: .pi / 2, endAngle: .pi, clockwise: true
|
|
825
|
+
)
|
|
826
|
+
path.addLine(to: CGPoint(x: rect.minX, y: rect.minY + adjusted.topLeft))
|
|
827
|
+
path.addArc(
|
|
828
|
+
withCenter: CGPoint(x: rect.minX + adjusted.topLeft, y: rect.minY + adjusted.topLeft),
|
|
829
|
+
radius: adjusted.topLeft, startAngle: .pi, endAngle: 3 * .pi / 2, clockwise: true
|
|
830
|
+
)
|
|
831
|
+
path.close()
|
|
832
|
+
return path
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/// 180 puts the lobe axis vertical: top and bottom edges lit, side rims fading to zero at
|
|
836
|
+
/// the midpoints — what real iOS 26 bars measure (research/04).
|
|
837
|
+
private static let defaultHighlightAngleDegrees: Double = 180
|
|
838
|
+
|
|
839
|
+
/// The crisp line's depth, points. Apple's line measures 2–3 px on a 238 px icon.
|
|
840
|
+
private static let defaultHighlightWidth: CGFloat = 0.75
|
|
841
|
+
|
|
842
|
+
/// Kyant's `InnerShadow` default: black at 15 %.
|
|
843
|
+
private static let defaultInnerShadowOpacity: CGFloat = 0.15
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
extension UIColor {
|
|
847
|
+
|
|
848
|
+
var simdRGBA: SIMD4<Float> {
|
|
849
|
+
var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
|
|
850
|
+
guard getRed(&r, green: &g, blue: &b, alpha: &a) else {
|
|
851
|
+
var white: CGFloat = 0
|
|
852
|
+
if getWhite(&white, alpha: &a) {
|
|
853
|
+
return SIMD4<Float>(Float(white), Float(white), Float(white), Float(a))
|
|
854
|
+
}
|
|
855
|
+
return SIMD4<Float>(0, 0, 0, 0)
|
|
856
|
+
}
|
|
857
|
+
return SIMD4<Float>(Float(r), Float(g), Float(b), Float(a))
|
|
858
|
+
}
|
|
859
|
+
}
|