Skip to content

Commit

Permalink
[PAY-1151] Handle chat reactions near top of screen on mobile (#3370)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored May 17, 2023
1 parent bff316f commit 4a00fad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/mobile/src/screens/chat-screen/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ export const ChatScreen = () => {
<ReactionPopup
chatId={chatId}
messageTop={messageTop.current}
containerTop={chatContainerTop.current}
containerBottom={chatContainerBottom.current}
isAuthor={decodeHashId(popupMessage?.sender_user_id) === userId}
message={popupMessage}
Expand Down
19 changes: 15 additions & 4 deletions packages/mobile/src/screens/chat-screen/ReactionPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { spacing } from 'app/styles/spacing'
import { ReactionList } from '../notifications-screen/Reaction'

import { ChatMessageListItem } from './ChatMessageListItem'
import { REACTION_CONTAINER_HEIGHT } from './constants'
import {
REACTION_CONTAINER_HEIGHT,
REACTION_CONTAINER_TOP_OFFSET
} from './constants'

const { getUserId } = accountSelectors
const { setMessageReaction } = chatActions
Expand Down Expand Up @@ -69,6 +72,7 @@ const useStyles = makeStyles(({ spacing, palette, typography }) => ({
type ReactionPopupProps = {
chatId: string
messageTop: number
containerTop: number
containerBottom: number
isAuthor: boolean
message: ChatMessageWithExtras
Expand All @@ -79,6 +83,7 @@ type ReactionPopupProps = {
export const ReactionPopup = ({
chatId,
messageTop,
containerTop,
containerBottom,
isAuthor,
message,
Expand Down Expand Up @@ -136,7 +141,8 @@ export const ReactionPopup = ({
style={[
styles.popupContainer,
{
height: containerBottom
height: containerBottom - containerTop,
top: containerTop
}
]}
>
Expand All @@ -152,7 +158,7 @@ export const ReactionPopup = ({
style={[
styles.popupChatMessage,
{
top: messageTop,
top: messageTop - containerTop,
alignSelf: isAuthor ? 'flex-end' : 'flex-start',
right: isAuthor ? spacing(6) : undefined,
left: !isAuthor ? spacing(6) : undefined
Expand All @@ -164,7 +170,12 @@ export const ReactionPopup = ({
style={[
styles.reactionsContainer,
{
top: messageTop - REACTION_CONTAINER_HEIGHT,
top: Math.max(
messageTop - containerTop - REACTION_CONTAINER_HEIGHT,
containerTop -
REACTION_CONTAINER_HEIGHT -
REACTION_CONTAINER_TOP_OFFSET
),
opacity: otherOpacityAnim.current,
transform: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/src/screens/chat-screen/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const REACTION_LONGPRESS_DELAY = 100
export const REACTION_CONTAINER_HEIGHT = 70
export const REACTION_CONTAINER_TOP_OFFSET = 20
export const BACKGROUND_OPACITY = 0.3
export const MOUNT_ANIMATION_DURATION_MS = 100
export const UNMOUNT_ANIMATION_DURATION_MS = 100

0 comments on commit 4a00fad

Please sign in to comment.