add a wep specific wrapper

This commit is contained in:
Hailey
2024-05-02 10:00:35 -07:00
parent 55dd945e7f
commit c3f5bfd7aa
3 changed files with 66 additions and 49 deletions
@@ -1,5 +1,5 @@
import React, {useCallback} from 'react' import React, {useCallback} from 'react'
import {Pressable} from 'react-native' import {Pressable, View} from 'react-native'
import Animated, { import Animated, {
cancelAnimation, cancelAnimation,
runOnJS, runOnJS,
@@ -9,13 +9,16 @@ import Animated, {
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {useHaptics} from 'lib/haptics' import {useHaptics} from 'lib/haptics'
import {atoms as a} from '#/alf'
const AnimatedPressable = Animated.createAnimatedComponent(Pressable) const AnimatedPressable = Animated.createAnimatedComponent(Pressable)
export const GrowWrapper = function GrowWrapper({ export const ActionsWrapper = function GrowWrapper({
isFromSelf,
onOpenMenu, onOpenMenu,
children, children,
}: { }: {
isFromSelf: boolean
onOpenMenu: () => unknown onOpenMenu: () => unknown
children: React.ReactNode children: React.ReactNode
}) { }) {
@@ -49,6 +52,13 @@ export const GrowWrapper = function GrowWrapper({
}, [scale, animationDidComplete, playHaptic, onOpenMenu, shrink]) }, [scale, animationDidComplete, playHaptic, onOpenMenu, shrink])
return ( return (
<View
style={[
{
maxWidth: '65%',
},
isFromSelf ? a.self_end : a.self_start,
]}>
<AnimatedPressable <AnimatedPressable
style={animatedStyle} style={animatedStyle}
unstable_pressDelay={200} unstable_pressDelay={200}
@@ -56,5 +66,6 @@ export const GrowWrapper = function GrowWrapper({
onTouchEnd={shrink}> onTouchEnd={shrink}>
{children} {children}
</AnimatedPressable> </AnimatedPressable>
</View>
) )
} }
+14
View File
@@ -0,0 +1,14 @@
import React from 'react'
import {View} from 'react-native'
export function ActionsWrapper({
isFromSelf,
onOpenMenu,
children,
}: {
isFromSelf: boolean
onOpenMenu: () => unknown
children: React.ReactNode
}) {
return <View>{children}</View>
}
+3 -11
View File
@@ -4,7 +4,7 @@ import {ChatBskyConvoDefs} from '@atproto-labs/api'
import {useSession} from 'state/session' import {useSession} from 'state/session'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {GrowWrapper} from '#/components/dms/GrowWrapper' import {ActionsWrapper} from '#/components/dms/ActionsWrapper'
import {MessageItemMetadata} from '#/components/dms/MesageItemMetadata' import {MessageItemMetadata} from '#/components/dms/MesageItemMetadata'
import {MessageMenu} from '#/components/dms/MessageMenu' import {MessageMenu} from '#/components/dms/MessageMenu'
import {useMenuControl} from '#/components/Menu' import {useMenuControl} from '#/components/Menu'
@@ -56,14 +56,7 @@ export function MessageItem({
}, [menuControl]) }, [menuControl])
return ( return (
<View <ActionsWrapper onOpenMenu={onOpenMenu} isFromSelf={isFromSelf}>
style={[
{
maxWidth: '65%',
},
isFromSelf ? a.self_end : a.self_start,
]}>
<GrowWrapper onOpenMenu={onOpenMenu}>
<View <View
style={[ style={[
a.py_sm, a.py_sm,
@@ -95,7 +88,6 @@ export function MessageItem({
style={isFromSelf ? a.text_right : a.text_left} style={isFromSelf ? a.text_right : a.text_left}
/> />
<MessageMenu message={item} control={menuControl} /> <MessageMenu message={item} control={menuControl} />
</GrowWrapper> </ActionsWrapper>
</View>
) )
} }