@luckylca/react-native-liquid-glass 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +307 -2
- package/README.zh-CN.md +310 -0
- package/THIRD_PARTY_NOTICES.md +98 -0
- package/android/build.gradle +19 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassEngineModule.kt +141 -0
- package/android/src/main/java/expo/modules/localglass/ExpoLocalGlassModule.kt +341 -0
- package/android/src/main/java/expo/modules/localglass/LocalGlassShader.kt +59 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/CoreLiquidGlassRegistry.kt +75 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/EffectiveScrollInputBridge.kt +47 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassCoreModule.kt +226 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassProviderCoreView.kt +1125 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/ExpoGlassSurfaceCoreView.kt +571 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/PassSurfaceSuppression.kt +39 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/SharedGlassPassProbeLog.kt +23 -0
- package/android/src/main/java/expo/modules/newhuliquidglass/SharedGlassPassWiring.kt +59 -0
- package/android-core/build.gradle +36 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/BackdropRecorder.kt +930 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/FrozenBackdrop.kt +66 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassBackdropCoordinator.kt +624 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassBackdropSourceHandle.kt +8 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassScrollSource.kt +13 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/GlassViewController.kt +1605 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/LiquidGlassProviderLayout.kt +340 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/LiquidGlassView.kt +103 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/ReferenceSourceWindowPolicy.kt +13 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/StableSceneTexturePolicy.kt +43 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/GlassViewRenderer.kt +1459 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/ReferenceTabSampling.kt +15 -0
- package/android-core/src/main/java/com/newhu/liquidglass/backdrop/internal/SharedSceneCapture.kt +163 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassCapabilities.kt +21 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassEngine.kt +131 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassMaterial.kt +89 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassMath.kt +131 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassOpticalInsets.kt +8 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassRenderTier.kt +54 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassShapePacker.kt +77 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassSurfaceState.kt +11 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/GlassUniforms.kt +113 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/LiquidGlassShaders.kt +234 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/SharedGlassPass.kt +456 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/geometry/G2RoundedRectangle.kt +207 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/geometry/ReferenceG2MaskTexture.kt +334 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/HeightFieldGlassShader.kt +7 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceBackdropBlurShader.kt +58 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceGaussianDiscBackdropBlur.kt +42 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceGlassUniforms.kt +111 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceParityGlassShader.kt +613 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/ReferenceParityMultiShapeShader.kt +128 -0
- package/android-core/src/main/java/com/newhu/liquidglass/core/shader/SdfScaleLensShader.kt +144 -0
- package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassHardwareLayerExperiment.kt +29 -0
- package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassMaterial.kt +14 -0
- package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassRenderer.kt +126 -0
- package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassRuntimeShader.kt +50 -0
- package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassShader.kt +59 -0
- package/android-core/src/main/java/com/newhu/liquidglass/local/LocalGlassView.kt +47 -0
- package/android-core/src/main/java/com/newhu/liquidglass/motion/GlassMotionDriver.kt +824 -0
- package/android-core/src/main/java/com/newhu/liquidglass/motion/GlassMotionState.kt +359 -0
- package/android-core/src/main/java/com/newhu/liquidglass/motion/PointerVelocityTracker.kt +109 -0
- package/android-core/src/main/java/com/newhu/liquidglass/motion/SpringSpec.kt +209 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/G2Corner.kt +194 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassMaterial.kt +250 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassOpticsShader.kt +696 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassParityProbe.kt +342 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassShapeGeometry.kt +317 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/GlassUniformBinder.kt +308 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/PixelDiff.kt +363 -0
- package/android-core/src/main/java/com/newhu/liquidglass/optics/ReferenceOptics.kt +568 -0
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassEngineSelection.kt +30 -0
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassSurfaceHost.kt +317 -0
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/GlassSurfaceRenderer.kt +847 -0
- package/android-core/src/main/java/com/newhu/liquidglass/rendering/RetainedBackdropLayer.kt +83 -0
- package/android-core/src/main/java/com/newhu/liquidglass/scheduler/GlassFrameScheduler.kt +27 -0
- package/android-core/src/main/java/com/newhu/liquidglass/telemetry/EffectiveScrollFpsProbe.kt +965 -0
- package/android-core/src/main/java/com/newhu/liquidglass/telemetry/GlassTelemetry.kt +16 -0
- package/android-core/src/main/java/com/newhu/liquidglass/telemetry/LiquidGlassPerfTelemetry.kt +676 -0
- package/android-core/src/main/java/com/newhu/liquidglass/telemetry/LiquidGlassTrace.kt +30 -0
- package/android-core/src/main/java/com/newhu/liquidglass/telemetry/LocalGlassTelemetry.kt +55 -0
- package/app.plugin.js +25 -0
- package/docs/images/buttons.webp +0 -0
- package/docs/images/controls.webp +0 -0
- package/docs/images/tabs.webp +0 -0
- package/docs/publishing.md +84 -0
- package/expo-module.config.json +10 -0
- package/lib/commonjs/GlassSurface.js +832 -0
- package/lib/commonjs/GlassSurface.js.map +1 -0
- package/lib/commonjs/GlassTabBar.js +976 -0
- package/lib/commonjs/GlassTabBar.js.map +1 -0
- package/lib/commonjs/GlassTabLens.js +67 -0
- package/lib/commonjs/GlassTabLens.js.map +1 -0
- package/lib/commonjs/LiquidGlassProvider.js +40 -0
- package/lib/commonjs/LiquidGlassProvider.js.map +1 -0
- package/lib/commonjs/LocalGlassMaterial.js +194 -0
- package/lib/commonjs/LocalGlassMaterial.js.map +1 -0
- package/lib/commonjs/adaptiveLuminance.js +14 -0
- package/lib/commonjs/adaptiveLuminance.js.map +1 -0
- package/lib/commonjs/badgePalette.js +46 -0
- package/lib/commonjs/badgePalette.js.map +1 -0
- package/lib/commonjs/buttonGesturePolicy.js +22 -0
- package/lib/commonjs/buttonGesturePolicy.js.map +1 -0
- package/lib/commonjs/components/AdaptiveLuminance.js +20 -0
- package/lib/commonjs/components/AdaptiveLuminance.js.map +1 -0
- package/lib/commonjs/components/BottomSheet.js +222 -0
- package/lib/commonjs/components/BottomSheet.js.map +1 -0
- package/lib/commonjs/components/Button.js +20 -0
- package/lib/commonjs/components/Button.js.map +1 -0
- package/lib/commonjs/components/Card.js +206 -0
- package/lib/commonjs/components/Card.js.map +1 -0
- package/lib/commonjs/components/Checkbox.js +123 -0
- package/lib/commonjs/components/Checkbox.js.map +1 -0
- package/lib/commonjs/components/ControlPressContext.js +8 -0
- package/lib/commonjs/components/ControlPressContext.js.map +1 -0
- package/lib/commonjs/components/Dialog.js +122 -0
- package/lib/commonjs/components/Dialog.js.map +1 -0
- package/lib/commonjs/components/DialogAction.js +124 -0
- package/lib/commonjs/components/DialogAction.js.map +1 -0
- package/lib/commonjs/components/DialogContent.js +23 -0
- package/lib/commonjs/components/DialogContent.js.map +1 -0
- package/lib/commonjs/components/GlassButton.js +96 -0
- package/lib/commonjs/components/GlassButton.js.map +1 -0
- package/lib/commonjs/components/GlassFab.js +43 -0
- package/lib/commonjs/components/GlassFab.js.map +1 -0
- package/lib/commonjs/components/GlassMagnifier.js +135 -0
- package/lib/commonjs/components/GlassMagnifier.js.map +1 -0
- package/lib/commonjs/components/GlassPlayground.js +158 -0
- package/lib/commonjs/components/GlassPlayground.js.map +1 -0
- package/lib/commonjs/components/GlassSlider.js +364 -0
- package/lib/commonjs/components/GlassSlider.js.map +1 -0
- package/lib/commonjs/components/GlassSwitch.js +334 -0
- package/lib/commonjs/components/GlassSwitch.js.map +1 -0
- package/lib/commonjs/components/GlassTabBar.js +387 -0
- package/lib/commonjs/components/GlassTabBar.js.map +1 -0
- package/lib/commonjs/components/Input.js +180 -0
- package/lib/commonjs/components/Input.js.map +1 -0
- package/lib/commonjs/components/ListRow.js +64 -0
- package/lib/commonjs/components/ListRow.js.map +1 -0
- package/lib/commonjs/components/Menu.js +214 -0
- package/lib/commonjs/components/Menu.js.map +1 -0
- package/lib/commonjs/components/NavigationBar.js +20 -0
- package/lib/commonjs/components/NavigationBar.js.map +1 -0
- package/lib/commonjs/components/NumberWheel.js +273 -0
- package/lib/commonjs/components/NumberWheel.js.map +1 -0
- package/lib/commonjs/components/PageFeedList.js +25 -0
- package/lib/commonjs/components/PageFeedList.js.map +1 -0
- package/lib/commonjs/components/PageScaffold.js +161 -0
- package/lib/commonjs/components/PageScaffold.js.map +1 -0
- package/lib/commonjs/components/PreferenceGroup.js +34 -0
- package/lib/commonjs/components/PreferenceGroup.js.map +1 -0
- package/lib/commonjs/components/ProgressIndicator.js +79 -0
- package/lib/commonjs/components/ProgressIndicator.js.map +1 -0
- package/lib/commonjs/components/ProgressiveBlur.js +29 -0
- package/lib/commonjs/components/ProgressiveBlur.js.map +1 -0
- package/lib/commonjs/components/ReferenceSlider.js +304 -0
- package/lib/commonjs/components/ReferenceSlider.js.map +1 -0
- package/lib/commonjs/components/ReferenceTabBar.js +381 -0
- package/lib/commonjs/components/ReferenceTabBar.js.map +1 -0
- package/lib/commonjs/components/SearchBar.js +200 -0
- package/lib/commonjs/components/SearchBar.js.map +1 -0
- package/lib/commonjs/components/SegmentedControl.js +62 -0
- package/lib/commonjs/components/SegmentedControl.js.map +1 -0
- package/lib/commonjs/components/Slider.js +12 -0
- package/lib/commonjs/components/Slider.js.map +1 -0
- package/lib/commonjs/components/Snackbar.js +11 -0
- package/lib/commonjs/components/Snackbar.js.map +1 -0
- package/lib/commonjs/components/SurfaceEnvironmentContext.js +35 -0
- package/lib/commonjs/components/SurfaceEnvironmentContext.js.map +1 -0
- package/lib/commonjs/components/SurfaceGroup.js +39 -0
- package/lib/commonjs/components/SurfaceGroup.js.map +1 -0
- package/lib/commonjs/components/Switch.js +11 -0
- package/lib/commonjs/components/Switch.js.map +1 -0
- package/lib/commonjs/components/Toast.js +110 -0
- package/lib/commonjs/components/Toast.js.map +1 -0
- package/lib/commonjs/components/TopAppBar.js +107 -0
- package/lib/commonjs/components/TopAppBar.js.map +1 -0
- package/lib/commonjs/components/bottomSheetMotion.js +14 -0
- package/lib/commonjs/components/bottomSheetMotion.js.map +1 -0
- package/lib/commonjs/components/glassControlMaterial.js +22 -0
- package/lib/commonjs/components/glassControlMaterial.js.map +1 -0
- package/lib/commonjs/components/menuPosition.js +42 -0
- package/lib/commonjs/components/menuPosition.js.map +1 -0
- package/lib/commonjs/components/pages/FeedPage.js +15 -0
- package/lib/commonjs/components/pages/FeedPage.js.map +1 -0
- package/lib/commonjs/components/pages/PageBenchmarkContext.js +123 -0
- package/lib/commonjs/components/pages/PageBenchmarkContext.js.map +1 -0
- package/lib/commonjs/components/pages/SettingsPage.js +47 -0
- package/lib/commonjs/components/pages/SettingsPage.js.map +1 -0
- package/lib/commonjs/components/pages/SettingsSection.js +14 -0
- package/lib/commonjs/components/pages/SettingsSection.js.map +1 -0
- package/lib/commonjs/components/pages/StaticSettingsPage.js +16 -0
- package/lib/commonjs/components/pages/StaticSettingsPage.js.map +1 -0
- package/lib/commonjs/fallbackKnobGeometry.js +19 -0
- package/lib/commonjs/fallbackKnobGeometry.js.map +1 -0
- package/lib/commonjs/glassController.js +65 -0
- package/lib/commonjs/glassController.js.map +1 -0
- package/lib/commonjs/glassNativeEngine.js +16 -0
- package/lib/commonjs/glassNativeEngine.js.map +1 -0
- package/lib/commonjs/glassRuntime.js +27 -0
- package/lib/commonjs/glassRuntime.js.map +1 -0
- package/lib/commonjs/index.js +218 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/inputPresentation.js +17 -0
- package/lib/commonjs/inputPresentation.js.map +1 -0
- package/lib/commonjs/localGlassTelemetry.js +113 -0
- package/lib/commonjs/localGlassTelemetry.js.map +1 -0
- package/lib/commonjs/motion/MotionProvider.js +15 -0
- package/lib/commonjs/motion/MotionProvider.js.map +1 -0
- package/lib/commonjs/motion/easings.js +71 -0
- package/lib/commonjs/motion/easings.js.map +1 -0
- package/lib/commonjs/motion/folmeSpring.js +24 -0
- package/lib/commonjs/motion/folmeSpring.js.map +1 -0
- package/lib/commonjs/motion/folmeSpringByResponse.js +22 -0
- package/lib/commonjs/motion/folmeSpringByResponse.js.map +1 -0
- package/lib/commonjs/motion/index.js +57 -0
- package/lib/commonjs/motion/index.js.map +1 -0
- package/lib/commonjs/motion/presets.js +101 -0
- package/lib/commonjs/motion/presets.js.map +1 -0
- package/lib/commonjs/nativeGlassViews.js +33 -0
- package/lib/commonjs/nativeGlassViews.js.map +1 -0
- package/lib/commonjs/performanceTelemetry.js +28 -0
- package/lib/commonjs/performanceTelemetry.js.map +1 -0
- package/lib/commonjs/pointerEventBridge.js +17 -0
- package/lib/commonjs/pointerEventBridge.js.map +1 -0
- package/lib/commonjs/pointerGeometry.js +12 -0
- package/lib/commonjs/pointerGeometry.js.map +1 -0
- package/lib/commonjs/pressVelocity.js +34 -0
- package/lib/commonjs/pressVelocity.js.map +1 -0
- package/lib/commonjs/primitives/Divider.js +32 -0
- package/lib/commonjs/primitives/Divider.js.map +1 -0
- package/lib/commonjs/primitives/Icon.js +22 -0
- package/lib/commonjs/primitives/Icon.js.map +1 -0
- package/lib/commonjs/primitives/PressIndication.js +58 -0
- package/lib/commonjs/primitives/PressIndication.js.map +1 -0
- package/lib/commonjs/primitives/Pressable.js +28 -0
- package/lib/commonjs/primitives/Pressable.js.map +1 -0
- package/lib/commonjs/primitives/PressableScale.js +64 -0
- package/lib/commonjs/primitives/PressableScale.js.map +1 -0
- package/lib/commonjs/primitives/Surface.js +122 -0
- package/lib/commonjs/primitives/Surface.js.map +1 -0
- package/lib/commonjs/primitives/Text.js +43 -0
- package/lib/commonjs/primitives/Text.js.map +1 -0
- package/lib/commonjs/primitives/index.js +18 -0
- package/lib/commonjs/primitives/index.js.map +1 -0
- package/lib/commonjs/renderer.js +58 -0
- package/lib/commonjs/renderer.js.map +1 -0
- package/lib/commonjs/sliderValue.js +28 -0
- package/lib/commonjs/sliderValue.js.map +1 -0
- package/lib/commonjs/surfaceRendererPolicy.js +32 -0
- package/lib/commonjs/surfaceRendererPolicy.js.map +1 -0
- package/lib/commonjs/theme/ThemeProvider.js +37 -0
- package/lib/commonjs/theme/ThemeProvider.js.map +1 -0
- package/lib/commonjs/theme/buildTheme.js +157 -0
- package/lib/commonjs/theme/buildTheme.js.map +1 -0
- package/lib/commonjs/theme/glassColors.js +17 -0
- package/lib/commonjs/theme/glassColors.js.map +1 -0
- package/lib/commonjs/theme/index.js +38 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/liquidGlass.js +24 -0
- package/lib/commonjs/theme/liquidGlass.js.map +1 -0
- package/lib/commonjs/theme/presentation.js +14 -0
- package/lib/commonjs/theme/presentation.js.map +1 -0
- package/lib/commonjs/theme/registry.js +17 -0
- package/lib/commonjs/theme/registry.js.map +1 -0
- package/lib/commonjs/theme/selectVariant.js +13 -0
- package/lib/commonjs/theme/selectVariant.js.map +1 -0
- package/lib/commonjs/theme/tokens.js +266 -0
- package/lib/commonjs/theme/tokens.js.map +1 -0
- package/lib/commonjs/theme/types.js +3 -0
- package/lib/commonjs/theme/types.js.map +1 -0
- package/lib/commonjs/theme/wallpaper.js +91 -0
- package/lib/commonjs/theme/wallpaper.js.map +1 -0
- package/lib/commonjs/types.js +3 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/useButtonGesture.js +135 -0
- package/lib/commonjs/useButtonGesture.js.map +1 -0
- package/lib/commonjs/useGlassKnobMotion.js +115 -0
- package/lib/commonjs/useGlassKnobMotion.js.map +1 -0
- package/lib/commonjs/useGlassPressMotion.js +147 -0
- package/lib/commonjs/useGlassPressMotion.js.map +1 -0
- package/lib/module/GlassSurface.js +782 -0
- package/lib/module/GlassSurface.js.map +1 -0
- package/lib/module/GlassTabBar.js +939 -0
- package/lib/module/GlassTabBar.js.map +1 -0
- package/lib/module/GlassTabLens.js +64 -0
- package/lib/module/GlassTabLens.js.map +1 -0
- package/lib/module/LiquidGlassProvider.js +37 -0
- package/lib/module/LiquidGlassProvider.js.map +1 -0
- package/lib/module/LocalGlassMaterial.js +191 -0
- package/lib/module/LocalGlassMaterial.js.map +1 -0
- package/lib/module/adaptiveLuminance.js +11 -0
- package/lib/module/adaptiveLuminance.js.map +1 -0
- package/lib/module/badgePalette.js +40 -0
- package/lib/module/badgePalette.js.map +1 -0
- package/lib/module/buttonGesturePolicy.js +17 -0
- package/lib/module/buttonGesturePolicy.js.map +1 -0
- package/lib/module/components/AdaptiveLuminance.js +16 -0
- package/lib/module/components/AdaptiveLuminance.js.map +1 -0
- package/lib/module/components/BottomSheet.js +186 -0
- package/lib/module/components/BottomSheet.js.map +1 -0
- package/lib/module/components/Button.js +17 -0
- package/lib/module/components/Button.js.map +1 -0
- package/lib/module/components/Card.js +170 -0
- package/lib/module/components/Card.js.map +1 -0
- package/lib/module/components/Checkbox.js +84 -0
- package/lib/module/components/Checkbox.js.map +1 -0
- package/lib/module/components/ControlPressContext.js +4 -0
- package/lib/module/components/ControlPressContext.js.map +1 -0
- package/lib/module/components/Dialog.js +86 -0
- package/lib/module/components/Dialog.js.map +1 -0
- package/lib/module/components/DialogAction.js +88 -0
- package/lib/module/components/DialogAction.js.map +1 -0
- package/lib/module/components/DialogContent.js +20 -0
- package/lib/module/components/DialogContent.js.map +1 -0
- package/lib/module/components/GlassButton.js +93 -0
- package/lib/module/components/GlassButton.js.map +1 -0
- package/lib/module/components/GlassFab.js +37 -0
- package/lib/module/components/GlassFab.js.map +1 -0
- package/lib/module/components/GlassMagnifier.js +99 -0
- package/lib/module/components/GlassMagnifier.js.map +1 -0
- package/lib/module/components/GlassPlayground.js +122 -0
- package/lib/module/components/GlassPlayground.js.map +1 -0
- package/lib/module/components/GlassSlider.js +328 -0
- package/lib/module/components/GlassSlider.js.map +1 -0
- package/lib/module/components/GlassSwitch.js +298 -0
- package/lib/module/components/GlassSwitch.js.map +1 -0
- package/lib/module/components/GlassTabBar.js +351 -0
- package/lib/module/components/GlassTabBar.js.map +1 -0
- package/lib/module/components/Input.js +144 -0
- package/lib/module/components/Input.js.map +1 -0
- package/lib/module/components/ListRow.js +61 -0
- package/lib/module/components/ListRow.js.map +1 -0
- package/lib/module/components/Menu.js +178 -0
- package/lib/module/components/Menu.js.map +1 -0
- package/lib/module/components/NavigationBar.js +14 -0
- package/lib/module/components/NavigationBar.js.map +1 -0
- package/lib/module/components/NumberWheel.js +238 -0
- package/lib/module/components/NumberWheel.js.map +1 -0
- package/lib/module/components/PageFeedList.js +19 -0
- package/lib/module/components/PageFeedList.js.map +1 -0
- package/lib/module/components/PageScaffold.js +114 -0
- package/lib/module/components/PageScaffold.js.map +1 -0
- package/lib/module/components/PreferenceGroup.js +28 -0
- package/lib/module/components/PreferenceGroup.js.map +1 -0
- package/lib/module/components/ProgressIndicator.js +44 -0
- package/lib/module/components/ProgressIndicator.js.map +1 -0
- package/lib/module/components/ProgressiveBlur.js +26 -0
- package/lib/module/components/ProgressiveBlur.js.map +1 -0
- package/lib/module/components/ReferenceSlider.js +268 -0
- package/lib/module/components/ReferenceSlider.js.map +1 -0
- package/lib/module/components/ReferenceTabBar.js +344 -0
- package/lib/module/components/ReferenceTabBar.js.map +1 -0
- package/lib/module/components/SearchBar.js +164 -0
- package/lib/module/components/SearchBar.js.map +1 -0
- package/lib/module/components/SegmentedControl.js +26 -0
- package/lib/module/components/SegmentedControl.js.map +1 -0
- package/lib/module/components/Slider.js +9 -0
- package/lib/module/components/Slider.js.map +1 -0
- package/lib/module/components/Snackbar.js +8 -0
- package/lib/module/components/Snackbar.js.map +1 -0
- package/lib/module/components/SurfaceEnvironmentContext.js +27 -0
- package/lib/module/components/SurfaceEnvironmentContext.js.map +1 -0
- package/lib/module/components/SurfaceGroup.js +33 -0
- package/lib/module/components/SurfaceGroup.js.map +1 -0
- package/lib/module/components/Switch.js +8 -0
- package/lib/module/components/Switch.js.map +1 -0
- package/lib/module/components/Toast.js +74 -0
- package/lib/module/components/Toast.js.map +1 -0
- package/lib/module/components/TopAppBar.js +68 -0
- package/lib/module/components/TopAppBar.js.map +1 -0
- package/lib/module/components/bottomSheetMotion.js +11 -0
- package/lib/module/components/bottomSheetMotion.js.map +1 -0
- package/lib/module/components/glassControlMaterial.js +19 -0
- package/lib/module/components/glassControlMaterial.js.map +1 -0
- package/lib/module/components/menuPosition.js +37 -0
- package/lib/module/components/menuPosition.js.map +1 -0
- package/lib/module/components/pages/FeedPage.js +12 -0
- package/lib/module/components/pages/FeedPage.js.map +1 -0
- package/lib/module/components/pages/PageBenchmarkContext.js +84 -0
- package/lib/module/components/pages/PageBenchmarkContext.js.map +1 -0
- package/lib/module/components/pages/SettingsPage.js +11 -0
- package/lib/module/components/pages/SettingsPage.js.map +1 -0
- package/lib/module/components/pages/SettingsSection.js +8 -0
- package/lib/module/components/pages/SettingsSection.js.map +1 -0
- package/lib/module/components/pages/StaticSettingsPage.js +10 -0
- package/lib/module/components/pages/StaticSettingsPage.js.map +1 -0
- package/lib/module/fallbackKnobGeometry.js +16 -0
- package/lib/module/fallbackKnobGeometry.js.map +1 -0
- package/lib/module/glassController.js +58 -0
- package/lib/module/glassController.js.map +1 -0
- package/lib/module/glassNativeEngine.js +11 -0
- package/lib/module/glassNativeEngine.js.map +1 -0
- package/lib/module/glassRuntime.js +22 -0
- package/lib/module/glassRuntime.js.map +1 -0
- package/lib/module/index.js +80 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/inputPresentation.js +14 -0
- package/lib/module/inputPresentation.js.map +1 -0
- package/lib/module/localGlassTelemetry.js +103 -0
- package/lib/module/localGlassTelemetry.js.map +1 -0
- package/lib/module/motion/MotionProvider.js +11 -0
- package/lib/module/motion/MotionProvider.js.map +1 -0
- package/lib/module/motion/easings.js +64 -0
- package/lib/module/motion/easings.js.map +1 -0
- package/lib/module/motion/folmeSpring.js +21 -0
- package/lib/module/motion/folmeSpring.js.map +1 -0
- package/lib/module/motion/folmeSpringByResponse.js +19 -0
- package/lib/module/motion/folmeSpringByResponse.js.map +1 -0
- package/lib/module/motion/index.js +6 -0
- package/lib/module/motion/index.js.map +1 -0
- package/lib/module/motion/presets.js +98 -0
- package/lib/module/motion/presets.js.map +1 -0
- package/lib/module/nativeGlassViews.js +27 -0
- package/lib/module/nativeGlassViews.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/performanceTelemetry.js +23 -0
- package/lib/module/performanceTelemetry.js.map +1 -0
- package/lib/module/pointerEventBridge.js +14 -0
- package/lib/module/pointerEventBridge.js.map +1 -0
- package/lib/module/pointerGeometry.js +9 -0
- package/lib/module/pointerGeometry.js.map +1 -0
- package/lib/module/pressVelocity.js +31 -0
- package/lib/module/pressVelocity.js.map +1 -0
- package/lib/module/primitives/Divider.js +29 -0
- package/lib/module/primitives/Divider.js.map +1 -0
- package/lib/module/primitives/Icon.js +19 -0
- package/lib/module/primitives/Icon.js.map +1 -0
- package/lib/module/primitives/PressIndication.js +22 -0
- package/lib/module/primitives/PressIndication.js.map +1 -0
- package/lib/module/primitives/Pressable.js +25 -0
- package/lib/module/primitives/Pressable.js.map +1 -0
- package/lib/module/primitives/PressableScale.js +28 -0
- package/lib/module/primitives/PressableScale.js.map +1 -0
- package/lib/module/primitives/Surface.js +83 -0
- package/lib/module/primitives/Surface.js.map +1 -0
- package/lib/module/primitives/Text.js +40 -0
- package/lib/module/primitives/Text.js.map +1 -0
- package/lib/module/primitives/index.js +8 -0
- package/lib/module/primitives/index.js.map +1 -0
- package/lib/module/renderer.js +22 -0
- package/lib/module/renderer.js.map +1 -0
- package/lib/module/sliderValue.js +25 -0
- package/lib/module/sliderValue.js.map +1 -0
- package/lib/module/surfaceRendererPolicy.js +27 -0
- package/lib/module/surfaceRendererPolicy.js.map +1 -0
- package/lib/module/theme/ThemeProvider.js +32 -0
- package/lib/module/theme/ThemeProvider.js.map +1 -0
- package/lib/module/theme/buildTheme.js +153 -0
- package/lib/module/theme/buildTheme.js.map +1 -0
- package/lib/module/theme/glassColors.js +14 -0
- package/lib/module/theme/glassColors.js.map +1 -0
- package/lib/module/theme/index.js +9 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/liquidGlass.js +21 -0
- package/lib/module/theme/liquidGlass.js.map +1 -0
- package/lib/module/theme/presentation.js +11 -0
- package/lib/module/theme/presentation.js.map +1 -0
- package/lib/module/theme/registry.js +13 -0
- package/lib/module/theme/registry.js.map +1 -0
- package/lib/module/theme/selectVariant.js +10 -0
- package/lib/module/theme/selectVariant.js.map +1 -0
- package/lib/module/theme/tokens.js +262 -0
- package/lib/module/theme/tokens.js.map +1 -0
- package/lib/module/theme/types.js +2 -0
- package/lib/module/theme/types.js.map +1 -0
- package/lib/module/theme/wallpaper.js +83 -0
- package/lib/module/theme/wallpaper.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/useButtonGesture.js +132 -0
- package/lib/module/useButtonGesture.js.map +1 -0
- package/lib/module/useGlassKnobMotion.js +112 -0
- package/lib/module/useGlassKnobMotion.js.map +1 -0
- package/lib/module/useGlassPressMotion.js +143 -0
- package/lib/module/useGlassPressMotion.js.map +1 -0
- package/lib/types/GlassSurface.d.ts +216 -0
- package/lib/types/GlassTabBar.d.ts +35 -0
- package/lib/types/GlassTabLens.d.ts +11 -0
- package/lib/types/LiquidGlassProvider.d.ts +47 -0
- package/lib/types/LocalGlassMaterial.d.ts +21 -0
- package/lib/types/adaptiveLuminance.d.ts +2 -0
- package/lib/types/badgePalette.d.ts +9 -0
- package/lib/types/buttonGesturePolicy.d.ts +4 -0
- package/lib/types/components/AdaptiveLuminance.d.ts +23 -0
- package/lib/types/components/BottomSheet.d.ts +33 -0
- package/lib/types/components/Button.d.ts +16 -0
- package/lib/types/components/Card.d.ts +25 -0
- package/lib/types/components/Checkbox.d.ts +11 -0
- package/lib/types/components/ControlPressContext.d.ts +9 -0
- package/lib/types/components/Dialog.d.ts +12 -0
- package/lib/types/components/DialogAction.d.ts +4 -0
- package/lib/types/components/DialogContent.d.ts +12 -0
- package/lib/types/components/GlassButton.d.ts +38 -0
- package/lib/types/components/GlassFab.d.ts +15 -0
- package/lib/types/components/GlassMagnifier.d.ts +41 -0
- package/lib/types/components/GlassPlayground.d.ts +12 -0
- package/lib/types/components/GlassSlider.d.ts +48 -0
- package/lib/types/components/GlassSwitch.d.ts +46 -0
- package/lib/types/components/GlassTabBar.d.ts +44 -0
- package/lib/types/components/Input.d.ts +47 -0
- package/lib/types/components/ListRow.d.ts +17 -0
- package/lib/types/components/Menu.d.ts +41 -0
- package/lib/types/components/NavigationBar.d.ts +14 -0
- package/lib/types/components/NumberWheel.d.ts +11 -0
- package/lib/types/components/PageFeedList.d.ts +6 -0
- package/lib/types/components/PageScaffold.d.ts +64 -0
- package/lib/types/components/PreferenceGroup.d.ts +12 -0
- package/lib/types/components/ProgressIndicator.d.ts +9 -0
- package/lib/types/components/ProgressiveBlur.d.ts +12 -0
- package/lib/types/components/ReferenceSlider.d.ts +31 -0
- package/lib/types/components/ReferenceTabBar.d.ts +61 -0
- package/lib/types/components/SearchBar.d.ts +52 -0
- package/lib/types/components/SegmentedControl.d.ts +10 -0
- package/lib/types/components/Slider.d.ts +19 -0
- package/lib/types/components/Snackbar.d.ts +5 -0
- package/lib/types/components/SurfaceEnvironmentContext.d.ts +17 -0
- package/lib/types/components/SurfaceGroup.d.ts +17 -0
- package/lib/types/components/Switch.d.ts +12 -0
- package/lib/types/components/Toast.d.ts +14 -0
- package/lib/types/components/TopAppBar.d.ts +49 -0
- package/lib/types/components/bottomSheetMotion.d.ts +2 -0
- package/lib/types/components/glassControlMaterial.d.ts +3 -0
- package/lib/types/components/menuPosition.d.ts +22 -0
- package/lib/types/components/pages/FeedPage.d.ts +31 -0
- package/lib/types/components/pages/PageBenchmarkContext.d.ts +30 -0
- package/lib/types/components/pages/SettingsPage.d.ts +20 -0
- package/lib/types/components/pages/SettingsSection.d.ts +9 -0
- package/lib/types/components/pages/StaticSettingsPage.d.ts +18 -0
- package/lib/types/fallbackKnobGeometry.d.ts +7 -0
- package/lib/types/glassController.d.ts +20 -0
- package/lib/types/glassNativeEngine.d.ts +5 -0
- package/lib/types/glassRuntime.d.ts +7 -0
- package/lib/types/index.d.ts +124 -0
- package/lib/types/inputPresentation.d.ts +12 -0
- package/lib/types/localGlassTelemetry.d.ts +28 -0
- package/lib/types/motion/MotionProvider.d.ts +7 -0
- package/lib/types/motion/easings.d.ts +33 -0
- package/lib/types/motion/folmeSpring.d.ts +15 -0
- package/lib/types/motion/folmeSpringByResponse.d.ts +14 -0
- package/lib/types/motion/index.d.ts +7 -0
- package/lib/types/motion/presets.d.ts +103 -0
- package/lib/types/nativeGlassViews.d.ts +114 -0
- package/lib/types/performanceTelemetry.d.ts +65 -0
- package/lib/types/pointerEventBridge.d.ts +17 -0
- package/lib/types/pointerGeometry.d.ts +2 -0
- package/lib/types/pressVelocity.d.ts +11 -0
- package/lib/types/primitives/Divider.d.ts +19 -0
- package/lib/types/primitives/Icon.d.ts +29 -0
- package/lib/types/primitives/PressIndication.d.ts +26 -0
- package/lib/types/primitives/Pressable.d.ts +9 -0
- package/lib/types/primitives/PressableScale.d.ts +19 -0
- package/lib/types/primitives/Surface.d.ts +63 -0
- package/lib/types/primitives/Text.d.ts +35 -0
- package/lib/types/primitives/index.d.ts +14 -0
- package/lib/types/renderer.d.ts +32 -0
- package/lib/types/sliderValue.d.ts +2 -0
- package/lib/types/surfaceRendererPolicy.d.ts +14 -0
- package/lib/types/theme/ThemeProvider.d.ts +26 -0
- package/lib/types/theme/buildTheme.d.ts +6 -0
- package/lib/types/theme/glassColors.d.ts +13 -0
- package/lib/types/theme/index.d.ts +11 -0
- package/lib/types/theme/liquidGlass.d.ts +5 -0
- package/lib/types/theme/presentation.d.ts +3 -0
- package/lib/types/theme/registry.d.ts +7 -0
- package/lib/types/theme/selectVariant.d.ts +10 -0
- package/lib/types/theme/tokens.d.ts +18 -0
- package/lib/types/theme/types.d.ts +305 -0
- package/lib/types/theme/wallpaper.d.ts +32 -0
- package/lib/types/types.d.ts +127 -0
- package/lib/types/useButtonGesture.d.ts +30 -0
- package/lib/types/useGlassKnobMotion.d.ts +40 -0
- package/lib/types/useGlassPressMotion.d.ts +61 -0
- package/licenses/Apache-2.0-Kyant0-Shapes.txt +191 -0
- package/package.json +139 -4
- package/patches/liquid-glass-kit+1.0.0.patch +2015 -0
- package/patches/liquid-glass-kit-invalidation-coalescing.diff +249 -0
- package/patches/liquid-glass-kit-native-infra.diff +624 -0
- package/scripts/apply-legacy-patches.mjs +116 -0
- package/src/GlassSurface.tsx +1786 -0
- package/src/GlassTabBar.tsx +1304 -0
- package/src/GlassTabLens.tsx +92 -0
- package/src/LiquidGlassProvider.tsx +135 -0
- package/src/LocalGlassMaterial.tsx +262 -0
- package/src/adaptiveLuminance.ts +15 -0
- package/src/badgePalette.ts +54 -0
- package/src/buttonGesturePolicy.ts +15 -0
- package/src/components/AdaptiveLuminance.tsx +40 -0
- package/src/components/BottomSheet.tsx +291 -0
- package/src/components/Button.tsx +30 -0
- package/src/components/Card.tsx +343 -0
- package/src/components/Checkbox.tsx +141 -0
- package/src/components/ControlPressContext.ts +11 -0
- package/src/components/Dialog.tsx +129 -0
- package/src/components/DialogAction.tsx +109 -0
- package/src/components/DialogContent.tsx +52 -0
- package/src/components/GlassButton.tsx +225 -0
- package/src/components/GlassFab.tsx +98 -0
- package/src/components/GlassMagnifier.tsx +178 -0
- package/src/components/GlassPlayground.tsx +190 -0
- package/src/components/GlassSlider.tsx +448 -0
- package/src/components/GlassSwitch.tsx +391 -0
- package/src/components/GlassTabBar.tsx +522 -0
- package/src/components/Input.tsx +277 -0
- package/src/components/ListRow.tsx +124 -0
- package/src/components/Menu.tsx +322 -0
- package/src/components/NavigationBar.tsx +27 -0
- package/src/components/NumberWheel.tsx +344 -0
- package/src/components/PageFeedList.tsx +37 -0
- package/src/components/PageScaffold.tsx +266 -0
- package/src/components/PreferenceGroup.tsx +65 -0
- package/src/components/ProgressIndicator.tsx +63 -0
- package/src/components/ProgressiveBlur.tsx +56 -0
- package/src/components/ReferenceSlider.tsx +364 -0
- package/src/components/ReferenceTabBar.tsx +564 -0
- package/src/components/SearchBar.tsx +340 -0
- package/src/components/SegmentedControl.tsx +45 -0
- package/src/components/Slider.tsx +25 -0
- package/src/components/Snackbar.tsx +10 -0
- package/src/components/SurfaceEnvironmentContext.tsx +46 -0
- package/src/components/SurfaceGroup.tsx +60 -0
- package/src/components/Switch.tsx +18 -0
- package/src/components/Toast.tsx +110 -0
- package/src/components/TopAppBar.tsx +272 -0
- package/src/components/bottomSheetMotion.ts +10 -0
- package/src/components/glassControlMaterial.ts +20 -0
- package/src/components/menuPosition.ts +58 -0
- package/src/components/pages/FeedPage.tsx +96 -0
- package/src/components/pages/PageBenchmarkContext.tsx +105 -0
- package/src/components/pages/SettingsPage.tsx +55 -0
- package/src/components/pages/SettingsSection.tsx +20 -0
- package/src/components/pages/StaticSettingsPage.tsx +50 -0
- package/src/fallbackKnobGeometry.ts +15 -0
- package/src/glassController.ts +74 -0
- package/src/glassNativeEngine.ts +16 -0
- package/src/glassRuntime.ts +28 -0
- package/src/index.ts +199 -0
- package/src/inputPresentation.ts +32 -0
- package/src/localGlassTelemetry.ts +138 -0
- package/src/motion/MotionProvider.tsx +12 -0
- package/src/motion/easings.ts +71 -0
- package/src/motion/folmeSpring.ts +22 -0
- package/src/motion/folmeSpringByResponse.ts +19 -0
- package/src/motion/index.ts +47 -0
- package/src/motion/presets.ts +128 -0
- package/src/nativeGlassViews.ts +147 -0
- package/src/performanceTelemetry.ts +95 -0
- package/src/pointerEventBridge.ts +27 -0
- package/src/pointerGeometry.ts +8 -0
- package/src/pressVelocity.ts +36 -0
- package/src/primitives/Divider.tsx +42 -0
- package/src/primitives/Icon.tsx +44 -0
- package/src/primitives/PressIndication.tsx +43 -0
- package/src/primitives/Pressable.tsx +75 -0
- package/src/primitives/PressableScale.tsx +50 -0
- package/src/primitives/Surface.tsx +171 -0
- package/src/primitives/Text.tsx +80 -0
- package/src/primitives/index.ts +14 -0
- package/src/renderer.ts +70 -0
- package/src/sliderValue.ts +19 -0
- package/src/surfaceRendererPolicy.ts +32 -0
- package/src/theme/ThemeProvider.tsx +52 -0
- package/src/theme/buildTheme.ts +160 -0
- package/src/theme/glassColors.ts +13 -0
- package/src/theme/index.ts +34 -0
- package/src/theme/liquidGlass.ts +25 -0
- package/src/theme/presentation.ts +12 -0
- package/src/theme/registry.ts +16 -0
- package/src/theme/selectVariant.ts +12 -0
- package/src/theme/tokens.ts +309 -0
- package/src/theme/types.ts +345 -0
- package/src/theme/wallpaper.ts +94 -0
- package/src/types.ts +95 -0
- package/src/useButtonGesture.ts +134 -0
- package/src/useGlassKnobMotion.ts +155 -0
- package/src/useGlassPressMotion.ts +209 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '../primitives';
|
|
3
|
+
import { glassController } from '../glassController';
|
|
4
|
+
import { GlassOverlay, GlassSurface } from '../GlassSurface';
|
|
5
|
+
import { useGlassProviderId } from '../GlassSurface';
|
|
6
|
+
import { bottomSheetEnter, bottomSheetSettle, linearEasing, sheetHandlePress, sheetHandleRelease } from '../motion';
|
|
7
|
+
import { useReducedMotionPreference } from '../motion/MotionProvider';
|
|
8
|
+
import { useTheme } from '../theme';
|
|
9
|
+
import { GlassOverlayContentScope } from './SurfaceEnvironmentContext';
|
|
10
|
+
import { getBottomSheetDismissThreshold } from './bottomSheetMotion';
|
|
11
|
+
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
12
|
+
import { BackHandler, Modal, Pressable, StyleSheet, useWindowDimensions, View } from 'react-native';
|
|
13
|
+
import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
14
|
+
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
15
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
16
|
+
const UPWARD_DAMPING = 0.1;
|
|
17
|
+
const FROZEN_SHEET_MATERIAL_OVERRIDE = { blurRadius: 0, referenceDepthEffect: true, highlightAlpha: 0.45 };
|
|
18
|
+
export const BottomSheet = React.memo(function BottomSheet({ visible = false, onClose, title, allowDismiss = true, closeOnClickModal = true, startAction, endAction, animationsEnabled = true, onDismissed, children, }) {
|
|
19
|
+
const theme = useTheme();
|
|
20
|
+
// The sheet is always a glass overlay; a disabled material provider only
|
|
21
|
+
// stops native sampling, leaving the surface on its own tint.
|
|
22
|
+
const usesGlassMaterial = theme.glass.enabled;
|
|
23
|
+
const reducedMotion = useReducedMotionPreference();
|
|
24
|
+
const c = theme.components.bottomSheet;
|
|
25
|
+
const { height: windowH } = useWindowDimensions();
|
|
26
|
+
const insets = useSafeAreaInsets();
|
|
27
|
+
const sheetBackground = usesGlassMaterial ? 'transparent' : theme.colors.surfaceContainer;
|
|
28
|
+
const overscrollFill = usesGlassMaterial
|
|
29
|
+
? (theme.dark ? 'rgba(20,24,32,0.52)' : 'rgba(250,250,252,0.54)')
|
|
30
|
+
: sheetBackground;
|
|
31
|
+
const providerId = useGlassProviderId();
|
|
32
|
+
const [rendered, setRendered] = useState(visible);
|
|
33
|
+
const [sheetHeight, setSheetHeight] = useState(0);
|
|
34
|
+
const openAnimationStarted = useRef(false);
|
|
35
|
+
const sheetY = useSharedValue(windowH);
|
|
36
|
+
const dimOpacity = useSharedValue(0);
|
|
37
|
+
const handlePressed = useSharedValue(0);
|
|
38
|
+
const handleDismissed = useCallback(() => {
|
|
39
|
+
if (usesGlassMaterial)
|
|
40
|
+
glassController.resume(providerId);
|
|
41
|
+
onDismissed?.();
|
|
42
|
+
}, [onDismissed, providerId, usesGlassMaterial]);
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
if (visible) {
|
|
45
|
+
if (!openAnimationStarted.current) {
|
|
46
|
+
openAnimationStarted.current = true;
|
|
47
|
+
if (usesGlassMaterial)
|
|
48
|
+
glassController.prepareFrozenBackdrop(providerId, 18);
|
|
49
|
+
setRendered(true);
|
|
50
|
+
sheetY.value = windowH;
|
|
51
|
+
dimOpacity.value = 0;
|
|
52
|
+
if (!animationsEnabled) {
|
|
53
|
+
sheetY.value = 0;
|
|
54
|
+
dimOpacity.value = 1;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
sheetY.value = reducedMotion ? 0 : withSpring(0, bottomSheetEnter);
|
|
58
|
+
dimOpacity.value = withTiming(1, { duration: reducedMotion ? 120 : 300, easing: linearEasing });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (rendered) {
|
|
63
|
+
openAnimationStarted.current = false;
|
|
64
|
+
const finish = (finished) => {
|
|
65
|
+
if (finished) {
|
|
66
|
+
runOnJS(setRendered)(false);
|
|
67
|
+
runOnJS(handleDismissed)();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (!animationsEnabled) {
|
|
71
|
+
sheetY.value = windowH;
|
|
72
|
+
dimOpacity.value = 0;
|
|
73
|
+
setRendered(false);
|
|
74
|
+
handleDismissed();
|
|
75
|
+
}
|
|
76
|
+
else if (reducedMotion) {
|
|
77
|
+
dimOpacity.value = withTiming(0, { duration: 100, easing: linearEasing }, finish);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
sheetY.value = withSpring(windowH, bottomSheetEnter, finish);
|
|
81
|
+
dimOpacity.value = withTiming(0, { duration: 250, easing: linearEasing });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [visible, usesGlassMaterial, providerId, windowH, rendered, animationsEnabled, reducedMotion, sheetY, dimOpacity, handleDismissed]);
|
|
85
|
+
const dragY = useSharedValue(0);
|
|
86
|
+
const handleClose = useCallback(() => {
|
|
87
|
+
onClose?.();
|
|
88
|
+
}, [onClose]);
|
|
89
|
+
const handleSheetLayout = useCallback((event) => {
|
|
90
|
+
const nextHeight = event.nativeEvent.layout.height;
|
|
91
|
+
setSheetHeight((current) => current === nextHeight ? current : nextHeight);
|
|
92
|
+
}, []);
|
|
93
|
+
const dismissThreshold = getBottomSheetDismissThreshold(sheetHeight);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!usesGlassMaterial || !rendered)
|
|
96
|
+
return;
|
|
97
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
98
|
+
handleClose();
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
return () => subscription.remove();
|
|
102
|
+
}, [usesGlassMaterial, rendered, handleClose]);
|
|
103
|
+
const pan = Gesture.Pan()
|
|
104
|
+
.enabled(visible && rendered)
|
|
105
|
+
.activeOffsetY([-4, 4])
|
|
106
|
+
.onBegin(() => {
|
|
107
|
+
handlePressed.value = 1;
|
|
108
|
+
})
|
|
109
|
+
.onUpdate((e) => {
|
|
110
|
+
const dy = e.translationY;
|
|
111
|
+
const damped = dy < 0 ? dy * UPWARD_DAMPING : allowDismiss ? dy : dy * UPWARD_DAMPING;
|
|
112
|
+
dragY.value = damped;
|
|
113
|
+
// Dim fades as the sheet travels down.
|
|
114
|
+
const progress = Math.max(0, Math.min(1, dy / dismissThreshold));
|
|
115
|
+
dimOpacity.value = 1 - progress * 0.6;
|
|
116
|
+
})
|
|
117
|
+
.onFinalize(() => {
|
|
118
|
+
handlePressed.value = 0;
|
|
119
|
+
const dy = dragY.value;
|
|
120
|
+
if (allowDismiss && dy > dismissThreshold) {
|
|
121
|
+
if (animationsEnabled) {
|
|
122
|
+
sheetY.value = withSpring(windowH, bottomSheetEnter, (finished) => {
|
|
123
|
+
if (finished) {
|
|
124
|
+
runOnJS(setRendered)(false);
|
|
125
|
+
runOnJS(handleClose)();
|
|
126
|
+
runOnJS(handleDismissed)();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
sheetY.value = windowH;
|
|
132
|
+
dimOpacity.value = 0;
|
|
133
|
+
runOnJS(setRendered)(false);
|
|
134
|
+
runOnJS(handleClose)();
|
|
135
|
+
runOnJS(handleDismissed)();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
sheetY.value = animationsEnabled ? withSpring(0, bottomSheetSettle) : 0;
|
|
140
|
+
if (animationsEnabled)
|
|
141
|
+
dimOpacity.value = withTiming(1, { duration: 150, easing: linearEasing });
|
|
142
|
+
else
|
|
143
|
+
dimOpacity.value = 1;
|
|
144
|
+
}
|
|
145
|
+
dragY.value = 0;
|
|
146
|
+
});
|
|
147
|
+
const handleStyle = useAnimatedStyle(() => ({
|
|
148
|
+
width: withTiming(handlePressed.value === 1 ? 55 : c.handleWidth, handlePressed.value === 1 ? sheetHandlePress : sheetHandleRelease),
|
|
149
|
+
transform: [{ scaleY: withTiming(handlePressed.value === 1 ? 1.15 : 1, handlePressed.value === 1 ? sheetHandlePress : sheetHandleRelease) }],
|
|
150
|
+
opacity: withTiming(handlePressed.value === 1 ? theme.opacity.sheetHandlePressed : theme.opacity.sheetHandle, handlePressed.value === 1 ? sheetHandlePress : sheetHandleRelease),
|
|
151
|
+
}));
|
|
152
|
+
const sheetStyle = useAnimatedStyle(() => ({
|
|
153
|
+
transform: [{ translateY: sheetY.value + dragY.value }],
|
|
154
|
+
}));
|
|
155
|
+
const dimStyle = useAnimatedStyle(() => ({
|
|
156
|
+
opacity: dimOpacity.value,
|
|
157
|
+
backgroundColor: theme.colors.windowDimming,
|
|
158
|
+
}));
|
|
159
|
+
const overscrollHeight = useAnimatedStyle(() => ({
|
|
160
|
+
height: Math.max(0, -dragY.value) + 1,
|
|
161
|
+
}));
|
|
162
|
+
const sheetBody = (_jsxs(_Fragment, { children: [_jsx(Animated.View, { pointerEvents: "none", style: [
|
|
163
|
+
{ position: 'absolute', left: 0, right: 0, bottom: 0, backgroundColor: overscrollFill },
|
|
164
|
+
overscrollHeight,
|
|
165
|
+
] }), _jsx(GestureDetector, { gesture: pan, children: _jsxs(View, { children: [_jsx(View, { style: { height: theme.spacing.xl, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Animated.View, { style: [{ height: c.handleHeight, borderRadius: 2, backgroundColor: usesGlassMaterial ? theme.colors.onGlassMuted : theme.colors.onSurfaceVariantSummary }, handleStyle] }) }), (title != null || startAction != null || endAction != null) && (_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', paddingVertical: 6, paddingBottom: 12 }, children: [_jsx(View, { style: { flex: 0, justifyContent: 'flex-start' }, children: startAction }), _jsx(Text, { type: "title4", weight: "medium", color: usesGlassMaterial ? theme.colors.onGlass : theme.colors.onSurface, style: { flex: 1, textAlign: 'center' }, children: title }), _jsx(View, { style: { flex: 0, justifyContent: 'flex-end', marginLeft: 'auto' }, children: endAction })] }))] }) }), _jsx(View, { style: { width: '100%', minHeight: 0, flexGrow: 0, flexShrink: 1 }, children: typeof children === 'function' ? children(handleClose) : children })] }));
|
|
166
|
+
const content = (_jsx(GestureHandlerRootView, { style: { flex: 1 }, children: _jsxs(Animated.View, { style: [{ flex: 1, justifyContent: 'flex-end', alignItems: 'center' }, dimStyle], children: [_jsx(Pressable, { style: StyleSheet.absoluteFill, onPress: closeOnClickModal && allowDismiss ? handleClose : undefined }), _jsx(GlassSurface, { variant: "sheet", positioning: "floating", sampling: "backdrop", samplingSource: "routeScene", inlineBackdrop: true, intrinsicInlineBackdrop: true, materialOverrides: usesGlassMaterial ? FROZEN_SHEET_MATERIAL_OVERRIDE : undefined, placement: "bottom", animatedStyle: sheetStyle, onLayout: handleSheetLayout, zIndex: 101, style: {
|
|
167
|
+
width: '100%',
|
|
168
|
+
maxWidth: c.maxWidth,
|
|
169
|
+
maxHeight: windowH - insets.top - 24,
|
|
170
|
+
borderTopLeftRadius: c.radius,
|
|
171
|
+
borderTopRightRadius: c.radius,
|
|
172
|
+
backgroundColor: sheetBackground,
|
|
173
|
+
overflow: 'hidden',
|
|
174
|
+
}, contentStyle: {
|
|
175
|
+
width: '100%',
|
|
176
|
+
maxHeight: windowH - insets.top - 24,
|
|
177
|
+
paddingHorizontal: c.horizontalPadding,
|
|
178
|
+
paddingBottom: insets.bottom,
|
|
179
|
+
overflow: 'hidden',
|
|
180
|
+
}, children: usesGlassMaterial ? (_jsx(GlassOverlayContentScope, { children: sheetBody })) : sheetBody })] }) }));
|
|
181
|
+
if (usesGlassMaterial)
|
|
182
|
+
return rendered ? _jsx(GlassOverlay, { zIndex: 200, children: content }) : null;
|
|
183
|
+
return (_jsx(Modal, { transparent: true, statusBarTranslucent: true, animationType: "none", visible: rendered, onRequestClose: handleClose, children: content }));
|
|
184
|
+
});
|
|
185
|
+
BottomSheet.displayName = 'HyperBottomSheet';
|
|
186
|
+
//# sourceMappingURL=BottomSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BottomSheet.js","sourceRoot":"","sources":["../../../src/components/BottomSheet.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpH,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE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O,GAAG,MAAM,CAAC,GAAG,GAAG,EAAE;wBACpC,iBAAiB,EAAE,CAAC,CAAC,iBAAiB;wBACtC,aAAa,EAAE,MAAM,CAAC,MAAM;wBAC5B,QAAQ,EAAE,QAAQ;qBACrB,YAEA,iBAAiB,CAAC,CAAC,CAAC,CACjB,KAAC,wBAAwB,cAAE,SAAS,GAA4B,CACnE,CAAC,CAAC,CAAC,SAAS,GACF,IACH,GACH,CAC5B,CAAC;IAEF,IAAI,iBAAiB;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAC,YAAY,IAAC,MAAM,EAAE,GAAG,YAAG,OAAO,GAAgB,CAAC,CAAC,CAAC,IAAI,CAAC;IACpG,OAAO,CACH,KAAC,KAAK,IAAC,WAAW,QAAC,oBAAoB,QAAC,aAAa,EAAC,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,YACtG,OAAO,GACJ,CACX,CAAC;AACN,CAAC,CAAC,CAAC;AACH,WAAW,CAAC,WAAW,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { GlassButton } from './GlassButton';
|
|
4
|
+
import { DialogAction } from './DialogAction';
|
|
5
|
+
import { useIsInsideDialog } from './SurfaceEnvironmentContext';
|
|
6
|
+
import { useTheme } from '../theme';
|
|
7
|
+
/** The consumer entry shares the reference renderer, except for dialog actions. */
|
|
8
|
+
export const Button = memo(function Button(props) {
|
|
9
|
+
const inDialog = useIsInsideDialog();
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
if (inDialog)
|
|
12
|
+
return _jsx(DialogAction, { ...props });
|
|
13
|
+
const { type = 'default', ...rest } = props;
|
|
14
|
+
return _jsx(GlassButton, { ...rest, appearance: type === 'primary' ? 'tinted' : 'surface', tintColor: theme.colors.primary });
|
|
15
|
+
});
|
|
16
|
+
Button.displayName = 'LiquidGlassButton';
|
|
17
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAcpC,mFAAmF;AACnF,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,MAAM,CAAC,KAAqB;IAC5D,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,QAAQ;QAAE,OAAO,KAAC,YAAY,OAAK,KAAK,GAAI,CAAC;IACjD,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC5C,OAAO,KAAC,WAAW,OAAK,IAAI,EAAE,UAAU,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAC/E,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,GAAI,CAAC;AAC5C,CAAC,CAAC,CAAC;AACH,MAAM,CAAC,WAAW,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PressIndication } from '../primitives';
|
|
3
|
+
import { cardSink, cardTilt } from '../motion';
|
|
4
|
+
import { useReducedMotionPreference } from '../motion/MotionProvider';
|
|
5
|
+
import { useTheme } from '../theme';
|
|
6
|
+
import { useSurfaceEnvironment } from './SurfaceEnvironmentContext';
|
|
7
|
+
import { Surface } from '../primitives/Surface';
|
|
8
|
+
import React, { useCallback, useRef } from 'react';
|
|
9
|
+
import { Pressable, StyleSheet } from 'react-native';
|
|
10
|
+
import Animated, { useAnimatedStyle, useDerivedValue, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
11
|
+
const SINK_AMOUNT = 0.94;
|
|
12
|
+
const TILT_AMOUNT = 9;
|
|
13
|
+
const TILT_PERSPECTIVE_FACTOR = 1.6;
|
|
14
|
+
export const Card = React.memo(function Card(props) {
|
|
15
|
+
const hasPressAction = !!props.onPress || !!props.onLongPress || !!props.onPressIn;
|
|
16
|
+
const feedback = props.feedback ?? (hasPressAction || props.holdDown ? 'sink' : 'none');
|
|
17
|
+
if (feedback === 'tilt')
|
|
18
|
+
return _jsx(TiltCard, { ...props });
|
|
19
|
+
if (feedback === 'sink' && props.holdDown && !hasPressAction && !props.showIndication) {
|
|
20
|
+
return _jsx(LatchedSinkCard, { ...props });
|
|
21
|
+
}
|
|
22
|
+
if (feedback === 'sink')
|
|
23
|
+
return _jsx(SinkCard, { ...props });
|
|
24
|
+
if (feedback === 'none' && props.showIndication)
|
|
25
|
+
return _jsx(IndicationCard, { ...props });
|
|
26
|
+
if (hasPressAction)
|
|
27
|
+
return _jsx(PressOnlyCard, { ...props });
|
|
28
|
+
return _jsx(StaticCardSurface, { ...props });
|
|
29
|
+
});
|
|
30
|
+
Card.displayName = 'HyperCard';
|
|
31
|
+
function CardSurface({ glassVariant, surfaceRole, contentStyle, animatedStyle, centeredTransformOrigin, style, showIndication, pressed, children, }) {
|
|
32
|
+
const theme = useTheme();
|
|
33
|
+
const surfaceEnvironment = useSurfaceEnvironment();
|
|
34
|
+
const radius = theme.components.card.radius;
|
|
35
|
+
// A card on the page samples the scene; a card inside a glass overlay paints
|
|
36
|
+
// a flat tint so it never nests a second lens in the sheet or dialog body.
|
|
37
|
+
const embeddedInGlassOverlay = surfaceEnvironment === 'glassOverlay';
|
|
38
|
+
const material = embeddedInGlassOverlay ? 'overlayTint' : 'glass';
|
|
39
|
+
return (_jsxs(Surface, { material: material, glassVariant: glassVariant, surfaceRole: surfaceRole, sampling: embeddedInGlassOverlay ? 'local' : 'backdrop', samplingSource: "themeBackdrop", inlineBackdrop: !embeddedInGlassOverlay, radius: radius, backgroundColor: embeddedInGlassOverlay
|
|
40
|
+
? theme.glass.tint[theme.dark ? 'dark' : 'light']
|
|
41
|
+
: theme.colors.surfaceContainer, borderWidth: embeddedInGlassOverlay ? StyleSheet.hairlineWidth : 0, borderColor: embeddedInGlassOverlay ? theme.colors.dividerLine : 'transparent', contentStyle: contentStyle, animatedStyle: animatedStyle, centeredTransformOrigin: centeredTransformOrigin, style: style, children: [children, showIndication && pressed != null &&
|
|
42
|
+
_jsx(PressIndication, { pressed: pressed, color: theme.colors.onBackground, radius: radius })] }));
|
|
43
|
+
}
|
|
44
|
+
function StaticCardSurface(props) {
|
|
45
|
+
return (_jsx(CardSurface, { glassVariant: props.glassVariant, surfaceRole: props.surfaceRole, contentStyle: props.contentStyle, style: props.style, showIndication: false, children: props.children }));
|
|
46
|
+
}
|
|
47
|
+
function PressOnlyCard(props) {
|
|
48
|
+
const longPressFired = useRef(false);
|
|
49
|
+
const handlePress = useCallback(() => {
|
|
50
|
+
if (longPressFired.current) {
|
|
51
|
+
longPressFired.current = false;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
props.onPress?.();
|
|
55
|
+
}, [props.onPress]);
|
|
56
|
+
const handleLongPress = useCallback((event) => {
|
|
57
|
+
longPressFired.current = true;
|
|
58
|
+
props.onLongPress?.(event);
|
|
59
|
+
}, [props.onLongPress]);
|
|
60
|
+
return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: props.accessibilityLabel, onPress: handlePress, onPressIn: props.onPressIn, onLongPress: props.onLongPress ? handleLongPress : undefined, style: props.style, children: _jsx(CardSurface, { glassVariant: props.glassVariant, surfaceRole: props.surfaceRole, contentStyle: props.contentStyle, showIndication: false, children: props.children }) }));
|
|
61
|
+
}
|
|
62
|
+
function IndicationCard(props) {
|
|
63
|
+
const pressed = useSharedValue(0);
|
|
64
|
+
const longPressFired = useRef(false);
|
|
65
|
+
const handlePress = useCallback(() => {
|
|
66
|
+
if (longPressFired.current) {
|
|
67
|
+
longPressFired.current = false;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
props.onPress?.();
|
|
71
|
+
}, [props.onPress]);
|
|
72
|
+
const handleLongPress = useCallback((event) => {
|
|
73
|
+
longPressFired.current = true;
|
|
74
|
+
props.onLongPress?.(event);
|
|
75
|
+
}, [props.onLongPress]);
|
|
76
|
+
const onPressIn = useCallback(() => {
|
|
77
|
+
pressed.value = 1;
|
|
78
|
+
props.onPressIn?.();
|
|
79
|
+
}, [props.onPressIn, pressed]);
|
|
80
|
+
const onPressOut = useCallback(() => {
|
|
81
|
+
pressed.value = 0;
|
|
82
|
+
}, [pressed]);
|
|
83
|
+
return (_jsx(Pressable, { accessibilityRole: props.onPress || props.onLongPress ? 'button' : undefined, accessibilityLabel: props.accessibilityLabel, onPress: handlePress, onPressIn: onPressIn, onPressOut: onPressOut, onLongPress: props.onLongPress ? handleLongPress : undefined, style: props.style, children: _jsx(CardSurface, { glassVariant: props.glassVariant, surfaceRole: props.surfaceRole, contentStyle: props.contentStyle, showIndication: true, pressed: pressed, children: props.children }) }));
|
|
84
|
+
}
|
|
85
|
+
function SinkCard(props) {
|
|
86
|
+
const reducedMotion = useReducedMotionPreference();
|
|
87
|
+
const pressed = useSharedValue(0);
|
|
88
|
+
const engaged = useDerivedValue(() => (pressed.value === 1 || props.holdDown ? 1 : 0));
|
|
89
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
90
|
+
transform: [{ scale: reducedMotion ? 1 : withSpring(engaged.value === 1 ? SINK_AMOUNT : 1, cardSink) }],
|
|
91
|
+
}), [reducedMotion]);
|
|
92
|
+
const longPressFired = useRef(false);
|
|
93
|
+
const handlePress = useCallback(() => {
|
|
94
|
+
if (longPressFired.current) {
|
|
95
|
+
longPressFired.current = false;
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
props.onPress?.();
|
|
99
|
+
}, [props.onPress]);
|
|
100
|
+
const handleLongPress = useCallback((event) => {
|
|
101
|
+
longPressFired.current = true;
|
|
102
|
+
props.onLongPress?.(event);
|
|
103
|
+
}, [props.onLongPress]);
|
|
104
|
+
const onPressIn = useCallback(() => {
|
|
105
|
+
longPressFired.current = false;
|
|
106
|
+
pressed.value = 1;
|
|
107
|
+
props.onPressIn?.();
|
|
108
|
+
}, [props.onPressIn, pressed]);
|
|
109
|
+
const onPressOut = useCallback(() => {
|
|
110
|
+
pressed.value = 0;
|
|
111
|
+
}, [pressed]);
|
|
112
|
+
return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: props.accessibilityLabel, onPress: handlePress, onPressIn: onPressIn, onPressOut: onPressOut, onLongPress: props.onLongPress ? handleLongPress : undefined, style: props.style, children: _jsx(CardSurface, { glassVariant: props.glassVariant, surfaceRole: props.surfaceRole, contentStyle: props.contentStyle, animatedStyle: animatedStyle, showIndication: props.showIndication, pressed: pressed, children: props.children }) }));
|
|
113
|
+
}
|
|
114
|
+
function LatchedSinkCard(props) {
|
|
115
|
+
const reducedMotion = useReducedMotionPreference();
|
|
116
|
+
const engaged = useDerivedValue(() => (props.holdDown ? 1 : 0), [props.holdDown]);
|
|
117
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
118
|
+
transform: [{ scale: reducedMotion ? 1 : withSpring(engaged.value === 1 ? SINK_AMOUNT : 1, cardSink) }],
|
|
119
|
+
}), [reducedMotion]);
|
|
120
|
+
return (_jsx(Animated.View, { style: props.style, children: _jsx(CardSurface, { glassVariant: props.glassVariant, surfaceRole: props.surfaceRole, contentStyle: props.contentStyle, animatedStyle: animatedStyle, showIndication: false, children: props.children }) }));
|
|
121
|
+
}
|
|
122
|
+
function TiltCard(props) {
|
|
123
|
+
const reducedMotion = useReducedMotionPreference();
|
|
124
|
+
const pressed = useSharedValue(0);
|
|
125
|
+
const tiltX = useSharedValue(0);
|
|
126
|
+
const tiltY = useSharedValue(0);
|
|
127
|
+
const cardWidth = useSharedValue(1000);
|
|
128
|
+
const cardSize = useRef({ width: 0, height: 0 });
|
|
129
|
+
const longPressFired = useRef(false);
|
|
130
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
131
|
+
transform: [
|
|
132
|
+
{ perspective: Math.max(cardWidth.value * TILT_PERSPECTIVE_FACTOR, 800) },
|
|
133
|
+
{ rotateX: reducedMotion ? '0deg' : withSpring(tiltX.value + 'deg', cardTilt) },
|
|
134
|
+
{ rotateY: reducedMotion ? '0deg' : withSpring(tiltY.value + 'deg', cardTilt) },
|
|
135
|
+
],
|
|
136
|
+
}), [reducedMotion]);
|
|
137
|
+
const onLayout = useCallback((event) => {
|
|
138
|
+
const { width, height } = event.nativeEvent.layout;
|
|
139
|
+
cardSize.current = { width, height };
|
|
140
|
+
cardWidth.value = width || 1000;
|
|
141
|
+
}, [cardWidth]);
|
|
142
|
+
const handlePressIn = useCallback((event) => {
|
|
143
|
+
longPressFired.current = false;
|
|
144
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
145
|
+
const halfW = (cardSize.current.width || 1) / 2;
|
|
146
|
+
const halfH = (cardSize.current.height || 1) / 2;
|
|
147
|
+
tiltX.value = locationY < halfH ? TILT_AMOUNT : -TILT_AMOUNT;
|
|
148
|
+
tiltY.value = locationX < halfW ? -TILT_AMOUNT : TILT_AMOUNT;
|
|
149
|
+
pressed.value = 1;
|
|
150
|
+
props.onPressIn?.();
|
|
151
|
+
}, [props.onPressIn, pressed, tiltX, tiltY]);
|
|
152
|
+
const handlePressOut = useCallback(() => {
|
|
153
|
+
pressed.value = 0;
|
|
154
|
+
tiltX.value = 0;
|
|
155
|
+
tiltY.value = 0;
|
|
156
|
+
}, [pressed, tiltX, tiltY]);
|
|
157
|
+
const handleLongPress = useCallback((event) => {
|
|
158
|
+
longPressFired.current = true;
|
|
159
|
+
props.onLongPress?.(event);
|
|
160
|
+
}, [props.onLongPress]);
|
|
161
|
+
const handlePress = useCallback(() => {
|
|
162
|
+
if (longPressFired.current) {
|
|
163
|
+
longPressFired.current = false;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
props.onPress?.();
|
|
167
|
+
}, [props.onPress]);
|
|
168
|
+
return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: props.accessibilityLabel, onPress: handlePress, onPressIn: handlePressIn, onPressOut: handlePressOut, onLongPress: props.onLongPress ? handleLongPress : undefined, onLayout: onLayout, style: props.style, children: _jsx(CardSurface, { glassVariant: props.glassVariant, surfaceRole: props.surfaceRole, contentStyle: props.contentStyle, animatedStyle: animatedStyle, centeredTransformOrigin: true, showIndication: props.showIndication, pressed: pressed, children: props.children }) }));
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=Card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../../../src/components/Card.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAIhD,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAwBlH,MAAM,WAA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AAO;QACX,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACtB,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpB,OAAO,CACH,KAAC,SAAS,IACN,iBAAiB,EAAC,QAAQ,EAC1B,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,cAAc,EAC1B,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,EAC5D,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,CAAC,KAAK,YAElB,KAAC,WAAW,IACR,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,aAAa,EAAE,aAAa,EAC5B,uBAAuB,QACvB,cAAc,EAAE,KAAK,CAAC,cAAc,EACpC,OAAO,EAAE,OAAO,YAEf,KAAK,CAAC,QAAQ,GACL,GACN,CACf,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { checkboxColor, checkboxMarkHide, checkboxMarkShow } from '../motion';
|
|
3
|
+
import { useReducedMotionPreference } from '../motion/MotionProvider';
|
|
4
|
+
import { useTheme } from '../theme';
|
|
5
|
+
import { GlassSurface } from '../GlassSurface';
|
|
6
|
+
import { useGlassPressMotion } from '../useGlassPressMotion';
|
|
7
|
+
import { glassControlMaterial } from './glassControlMaterial';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Pressable, View } from 'react-native';
|
|
10
|
+
import Animated, { interpolateColor, useAnimatedProps, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
11
|
+
import Svg, { Path } from 'react-native-svg';
|
|
12
|
+
const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
13
|
+
const GLASS_CHECKBOX_SPRING = { damping: 14, stiffness: 520, mass: 0.7 };
|
|
14
|
+
/** 26dp Liquid Glass circular checkbox with frosted rim, spring pop, and animated checkmark. */
|
|
15
|
+
export const Checkbox = React.memo(function Checkbox({ value, defaultValue = false, onValueChange, disabled = false, accessibilityLabel }) {
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const usesGlass = theme.glass.enabled;
|
|
18
|
+
const reduced = useReducedMotionPreference();
|
|
19
|
+
const controlled = value !== undefined;
|
|
20
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
21
|
+
const checkedValue = value ?? internalValue;
|
|
22
|
+
const checked = useSharedValue(checkedValue ? 1 : 0);
|
|
23
|
+
const pressed = useSharedValue(0);
|
|
24
|
+
const motion = useGlassPressMotion(13, 13, 0.5);
|
|
25
|
+
React.useEffect(() => {
|
|
26
|
+
checked.value = reduced ? (checkedValue ? 1 : 0) : withTiming(checkedValue ? 1 : 0, checkboxColor);
|
|
27
|
+
}, [checked, checkedValue, reduced]);
|
|
28
|
+
const offFill = usesGlass
|
|
29
|
+
? 'rgba(255,255,255,0.02)'
|
|
30
|
+
: theme.colors.secondary;
|
|
31
|
+
const offBorder = usesGlass
|
|
32
|
+
? (theme.dark ? 'rgba(255,255,255,0.36)' : 'rgba(255,255,255,0.82)')
|
|
33
|
+
: 'transparent';
|
|
34
|
+
const onFill = usesGlass ? (theme.dark ? 'rgba(10,132,255,0.92)' : 'rgba(0,136,255,0.92)') : theme.colors.primary;
|
|
35
|
+
const onBorder = usesGlass ? 'rgba(255,255,255,0.52)' : 'transparent';
|
|
36
|
+
const fillStyle = useAnimatedStyle(() => ({
|
|
37
|
+
backgroundColor: interpolateColor(checked.value, [0, 1], [disabled ? theme.colors.disabledSecondary : offFill, disabled ? theme.colors.disabledPrimary : onFill]),
|
|
38
|
+
}), [checked, disabled, offFill, onFill, theme.colors.disabledPrimary, theme.colors.disabledSecondary]);
|
|
39
|
+
const containerStyle = useAnimatedStyle(() => ({
|
|
40
|
+
borderColor: interpolateColor(checked.value, [0, 1], [offBorder, onBorder]),
|
|
41
|
+
transform: [{
|
|
42
|
+
scale: reduced
|
|
43
|
+
? 1
|
|
44
|
+
: withSpring(pressed.value ? 0.94 : 1, GLASS_CHECKBOX_SPRING),
|
|
45
|
+
}],
|
|
46
|
+
}), [disabled, offBorder, offFill, onBorder, onFill, pressed, reduced]);
|
|
47
|
+
const markProps = useAnimatedProps(() => ({
|
|
48
|
+
strokeDashoffset: reduced
|
|
49
|
+
? (checked.value ? 0 : 30)
|
|
50
|
+
: withTiming(checked.value ? 0 : 30, checked.value ? checkboxMarkShow : checkboxMarkHide),
|
|
51
|
+
opacity: checked.value,
|
|
52
|
+
}));
|
|
53
|
+
return (_jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: accessibilityLabel, accessibilityState: { checked: checkedValue, disabled }, disabled: disabled, hitSlop: 10, onPress: () => {
|
|
54
|
+
const next = !checkedValue;
|
|
55
|
+
if (!controlled)
|
|
56
|
+
setInternalValue(next);
|
|
57
|
+
onValueChange?.(next);
|
|
58
|
+
}, onPressIn: (event) => { pressed.value = 1; if (!reduced)
|
|
59
|
+
motion.onPressIn(event); }, onTouchMove: reduced ? undefined : motion.onTouchMove, onPressOut: (event) => { pressed.value = 0; if (!reduced)
|
|
60
|
+
motion.onPressOut(event); }, children: _jsxs(Animated.View, { style: [
|
|
61
|
+
{
|
|
62
|
+
width: 26,
|
|
63
|
+
height: 26,
|
|
64
|
+
borderRadius: 13,
|
|
65
|
+
borderWidth: usesGlass ? 1 : 0,
|
|
66
|
+
overflow: 'visible',
|
|
67
|
+
},
|
|
68
|
+
containerStyle,
|
|
69
|
+
], children: [usesGlass ? _jsx(GlassSurface, { variant: "control", positioning: "inFlow", sampling: "backdrop", samplingSource: "themeBackdrop", inlineBackdrop: true, pointerEvents: "none", pointerEvent: motion.pointerEvent, pointerEventValue: motion.pointerEventValue, pointerEventSink: motion.pointerEventSink, opticalProgress: motion.progress, materialOverrides: { ...glassControlMaterial, radius: 13, shadowOpacity: 0.05,
|
|
70
|
+
shadowRadius: 8, shadowOffsetY: 2 }, style: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 } }) : null, _jsx(Animated.View, { pointerEvents: "none", style: [{
|
|
71
|
+
position: 'absolute', top: 0, right: 0, bottom: 0, left: 0, borderRadius: 13,
|
|
72
|
+
}, fillStyle] }), usesGlass ? (_jsx(View, { pointerEvents: "none", style: {
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
top: 1,
|
|
75
|
+
left: 2,
|
|
76
|
+
right: 2,
|
|
77
|
+
height: 11,
|
|
78
|
+
borderTopLeftRadius: 11,
|
|
79
|
+
borderTopRightRadius: 11,
|
|
80
|
+
backgroundColor: 'rgba(255,255,255,0.28)',
|
|
81
|
+
} })) : null, _jsx(Svg, { width: 26, height: 26, viewBox: "0 0 26 26", children: _jsx(AnimatedPath, { animatedProps: markProps, d: "M6.9 12.1 L11.8 17.2 L19.1 7.8", fill: "none", stroke: disabled ? theme.colors.disabledOnPrimary : theme.colors.onPrimary, strokeWidth: 2.34, strokeLinecap: "round", strokeLinejoin: "round", strokeDasharray: 30 }) })] }) }));
|
|
82
|
+
});
|
|
83
|
+
Checkbox.displayName = 'HyperCheckbox';
|
|
84
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../src/components/Checkbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,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MAAM,EACX,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAC1E,WAAW,EAAE,IAAI,EACjB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,eAAe,EAAE,EAAE,GACrB,GACA,IACM,GACR,CACf,CAAC;AACN,CAAC,CAAC,CAAC;AACH,QAAQ,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControlPressContext.js","sourceRoot":"","sources":["../../../src/components/ControlPressContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AASlD,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAC;AACjF,MAAM,UAAU,eAAe,KAAK,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GlassOverlay } from '../GlassSurface';
|
|
3
|
+
import { DialogContent } from './DialogContent';
|
|
4
|
+
import { dialogContentExit, dialogDimEnter, dialogDimExit, dialogLargeEnter } from '../motion';
|
|
5
|
+
import { useReducedMotionPreference } from '../motion/MotionProvider';
|
|
6
|
+
import { useTheme } from '../theme';
|
|
7
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { BackHandler, Modal, Pressable, StyleSheet, useWindowDimensions } from 'react-native';
|
|
9
|
+
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
|
|
10
|
+
const LARGE_MIN_WIDTH = 840;
|
|
11
|
+
const LARGE_MIN_HEIGHT = 480;
|
|
12
|
+
export const Dialog = React.memo(function Dialog({ visible = false, onClose, title, summary, closeOnClickModal = true, children }) {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
// The dialog is always a glass overlay; a disabled material provider just
|
|
15
|
+
// stops native sampling and the surface falls back to its own tint.
|
|
16
|
+
const usesGlassMaterial = theme.glass.enabled;
|
|
17
|
+
const reducedMotion = useReducedMotionPreference();
|
|
18
|
+
const c = theme.components.dialog;
|
|
19
|
+
const { width: windowW, height: windowH } = useWindowDimensions();
|
|
20
|
+
// Mounted stays true while the exit animation plays, so the Modal is still
|
|
21
|
+
// on screen when visible flips false.
|
|
22
|
+
const [rendered, setRendered] = useState(visible);
|
|
23
|
+
const visibleRef = useRef(visible);
|
|
24
|
+
visibleRef.current = visible;
|
|
25
|
+
const finishClose = useCallback(() => {
|
|
26
|
+
if (!visibleRef.current)
|
|
27
|
+
setRendered(false);
|
|
28
|
+
}, []);
|
|
29
|
+
const isLarge = windowW >= LARGE_MIN_WIDTH && windowH >= LARGE_MIN_HEIGHT;
|
|
30
|
+
const dimOpacity = useSharedValue(0);
|
|
31
|
+
const largeScale = useSharedValue(0.8);
|
|
32
|
+
const largeOpacity = useSharedValue(0);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (visible) {
|
|
35
|
+
setRendered(true);
|
|
36
|
+
// Enter.
|
|
37
|
+
dimOpacity.value = withTiming(1, reducedMotion ? { duration: 120 } : dialogDimEnter);
|
|
38
|
+
// Pinned Dialog page centres the card on every screen size and scales
|
|
39
|
+
// it in; the bottom sheet form read as a different component.
|
|
40
|
+
largeOpacity.value = withTiming(1, reducedMotion ? { duration: 120 } : dialogDimEnter);
|
|
41
|
+
largeScale.value = reducedMotion ? 1 : withSpring(1, dialogLargeEnter);
|
|
42
|
+
}
|
|
43
|
+
else if (rendered) {
|
|
44
|
+
// Exit: content tween 260ms Decelerate(1.5), dim 250ms.
|
|
45
|
+
const finish = (finished) => {
|
|
46
|
+
if (finished)
|
|
47
|
+
runOnJS(finishClose)();
|
|
48
|
+
};
|
|
49
|
+
dimOpacity.value = withTiming(0, reducedMotion ? { duration: 100 } : dialogDimExit);
|
|
50
|
+
largeOpacity.value = withTiming(0, reducedMotion ? { duration: 100 } : dialogContentExit, finish);
|
|
51
|
+
largeScale.value = reducedMotion ? 1 : withTiming(0.8, dialogContentExit);
|
|
52
|
+
}
|
|
53
|
+
}, [visible, rendered, reducedMotion, dimOpacity, largeOpacity, largeScale, finishClose]);
|
|
54
|
+
const dimStyle = useAnimatedStyle(() => ({
|
|
55
|
+
opacity: dimOpacity.value,
|
|
56
|
+
backgroundColor: theme.dark ? 'rgba(18,18,18,0.56)' : 'rgba(41,41,58,0.23)',
|
|
57
|
+
}));
|
|
58
|
+
const largeStyle = useAnimatedStyle(() => ({
|
|
59
|
+
opacity: largeOpacity.value,
|
|
60
|
+
transform: [{ scale: largeScale.value }],
|
|
61
|
+
}));
|
|
62
|
+
const handleClose = useCallback(() => {
|
|
63
|
+
onClose?.();
|
|
64
|
+
}, [onClose]);
|
|
65
|
+
const handleBackdrop = useCallback(() => {
|
|
66
|
+
if (closeOnClickModal)
|
|
67
|
+
handleClose();
|
|
68
|
+
}, [closeOnClickModal, handleClose]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (!usesGlassMaterial || !rendered)
|
|
71
|
+
return;
|
|
72
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
73
|
+
handleClose();
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
return () => subscription.remove();
|
|
77
|
+
}, [usesGlassMaterial, rendered, handleClose]);
|
|
78
|
+
const content = (_jsxs(Animated.View, { style: { flex: 1, padding: 40, justifyContent: 'center' }, children: [_jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, dimStyle] }), _jsx(Pressable, { style: StyleSheet.absoluteFill, onPress: handleBackdrop }), _jsx(Animated.View, { style: [{ width: '100%', maxWidth: c.maxWidth, alignSelf: 'center' }, largeStyle], children: _jsx(DialogContent, { title: title, summary: summary, style: {
|
|
79
|
+
maxHeight: isLarge ? (windowH * 2) / 3 : windowH - 80,
|
|
80
|
+
}, children: typeof children === 'function' ? children(handleClose) : children }) })] }));
|
|
81
|
+
if (usesGlassMaterial)
|
|
82
|
+
return rendered ? _jsx(GlassOverlay, { zIndex: 200, children: content }) : null;
|
|
83
|
+
return (_jsx(Modal, { transparent: true, statusBarTranslucent: true, animationType: "none", visible: rendered, onRequestClose: handleClose, children: content }));
|
|
84
|
+
});
|
|
85
|
+
Dialog.displayName = 'Dialog';
|
|
86
|
+
//# sourceMappingURL=Dialog.js.map
|