Extract UserAvatar to its own file.
This commit is contained in:
parent
ebda14b37b
commit
041eb88aee
2 changed files with 39 additions and 27 deletions
|
|
@ -57,33 +57,6 @@ fun Avatar(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun UserAvatar(
|
|
||||||
avatarData: AvatarData,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
contentDescription: String? = null,
|
|
||||||
forcedAvatarSize: Dp? = null,
|
|
||||||
hideImage: Boolean = false,
|
|
||||||
) {
|
|
||||||
if (avatarData.url.isNullOrBlank() || hideImage) {
|
|
||||||
InitialLetterAvatar(
|
|
||||||
avatarData = avatarData,
|
|
||||||
avatarType = AvatarType.User,
|
|
||||||
forcedAvatarSize = forcedAvatarSize,
|
|
||||||
modifier = modifier,
|
|
||||||
contentDescription = contentDescription,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
ImageAvatar(
|
|
||||||
avatarData = avatarData,
|
|
||||||
avatarType = AvatarType.User,
|
|
||||||
forcedAvatarSize = forcedAvatarSize,
|
|
||||||
modifier = modifier,
|
|
||||||
contentDescription = contentDescription,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Preview(group = PreviewGroup.Avatars)
|
@Preview(group = PreviewGroup.Avatars)
|
||||||
@Composable
|
@Composable
|
||||||
internal fun AvatarPreview(@PreviewParameter(AvatarDataProvider::class) avatarData: AvatarData) =
|
internal fun AvatarPreview(@PreviewParameter(AvatarDataProvider::class) avatarData: AvatarData) =
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 New Vector Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
* Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.element.android.libraries.designsystem.components.avatar
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
internal fun UserAvatar(
|
||||||
|
avatarData: AvatarData,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
contentDescription: String? = null,
|
||||||
|
forcedAvatarSize: Dp? = null,
|
||||||
|
hideImage: Boolean = false,
|
||||||
|
) {
|
||||||
|
if (avatarData.url.isNullOrBlank() || hideImage) {
|
||||||
|
InitialLetterAvatar(
|
||||||
|
avatarData = avatarData,
|
||||||
|
avatarType = AvatarType.User,
|
||||||
|
forcedAvatarSize = forcedAvatarSize,
|
||||||
|
modifier = modifier,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ImageAvatar(
|
||||||
|
avatarData = avatarData,
|
||||||
|
avatarType = AvatarType.User,
|
||||||
|
forcedAvatarSize = forcedAvatarSize,
|
||||||
|
modifier = modifier,
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue