add a wep specific wrapper
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, {useCallback} from 'react'
|
||||
import {Pressable} from 'react-native'
|
||||
import {Pressable, View} from 'react-native'
|
||||
import Animated, {
|
||||
cancelAnimation,
|
||||
runOnJS,
|
||||
@@ -9,13 +9,16 @@ import Animated, {
|
||||
} from 'react-native-reanimated'
|
||||
|
||||
import {useHaptics} from 'lib/haptics'
|
||||
import {atoms as a} from '#/alf'
|
||||
|
||||
const AnimatedPressable = Animated.createAnimatedComponent(Pressable)
|
||||
|
||||
export const GrowWrapper = function GrowWrapper({
|
||||
export const ActionsWrapper = function GrowWrapper({
|
||||
isFromSelf,
|
||||
onOpenMenu,
|
||||
children,
|
||||
}: {
|
||||
isFromSelf: boolean
|
||||
onOpenMenu: () => unknown
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
@@ -49,12 +52,20 @@ export const GrowWrapper = function GrowWrapper({
|
||||
}, [scale, animationDidComplete, playHaptic, onOpenMenu, shrink])
|
||||
|
||||
return (
|
||||
<AnimatedPressable
|
||||
style={animatedStyle}
|
||||
unstable_pressDelay={200}
|
||||
onPressIn={grow}
|
||||
onTouchEnd={shrink}>
|
||||
{children}
|
||||
</AnimatedPressable>
|
||||
<View
|
||||
style={[
|
||||
{
|
||||
maxWidth: '65%',
|
||||
},
|
||||
isFromSelf ? a.self_end : a.self_start,
|
||||
]}>
|
||||
<AnimatedPressable
|
||||
style={animatedStyle}
|
||||
unstable_pressDelay={200}
|
||||
onPressIn={grow}
|
||||
onTouchEnd={shrink}>
|
||||
{children}
|
||||
</AnimatedPressable>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -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>
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import {ChatBskyConvoDefs} from '@atproto-labs/api'
|
||||
|
||||
import {useSession} from 'state/session'
|
||||
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 {MessageMenu} from '#/components/dms/MessageMenu'
|
||||
import {useMenuControl} from '#/components/Menu'
|
||||
@@ -56,46 +56,38 @@ export function MessageItem({
|
||||
}, [menuControl])
|
||||
|
||||
return (
|
||||
<View
|
||||
style={[
|
||||
{
|
||||
maxWidth: '65%',
|
||||
},
|
||||
isFromSelf ? a.self_end : a.self_start,
|
||||
]}>
|
||||
<GrowWrapper onOpenMenu={onOpenMenu}>
|
||||
<View
|
||||
<ActionsWrapper onOpenMenu={onOpenMenu} isFromSelf={isFromSelf}>
|
||||
<View
|
||||
style={[
|
||||
a.py_sm,
|
||||
a.px_lg,
|
||||
a.my_2xs,
|
||||
a.rounded_md,
|
||||
{
|
||||
backgroundColor: isFromSelf
|
||||
? t.palette.primary_500
|
||||
: t.palette.contrast_50,
|
||||
borderRadius: 17,
|
||||
},
|
||||
isFromSelf
|
||||
? {borderBottomRightRadius: isLastInGroup ? 2 : 17}
|
||||
: {borderBottomLeftRadius: isLastInGroup ? 2 : 17},
|
||||
]}>
|
||||
<Text
|
||||
style={[
|
||||
a.py_sm,
|
||||
a.px_lg,
|
||||
a.my_2xs,
|
||||
a.rounded_md,
|
||||
{
|
||||
backgroundColor: isFromSelf
|
||||
? t.palette.primary_500
|
||||
: t.palette.contrast_50,
|
||||
borderRadius: 17,
|
||||
},
|
||||
isFromSelf
|
||||
? {borderBottomRightRadius: isLastInGroup ? 2 : 17}
|
||||
: {borderBottomLeftRadius: isLastInGroup ? 2 : 17},
|
||||
a.text_md,
|
||||
a.leading_snug,
|
||||
isFromSelf && {color: t.palette.white},
|
||||
]}>
|
||||
<Text
|
||||
style={[
|
||||
a.text_md,
|
||||
a.leading_snug,
|
||||
isFromSelf && {color: t.palette.white},
|
||||
]}>
|
||||
{item.text}
|
||||
</Text>
|
||||
</View>
|
||||
<MessageItemMetadata
|
||||
message={item}
|
||||
isLastInGroup={isLastInGroup}
|
||||
style={isFromSelf ? a.text_right : a.text_left}
|
||||
/>
|
||||
<MessageMenu message={item} control={menuControl} />
|
||||
</GrowWrapper>
|
||||
</View>
|
||||
{item.text}
|
||||
</Text>
|
||||
</View>
|
||||
<MessageItemMetadata
|
||||
message={item}
|
||||
isLastInGroup={isLastInGroup}
|
||||
style={isFromSelf ? a.text_right : a.text_left}
|
||||
/>
|
||||
<MessageMenu message={item} control={menuControl} />
|
||||
</ActionsWrapper>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user