mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-08 17:48:42 +01:00
tweaked comment indentation style and elements
This commit is contained in:
parent
0d3186497d
commit
b54124ec72
@ -3,6 +3,7 @@ package com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
@ -26,7 +27,7 @@ import com.livefast.eattrash.raccoonforlemmy.core.utils.toLocalDp
|
||||
import com.livefast.eattrash.raccoonforlemmy.domain.lemmy.data.CommentModel
|
||||
import com.livefast.eattrash.raccoonforlemmy.domain.lemmy.data.UserModel
|
||||
|
||||
private const val INDENT_AMOUNT = 3
|
||||
private const val INDENT_AMOUNT = 2
|
||||
|
||||
@Composable
|
||||
fun CollapsedCommentCard(
|
||||
@ -59,78 +60,76 @@ fun CollapsedCommentCard(
|
||||
depth = comment.depth,
|
||||
commentBarTheme = commentBarTheme,
|
||||
)
|
||||
Column(
|
||||
Row(
|
||||
modifier =
|
||||
modifier.onClick(
|
||||
onClick = onClick ?: {},
|
||||
),
|
||||
modifier.onClick(
|
||||
onClick = onClick ?: {},
|
||||
),
|
||||
) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier.padding(
|
||||
start = (INDENT_AMOUNT * comment.depth).dp,
|
||||
),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.width((INDENT_AMOUNT * comment.depth).dp),
|
||||
)
|
||||
if (comment.depth > 0) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(start = barWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
vertical = Spacing.xxs,
|
||||
horizontal = Spacing.s,
|
||||
).onGloballyPositioned {
|
||||
commentHeight = it.size.toSize().height
|
||||
},
|
||||
) {
|
||||
CommunityAndCreatorInfo(
|
||||
iconSize = IconSize.s,
|
||||
creator = comment.creator,
|
||||
indicatorExpanded = comment.expanded,
|
||||
distinguished = comment.distinguished,
|
||||
isOp = isOp,
|
||||
isMod = isMod,
|
||||
isBot = comment.creator?.bot?.takeIf { showBot } ?: false,
|
||||
autoLoadImages = autoLoadImages,
|
||||
preferNicknames = preferNicknames,
|
||||
onToggleExpanded = {
|
||||
onToggleExpanded?.invoke()
|
||||
},
|
||||
onOpenCreator = onOpenCreator,
|
||||
)
|
||||
PostCardFooter(
|
||||
modifier = Modifier.padding(vertical = Spacing.xs),
|
||||
score = comment.score,
|
||||
showScores = showScores,
|
||||
voteFormat = voteFormat,
|
||||
upVotes = comment.upvotes,
|
||||
downVotes = comment.downvotes,
|
||||
saved = comment.saved,
|
||||
upVoted = comment.myVote > 0,
|
||||
downVoted = comment.myVote < 0,
|
||||
comments = comment.comments,
|
||||
onClick = onClick,
|
||||
onUpVote = onUpVote,
|
||||
onDownVote = onDownVote,
|
||||
onSave = onSave,
|
||||
onReply = onReply,
|
||||
publishDate = comment.publishDate,
|
||||
updateDate = comment.updateDate,
|
||||
actionButtonsActive = actionButtonsActive,
|
||||
options = options,
|
||||
onOptionSelected = onOptionSelected,
|
||||
)
|
||||
}
|
||||
if (comment.depth > 0) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(top = Spacing.xxs)
|
||||
.width(barWidth)
|
||||
.height(commentHeight.toLocalDp())
|
||||
.background(color = barColor),
|
||||
)
|
||||
}
|
||||
Modifier
|
||||
.padding(top = Spacing.xxs)
|
||||
.width(INDENT_AMOUNT.dp)
|
||||
.height(commentHeight.toLocalDp())
|
||||
.background(color = barColor),
|
||||
)
|
||||
}
|
||||
Column(
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(start = barWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
vertical = Spacing.xxs,
|
||||
horizontal = Spacing.s,
|
||||
).onGloballyPositioned {
|
||||
commentHeight = it.size.toSize().height
|
||||
},
|
||||
) {
|
||||
CommunityAndCreatorInfo(
|
||||
modifier = Modifier.padding(top = Spacing.xxs),
|
||||
iconSize = IconSize.s,
|
||||
creator = comment.creator,
|
||||
indicatorExpanded = comment.expanded,
|
||||
distinguished = comment.distinguished,
|
||||
isOp = isOp,
|
||||
isMod = isMod,
|
||||
isBot = comment.creator?.bot?.takeIf { showBot } ?: false,
|
||||
autoLoadImages = autoLoadImages,
|
||||
preferNicknames = preferNicknames,
|
||||
onToggleExpanded = {
|
||||
onToggleExpanded?.invoke()
|
||||
},
|
||||
onOpenCreator = onOpenCreator,
|
||||
)
|
||||
PostCardFooter(
|
||||
modifier = Modifier.padding(vertical = Spacing.xs),
|
||||
score = comment.score,
|
||||
showScores = showScores,
|
||||
voteFormat = voteFormat,
|
||||
upVotes = comment.upvotes,
|
||||
downVotes = comment.downvotes,
|
||||
saved = comment.saved,
|
||||
upVoted = comment.myVote > 0,
|
||||
downVoted = comment.myVote < 0,
|
||||
comments = comment.comments,
|
||||
onClick = onClick,
|
||||
onUpVote = onUpVote,
|
||||
onDownVote = onDownVote,
|
||||
onSave = onSave,
|
||||
onReply = onReply,
|
||||
publishDate = comment.publishDate,
|
||||
updateDate = comment.updateDate,
|
||||
actionButtonsActive = actionButtonsActive,
|
||||
options = options,
|
||||
onOptionSelected = onOptionSelected,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
@ -112,48 +113,54 @@ fun CommentCard(
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalTextToolbar provides
|
||||
getCustomTextToolbar(
|
||||
shareActionLabel = shareActionLabel,
|
||||
onShare = onShareLambda,
|
||||
),
|
||||
getCustomTextToolbar(
|
||||
shareActionLabel = shareActionLabel,
|
||||
onShare = onShareLambda,
|
||||
),
|
||||
) {
|
||||
Column(
|
||||
Row(
|
||||
modifier = modifier,
|
||||
) {
|
||||
Box(
|
||||
modifier =
|
||||
modifier = Modifier
|
||||
.width((indentAmount * comment.depth).dp)
|
||||
)
|
||||
if (indentAmount > 0 && comment.depth > 0) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.onClick(
|
||||
onClick = {
|
||||
if (textSelection) {
|
||||
focusManager.clearFocus()
|
||||
textSelection = false
|
||||
} else {
|
||||
onClick?.invoke()
|
||||
}
|
||||
},
|
||||
onDoubleClick = onDoubleClick ?: {},
|
||||
).padding(
|
||||
start =
|
||||
indentAmount
|
||||
.takeIf {
|
||||
it > 0 && comment.depth > 0
|
||||
}?.let {
|
||||
(it * comment.depth).dp + Spacing.xxxs
|
||||
} ?: 0.dp,
|
||||
),
|
||||
.padding(top = Spacing.xxs)
|
||||
.width(indentAmount.dp)
|
||||
.height(commentHeight.toLocalDp())
|
||||
.background(color = barColor, shape = RoundedCornerShape(indentAmount / 2)),
|
||||
)
|
||||
}
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.onClick(
|
||||
onClick = {
|
||||
if (textSelection) {
|
||||
focusManager.clearFocus()
|
||||
textSelection = false
|
||||
} else {
|
||||
onClick?.invoke()
|
||||
}
|
||||
},
|
||||
onDoubleClick = onDoubleClick ?: {},
|
||||
),
|
||||
) {
|
||||
Column(
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(start = barWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
vertical = Spacing.xxs,
|
||||
horizontal = Spacing.s,
|
||||
).onGloballyPositioned {
|
||||
commentHeight = it.size.toSize().height
|
||||
},
|
||||
Modifier
|
||||
.padding(start = barWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(
|
||||
vertical = Spacing.xxs,
|
||||
horizontal = Spacing.s,
|
||||
).onGloballyPositioned {
|
||||
commentHeight = it.size.toSize().height
|
||||
},
|
||||
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
|
||||
) {
|
||||
CommunityAndCreatorInfo(
|
||||
@ -170,13 +177,13 @@ fun CommentCard(
|
||||
isAdmin = isAdmin,
|
||||
isBot = comment.creator?.bot.takeIf { showBot } ?: false,
|
||||
onOpenCreator =
|
||||
rememberCallbackArgs { user ->
|
||||
onOpenCreator?.invoke(user, "")
|
||||
},
|
||||
rememberCallbackArgs { user ->
|
||||
onOpenCreator?.invoke(user, "")
|
||||
},
|
||||
onOpenCommunity =
|
||||
rememberCallbackArgs { community ->
|
||||
onOpenCommunity?.invoke(community, "")
|
||||
},
|
||||
rememberCallbackArgs { community ->
|
||||
onOpenCommunity?.invoke(community, "")
|
||||
},
|
||||
onToggleExpanded = onToggleExpanded,
|
||||
)
|
||||
if (comment.removed) {
|
||||
@ -197,11 +204,11 @@ fun CommentCard(
|
||||
CustomizedContent(ContentFontClass.Comment) {
|
||||
CompositionLocalProvider(
|
||||
LocalDensity provides
|
||||
Density(
|
||||
density = LocalDensity.current.density,
|
||||
// additional downscale for font in comments
|
||||
fontScale = LocalDensity.current.fontScale * COMMENT_TEXT_SCALE_FACTOR,
|
||||
),
|
||||
Density(
|
||||
density = LocalDensity.current.density,
|
||||
// additional downscale for font in comments
|
||||
fontScale = LocalDensity.current.fontScale * COMMENT_TEXT_SCALE_FACTOR,
|
||||
),
|
||||
) {
|
||||
PostCardBody(
|
||||
text = comment.text.orEmpty(),
|
||||
@ -252,16 +259,6 @@ fun CommentCard(
|
||||
onOptionSelected = onOptionSelected,
|
||||
)
|
||||
}
|
||||
if (indentAmount > 0 && comment.depth > 0) {
|
||||
Box(
|
||||
modifier =
|
||||
Modifier
|
||||
.padding(top = Spacing.xxs)
|
||||
.width(barWidth)
|
||||
.height(commentHeight.toLocalDp())
|
||||
.background(color = barColor, shape = RoundedCornerShape(barWidth / 2)),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user