Remove default param for Avatar.avatarType
This commit is contained in:
@@ -26,6 +26,7 @@ import androidx.compose.ui.unit.dp
|
||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarType
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.text.toPx
|
||||
@@ -43,6 +44,7 @@ import kotlinx.collections.immutable.toImmutableList
|
||||
@Composable
|
||||
fun AvatarRow(
|
||||
avatarDataList: ImmutableList<AvatarData>,
|
||||
avatarType: AvatarType,
|
||||
modifier: Modifier = Modifier,
|
||||
overlapRatio: Float = 0.5f,
|
||||
) {
|
||||
@@ -58,35 +60,36 @@ fun AvatarRow(
|
||||
.forEachIndexed { index, avatarData ->
|
||||
Avatar(
|
||||
modifier = Modifier
|
||||
.padding(start = avatarSize * (1 - overlapRatio) * (lastItemIndex - index))
|
||||
.graphicsLayer {
|
||||
compositingStrategy = CompositingStrategy.Offscreen
|
||||
.padding(start = avatarSize * (1 - overlapRatio) * (lastItemIndex - index))
|
||||
.graphicsLayer {
|
||||
compositingStrategy = CompositingStrategy.Offscreen
|
||||
}
|
||||
.drawWithContent {
|
||||
// Draw content and clear the pixels for the avatar on the left (right in RTL).
|
||||
drawContent()
|
||||
val xOffset = if (isRtl) {
|
||||
size.width - avatarSizePx * (overlapRatio - 0.5f)
|
||||
} else {
|
||||
0f + avatarSizePx * (overlapRatio - 0.5f)
|
||||
}
|
||||
.drawWithContent {
|
||||
// Draw content and clear the pixels for the avatar on the left (right in RTL).
|
||||
drawContent()
|
||||
val xOffset = if (isRtl) {
|
||||
size.width - avatarSizePx * (overlapRatio - 0.5f)
|
||||
} else {
|
||||
0f + avatarSizePx * (overlapRatio - 0.5f)
|
||||
}
|
||||
if (index < lastItemIndex) {
|
||||
drawCircle(
|
||||
color = Color.Black,
|
||||
center = Offset(
|
||||
x = xOffset,
|
||||
y = size.height / 2,
|
||||
),
|
||||
radius = avatarSizePx / 2,
|
||||
blendMode = BlendMode.Clear,
|
||||
)
|
||||
}
|
||||
if (index < lastItemIndex) {
|
||||
drawCircle(
|
||||
color = Color.Black,
|
||||
center = Offset(
|
||||
x = xOffset,
|
||||
y = size.height / 2,
|
||||
),
|
||||
radius = avatarSizePx / 2,
|
||||
blendMode = BlendMode.Clear,
|
||||
)
|
||||
}
|
||||
.size(size = avatarSize)
|
||||
// Keep internal padding, it has the advantage to not reduce the size of the Avatar image,
|
||||
// which is already small in our use case.
|
||||
.padding(2.dp),
|
||||
}
|
||||
.size(size = avatarSize)
|
||||
// Keep internal padding, it has the advantage to not reduce the size of the Avatar image,
|
||||
// which is already small in our use case.
|
||||
.padding(2.dp),
|
||||
avatarData = avatarData,
|
||||
avatarType = avatarType,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -122,6 +125,7 @@ private fun ContentToPreview(overlapRatio: Float) {
|
||||
size = AvatarSize.RoomListItem,
|
||||
)
|
||||
}.toImmutableList(),
|
||||
avatarType = AvatarType.User,
|
||||
overlapRatio = overlapRatio,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import io.element.android.libraries.designsystem.components.async.AsyncIndicator
|
||||
import io.element.android.libraries.designsystem.components.async.rememberAsyncIndicatorState
|
||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarType
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||
import io.element.android.libraries.designsystem.theme.components.Button
|
||||
@@ -195,7 +196,10 @@ private fun KnockRequestAvatarView(
|
||||
Box(modifier) {
|
||||
when (knockRequests.size) {
|
||||
0 -> Unit
|
||||
1 -> Avatar(knockRequests.first().getAvatarData(AvatarSize.KnockRequestBanner))
|
||||
1 -> Avatar(
|
||||
avatarData = knockRequests.first().getAvatarData(AvatarSize.KnockRequestBanner),
|
||||
avatarType = AvatarType.User,
|
||||
)
|
||||
else -> KnockRequestAvatarListView(knockRequests)
|
||||
}
|
||||
}
|
||||
@@ -214,6 +218,7 @@ private fun KnockRequestAvatarListView(
|
||||
.toImmutableList()
|
||||
AvatarRow(
|
||||
avatarDataList = avatars,
|
||||
avatarType = AvatarType.User,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ import io.element.android.libraries.designsystem.components.ProgressDialog
|
||||
import io.element.android.libraries.designsystem.components.async.AsyncActionView
|
||||
import io.element.android.libraries.designsystem.components.avatar.Avatar
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarType
|
||||
import io.element.android.libraries.designsystem.components.button.BackButton
|
||||
import io.element.android.libraries.designsystem.components.dialogs.ConfirmationDialog
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
@@ -318,7 +319,10 @@ private fun KnockRequestItem(
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
) {
|
||||
Avatar(knockRequest.getAvatarData(AvatarSize.KnockRequestItem))
|
||||
Avatar(
|
||||
avatarData = knockRequest.getAvatarData(AvatarSize.KnockRequestItem),
|
||||
avatarType = AvatarType.User,
|
||||
)
|
||||
Spacer(modifier = Modifier.width(16.dp))
|
||||
Column {
|
||||
// Name and date
|
||||
|
||||
Reference in New Issue
Block a user