Fix chat request buttons not moving with swipe gesture (#9155)

* portal in buttons so they move with swipe

* remove outline style buttons
This commit is contained in:
Samuel Newman
2025-10-10 19:30:29 +03:00
committed by GitHub
parent b7b47d30bf
commit 54b8eacba1
4 changed files with 231 additions and 217 deletions
@@ -42,11 +42,14 @@ import {Trash_Stroke2_Corner0_Rounded} from '#/components/icons/Trash'
import {Link} from '#/components/Link' import {Link} from '#/components/Link'
import {useMenuControl} from '#/components/Menu' import {useMenuControl} from '#/components/Menu'
import {PostAlerts} from '#/components/moderation/PostAlerts' import {PostAlerts} from '#/components/moderation/PostAlerts'
import {createPortalGroup} from '#/components/Portal'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {useSimpleVerificationState} from '#/components/verification' import {useSimpleVerificationState} from '#/components/verification'
import {VerificationCheck} from '#/components/verification/VerificationCheck' import {VerificationCheck} from '#/components/verification/VerificationCheck'
import type * as bsky from '#/types/bsky' import type * as bsky from '#/types/bsky'
export const ChatListItemPortal = createPortalGroup()
export let ChatListItem = ({ export let ChatListItem = ({
convo, convo,
showMenu = true, showMenu = true,
@@ -331,6 +334,7 @@ function ChatListItemReady({
const hasUnread = convo.unreadCount > 0 && !isDeletedAccount const hasUnread = convo.unreadCount > 0 && !isDeletedAccount
return ( return (
<ChatListItemPortal.Provider>
<GestureActionView actions={actions}> <GestureActionView actions={actions}>
<View <View
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
@@ -365,8 +369,14 @@ function ChatListItemReady({
accessibilityActions={ accessibilityActions={
isNative isNative
? [ ? [
{name: 'magicTap', label: _(msg`Open conversation options`)}, {
{name: 'longpress', label: _(msg`Open conversation options`)}, name: 'magicTap',
label: _(msg`Open conversation options`),
},
{
name: 'longpress',
label: _(msg`Open conversation options`),
},
] ]
: undefined : undefined
} }
@@ -450,7 +460,11 @@ function ChatListItemReady({
{!isDeletedAccount && ( {!isDeletedAccount && (
<Text <Text
numberOfLines={1} numberOfLines={1}
style={[a.text_sm, t.atoms.text_contrast_medium, a.pb_xs]}> style={[
a.text_sm,
t.atoms.text_contrast_medium,
a.pb_xs,
]}>
@{profile.handle} @{profile.handle}
</Text> </Text>
)} )}
@@ -497,6 +511,8 @@ function ChatListItemReady({
)} )}
</Link> </Link>
<ChatListItemPortal.Outlet />
{showMenu && ( {showMenu && (
<ConvoMenu <ConvoMenu
convo={convo} convo={convo}
@@ -513,7 +529,8 @@ function ChatListItemReady({
a.justify_center, a.justify_center,
{ {
right: tokens.space.lg, right: tokens.space.lg,
opacity: !gtMobile || showActions || menuControl.isOpen ? 1 : 0, opacity:
!gtMobile || showActions || menuControl.isOpen ? 1 : 0,
}, },
]} ]}
latestReportableMessage={latestReportableMessage} latestReportableMessage={latestReportableMessage}
@@ -526,5 +543,6 @@ function ChatListItemReady({
/> />
</View> </View>
</GestureActionView> </GestureActionView>
</ChatListItemPortal.Provider>
) )
} }
@@ -46,7 +46,7 @@ export function ChatStatusInfo({convoState}: {convoState: ActiveConvoStates}) {
label={_(msg`Block or report`)} label={_(msg`Block or report`)}
convo={convoState.convo} convo={convoState.convo}
profile={otherUser} profile={otherUser}
color="negative" color="negative_subtle"
size="small" size="small"
currentScreen="conversation" currentScreen="conversation"
/> />
@@ -70,8 +70,7 @@ export function ChatStatusInfo({convoState}: {convoState: ActiveConvoStates}) {
<AcceptChatButton <AcceptChatButton
onAcceptConvo={onAcceptChat} onAcceptConvo={onAcceptChat}
convo={convoState.convo} convo={convoState.convo}
color="primary" color="primary_subtle"
variant="outline"
size="small" size="small"
currentScreen="conversation" currentScreen="conversation"
/> />
@@ -36,7 +36,6 @@ export function RejectMenu({
convo, convo,
profile, profile,
size = 'tiny', size = 'tiny',
variant = 'outline',
color = 'secondary', color = 'secondary',
label, label,
showDeleteConvo, showDeleteConvo,
@@ -117,7 +116,6 @@ export function RejectMenu({
label={triggerProps.accessibilityLabel} label={triggerProps.accessibilityLabel}
style={[a.flex_1]} style={[a.flex_1]}
color={color} color={color}
variant={variant}
size={size}> size={size}>
<ButtonText> <ButtonText>
{label || ( {label || (
@@ -129,7 +127,7 @@ export function RejectMenu({
</Button> </Button>
)} )}
</Menu.Trigger> </Menu.Trigger>
<Menu.Outer> <Menu.Outer showCancel>
<Menu.Group> <Menu.Group>
{showDeleteConvo && ( {showDeleteConvo && (
<Menu.Item <Menu.Item
@@ -181,7 +179,6 @@ export function RejectMenu({
export function AcceptChatButton({ export function AcceptChatButton({
convo, convo,
size = 'tiny', size = 'tiny',
variant = 'solid',
color = 'secondary_inverted', color = 'secondary_inverted',
label, label,
currentScreen, currentScreen,
@@ -248,7 +245,6 @@ export function AcceptChatButton({
{...props} {...props}
label={label || _(msg`Accept chat request`)} label={label || _(msg`Accept chat request`)}
size={size} size={size}
variant={variant}
color={color} color={color}
style={a.flex_1} style={a.flex_1}
onPress={onPressAccept}> onPress={onPressAccept}>
@@ -266,7 +262,6 @@ export function AcceptChatButton({
export function DeleteChatButton({ export function DeleteChatButton({
convo, convo,
size = 'tiny', size = 'tiny',
variant = 'outline',
color = 'secondary', color = 'secondary',
label, label,
currentScreen, currentScreen,
@@ -315,7 +310,6 @@ export function DeleteChatButton({
<Button <Button
label={label || _(msg`Delete chat`)} label={label || _(msg`Delete chat`)}
size={size} size={size}
variant={variant}
color={color} color={color}
style={a.flex_1} style={a.flex_1}
onPress={onPressDelete} onPress={onPressDelete}
@@ -7,7 +7,7 @@ import {useSession} from '#/state/session'
import {atoms as a, tokens} from '#/alf' import {atoms as a, tokens} from '#/alf'
import {KnownFollowers} from '#/components/KnownFollowers' import {KnownFollowers} from '#/components/KnownFollowers'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {ChatListItem} from './ChatListItem' import {ChatListItem, ChatListItemPortal} from './ChatListItem'
import {AcceptChatButton, DeleteChatButton, RejectMenu} from './RequestButtons' import {AcceptChatButton, DeleteChatButton, RejectMenu} from './RequestButtons'
export function RequestListItem({convo}: {convo: ChatBskyConvoDefs.ConvoView}) { export function RequestListItem({convo}: {convo: ChatBskyConvoDefs.ConvoView}) {
@@ -42,7 +42,8 @@ export function RequestListItem({convo}: {convo: ChatBskyConvoDefs.ConvoView}) {
<Trans comment="Accept a chat request">Accept Request</Trans> <Trans comment="Accept a chat request">Accept Request</Trans>
</Text> </Text>
</View> </View>
</ChatListItem> {/* then, this gets absolutely positioned on top of the spacer */}
<ChatListItemPortal.Portal>
<View <View
style={[ style={[
a.absolute, a.absolute,
@@ -73,6 +74,8 @@ export function RequestListItem({convo}: {convo: ChatBskyConvoDefs.ConvoView}) {
</> </>
)} )}
</View> </View>
</ChatListItemPortal.Portal>
</ChatListItem>
</View> </View>
) )
} }