Skip to content

Commit

Permalink
Bugfix: Fix PostItem scaling (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
eylulnc authored Feb 7, 2025
1 parent cfee96a commit 993b2c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private fun TextView.applyStyleAndColor(
)

setTextColor(textColor.toArgb())
setTextSize(TypedValue.COMPLEX_UNIT_DIP, mergedStyle.fontSize.value)
setTextSize(TypedValue.COMPLEX_UNIT_SP, mergedStyle.fontSize.value)

textAlignment = when (textAlign) {
TextAlign.Left, TextAlign.Start -> View.TEXT_ALIGNMENT_TEXT_START
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -57,6 +59,7 @@ import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -379,7 +382,7 @@ private fun PostHeadline(
HeadlineAuthorInfo(
modifier = Modifier
.fillMaxWidth()
.height(Spacings.Post.postHeadlineHeight),
.wrapContentHeight(),
authorName = authorName,
authorRole = authorRole,
creationDate = creationDate,
Expand Down Expand Up @@ -509,18 +512,20 @@ private fun HeadlineProfilePicture(
displayImage: Boolean = true,
isGrayscale: Boolean = false
) {
val size = Spacings.Post.postHeadlineHeight
val fontScale = LocalDensity.current.fontScale
val scaledSizeDp = Spacings.Post.postHeadlineHeight * fontScale

Box(
modifier = Modifier
.size(size)
.sizeIn(minWidth = scaledSizeDp, minHeight = scaledSizeDp)
.applyGrayscale(isGrayscale)
) {
if (!displayImage) {
return
}

ProfilePictureWithDialog(
modifier = Modifier.size(size),
modifier = Modifier.sizeIn(minWidth = scaledSizeDp, minHeight = scaledSizeDp),
userId = userId,
userName = userName,
userRole = userRole,
Expand Down Expand Up @@ -593,7 +598,7 @@ private fun StandalonePostFooter(
) {
Icon(
modifier = Modifier
.size(Spacings.Post.emojiHeight)
.sizeIn(minHeight = Spacings.Post.emojiHeight)
.padding(5.dp),
imageVector = Icons.Default.InsertEmoticon,
contentDescription = null,
Expand Down Expand Up @@ -678,7 +683,7 @@ private fun EmojiChip(
modifier = modifier
.background(color = backgroundColor, shape)
.clip(shape)
.heightIn(max = Spacings.Post.emojiHeight)
.heightIn(min = Spacings.Post.emojiHeight)
.combinedClickable(
onClick = onClick,
onLongClick = { onLongClick(EmojiSelection.SINGLE(emojiId)) }
Expand Down

0 comments on commit 993b2c1

Please sign in to comment.