Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#249: Long posts should have the see more feature #290

Merged
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
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,
},
}));
Loading