Repository: thunderbird/thunderbird-android
File: legacy/ui/legacy/src/main/java/com/fsck/k9/ui/messagelist/item/MessageItemContent.kt (Kotlin)

Code before:
            selected = isSelected,
            maxPreviewLines = appearance.previewLines,
            threadCount = item.threadCount,
            hasAttachments = item.hasAttachments,
            swapSenderWithSubject = !appearance.senderAboveSubject,
        )
    }
}

@Composable
fun ContactImageAvatar(address: Address, imageLoader: ImageLoader, modifier: Modifier = Modifier) {
    val model = remember(address) {
        ContactImageModel(address = address, contactLetterOnly = false)
    }
    CoilImage(
        imageModel = { model },
        imageLoader = { imageLoader },
        imageOptions = ImageOptions(
            contentScale = ContentScale.Crop,
            alignment = Alignment.Center,
        ),
        modifier = modifier
            .size(40.dp)
            .clip(CircleShape),
        loading = {
            CircularProgressIndicator(modifier = Modifier.size(20.dp))
        },
    )
}


Review comment (suggestion):
This should be wrapped in a box to avoid using all available space and ignoring the given size.


```suggestion
                Box(contentAlignment = Alignment.Center) {
                    CircularProgressIndicator(
                        modifier = Modifier.size(MainTheme.sizes.icon)

                    )
                }
```

I think `MainTheme.sizes.icon` better fits here.

Code after:
            threadCount = item.threadCount,
            hasAttachments = item.hasAttachments,
            swapSenderWithSubject = !appearance.senderAboveSubject,
        )

        else -> UnreadMessageItem(
            sender = "${item.displayName}",
            subject = item.subject ?: "n/a",
            preview = item.previewText,
            receivedAt = receivedAt,
            avatar = {
                if (appearance.showContactPicture) {
                    ContactImageAvatar(
                        contactImageUri = uri,
                        contactImageMonogram = monogram,
                        onAvatarClick = onAvatarClick,
                    )
                }
            },
            onClick = onClick,
            onLongClick = onLongClick,
            onLeadingClick = onAvatarClick,
            onFavouriteChange = onFavouriteClick,
            favourite = item.isStarred,
            selected = isSelected,
            maxPreviewLines = appearance.previewLines,
            threadCount = item.threadCount,
            hasAttachments = item.hasAttachments,
            swapSenderWithSubject = !appearance.senderAboveSubject,
        )
    }
}

@Composable
fun ContactImageAvatar(
    contactImageUri: Uri?,
    contactImageMonogram: String,
    modifier: Modifier = Modifier,
    onAvatarClick: () -> Unit,
) {
    Box(
        contentAlignment = Alignment.Center,
        modifier = Modifier
            .size(MainTheme.sizes.iconAvatar)
            .padding(MainTheme.spacings.half)
            .background(color = MainTheme.colors.primaryContainer.copy(alpha = 0.15f), shape = CircleShape)
            .border(width = 1.dp, color = MainTheme.colors.primary, shape = CircleShape)
            .clickable(onClick = onAvatarClick),
    ) {
        contactImageUri?.let {
            RemoteImage(