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

Fix comment click deadzones #1175

Merged
merged 5 commits into from
Aug 15, 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
25 changes: 15 additions & 10 deletions app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.rememberLazyListState
Expand Down Expand Up @@ -51,6 +49,7 @@ import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.jerboa.Border
Expand Down Expand Up @@ -159,17 +158,15 @@ fun CommentBody(
SelectionContainer {
Text(
text = comment.content,
modifier = Modifier.combinedClickable(
onClick = onClick,
onLongClick = onLongClick,
),
fontFamily = FontFamily.Monospace,
)
}
} else {
MyMarkdownText(
markdown = content,
onClick = onClick,
onLongClick = onLongClick,
modifier = Modifier.padding(0.dp, 0.dp, 0.dp, MEDIUM_PADDING),
)
}
}
Expand Down Expand Up @@ -320,7 +317,6 @@ fun LazyListScope.commentNodeItem(
toggleActionBar(commentId)
},
)
Spacer(modifier = Modifier.height(MEDIUM_PADDING))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The combination of this unclickable spacer and the modifier with unclickable padding on the footer line below seems to have been a deadzone when clicking to collapse comments.

AnimatedVisibility(
visible = showActionBar(commentId),
enter = expandVertically(),
Expand Down Expand Up @@ -363,6 +359,7 @@ fun LazyListScope.commentNodeItem(
account = account,
enableDownVotes = enableDownVotes,
showScores = showScores,
viewSource = viewSource,
)
}
}
Expand Down Expand Up @@ -535,6 +532,7 @@ fun CommentFooterLine(
onLongClick: () -> Unit,
account: Account,
showScores: Boolean,
viewSource: Boolean,
) {
var showMoreOptions by remember { mutableStateOf(false) }

Expand Down Expand Up @@ -571,20 +569,21 @@ fun CommentFooterLine(
onPersonClick(commentView.creator.id)
},
isCreator = account.id == commentView.creator.id,
viewSource = viewSource,
)
}

