make triggers accessible
This commit is contained in:
@@ -1,11 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {StyleSheet, View} from 'react-native'
|
||||||
import {ChatBskyConvoDefs} from '@atproto-labs/api'
|
import {ChatBskyConvoDefs} from '@atproto-labs/api'
|
||||||
|
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
import {MessageMenu} from '#/components/dms/MessageMenu'
|
import {MessageMenu} from '#/components/dms/MessageMenu'
|
||||||
import {useMenuControl} from '#/components/Menu'
|
import {useMenuControl} from '#/components/Menu'
|
||||||
import {Text} from '#/components/Typography'
|
|
||||||
|
|
||||||
export function ActionsWrapper({
|
export function ActionsWrapper({
|
||||||
message,
|
message,
|
||||||
@@ -32,44 +31,39 @@ export function ActionsWrapper({
|
|||||||
<View
|
<View
|
||||||
onMouseEnter={onMouseEnter}
|
onMouseEnter={onMouseEnter}
|
||||||
onMouseLeave={onMouseLeave}
|
onMouseLeave={onMouseLeave}
|
||||||
style={[a.flex_1, a.flex_row]}>
|
onFocus={onMouseEnter}
|
||||||
|
onBlur={onMouseLeave}
|
||||||
|
style={StyleSheet.flatten([a.flex_1, a.flex_row])}>
|
||||||
{isFromSelf && (
|
{isFromSelf && (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
a.mr_md,
|
||||||
{
|
{
|
||||||
width: 100,
|
|
||||||
marginLeft: 'auto',
|
marginLeft: 'auto',
|
||||||
alignItems: 'flex-end',
|
|
||||||
},
|
},
|
||||||
]}>
|
]}>
|
||||||
<ActionBar control={menuControl} message={message} />
|
<MessageMenu
|
||||||
|
message={message}
|
||||||
|
control={menuControl}
|
||||||
|
triggerOpacity={showActions ? 1 : 0}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
<View
|
<View
|
||||||
style={[
|
style={{
|
||||||
{
|
maxWidth: '65%',
|
||||||
maxWidth: '65%',
|
}}>
|
||||||
},
|
|
||||||
]}>
|
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</View>
|
||||||
{!isFromSelf && (
|
{!isFromSelf && (
|
||||||
<View style={[{width: 100}]}>{showActions && <Text>Hello</Text>}</View>
|
<View style={[a.flex_row, a.align_center, a.ml_xl]}>
|
||||||
|
<MessageMenu
|
||||||
|
message={message}
|
||||||
|
control={menuControl}
|
||||||
|
triggerOpacity={showActions ? 1 : 0}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function ActionBar({
|
|
||||||
control,
|
|
||||||
message,
|
|
||||||
}: {
|
|
||||||
control: Menu.MenuControlProps
|
|
||||||
message: ChatBskyConvoDefs.MessageView
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<View style={[a.flex_row, a.mx_md]}>
|
|
||||||
<MessageMenu message={message} control={control} />
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Pressable} from 'react-native'
|
import {Pressable, View} from 'react-native'
|
||||||
import {ChatBskyConvoDefs} from '@atproto-labs/api'
|
import {ChatBskyConvoDefs} from '@atproto-labs/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
@@ -17,8 +17,10 @@ export let MessageMenu = ({
|
|||||||
message,
|
message,
|
||||||
control,
|
control,
|
||||||
hideTrigger,
|
hideTrigger,
|
||||||
|
triggerOpacity,
|
||||||
}: {
|
}: {
|
||||||
hideTrigger?: boolean
|
hideTrigger?: boolean
|
||||||
|
triggerOpacity?: number
|
||||||
message: ChatBskyConvoDefs.MessageView
|
message: ChatBskyConvoDefs.MessageView
|
||||||
control: Menu.MenuControlProps
|
control: Menu.MenuControlProps
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
@@ -41,21 +43,23 @@ export let MessageMenu = ({
|
|||||||
<>
|
<>
|
||||||
<Menu.Root control={control}>
|
<Menu.Root control={control}>
|
||||||
{!hideTrigger && (
|
{!hideTrigger && (
|
||||||
<Menu.Trigger label={_(msg`Chat settings`)}>
|
<View style={{opacity: triggerOpacity}}>
|
||||||
{({props, state}) => (
|
<Menu.Trigger label={_(msg`Chat settings`)}>
|
||||||
<Pressable
|
{({props, state}) => (
|
||||||
{...props}
|
<Pressable
|
||||||
style={[
|
{...props}
|
||||||
a.p_sm,
|
style={[
|
||||||
a.rounded_full,
|
a.p_sm,
|
||||||
(state.hovered || state.pressed) && t.atoms.bg_contrast_25,
|
a.rounded_full,
|
||||||
// make sure pfp is in the middle
|
(state.hovered || state.pressed) && t.atoms.bg_contrast_25,
|
||||||
{marginLeft: -10},
|
// make sure pfp is in the middle
|
||||||
]}>
|
{marginLeft: -10},
|
||||||
<DotsHorizontal size="sm" style={t.atoms.text} />
|
]}>
|
||||||
</Pressable>
|
<DotsHorizontal size="sm" style={t.atoms.text} />
|
||||||
)}
|
</Pressable>
|
||||||
</Menu.Trigger>
|
)}
|
||||||
|
</Menu.Trigger>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Menu.Outer>
|
<Menu.Outer>
|
||||||
|
|||||||
Reference in New Issue
Block a user