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

Collapse comments by tapping directly on the comment body #398

Merged
merged 2 commits into from
Jun 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun CommentNodeHeader(
score: Int,
myVote: Int?,
isModerator: Boolean,
onLongClick: () -> Unit = {}
onClick: () -> Unit
) {
CommentOrPostNodeHeader(
creator = commentView.creator,
Expand All @@ -99,7 +99,7 @@ fun CommentNodeHeader(
isPostCreator = isPostCreator(commentView),
isModerator = isModerator,
isCommunityBanned = commentView.creator_banned_from_community,
onLongClick = onLongClick
onClick = onClick
)
}

Expand All @@ -111,14 +111,16 @@ fun CommentNodeHeaderPreview() {
score = 23,
myVote = 26,
isModerator = false,
onPersonClick = {}
onPersonClick = {},
onClick = {}
)
}

@Composable
fun CommentBody(
comment: Comment,
viewSource: Boolean
viewSource: Boolean,
onClick: () -> Unit
) {
val content = if (comment.removed) {
"*Removed*"
Expand All @@ -131,18 +133,26 @@ fun CommentBody(
if (viewSource) {
SelectionContainer {
Text(
text = comment.content
text = comment.content,
modifier = Modifier.clickable { onClick() }
)
}
} else {
MyMarkdownText(markdown = content)
MyMarkdownText(
markdown = content,
onClick = onClick
)
}
}

@Preview
@Composable
fun CommentBodyPreview() {
CommentBody(comment = sampleCommentView.comment, viewSource = false)
CommentBody(
comment = sampleCommentView.comment,
viewSource = false,
onClick = {}
)
}

fun LazyListScope.commentNodeItem(
Expand Down Expand Up @@ -228,7 +238,7 @@ fun LazyListScope.commentNodeItem(
score = instantScores.value.score,
myVote = instantScores.value.myVote,
isModerator = isModerator(commentView.creator, moderators),
onLongClick = {
onClick = {
toggleExpanded(commentId)
}
)
Expand All @@ -240,7 +250,10 @@ fun LazyListScope.commentNodeItem(
Column {
CommentBody(
comment = commentView.comment,
viewSource = viewSource
viewSource = viewSource,
onClick = {
toggleExpanded(commentId)
}
)
CommentFooterLine(
commentView = commentView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun CommentMentionNodeHeader(
onPersonClick: (personId: Int) -> Unit,
score: Int,
myVote: Int?,
onLongClick: () -> Unit = {}
onClick: () -> Unit
) {
CommentOrPostNodeHeader(
creator = personMentionView.creator,
Expand All @@ -69,7 +69,7 @@ fun CommentMentionNodeHeader(
isPostCreator = false,
isModerator = false,
isCommunityBanned = personMentionView.creator_banned_from_community,
onLongClick = onLongClick
onClick = onClick
)
}

Expand All @@ -80,7 +80,8 @@ fun CommentMentionNodeHeaderPreview() {
personMentionView = samplePersonMentionView,
score = 23,
myVote = 26,
onPersonClick = {}
onPersonClick = {},
onClick = {}
)
}

Expand Down Expand Up @@ -286,7 +287,7 @@ fun CommentMentionNode(
onPersonClick = onPersonClick,
score = score,
myVote = myVote,
onLongClick = {
onClick = {
isExpanded = !isExpanded
}
)
Expand All @@ -298,7 +299,8 @@ fun CommentMentionNode(
Column {
CommentBody(
comment = personMentionView.comment,
viewSource = viewSource
viewSource = viewSource,
onClick = {}
)
CommentMentionNodeFooterLine(
personMentionView = personMentionView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ fun RepliedComment(
onPersonClick = onPersonClick,
score = commentView.counts.score,
myVote = commentView.my_vote,
isModerator = isModerator
isModerator = isModerator,
onClick = {}
)
SelectionContainer {
Text(text = commentView.comment.content)
Expand All @@ -105,7 +106,8 @@ fun RepliedCommentReply(
commentReplyView = commentReplyView,
onPersonClick = onPersonClick,
score = commentReplyView.counts.score,
myVote = commentReplyView.my_vote
myVote = commentReplyView.my_vote,
onClick = {}
)
SelectionContainer {
Text(text = commentReplyView.comment.content)
Expand All @@ -123,7 +125,8 @@ fun RepliedMentionReply(
personMentionView = personMentionView,
onPersonClick = onPersonClick,
score = personMentionView.counts.score,
myVote = personMentionView.my_vote
myVote = personMentionView.my_vote,
onClick = {}
)
SelectionContainer {
Text(text = personMentionView.comment.content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fun CommentReplyNodeHeader(
onPersonClick: (personId: Int) -> Unit,
score: Int,
myVote: Int?,
onLongClick: () -> Unit = {}
onClick: () -> Unit
) {
CommentOrPostNodeHeader(
creator = commentReplyView.creator,
Expand All @@ -69,7 +69,7 @@ fun CommentReplyNodeHeader(
isPostCreator = false,
isModerator = false,
isCommunityBanned = commentReplyView.creator_banned_from_community,
onLongClick = onLongClick
onClick = onClick
)
}

Expand All @@ -80,7 +80,8 @@ fun CommentReplyNodeHeaderPreview() {
commentReplyView = sampleCommentReplyView,
score = 23,
myVote = 26,
onPersonClick = {}
onPersonClick = {},
onClick = {}
)
}

Expand Down Expand Up @@ -286,7 +287,7 @@ fun CommentReplyNode(
onPersonClick = onPersonClick,
score = score,
myVote = myVote,
onLongClick = {
onClick = {
isExpanded = !isExpanded
}
)
Expand All @@ -298,7 +299,8 @@ fun CommentReplyNode(
Column {
CommentBody(
comment = commentReplyView.comment,
viewSource = viewSource
viewSource = viewSource,
onClick = {}
)
CommentReplyNodeFooterLine(
commentReplyView = commentReplyView,
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fun CommentOrPostNodeHeader(
isPostCreator: Boolean,
isModerator: Boolean,
isCommunityBanned: Boolean,
onLongClick: () -> Unit = {}
onClick: () -> Unit
) {
FlowRow(
mainAxisAlignment = FlowMainAxisAlignment.SpaceBetween,
Expand All @@ -215,8 +215,8 @@ fun CommentOrPostNodeHeader(
bottom = MEDIUM_PADDING
)
.combinedClickable(
onLongClick = onLongClick,
onClick = {}
onLongClick = {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create a github issue for long-click voting? I think that'd be really nice to have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onClick = onClick
)
) {
Row(
Expand Down Expand Up @@ -258,7 +258,8 @@ fun CommentOrPostNodeHeaderPreview() {
onPersonClick = {},
isPostCreator = true,
isModerator = true,
isCommunityBanned = false
isCommunityBanned = false,
onClick = {}
)
}

Expand Down Expand Up @@ -452,7 +453,8 @@ fun Sidebar(
) {
MyMarkdownText(
markdown = it,
color = MaterialTheme.colorScheme.onBackground.muted
color = MaterialTheme.colorScheme.onBackground.muted,
onClick = {}
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ fun ShowChangelog(appSettingsViewModel: AppSettingsViewModel) {
AlertDialog(
text = {
Column(modifier = Modifier.fillMaxSize().verticalScroll(scrollState)) {
MyMarkdownText(markdown = DONATION_MARKDOWN + markdown.value)
MyMarkdownText(
markdown = DONATION_MARKDOWN + markdown.value,
onClick = {}
)
}
},
confirmButton = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ fun ShowPreviewDialog(
modifier = Modifier.verticalScroll(rememberScrollState())
) {
MyMarkdownText(
markdown = content
markdown = content,
onClick = {}
)
}
},
Expand Down Expand Up @@ -674,11 +675,13 @@ fun PreviewLines(
@Composable
fun MyMarkdownText(
markdown: String,
color: Color = MaterialTheme.colorScheme.onSurface
color: Color = MaterialTheme.colorScheme.onSurface,
onClick: () -> Unit
) {
MarkdownText(
markdown = markdown,
modifier = Modifier.fillMaxSize(),
onClick = onClick,
color = color,
fontSize = MaterialTheme.typography.bodyLarge.fontSize.times(MARKDOWN_FONT_MULTIPLIER)
// style = MaterialTheme.typography.titleLarge,
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ fun Tagline(taglines: List<Tagline>) {
Column(
Modifier.padding(LARGE_PADDING)
) {
MyMarkdownText(markdown = tagline.content)
MyMarkdownText(
markdown = tagline.content,
onClick = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ fun PersonProfileTopSection(
personView.person.bio?.also {
MyMarkdownText(
markdown = it,
color = MaterialTheme.colorScheme.onBackground.muted
color = MaterialTheme.colorScheme.onBackground.muted,
onClick = {}
)
}
}
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/jerboa/ui/components/post/PostListing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ fun PostNodeHeader(
onPersonClick = onPersonClick,
isPostCreator = true,
isModerator = isModerator,
isCommunityBanned = postView.creator_banned_from_community
isCommunityBanned = postView.creator_banned_from_community,
onClick = {}
)
}

Expand Down Expand Up @@ -391,7 +392,8 @@ fun PostBody(
.padding(MEDIUM_PADDING)
) {
MyMarkdownText(
markdown = text
markdown = text,
onClick = {}
)
}
} else {
Expand Down Expand Up @@ -1133,7 +1135,10 @@ fun MetadataCard(post: Post) {
post.embed_description?.also {
Divider(modifier = Modifier.padding(vertical = LARGE_PADDING))
// This is actually html, but markdown can render it
MyMarkdownText(markdown = it)
MyMarkdownText(
markdown = it,
onClick = {}
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ fun PrivateMessageViewPreview() {

@Composable
fun PrivateMessageBody(privateMessageView: PrivateMessageView) {
MyMarkdownText(markdown = privateMessageView.private_message.content)
MyMarkdownText(
markdown = privateMessageView.private_message.content,
onClick = {}
)
}

@Composable
Expand Down