about summary refs log tree commit diff
path: root/src/components/ContextMenu/Backdrop.ios.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-03-21 18:29:14 +0200
committerGitHub <noreply@github.com>2025-03-21 09:29:14 -0700
commitc4785ef96e13d02b217dce4e777269c0e895507d (patch)
tree785b8f00ded8dbdb6cd167a280141faad8873e3b /src/components/ContextMenu/Backdrop.ios.tsx
parentf6f253b4c93f5166648615d03f38ede40135f646 (diff)
downloadvoidsky-c4785ef96e13d02b217dce4e777269c0e895507d.tar.zst
New `ContextMenu` menu type for DM messages (#8014)
* get context menu somewhat working ish

* take screenshot rather than double rendering

* get animations somewhat working

* get transform animation working

* rm log

* upwards safe area

* get working on android

* get android working once and for all

* fix positioning on both platforms

* use dark blur on ios always, fix dark mode

* allow closing with hardware back press

* try and fix type error

* add note about ts-ignore

* round post

* add image capture error handling

* extract magic numbers

* set explicit embed width, rm top margin

* Message embed width tweaks

* Format

* fix position of embeds

* same as above for web

---------

Co-authored-by: Eric Bailey <git@esb.lol>
Diffstat (limited to 'src/components/ContextMenu/Backdrop.ios.tsx')
-rw-r--r--src/components/ContextMenu/Backdrop.ios.tsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/components/ContextMenu/Backdrop.ios.tsx b/src/components/ContextMenu/Backdrop.ios.tsx
new file mode 100644
index 000000000..27a4ed1d8
--- /dev/null
+++ b/src/components/ContextMenu/Backdrop.ios.tsx
@@ -0,0 +1,49 @@
+import {Pressable} from 'react-native'
+import Animated, {
+  Extrapolation,
+  interpolate,
+  SharedValue,
+  useAnimatedProps,
+} from 'react-native-reanimated'
+import {BlurView} from 'expo-blur'
+import {msg} from '@lingui/macro'
+import {useLingui} from '@lingui/react'
+
+import {atoms as a} from '#/alf'
+
+const AnimatedBlurView = Animated.createAnimatedComponent(BlurView)
+
+export function Backdrop({
+  animation,
+  intensity = 50,
+  onPress,
+}: {
+  animation: SharedValue<number>
+  intensity?: number
+  onPress?: () => void
+}) {
+  const {_} = useLingui()
+
+  const animatedProps = useAnimatedProps(() => ({
+    intensity: interpolate(
+      animation.get(),
+      [0, 1],
+      [0, intensity],
+      Extrapolation.CLAMP,
+    ),
+  }))
+
+  return (
+    <AnimatedBlurView
+      animatedProps={animatedProps}
+      style={[a.absolute, a.inset_0]}
+      tint="systemThinMaterialDark">
+      <Pressable
+        style={a.flex_1}
+        accessibilityLabel={_(msg`Close menu`)}
+        accessibilityHint={_(msg`Tap to close context menu`)}
+        onPress={onPress}
+      />
+    </AnimatedBlurView>
+  )
+}