UserAvatar

fun UserAvatar(modifier: Modifier = Modifier, userImage: String? = null, userName: String? = null, shape: Shape = VideoTheme.shapes.circle, imageScale: ContentScale = ContentScale.Crop, imageDescription: String? = null, imageRequestSize: IntSize = IntSize(DEFAULT_IMAGE_SIZE, DEFAULT_IMAGE_SIZE), @DrawableRes loadingPlaceholder: Int? = LocalAvatarPreviewProvider.getLocalAvatarLoadingPlaceholder(), @DrawableRes previewModePlaceholder: Int = LocalAvatarPreviewProvider.getLocalAvatarPreviewPlaceholder(), textStyle: TextStyle = VideoTheme.typography.titleM, textOffset: DpOffset = DpOffset(0.dp, 0.dp), isShowingOnlineIndicator: Boolean = false, onlineIndicatorAlignment: OnlineIndicatorAlignment = OnlineIndicatorAlignment.TopEnd, onlineIndicator: @Composable BoxScope.() -> Unit = { DefaultOnlineIndicator(onlineIndicatorAlignment) }, onClick: () -> Unit? = null)

Component that renders an image or a name as an avatar. If the image is null or unavailable, it uses the name initials. Can also show an "is online" indicator. If needed, the initials font size is gradually decreased automatically until the text fits within the avatar boundaries.

Parameters

modifier

Modifier used for styling.

userImage

The URL of the image to be displayed. Usually User.image.

userName

The name to be used for the initials. Usually User.name.

shape

The shape of the avatar. CircleShape by default.

imageScale

The scale rule used for the image. Crop by default.

imageDescription

The image content description for accessibility. Null by default.

imageRequestSize

The image size to be requested. Original size by default.

loadingPlaceholder

Placeholder image to be displayed while loading the remote image.

previewModePlaceholder

Placeholder image to be displayed in Compose previews (IDE).

textStyle

The TextStyle to be used for the initials text. The fontSize, fontFamily and fontWeight properties are used. If the font size is too large, it will be gradually decreased automatically.

textOffset

Offset to be applied to the initials text.

isShowingOnlineIndicator

Flag used to display/hide the "is online" indicator. False by default.

onlineIndicatorAlignment

Alignment of the "is online" indicator. TopEnd by default.

onlineIndicator

A custom composable to represent the "is online" indicator. DefaultOnlineIndicator by default.

onClick

Handler to be called when the user clicks on the avatar.

See also