Row(
horizontalArrangement = Arrangement.End,
modifier = Modifier
.fillMaxWidth()
.padding(top = LARGE_PADDING, bottom = SMALL_PADDING)
.combinedClickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClick = onClick,
onLongClick = onLongClick,
),
)
.padding(top = LARGE_PADDING, bottom = SMALL_PADDING),
) {
Row(
horizontalArrangement = Arrangement.spacedBy(XXL_PADDING),
Expand Down Expand Up @@ -701,6 +700,7 @@ fun CommentOptionsDialog(
onPersonClick: () -> Unit,
isCreator: Boolean,
commentView: CommentView,
viewSource: Boolean,
) {
val localClipboardManager = LocalClipboardManager.current
val ctx = LocalContext.current
Expand All @@ -723,7 +723,11 @@ fun CommentOptionsDialog(
onClick = onPersonClick,
)
IconAndTextDrawerItem(
text = stringResource(R.string.comment_node_view_source),
text = if (viewSource) {
stringResource(R.string.comment_node_view_original)
} else {
stringResource(R.string.comment_node_view_source)
},
icon = Icons.Outlined.Description,
onClick = onViewSourceClick,
)
Expand Down Expand Up @@ -806,6 +810,7 @@ fun CommentOptionsDialogPreview() {
onCommentLinkClick = {},
onPersonClick = {},
onBlockCreatorClick = {},
viewSource = false,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fun CommentMentionNodeFooterLine(
account: Account,
enableDownvotes: Boolean,
showScores: Boolean,
viewSource: Boolean,
) {
var showMoreOptions by remember { mutableStateOf(false) }

Expand All @@ -142,6 +143,7 @@ fun CommentMentionNodeFooterLine(
onBlockCreatorClick(personMentionView.creator)
},
isCreator = account.id == personMentionView.creator.id,
viewSource = viewSource,
)
}

Expand Down Expand Up @@ -245,6 +247,7 @@ fun CommentReplyNodeOptionsDialog(
onReportClick: () -> Unit,
onBlockCreatorClick: () -> Unit,
isCreator: Boolean,
viewSource: Boolean,
) {
val localClipboardManager = LocalClipboardManager.current
val ctx = LocalContext.current
Expand All @@ -262,7 +265,11 @@ fun CommentReplyNodeOptionsDialog(
onClick = onPersonClick,
)
IconAndTextDrawerItem(
text = stringResource(R.string.comment_mention_node_view_source),
text = if (viewSource) {
stringResource(R.string.comment_node_view_original)
} else {
stringResource(R.string.comment_mention_node_view_source)
},
icon = Icons.Outlined.Description,
onClick = onViewSourceClick,
)
Expand Down Expand Up @@ -411,6 +418,7 @@ fun CommentMentionNode(
account = account,
enableDownvotes = enableDownvotes,
showScores = showScores,
viewSource = viewSource,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ fun CommentReplyNodeInboxFooterLine(
account: Account,
enableDownvotes: Boolean,
showScores: Boolean,
viewSource: Boolean,
) {
var showMoreOptions by remember { mutableStateOf(false) }

Expand All @@ -140,6 +141,7 @@ fun CommentReplyNodeInboxFooterLine(
onBlockCreatorClick(commentReplyView.creator)
},
isCreator = account.id == commentReplyView.creator.id,
viewSource = viewSource,
)
}

Expand Down Expand Up @@ -241,6 +243,7 @@ fun CommentReplyNodeOptionsDialog(
onReportClick: () -> Unit,
onBlockCreatorClick: () -> Unit,
isCreator: Boolean,
viewSource: Boolean,
) {
val localClipboardManager = LocalClipboardManager.current
val ctx = LocalContext.current
Expand All @@ -258,7 +261,11 @@ fun CommentReplyNodeOptionsDialog(
onClick = onPersonClick,
)
IconAndTextDrawerItem(
text = stringResource(R.string.comment_reply_node_view_source),
text = if (viewSource) {
stringResource(R.string.comment_node_view_original)
} else {
stringResource(R.string.comment_reply_node_view_source)
},
icon = Icons.Outlined.Description,
onClick = onViewSourceClick,
)
Expand Down Expand Up @@ -396,6 +403,7 @@ fun CommentReplyNodeInbox(
account = account,
enableDownvotes = enableDownvotes,
showScores = showScores,
viewSource = viewSource,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
Expand Down Expand Up @@ -476,6 +477,7 @@ fun PostBody(
SelectionContainer {
Text(
text = text,
fontFamily = FontFamily.Monospace,
)
}
} else {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-az/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<string name="comment_node_report_comment">Şərhi Şikayət Et</string>
<string name="comment_node_restore">Bərpa et</string>
<string name="comment_node_view_context">Məzmuna bax</string>
<string name="comment_node_view_original">Orijinala Bax</string>
<string name="comment_node_view_post">Elana Bax</string>
<string name="comment_node_view_source">Mənbəyə Bax</string>
<string name="comment_reply_back">Geri</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<string name="comment_node_report_comment">Αναφορά σχολίου</string>
<string name="comment_node_restore">Επαναφορά</string>
<string name="comment_node_view_context">Προβολή Περιεχομένου</string>
<string name="comment_node_view_original">Προβολή πρωτότυπου</string>
<string name="comment_node_view_post">Προβολή Ανάρτησης</string>
<string name="comment_node_view_source">Προβολή Πηγής</string>
<string name="comment_reply_back">Πίσω</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<string name="comment_node_report_comment">Segnala commento</string>
<string name="comment_node_restore">Ripristina</string>
<string name="comment_node_view_context">Mostra contesto</string>
<string name="comment_node_view_original">Mostra originale</string>
<string name="comment_node_view_post">Mostra Post</string>
<string name="comment_node_view_source">Mostra markdown</string>
<string name="comment_reply_back">Indietro</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<string name="comment_node_report_comment">댓글 신고</string>
<string name="comment_node_restore">복구</string>
<string name="comment_node_view_context">문맥 보기</string>
<string name="comment_node_view_original">원본 보기</string>
<string name="comment_node_view_post">게시물 보기</string>
<string name="comment_node_view_source">소스 보기</string>
<string name="comment_reply_back">뒤로</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<string name="comment_node_report_comment">Rapporter kommentar</string>
<string name="comment_node_restore">Gjenopprett</string>
<string name="comment_node_view_context">Vis kontekst</string>
<string name="comment_node_view_original">Vis opphavleg</string>
<string name="comment_node_view_post">Vis innlegg</string>
<string name="comment_node_view_source">Vis kjeldekode</string>
<string name="comment_reply_back">Tilbake</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<string name="comment_node_report_comment">Поскаржитися на коментар</string>
<string name="comment_node_restore">Відновити</string>
<string name="comment_node_view_context">Переглянути контекст</string>
<string name="comment_node_view_original">Переглянути оригінал</string>
<string name="comment_node_view_post">Переглянути допис</string>
<string name="comment_node_view_source">Переглянути джерельний код</string>
<string name="comment_reply_back">Повернутися</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<string name="comment_node_report_comment">Report Comment</string>
<string name="comment_node_restore">Restore</string>
<string name="comment_node_view_context">View Context</string>
<string name="comment_node_view_original">View Original</string>
<string name="comment_node_view_post">View Post</string>
<string name="comment_node_view_source">View Source</string>
<string name="comment_reply_back">Back</string>
Expand Down