Skip to content

Commit

Permalink
#249: Long posts should have the see more feature (#290)
Browse files Browse the repository at this point in the history
Co-authored-by: lauchaves <lauchavesmendez@gmail.comA>
  • Loading branch information
lauchaves and lauchaves authored Jul 25, 2024
1 parent 63b9ef2 commit 83edcf5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 15 additions & 1 deletion JoyboyCommunity/src/modules/Post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export const Post: React.FC<PostProps> = ({asComment, event}) => {
const queryClient = useQueryClient();

const [menuOpen, setMenuOpen] = useState(false);
const [isContentExpanded, setIsContentExpanded] = useState(false);

const toggleExpandedContent = () => {
setIsContentExpanded((prev) => !prev);
};

const scale = useSharedValue(1);

Expand Down Expand Up @@ -107,6 +112,9 @@ export const Post: React.FC<PostProps> = ({asComment, event}) => {
);
};

const content = event?.content || '';
const truncatedContent = content.length > 200 ? `${content.slice(0, 200)}...` : content;

return (
<View style={styles.container}>
{repostedEvent && (
Expand Down Expand Up @@ -188,9 +196,15 @@ export const Post: React.FC<PostProps> = ({asComment, event}) => {
<View style={styles.content}>
<Pressable onPress={handleNavigateToPostDetails}>
<Text color="textStrong" fontSize={13} lineHeight={20}>
{event?.content}
{isContentExpanded ? content : truncatedContent}
</Text>

{content.length > 200 && (
<Pressable onPress={toggleExpandedContent}>
<Text style={styles.seeMore}>{isContentExpanded ? 'See less' : 'See more...'}</Text>
</Pressable>
)}

{postSource && (
<Image
source={postSource}
Expand Down
5 changes: 5 additions & 0 deletions JoyboyCommunity/src/modules/Post/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ export default ThemedStyleSheet((theme) => ({
alignItems: 'center',
gap: Spacing.xxxsmall,
},
seeMore: {
color: theme.colors.primary,
fontSize: 13,
marginTop: Spacing.xsmall,
},
}));

0 comments on commit 83edcf5

Please sign in to comment.