Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[PAY-1468] Fix mobile chats copy message button #3623

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions packages/mobile/src/screens/chat-screen/CopyMessagesButton.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
import { useState } from 'react'

import { Text, Pressable, View } from 'react-native'
import { Text, TouchableOpacity } from 'react-native'

import IconCopy from 'app/assets/images/iconCopy2.svg'
import { makeStyles } from 'app/styles'
import { spacing } from 'app/styles/spacing'
import { useThemeColors } from 'app/utils/theme'
import { zIndex } from 'app/utils/zIndex'

const messages = {
copy: 'Copy Message'
}

const useStyles = makeStyles(({ spacing, palette, typography }) => ({
copyPressableContainer: {
root: {
position: 'absolute',
dipslay: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: spacing(1.5),
zIndex: zIndex.CHAT_REACTIONS_POPUP_CONTENT
},
copyAnimatedContainer: {
dipslay: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: spacing(1.5),
zIndex: zIndex.CHAT_REACTIONS_POPUP_CONTENT
gap: spacing(1.5)
},
copyText: {
fontSize: typography.fontSize.xs,
Expand All @@ -51,29 +39,22 @@ export const CopyMessagesButton = ({
onPress
}: CopyMessagesButtonProps) => {
const styles = useStyles()
const { white } = useThemeColors()
const [isPressed, setIsPressed] = useState(false)
const { staticWhite } = useThemeColors()

return (
<Pressable
<TouchableOpacity
onPress={onPress}
onPressIn={() => setIsPressed(true)}
onPressOut={() => setIsPressed(false)}
style={[
styles.copyPressableContainer,
styles.root,
{
top: messageTop - containerTop + messageHeight + spacing(5),
right: isAuthor ? spacing(6) : undefined,
left: isAuthor ? undefined : spacing(6)
}
]}
>
<View
style={[styles.copyAnimatedContainer, { opacity: isPressed ? 0.5 : 1 }]}
>
<IconCopy fill={white} height={12} width={12} />
<Text style={styles.copyText}>{messages.copy}</Text>
</View>
</Pressable>
<IconCopy fill={staticWhite} height={12} width={12} />
<Text style={styles.copyText}>{messages.copy}</Text>
</TouchableOpacity>
)
}
24 changes: 4 additions & 20 deletions packages/mobile/src/screens/chat-screen/ReactionPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const useStyles = makeStyles(({ spacing, palette, typography }) => ({
},
popupContainer: {
position: 'absolute',
display: 'flex',
zIndex: zIndex.CHAT_REACTIONS_POPUP_CLOSE_PRESSABLES,
overflow: 'hidden'
},
Expand Down Expand Up @@ -75,25 +74,8 @@ const useStyles = makeStyles(({ spacing, palette, typography }) => ({
emoji: {
height: spacing(17)
},
copyPressableContainer: {
position: 'absolute',
dipslay: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: spacing(1.5),
zIndex: zIndex.CHAT_REACTIONS_POPUP_CONTENT
},
copyAnimatedContainer: {
dipslay: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: spacing(1.5),
copyContainer: {
zIndex: zIndex.CHAT_REACTIONS_POPUP_CONTENT
},
copyText: {
fontSize: typography.fontSize.xs,
fontFamily: typography.fontByWeight.bold,
color: palette.white
}
}))

Expand Down Expand Up @@ -217,7 +199,9 @@ export const ReactionPopup = ({
]}
handleClosePopup={handleClosePopup}
/>
<Animated.View style={{ opacity: otherOpacityAnim }}>
<Animated.View
style={[styles.copyContainer, { opacity: otherOpacityAnim }]}
>
<CopyMessagesButton
isAuthor={isAuthor}
messageTop={messageTop}
Expand Down